Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,27 +3,26 @@ from ultralytics import YOLO
|
|
3 |
# Import YOLOv9
|
4 |
import yolov9
|
5 |
|
6 |
-
# Define function to perform prediction with
|
7 |
def predict_image(image, model_path, image_size, conf_threshold, iou_threshold):
|
8 |
|
9 |
-
|
10 |
# Load YOLO model
|
11 |
model = YOLO(model_path)
|
12 |
|
13 |
# Perform inference with YOLO model
|
14 |
-
results = model(image, size=image_size, conf=conf_threshold, iou=iou_threshold)
|
15 |
|
16 |
# Render the output
|
17 |
output_image = results.render()
|
18 |
|
19 |
-
return output_image
|
20 |
|
21 |
# Define Gradio interface
|
22 |
def app():
|
23 |
with gr.Blocks():
|
24 |
with gr.Row():
|
25 |
with gr.Column():
|
26 |
-
img_path = gr.Image(type="
|
27 |
model_path = gr.Dropdown(
|
28 |
label="Model",
|
29 |
choices=[
|
@@ -52,10 +51,10 @@ def app():
|
|
52 |
step=0.1,
|
53 |
value=0.5,
|
54 |
)
|
55 |
-
yolov9_infer = gr.Button(
|
56 |
|
57 |
with gr.Column():
|
58 |
-
|
59 |
|
60 |
yolov9_infer.click(
|
61 |
fn=predict_image,
|
@@ -66,7 +65,7 @@ def app():
|
|
66 |
conf_threshold,
|
67 |
iou_threshold,
|
68 |
],
|
69 |
-
outputs=[
|
70 |
)
|
71 |
|
72 |
gradio_app = gr.Blocks()
|
|
|
3 |
# Import YOLOv9
|
4 |
import yolov9
|
5 |
|
6 |
+
# Define function to perform prediction with YOLO model
|
7 |
def predict_image(image, model_path, image_size, conf_threshold, iou_threshold):
|
8 |
|
|
|
9 |
# Load YOLO model
|
10 |
model = YOLO(model_path)
|
11 |
|
12 |
# Perform inference with YOLO model
|
13 |
+
results = model.predict(image, size=image_size, conf=conf_threshold, iou=iou_threshold)
|
14 |
|
15 |
# Render the output
|
16 |
output_image = results.render()
|
17 |
|
18 |
+
return output_image
|
19 |
|
20 |
# Define Gradio interface
|
21 |
def app():
|
22 |
with gr.Blocks():
|
23 |
with gr.Row():
|
24 |
with gr.Column():
|
25 |
+
img_path = gr.Image(type="file", label="Image")
|
26 |
model_path = gr.Dropdown(
|
27 |
label="Model",
|
28 |
choices=[
|
|
|
51 |
step=0.1,
|
52 |
value=0.5,
|
53 |
)
|
54 |
+
yolov9_infer = gr.Button(label="Submit")
|
55 |
|
56 |
with gr.Column():
|
57 |
+
output_image = gr.Image(type="numpy", label="Output")
|
58 |
|
59 |
yolov9_infer.click(
|
60 |
fn=predict_image,
|
|
|
65 |
conf_threshold,
|
66 |
iou_threshold,
|
67 |
],
|
68 |
+
outputs=[output_image],
|
69 |
)
|
70 |
|
71 |
gradio_app = gr.Blocks()
|