Spaces:
Runtime error
Runtime error
Commit
·
b464d0d
1
Parent(s):
651391d
Upload app.py
Browse files
app.py
CHANGED
|
@@ -107,7 +107,7 @@ def predict(image, model_id, threshold):
|
|
| 107 |
|
| 108 |
|
| 109 |
with gr.Blocks() as demo:
|
| 110 |
-
gr.Markdown("""# <p align='center'><img width='500px' src='https://user-images.githubusercontent.com/34196005/215836968-fb54e066-a524-4caf-b469-92bbaa96f921.gif' /></p>
|
| 111 |
<p style='text-align: center'>
|
| 112 |
<br> <a href='https://yolov8.xyz' target='_blank'>project website</a> | <a href='https://github.com/keremberke/awesome-yolov8-models' target='_blank'>project github</a>
|
| 113 |
</p>
|
|
@@ -128,20 +128,22 @@ with gr.Blocks() as demo:
|
|
| 128 |
with gr.Row():
|
| 129 |
half_ind = int(len(det_examples) / 2)
|
| 130 |
with gr.Column():
|
| 131 |
-
|
| 132 |
-
det_examples[:
|
| 133 |
inputs=[detect_input, detect_model_id, detect_threshold],
|
| 134 |
outputs=detect_output,
|
| 135 |
fn=predict,
|
| 136 |
cache_examples=False,
|
|
|
|
| 137 |
)
|
| 138 |
with gr.Column():
|
| 139 |
-
|
| 140 |
det_examples[:half_ind],
|
| 141 |
inputs=[detect_input, detect_model_id, detect_threshold],
|
| 142 |
outputs=detect_output,
|
| 143 |
fn=predict,
|
| 144 |
cache_examples=False,
|
|
|
|
| 145 |
)
|
| 146 |
with gr.Tab("Segmentation"):
|
| 147 |
with gr.Row():
|
|
@@ -153,22 +155,24 @@ with gr.Blocks() as demo:
|
|
| 153 |
with gr.Column():
|
| 154 |
segment_output = gr.Image(label="Predictions:", interactive=False)
|
| 155 |
with gr.Row():
|
| 156 |
-
half_ind = int(len(
|
| 157 |
with gr.Column():
|
| 158 |
-
|
| 159 |
-
seg_examples[:
|
| 160 |
inputs=[segment_input, segment_model_id, segment_threshold],
|
| 161 |
outputs=segment_output,
|
| 162 |
fn=predict,
|
| 163 |
cache_examples=False,
|
|
|
|
| 164 |
)
|
| 165 |
with gr.Column():
|
| 166 |
-
|
| 167 |
seg_examples[:half_ind],
|
| 168 |
inputs=[segment_input, segment_model_id, segment_threshold],
|
| 169 |
outputs=segment_output,
|
| 170 |
fn=predict,
|
| 171 |
cache_examples=False,
|
|
|
|
| 172 |
)
|
| 173 |
with gr.Tab("Classification"):
|
| 174 |
with gr.Row():
|
|
@@ -182,32 +186,34 @@ with gr.Blocks() as demo:
|
|
| 182 |
label="Predictions:", show_label=True, num_top_classes=5
|
| 183 |
)
|
| 184 |
with gr.Row():
|
| 185 |
-
half_ind = int(len(
|
| 186 |
with gr.Column():
|
| 187 |
-
|
| 188 |
cls_examples[half_ind:],
|
| 189 |
inputs=[classify_input, classify_model_id, classify_threshold],
|
| 190 |
outputs=classify_output,
|
| 191 |
fn=predict,
|
| 192 |
cache_examples=False,
|
|
|
|
| 193 |
)
|
| 194 |
with gr.Column():
|
| 195 |
-
|
| 196 |
cls_examples[:half_ind],
|
| 197 |
inputs=[classify_input, classify_model_id, classify_threshold],
|
| 198 |
outputs=classify_output,
|
| 199 |
fn=predict,
|
| 200 |
cache_examples=False,
|
|
|
|
| 201 |
)
|
| 202 |
|
| 203 |
detect_button.click(
|
| 204 |
-
predict, inputs=[detect_input, detect_model_id, detect_threshold], outputs=detect_output
|
| 205 |
)
|
| 206 |
segment_button.click(
|
| 207 |
-
predict, inputs=[segment_input, segment_model_id, segment_threshold], outputs=segment_output
|
| 208 |
)
|
| 209 |
classify_button.click(
|
| 210 |
-
predict, inputs=[classify_input, classify_model_id, classify_threshold], outputs=classify_output
|
| 211 |
)
|
| 212 |
|
| 213 |
demo.launch(server_port=8080)
|
|
|
|
| 107 |
|
| 108 |
|
| 109 |
with gr.Blocks() as demo:
|
| 110 |
+
gr.Markdown("""# <p align='center'><a href="https://github.com/keremberke/awesome-yolov8-models" target='_blank'><img width='500px' src='https://user-images.githubusercontent.com/34196005/215836968-fb54e066-a524-4caf-b469-92bbaa96f921.gif' /></a></p>
|
| 111 |
<p style='text-align: center'>
|
| 112 |
<br> <a href='https://yolov8.xyz' target='_blank'>project website</a> | <a href='https://github.com/keremberke/awesome-yolov8-models' target='_blank'>project github</a>
|
| 113 |
</p>
|
|
|
|
| 128 |
with gr.Row():
|
| 129 |
half_ind = int(len(det_examples) / 2)
|
| 130 |
with gr.Column():
|
| 131 |
+
gr.Examples(
|
| 132 |
+
det_examples[half_ind:],
|
| 133 |
inputs=[detect_input, detect_model_id, detect_threshold],
|
| 134 |
outputs=detect_output,
|
| 135 |
fn=predict,
|
| 136 |
cache_examples=False,
|
| 137 |
+
run_on_click=True,
|
| 138 |
)
|
| 139 |
with gr.Column():
|
| 140 |
+
gr.Examples(
|
| 141 |
det_examples[:half_ind],
|
| 142 |
inputs=[detect_input, detect_model_id, detect_threshold],
|
| 143 |
outputs=detect_output,
|
| 144 |
fn=predict,
|
| 145 |
cache_examples=False,
|
| 146 |
+
run_on_click=True,
|
| 147 |
)
|
| 148 |
with gr.Tab("Segmentation"):
|
| 149 |
with gr.Row():
|
|
|
|
| 155 |
with gr.Column():
|
| 156 |
segment_output = gr.Image(label="Predictions:", interactive=False)
|
| 157 |
with gr.Row():
|
| 158 |
+
half_ind = int(len(seg_examples) / 2)
|
| 159 |
with gr.Column():
|
| 160 |
+
gr.Examples(
|
| 161 |
+
seg_examples[half_ind:],
|
| 162 |
inputs=[segment_input, segment_model_id, segment_threshold],
|
| 163 |
outputs=segment_output,
|
| 164 |
fn=predict,
|
| 165 |
cache_examples=False,
|
| 166 |
+
run_on_click=True,
|
| 167 |
)
|
| 168 |
with gr.Column():
|
| 169 |
+
gr.Examples(
|
| 170 |
seg_examples[:half_ind],
|
| 171 |
inputs=[segment_input, segment_model_id, segment_threshold],
|
| 172 |
outputs=segment_output,
|
| 173 |
fn=predict,
|
| 174 |
cache_examples=False,
|
| 175 |
+
run_on_click=True,
|
| 176 |
)
|
| 177 |
with gr.Tab("Classification"):
|
| 178 |
with gr.Row():
|
|
|
|
| 186 |
label="Predictions:", show_label=True, num_top_classes=5
|
| 187 |
)
|
| 188 |
with gr.Row():
|
| 189 |
+
half_ind = int(len(cls_examples) / 2)
|
| 190 |
with gr.Column():
|
| 191 |
+
gr.Examples(
|
| 192 |
cls_examples[half_ind:],
|
| 193 |
inputs=[classify_input, classify_model_id, classify_threshold],
|
| 194 |
outputs=classify_output,
|
| 195 |
fn=predict,
|
| 196 |
cache_examples=False,
|
| 197 |
+
run_on_click=True,
|
| 198 |
)
|
| 199 |
with gr.Column():
|
| 200 |
+
gr.Examples(
|
| 201 |
cls_examples[:half_ind],
|
| 202 |
inputs=[classify_input, classify_model_id, classify_threshold],
|
| 203 |
outputs=classify_output,
|
| 204 |
fn=predict,
|
| 205 |
cache_examples=False,
|
| 206 |
+
run_on_click=True,
|
| 207 |
)
|
| 208 |
|
| 209 |
detect_button.click(
|
| 210 |
+
predict, inputs=[detect_input, detect_model_id, detect_threshold], outputs=detect_output, api_name="detect"
|
| 211 |
)
|
| 212 |
segment_button.click(
|
| 213 |
+
predict, inputs=[segment_input, segment_model_id, segment_threshold], outputs=segment_output, api_name="segment"
|
| 214 |
)
|
| 215 |
classify_button.click(
|
| 216 |
+
predict, inputs=[classify_input, classify_model_id, classify_threshold], outputs=classify_output, api_name="classify"
|
| 217 |
)
|
| 218 |
|
| 219 |
demo.launch(server_port=8080)
|