Spaces:
Runtime error
Runtime error
Martin Tomov
commited on
gr.Blocks
Browse files
app.py
CHANGED
|
@@ -222,10 +222,26 @@ examples = [
|
|
| 222 |
["flower-night.jpg"]
|
| 223 |
]
|
| 224 |
|
| 225 |
-
gr.
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 222 |
["flower-night.jpg"]
|
| 223 |
]
|
| 224 |
|
| 225 |
+
with gr.Blocks() as demo:
|
| 226 |
+
with gr.Row():
|
| 227 |
+
image_input = gr.Image(type="pil")
|
| 228 |
+
include_json = gr.Checkbox(label="Include JSON", value=False)
|
| 229 |
+
include_bboxes = gr.Checkbox(label="Include Bounding Boxes", value=False)
|
| 230 |
+
submit_button = gr.Button("Submit")
|
| 231 |
+
|
| 232 |
+
annotated_output = gr.Image(type="numpy")
|
| 233 |
+
json_output = gr.Textbox()
|
| 234 |
+
crops_output = gr.Gallery(label="Cropped Bounding Boxes").style(grid=[2], height="auto")
|
| 235 |
+
|
| 236 |
+
def update_outputs(image, include_json, include_bboxes):
|
| 237 |
+
results = process_image(image, include_json, include_bboxes)
|
| 238 |
+
if include_bboxes:
|
| 239 |
+
annotated_img, *crops, json_txt = results
|
| 240 |
+
return (annotated_img, json_txt, crops)
|
| 241 |
+
else:
|
| 242 |
+
annotated_img, json_txt = results
|
| 243 |
+
return (annotated_img, json_txt, [])
|
| 244 |
+
|
| 245 |
+
submit_button.click(update_outputs, [image_input, include_json, include_bboxes], [annotated_output, json_output, crops_output])
|
| 246 |
+
|
| 247 |
+
demo.launch()
|