Fix compatibility with latest Gradio and Pillow versions
Browse files- Update to Gradio 6.1.0 (newer SDK version)
- Update Gradio API: gr.inputs.Image gr.Image and gr.outputs.Image gr.Image
- Replace deprecated PIL method: Image.ANTIALIAS Image.LANCZOS
- Add ultralytics package dependency for YOLOv5 model support
- README.md +2 -2
- app.py +3 -3
- requirements.txt +13 -14
README.md
CHANGED
|
@@ -4,10 +4,10 @@ emoji: 🔥
|
|
| 4 |
colorFrom: purple
|
| 5 |
colorTo: pink
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: apache-2.0
|
| 11 |
---
|
| 12 |
|
| 13 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 4 |
colorFrom: purple
|
| 5 |
colorTo: pink
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 6.1.0
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: apache-2.0
|
| 11 |
---
|
| 12 |
|
| 13 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
CHANGED
|
@@ -11,14 +11,14 @@ model = torch.hub.load('ultralytics/yolov5', 'custom', 'best.pt') # force_reloa
|
|
| 11 |
|
| 12 |
def yolo(im, size=640):
|
| 13 |
g = (size / max(im.size)) # gain
|
| 14 |
-
im = im.resize((int(x * g) for x in im.size), Image.
|
| 15 |
results = model(im) # inference
|
| 16 |
results.render() # updates results.ims with boxes and labels
|
| 17 |
return Image.fromarray(results.ims[0])
|
| 18 |
|
| 19 |
|
| 20 |
-
inputs = gr.
|
| 21 |
-
outputs = gr.
|
| 22 |
|
| 23 |
title = "YOLOv5"
|
| 24 |
description = "YOLOv5 demo for fire detection. Upload an image or click an example image to use."
|
|
|
|
| 11 |
|
| 12 |
def yolo(im, size=640):
|
| 13 |
g = (size / max(im.size)) # gain
|
| 14 |
+
im = im.resize((int(x * g) for x in im.size), Image.LANCZOS) # resize
|
| 15 |
results = model(im) # inference
|
| 16 |
results.render() # updates results.ims with boxes and labels
|
| 17 |
return Image.fromarray(results.ims[0])
|
| 18 |
|
| 19 |
|
| 20 |
+
inputs = gr.Image(type='pil', label="Original Image")
|
| 21 |
+
outputs = gr.Image(type="pil", label="Output Image")
|
| 22 |
|
| 23 |
title = "YOLOv5"
|
| 24 |
description = "YOLOv5 demo for fire detection. Upload an image or click an example image to use."
|
requirements.txt
CHANGED
|
@@ -1,20 +1,19 @@
|
|
| 1 |
gradio
|
| 2 |
pandas
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
seaborn>=0.11.0
|
| 16 |
|
| 17 |
# Extras --------------------------------------
|
| 18 |
ipython # interactive notebook
|
| 19 |
psutil # system utilization
|
| 20 |
-
thop
|
|
|
|
| 1 |
gradio
|
| 2 |
pandas
|
| 3 |
+
ultralytics
|
| 4 |
+
matplotlib
|
| 5 |
+
numpy
|
| 6 |
+
opencv-python
|
| 7 |
+
Pillow
|
| 8 |
+
PyYAML
|
| 9 |
+
requests
|
| 10 |
+
scipy
|
| 11 |
+
torch
|
| 12 |
+
torchvision
|
| 13 |
+
tqdm
|
| 14 |
+
seaborn
|
|
|
|
| 15 |
|
| 16 |
# Extras --------------------------------------
|
| 17 |
ipython # interactive notebook
|
| 18 |
psutil # system utilization
|
| 19 |
+
thop # FLOPs computation
|