ducngg commited on
Commit
78117b4
1 Parent(s): b489f83

Fix bug and new samples

Browse files
app.py CHANGED
@@ -1,14 +1,8 @@
1
  import gradio as gr
2
- import torch
 
3
  from ultralytics import YOLO
4
-
5
- torch.hub.download_url_to_file(
6
- 'http://www.imesclub.org/images/stories/arabidentity.jpeg', 'one.jpg')
7
- torch.hub.download_url_to_file(
8
- 'https://lp-cms-production.imgix.net/2023-08/GettyImages-1224548888-16.9.jpg', 'two.jpg')
9
- torch.hub.download_url_to_file(
10
- 'https://s.wsj.net/public/resources/images/OB-EQ974_diwali_G_20091014112400.jpg', 'three.jpg')
11
-
12
 
13
  def handle_classify(image=None):
14
  """This function performs YOLOv8 object detection on the given image.
@@ -36,7 +30,7 @@ def handle_classify(image=None):
36
 
37
 
38
  inputs = [
39
- gr.Image(type="filepath", label="Input Image"),
40
  ]
41
 
42
 
@@ -44,10 +38,8 @@ outputs = gr.Textbox()
44
 
45
  title = "Racist model v2"
46
 
47
-
48
- examples = [['one.jpg'],
49
- ['two.jpg'],
50
- ['three.jpg']]
51
 
52
  yolo_app = gr.Interface(
53
  fn=handle_classify,
 
1
  import gradio as gr
2
+ from PIL import Image
3
+ import numpy as np
4
  from ultralytics import YOLO
5
+ import os
 
 
 
 
 
 
 
6
 
7
  def handle_classify(image=None):
8
  """This function performs YOLOv8 object detection on the given image.
 
30
 
31
 
32
  inputs = [
33
+ gr.Image(type='numpy', label="Input Image"),
34
  ]
35
 
36
 
 
38
 
39
  title = "Racist model v2"
40
 
41
+ SAMPLE_DIR = 'samples'
42
+ examples = [np.array(Image.open(os.path.join(SAMPLE_DIR, path))) for path in os.listdir(SAMPLE_DIR)]
 
 
43
 
44
  yolo_app = gr.Interface(
45
  fn=handle_classify,
requirements.txt CHANGED
@@ -1,3 +1,4 @@
1
  torch
2
  gradio==4.14.0
3
- ultralytics
 
 
1
  torch
2
  gradio==4.14.0
3
+ ultralytics
4
+ PIL
samples/sample1.jpg ADDED
samples/sample2.jpg ADDED
samples/sample3.jpeg ADDED
samples/sample4.jpg ADDED