Spaces:
Sleeping
Sleeping
Update src/ui_components_original.py
Browse files
src/ui_components_original.py
CHANGED
|
@@ -184,9 +184,10 @@ def standalone_run_analysis(
|
|
| 184 |
'additional_notes': notes
|
| 185 |
}
|
| 186 |
|
| 187 |
-
#
|
| 188 |
-
if manual_annotation
|
| 189 |
q_for_ai['manual_mask'] = manual_annotation
|
|
|
|
| 190 |
# Run AI
|
| 191 |
analysis_result = wound_analyzer.analyze_wound(img_path, q_for_ai)
|
| 192 |
if not analysis_result or not analysis_result.get("success"):
|
|
@@ -673,9 +674,9 @@ button.gr-button:hover, button.gr-button-primary:hover {
|
|
| 673 |
with gr.Column(scale=1):
|
| 674 |
gr.HTML("<h3>📸 Wound Image</h3>")
|
| 675 |
wound_image = gr.Image(label="Upload Wound Image", type="filepath")
|
| 676 |
-
#
|
| 677 |
gr.HTML("<h3>✏️ Manual Annotation (optional)</h3>")
|
| 678 |
-
manual_annotation = gr.Image(label="
|
| 679 |
gr.HTML("<h3>📝 Medical History</h3>")
|
| 680 |
previous_treatment = gr.Textbox(label="Previous Treatment", lines=3)
|
| 681 |
medical_history = gr.Textbox(label="Medical History", lines=3)
|
|
@@ -871,22 +872,6 @@ button.gr-button:hover, button.gr-button-primary:hover {
|
|
| 871 |
outputs=[new_patient_group, existing_patient_dd]
|
| 872 |
)
|
| 873 |
|
| 874 |
-
# Keep manual annotation preview in sync with uploaded image
|
| 875 |
-
def _update_annotation_preview(path):
|
| 876 |
-
try:
|
| 877 |
-
if not path:
|
| 878 |
-
return None
|
| 879 |
-
from PIL import Image
|
| 880 |
-
return Image.open(path).convert("RGB")
|
| 881 |
-
except Exception:
|
| 882 |
-
return None
|
| 883 |
-
|
| 884 |
-
wound_image.change(
|
| 885 |
-
_update_annotation_preview,
|
| 886 |
-
inputs=[wound_image],
|
| 887 |
-
outputs=[manual_annotation]
|
| 888 |
-
)
|
| 889 |
-
|
| 890 |
# --- IMPORTANT: call standalone GPU function via lambda to pass instance/ctx ---
|
| 891 |
analyze_btn.click(
|
| 892 |
fn=lambda mode, ex_lbl, np_n, np_a, np_g, wl, wd, p, m, i, d, pt, mh, med, al, nt, img, annot: \
|
|
|
|
| 184 |
'additional_notes': notes
|
| 185 |
}
|
| 186 |
|
| 187 |
+
# Attach manual annotation mask if provided
|
| 188 |
+
if manual_annotation:
|
| 189 |
q_for_ai['manual_mask'] = manual_annotation
|
| 190 |
+
|
| 191 |
# Run AI
|
| 192 |
analysis_result = wound_analyzer.analyze_wound(img_path, q_for_ai)
|
| 193 |
if not analysis_result or not analysis_result.get("success"):
|
|
|
|
| 674 |
with gr.Column(scale=1):
|
| 675 |
gr.HTML("<h3>📸 Wound Image</h3>")
|
| 676 |
wound_image = gr.Image(label="Upload Wound Image", type="filepath")
|
| 677 |
+
# Optional manual wound mask upload
|
| 678 |
gr.HTML("<h3>✏️ Manual Annotation (optional)</h3>")
|
| 679 |
+
manual_annotation = gr.Image(label="Upload Manual Wound Mask", type="filepath")
|
| 680 |
gr.HTML("<h3>📝 Medical History</h3>")
|
| 681 |
previous_treatment = gr.Textbox(label="Previous Treatment", lines=3)
|
| 682 |
medical_history = gr.Textbox(label="Medical History", lines=3)
|
|
|
|
| 872 |
outputs=[new_patient_group, existing_patient_dd]
|
| 873 |
)
|
| 874 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 875 |
# --- IMPORTANT: call standalone GPU function via lambda to pass instance/ctx ---
|
| 876 |
analyze_btn.click(
|
| 877 |
fn=lambda mode, ex_lbl, np_n, np_a, np_g, wl, wd, p, m, i, d, pt, mh, med, al, nt, img, annot: \
|