Abs6187 commited on
Commit
1752e5c
·
verified ·
1 Parent(s): 0123356

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -18
app.py CHANGED
@@ -97,12 +97,43 @@ def yoloV8_func(image=None, image_size=640, conf_threshold=0.4, iou_threshold=0.
97
 
98
  return annotated_image
99
 
100
- inputs = [
101
- gr.Image(type="filepath", label="Input Image"),
102
- gr.Slider(minimum=320, maximum=1280, value=640, step=32, label="Image Size"),
103
- gr.Slider(minimum=0.0, maximum=1.0, value=0.4, step=0.05, label="Confidence Threshold"),
104
- gr.Slider(minimum=0.0, maximum=1.0, value=0.5, step=0.05, label="IOU Threshold")
105
- ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
 
107
  outputs = gr.Image(type="pil", label="Output Image")
108
 
@@ -119,16 +150,5 @@ article = """
119
  <p>Upload your images and try it out!</p>
120
  """
121
 
122
- yolo_app = gr.Interface(
123
- fn=yoloV8_func,
124
- inputs=inputs,
125
- outputs=outputs,
126
- title=title,
127
- description=description,
128
- article=article,
129
- examples=[["sample_1.jpg"], ["sample_2.jpg"], ["sample_3.jpg"], ["sample_4.jpg"], ["sample_5.jpg"]],
130
- cache_examples=True,
131
- )
132
-
133
  if __name__ == "__main__":
134
- yolo_app.launch(debug=True)
 
97
 
98
  return annotated_image
99
 
100
+ with gr.Blocks() as demo:
101
+ with gr.Row():
102
+ image_input = gr.Image(type="filepath", label="Input Image")
103
+ output_image = gr.Image(type="pil", label="Output Image")
104
+
105
+ with gr.Row():
106
+ image_size = gr.Slider(
107
+ minimum=320,
108
+ maximum=1280,
109
+ value=640,
110
+ step=32,
111
+ label="Image Size",
112
+ interactive=True
113
+ )
114
+ conf_threshold = gr.Slider(
115
+ minimum=0.1,
116
+ maximum=1.0,
117
+ value=0.4,
118
+ step=0.05,
119
+ label="Confidence Threshold",
120
+ interactive=True
121
+ )
122
+ iou_threshold = gr.Slider(
123
+ minimum=0.1,
124
+ maximum=1.0,
125
+ value=0.5,
126
+ step=0.05,
127
+ label="IOU Threshold",
128
+ interactive=True
129
+ )
130
+
131
+ process_btn = gr.Button("Process Image")
132
+ process_btn.click(
133
+ fn=yoloV8_func,
134
+ inputs=[image_input, image_size, conf_threshold, iou_threshold],
135
+ outputs=output_image
136
+ )
137
 
138
  outputs = gr.Image(type="pil", label="Output Image")
139
 
 
150
  <p>Upload your images and try it out!</p>
151
  """
152
 
 
 
 
 
 
 
 
 
 
 
 
153
  if __name__ == "__main__":
154
+ demo.launch(debug=True)