PierreLeveau commited on
Commit
7cbd81c
1 Parent(s): 09e128c

working version

Browse files
Files changed (2) hide show
  1. app.py +7 -7
  2. requirements.txt +32 -0
app.py CHANGED
@@ -3,12 +3,12 @@ import torch
3
  from PIL import Image
4
 
5
  # Images
6
- torch.hub.download_url_to_file('https://storage.googleapis.com/kili-datasets-public/plastic-in-river/ckze0btj10ejf0lyy1imtdy7o.jpg', 'bottles1.jpg')
7
- torch.hub.download_url_to_file('https://storage.googleapis.com/kili-datasets-public/plastic-in-river/ckze0btj10ejd0lyyfzm85k9u.jpg', 'bottles2.jpg')
8
 
9
  # Model
10
- model = torch.hub.load_state_dict_from_url("gs://kili-datasets-public/plastic_in_river/model/best.pt", force_reload=True) # force_reload=True to update
11
- # -> load the model from HF models.
12
 
13
  def yolo(im, size=640):
14
  g = (size / max(im.size)) # gain
@@ -22,9 +22,9 @@ def yolo(im, size=640):
22
  inputs = gr.inputs.Image(type='pil', label="Original Image")
23
  outputs = gr.outputs.Image(type="pil", label="Output Image")
24
 
25
- title = "YOLOv5"
26
- description = "YOLOv5 Gradio demo for object detection. Upload an image or click an example image to use."
27
- article = "<p style='text-align: center'>YOLOv5 is a family of compound-scaled object detection models trained on the COCO dataset, and includes simple functionality for Test Time Augmentation (TTA), model ensembling, hyperparameter evolution, and export to ONNX, CoreML and TFLite. <a href='https://github.com/ultralytics/yolov5'>Source code</a> |<a href='https://apps.apple.com/app/id1452689527'>iOS App</a> | <a href='https://pytorch.org/hub/ultralytics_yolov5'>PyTorch Hub</a></p>"
28
 
29
  examples = [['bottles1.jpg'], ['bottles2.jpg']]
30
  gr.Interface(yolo, inputs, outputs, title=title, description=description, article=article, examples=examples, theme="huggingface").launch(
3
  from PIL import Image
4
 
5
  # Images
6
+ torch.hub.download_url_to_file('https://storage.googleapis.com/kili-datasets-public/plastic-in-river/samples/ckze0btj10ejf0lyy1imtdy7o.jpg', 'bottles1.jpg')
7
+ torch.hub.download_url_to_file('https://storage.googleapis.com/kili-datasets-public/plastic-in-river/samples/ckze0btj10ejd0lyyfzm85k9u.jpg', 'bottles2.jpg')
8
 
9
  # Model
10
+ model = torch.hub.load('PierreLeveau/yolov5', 'custom', 'https://storage.googleapis.com/kili-datasets-public/plastic-in-river/model/best.pt') # force_reload=True to update
11
+
12
 
13
  def yolo(im, size=640):
14
  g = (size / max(im.size)) # gain
22
  inputs = gr.inputs.Image(type='pil', label="Original Image")
23
  outputs = gr.outputs.Image(type="pil", label="Output Image")
24
 
25
+ title = "YOLOv5 - Plastic in river detection"
26
+ description = "This space demontrates a YOLOv5 model fine-tuned on a dataset of annotated photos of plastic waste in rivers. Upload an image or click an example image to use."
27
+ article = "<p style='text-align: center'>YOLOv5 is a family of compound-scaled object detection models trained on the COCO dataset. We performed fine-tuning of models trained by Ultralytics with the help of their awesome <a href='https://github.com/ultralytics/yolov5'>code repository</a>. The data comes from a community challenge organized by [Kili](https://kili-technology.com/blog/kili-s-community-challenge-plastic-in-river-dataset), and the demo site is heavily inspired from the original [YoloV5 space](https://huggingface.co/spaces/akhaliq/YOLOv5). We will update the model during the challenge."
28
 
29
  examples = [['bottles1.jpg'], ['bottles2.jpg']]
30
  gr.Interface(yolo, inputs, outputs, title=title, description=description, article=article, examples=examples, theme="huggingface").launch(
requirements.txt ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # pip install -r requirements.txt
2
+
3
+ # base ----------------------------------------
4
+ matplotlib>=3.2.2
5
+ numpy>=1.18.5
6
+ opencv-python-headless
7
+ Pillow
8
+ PyYAML>=5.3.1
9
+ scipy>=1.4.1
10
+ torch>=1.7.0
11
+ torchvision>=0.8.1
12
+ tqdm>=4.41.0
13
+ kili
14
+
15
+ # logging -------------------------------------
16
+ tensorboard>=2.4.1
17
+ # wandb
18
+
19
+ # plotting ------------------------------------
20
+ seaborn>=0.11.0
21
+ pandas
22
+
23
+ # export --------------------------------------
24
+ # coremltools>=4.1
25
+ # onnx>=1.9.0
26
+ # scikit-learn==0.19.2 # for coreml quantization
27
+
28
+ # extras --------------------------------------
29
+ # Cython # for pycocotools https://github.com/cocodataset/cocoapi/issues/172
30
+ # pycocotools>=2.0 # COCO mAP
31
+ # albumentations>=1.0.3
32
+ thop # FLOPs computation