Spaces:
Runtime error
Runtime error
Eugene Siow
commited on
Commit
·
789f9df
1
Parent(s):
0c92f53
Initial commit.
Browse files- .gitignore +6 -0
- README.md +4 -4
- app.py +32 -0
- packages.txt +4 -0
- requirements.txt +7 -0
.gitignore
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.idea/
|
2 |
+
venv/
|
3 |
+
flagged/
|
4 |
+
*.jpg
|
5 |
+
*.png
|
6 |
+
*.db
|
README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
app_file: app.py
|
8 |
pinned: false
|
|
|
1 |
---
|
2 |
+
title: YOLOv5
|
3 |
+
emoji: 🤙
|
4 |
+
colorFrom: purple
|
5 |
+
colorTo: pink
|
6 |
sdk: gradio
|
7 |
app_file: app.py
|
8 |
pinned: false
|
app.py
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import torch
|
3 |
+
|
4 |
+
|
5 |
+
title = "Object Detection with YOLOv5"
|
6 |
+
description = "Detect objects in images with YOLOv5 (You Only Look Once v5)"
|
7 |
+
article = "<p style='text-align: center'><a href='https://news.machinelearning.sg/posts/object_detection_with_yolov5/'>Blog</a> | <a href='https://github.com/eugenesiow/practical-ml'>Github Repo</a></p>"
|
8 |
+
|
9 |
+
|
10 |
+
def inference(img):
|
11 |
+
results = model([img], size=640)
|
12 |
+
results.render()
|
13 |
+
return results.imgs[0]
|
14 |
+
|
15 |
+
|
16 |
+
torch.hub.download_url_to_file('https://images.unsplash.com/photo-1526497127495-3b388dc87620?auto=format&fit=crop&w=640&q=80',
|
17 |
+
'baseball.jpg')
|
18 |
+
torch.hub.download_url_to_file('https://images.unsplash.com/photo-1608278047522-58806a6ac85b?auto=format&fit=crop&w=640&q=80', 'hulk.jpg')
|
19 |
+
model = torch.hub.load('ultralytics/yolov5', 'yolov5s')
|
20 |
+
|
21 |
+
|
22 |
+
gr.Interface(
|
23 |
+
inference,
|
24 |
+
gr.inputs.Image(type="pil", label="Input"),
|
25 |
+
gr.outputs.Image(type="pil", label="Output"),
|
26 |
+
title=title,
|
27 |
+
description=description,
|
28 |
+
article=article,
|
29 |
+
examples=[['baseball.jpg'], ['hulk.jpg']],
|
30 |
+
enable_queue=True,
|
31 |
+
allow_flagging=False,
|
32 |
+
).launch(debug=False)
|
packages.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
python3-opencv
|
2 |
+
ffmpeg
|
3 |
+
libsm6
|
4 |
+
libxext6
|
requirements.txt
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
opencv-python==4.5.4.58
|
2 |
+
pyaml==21.10.1
|
3 |
+
PyYAML==6.0
|
4 |
+
seaborn==0.11.2
|
5 |
+
torch==1.10.0
|
6 |
+
torchvision==0.11.1
|
7 |
+
tqdm==4.62.3
|