kadirnar commited on
Commit
c1d83a1
·
verified ·
1 Parent(s): 2576708

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +74 -27
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
- inputs = [
38
- gr.Image(type="filepath", label="Input Image"),
39
- gr.Dropdown(
40
- label="Model",
41
- choices=[
42
- "gelan-c.pt",
43
- "gelan-e.pt",
44
- "yolov9-c.pt",
45
- "yolov9-e.pt",
46
- ],
47
- value="gelan-c.pt",
48
- ),
49
- gr.Slider(minimum=320, maximum=1280, value=640, step=32, label="Image Size"),
50
- gr.Slider(minimum=0.0, maximum=1.0, value=0.25, step=0.05, label="Confidence Threshold"),
51
- gr.Slider(minimum=0.0, maximum=1.0, value=0.45, step=0.05, label="IOU Threshold"),
52
- ]
53
-
54
- outputs = gr.Image(type="numpy",label="Output Image")
55
- title = "YOLOv9: Learning What You Want to Learn Using Programmable Gradient Information"
56
-
57
- demo_app = gr.Interface(
58
- fn=yolov9_inference,
59
- inputs=inputs,
60
- outputs=outputs,
61
- title=title,
62
- )
63
- demo_app.launch(debug=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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)