Update app.py
Browse files
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 |
-
|
| 101 |
-
gr.
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 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 |
-
|
|
|
|
| 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)
|