chore: remove button and inference on image loading
Browse files
app.py
CHANGED
|
@@ -480,11 +480,11 @@ def handle_upload_preview(
|
|
| 480 |
|
| 481 |
return (
|
| 482 |
display,
|
| 483 |
-
"Image uploaded.
|
| 484 |
-
"",
|
| 485 |
pd.DataFrame(),
|
| 486 |
gr.update(value=""),
|
| 487 |
-
{"image": np_image, "mask": None},
|
| 488 |
)
|
| 489 |
except Exception as exc: # pragma: no cover - surfaced in UI
|
| 490 |
return None, f"Failed to load image: {exc}", "", pd.DataFrame(), gr.update(value=""), None
|
|
@@ -547,7 +547,6 @@ def build_demo() -> gr.Blocks:
|
|
| 547 |
|
| 548 |
gr.Markdown("---")
|
| 549 |
|
| 550 |
-
infer_btn = gr.Button("Run inference", variant="primary")
|
| 551 |
status_text = gr.Markdown()
|
| 552 |
with gr.Row():
|
| 553 |
with gr.Column():
|
|
@@ -592,6 +591,10 @@ def build_demo() -> gr.Blocks:
|
|
| 592 |
ground_truth_display,
|
| 593 |
image_state,
|
| 594 |
],
|
|
|
|
|
|
|
|
|
|
|
|
|
| 595 |
)
|
| 596 |
|
| 597 |
upload_component.upload(
|
|
@@ -605,9 +608,7 @@ def build_demo() -> gr.Blocks:
|
|
| 605 |
ground_truth_display,
|
| 606 |
image_state,
|
| 607 |
],
|
| 608 |
-
)
|
| 609 |
-
|
| 610 |
-
infer_btn.click(
|
| 611 |
fn=run_inference,
|
| 612 |
inputs=[image_state, head_dropdown],
|
| 613 |
outputs=[main_prediction, prediction_probs],
|
|
|
|
| 480 |
|
| 481 |
return (
|
| 482 |
display,
|
| 483 |
+
"Image uploaded. Computing predictions...",
|
| 484 |
+
"",
|
| 485 |
pd.DataFrame(),
|
| 486 |
gr.update(value=""),
|
| 487 |
+
{"image": np_image, "mask": None},
|
| 488 |
)
|
| 489 |
except Exception as exc: # pragma: no cover - surfaced in UI
|
| 490 |
return None, f"Failed to load image: {exc}", "", pd.DataFrame(), gr.update(value=""), None
|
|
|
|
| 547 |
|
| 548 |
gr.Markdown("---")
|
| 549 |
|
|
|
|
| 550 |
status_text = gr.Markdown()
|
| 551 |
with gr.Row():
|
| 552 |
with gr.Column():
|
|
|
|
| 591 |
ground_truth_display,
|
| 592 |
image_state,
|
| 593 |
],
|
| 594 |
+
).then(
|
| 595 |
+
fn=run_inference,
|
| 596 |
+
inputs=[image_state, head_dropdown],
|
| 597 |
+
outputs=[main_prediction, prediction_probs],
|
| 598 |
)
|
| 599 |
|
| 600 |
upload_component.upload(
|
|
|
|
| 608 |
ground_truth_display,
|
| 609 |
image_state,
|
| 610 |
],
|
| 611 |
+
).then(
|
|
|
|
|
|
|
| 612 |
fn=run_inference,
|
| 613 |
inputs=[image_state, head_dropdown],
|
| 614 |
outputs=[main_prediction, prediction_probs],
|