harshinde commited on
Commit
a831869
·
1 Parent(s): bbf2a5a

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

Files changed (3) hide show
  1. README.md +2 -2
  2. app.py +3 -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: 3.12.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
 
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.ANTIALIAS) # 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.inputs.Image(type='pil', label="Original Image")
21
- outputs = gr.outputs.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."
 
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
- # YOLOv5 requirements
5
- matplotlib>=3.2.2
6
- numpy>=1.18.5
7
- opencv-python>=4.1.1
8
- Pillow>=7.1.2
9
- PyYAML>=5.3.1
10
- requests>=2.23.0
11
- scipy>=1.4.1
12
- torch>=1.7.0
13
- torchvision>=0.8.1
14
- tqdm>=4.64.0
15
- seaborn>=0.11.0
16
 
17
  # Extras --------------------------------------
18
  ipython # interactive notebook
19
  psutil # system utilization
20
- thop>=0.1.1 # FLOPs computation
 
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