Danil
commited on
Commit
·
7e64245
1
Parent(s):
26343d6
add
Browse files- README.md +4 -4
- app.py +22 -0
- packages.txt +3 -0
- requirements.txt +23 -0
README.md
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
---
|
2 |
title: Yolov3
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
-
sdk:
|
7 |
app_file: app.py
|
8 |
pinned: false
|
9 |
---
|
|
|
1 |
---
|
2 |
title: Yolov3
|
3 |
+
emoji: 🔥
|
4 |
+
colorFrom: pink
|
5 |
+
colorTo: purple
|
6 |
+
sdk: gradio
|
7 |
app_file: app.py
|
8 |
pinned: false
|
9 |
---
|
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import torch
|
3 |
+
from PIL import Image
|
4 |
+
# Images
|
5 |
+
torch.hub.download_url_to_file('https://cdn.pixabay.com/photo/2016/06/15/01/11/soccer-1457988_1280.jpg', 'soccer.jpg')
|
6 |
+
torch.hub.download_url_to_file('https://cdn.pixabay.com/photo/2016/11/21/14/31/vw-bus-1845719_1280.jpg', 'bus.jpg')
|
7 |
+
# Model
|
8 |
+
model = torch.hub.load('ultralytics/yolov3', 'yolov3') # or yolov3-spp, yolov3-tiny, custom
|
9 |
+
def yolo(im, size=640):
|
10 |
+
g = (size / max(im.size)) # gain
|
11 |
+
im = im.resize((int(x * g) for x in im.size), Image.ANTIALIAS) # resize
|
12 |
+
results = model(im) # inference
|
13 |
+
results.render() # updates results.imgs with boxes and labels
|
14 |
+
return Image.fromarray(results.imgs[0])
|
15 |
+
inputs = gr.inputs.Image(type='pil', label="Original Image")
|
16 |
+
outputs = gr.outputs.Image(type="pil", label="Output Image")
|
17 |
+
title = "YOLOv3"
|
18 |
+
description = "YOLOv3 Gradio demo for object detection. Upload an image or click an example image to use."
|
19 |
+
article = "<p style='text-align: center'>YOLOv3 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/yolov3' target='_blank'>Source code</a> |<a href='https://apps.apple.com/app/id1452689527' target='_blank'>iOS App</a></p>"
|
20 |
+
examples = [['soccer.jpg'], ['bus.jpg']]
|
21 |
+
gr.Interface(yolo, inputs, outputs, title=title, description=description, article=article, examples=examples, theme="huggingface").launch(
|
22 |
+
debug=True)
|
packages.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
ffmpeg
|
2 |
+
libsm6
|
3 |
+
libxext6
|
requirements.txt
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
opencv-python-headless
|
2 |
+
|
3 |
+
# pip install -r requirements.txt
|
4 |
+
|
5 |
+
# Base ----------------------------------------
|
6 |
+
matplotlib>=3.2.2
|
7 |
+
numpy>=1.18.5
|
8 |
+
opencv-python>=4.1.2
|
9 |
+
Pillow>=7.1.2
|
10 |
+
PyYAML>=5.3.1
|
11 |
+
requests>=2.23.0
|
12 |
+
scipy>=1.4.1
|
13 |
+
torch>=1.7.0
|
14 |
+
torchvision>=0.8.1
|
15 |
+
tqdm>=4.41.0
|
16 |
+
|
17 |
+
# Logging -------------------------------------
|
18 |
+
tensorboard>=2.4.1
|
19 |
+
# wandb
|
20 |
+
|
21 |
+
# Plotting ------------------------------------
|
22 |
+
pandas>=1.1.4
|
23 |
+
seaborn>=0.11.0
|