Spaces:
Runtime error
Runtime error
Commit
·
11dd1e3
1
Parent(s):
5d37f7b
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,14 +3,14 @@ import torch
|
|
| 3 |
from ultralyticsplus import YOLO, render_result
|
| 4 |
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
def yoloV8_func(image: gr.
|
| 11 |
-
image_size: gr.
|
| 12 |
-
conf_threshold: gr.
|
| 13 |
-
iou_threshold: gr.
|
| 14 |
"""This function performs YOLOv8 object detection on the given image.
|
| 15 |
|
| 16 |
Args:
|
|
@@ -41,24 +41,25 @@ def yoloV8_func(image: gr.inputs.Image = None,
|
|
| 41 |
|
| 42 |
|
| 43 |
inputs = [
|
| 44 |
-
gr.
|
| 45 |
-
gr.
|
| 46 |
step=32, label="Image Size"),
|
| 47 |
-
gr.
|
| 48 |
step=0.05, label="Confidence Threshold"),
|
| 49 |
-
gr.
|
| 50 |
step=0.05, label="IOU Threshold"),
|
| 51 |
]
|
| 52 |
|
| 53 |
|
| 54 |
-
outputs = gr.outputs.Image(
|
|
|
|
| 55 |
|
| 56 |
title = "YOLOv8 101: Custom Object Detection on Construction Workers"
|
| 57 |
|
| 58 |
|
| 59 |
examples = [['img1.jpg', 640, 0.5, 0.7],
|
| 60 |
['img2.jpg', 800, 0.5, 0.6],
|
| 61 |
-
['
|
| 62 |
|
| 63 |
yolo_app = gr.Interface(
|
| 64 |
fn=yoloV8_func,
|
|
|
|
| 3 |
from ultralyticsplus import YOLO, render_result
|
| 4 |
|
| 5 |
|
| 6 |
+
torch.hub.download_url_to_file("img1.jpg", 'one.jpg')
|
| 7 |
+
torch.hub.download_url_to_file("img2.jpg", 'two.jpg')
|
| 8 |
+
torch.hub.download_url_to_file("img3.jpg", 'three.jpg')
|
| 9 |
+
|
| 10 |
+
def yoloV8_func(image: gr.Image = None,
|
| 11 |
+
image_size: gr.Slider = 640,
|
| 12 |
+
conf_threshold: gr.Slider = 0.4,
|
| 13 |
+
iou_threshold: gr.Slider = 0.50):
|
| 14 |
"""This function performs YOLOv8 object detection on the given image.
|
| 15 |
|
| 16 |
Args:
|
|
|
|
| 41 |
|
| 42 |
|
| 43 |
inputs = [
|
| 44 |
+
gr.Image(type="filepath", label="Input Image"),
|
| 45 |
+
gr.Slider(minimum=320, maximum=1280, default=640,
|
| 46 |
step=32, label="Image Size"),
|
| 47 |
+
gr.Slider(minimum=0.0, maximum=1.0, default=0.25,
|
| 48 |
step=0.05, label="Confidence Threshold"),
|
| 49 |
+
gr.Slider(minimum=0.0, maximum=1.0, default=0.45,
|
| 50 |
step=0.05, label="IOU Threshold"),
|
| 51 |
]
|
| 52 |
|
| 53 |
|
| 54 |
+
outputs = gr.outputs.Image( label="Output Image")
|
| 55 |
+
|
| 56 |
|
| 57 |
title = "YOLOv8 101: Custom Object Detection on Construction Workers"
|
| 58 |
|
| 59 |
|
| 60 |
examples = [['img1.jpg', 640, 0.5, 0.7],
|
| 61 |
['img2.jpg', 800, 0.5, 0.6],
|
| 62 |
+
['img3.jpg', 900, 0.5, 0.8]]
|
| 63 |
|
| 64 |
yolo_app = gr.Interface(
|
| 65 |
fn=yoloV8_func,
|