Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -34,30 +34,77 @@ def yolov9_inference(img_path, model_path,image_size, conf_threshold, iou_thresh
|
|
34 |
return output[0]
|
35 |
|
36 |
|
37 |
-
|
38 |
-
gr.
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
return output[0]
|
35 |
|
36 |
|
37 |
+
def app():
|
38 |
+
with gr.Blocks():
|
39 |
+
with gr.Row():
|
40 |
+
with gr.Column():
|
41 |
+
img_path = gr.Image(type="filepath", label="Image")
|
42 |
+
model_path = gr.Dropdown(
|
43 |
+
label="Model",
|
44 |
+
choices=[
|
45 |
+
"gelan-c.pt",
|
46 |
+
"gelan-e.pt",
|
47 |
+
"yolov9-c.pt",
|
48 |
+
"yolov9-e.pt",
|
49 |
+
],
|
50 |
+
default="gelan-e.pt",
|
51 |
+
)
|
52 |
+
image_size = gr.Slider(
|
53 |
+
label="Image Size",
|
54 |
+
min=320,
|
55 |
+
max=1280,
|
56 |
+
step=32,
|
57 |
+
default=640,
|
58 |
+
)
|
59 |
+
conf_threshold = gr.Slider(
|
60 |
+
label="Confidence Threshold",
|
61 |
+
min=0.1,
|
62 |
+
max=1.0,
|
63 |
+
step=0.1,
|
64 |
+
default=0.4,
|
65 |
+
)
|
66 |
+
iou_threshold = gr.Slider(
|
67 |
+
label="IoU Threshold",
|
68 |
+
min=0.1,
|
69 |
+
max=1.0,
|
70 |
+
step=0.1,
|
71 |
+
default=0.5,
|
72 |
+
)
|
73 |
+
yolov9_infer = gr.Button(value="Inferince")
|
74 |
+
|
75 |
+
with gr.Column():
|
76 |
+
output_numpy = gr.Image(type="numpy",label="Output")
|
77 |
+
|
78 |
+
yolov9_inference.click(
|
79 |
+
fn=yolov9_inference,
|
80 |
+
inputs=[
|
81 |
+
img_path,
|
82 |
+
model_path,
|
83 |
+
image_size,
|
84 |
+
conf_threshold,
|
85 |
+
iou_threshold,
|
86 |
+
],
|
87 |
+
outputs=[output_numpy],
|
88 |
+
)
|
89 |
+
|
90 |
+
|
91 |
+
gradio_app = gr.Blocks()
|
92 |
+
with gradio_app:
|
93 |
+
gr.HTML(
|
94 |
+
"""
|
95 |
+
<h1 style='text-align: center'>
|
96 |
+
YOLOv9: Learning What You Want to Learn Using Programmable Gradient Information
|
97 |
+
</h1>
|
98 |
+
""")
|
99 |
+
gr.HTML(
|
100 |
+
"""
|
101 |
+
<h3 style='text-align: center'>
|
102 |
+
Follow me for more!
|
103 |
+
<a href='https://twitter.com/kadirnar_ai' target='_blank'>Twitter</a> | <a href='https://github.com/kadirnar' target='_blank'>Github</a> | <a href='https://www.linkedin.com/in/kadir-nar/' target='_blank'>Linkedin</a> | <a href='https://www.huggingface.co/kadirnar/' target='_blank'>HuggingFace</a>
|
104 |
+
</h3>
|
105 |
+
""")
|
106 |
+
with gr.Row():
|
107 |
+
with gr.Column():
|
108 |
+
app()
|
109 |
+
|
110 |
+
gradio_app.launch(debug=True)
|