Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -9,18 +9,20 @@ torch.hub.download_url_to_file('https://github.com/ultralytics/yolov5/raw/master
|
|
9 |
# Model
|
10 |
model = torch.hub.load('ultralytics/yolov5', 'yolov5s') # force_reload=True to update
|
11 |
|
12 |
-
|
13 |
def yolo(im, size=640):
|
14 |
g = (size / max(im.size)) # gain
|
15 |
im = im.resize((int(x * g) for x in im.size), Image.ANTIALIAS) # resize
|
16 |
|
17 |
results = model(im) # inference
|
18 |
results.render() # updates results.imgs with boxes and labels
|
19 |
-
|
|
|
|
|
20 |
|
21 |
|
22 |
inputs = gr.inputs.Image(type='pil', label="Original Image")
|
23 |
-
outputs = gr.outputs.Image(type="
|
24 |
|
25 |
title = "YOLOv5"
|
26 |
description = "YOLOv5 Gradio demo for object detection. Upload an image or click an example image to use."
|
|
|
9 |
# Model
|
10 |
model = torch.hub.load('ultralytics/yolov5', 'yolov5s') # force_reload=True to update
|
11 |
|
12 |
+
os.mkdir("out")
|
13 |
def yolo(im, size=640):
|
14 |
g = (size / max(im.size)) # gain
|
15 |
im = im.resize((int(x * g) for x in im.size), Image.ANTIALIAS) # resize
|
16 |
|
17 |
results = model(im) # inference
|
18 |
results.render() # updates results.imgs with boxes and labels
|
19 |
+
results.save()
|
20 |
+
os.system("ls")
|
21 |
+
return "out.png"
|
22 |
|
23 |
|
24 |
inputs = gr.inputs.Image(type='pil', label="Original Image")
|
25 |
+
outputs = gr.outputs.Image(type="file", label="Output Image")
|
26 |
|
27 |
title = "YOLOv5"
|
28 |
description = "YOLOv5 Gradio demo for object detection. Upload an image or click an example image to use."
|