LiangLabUMB commited on
Commit
8ce5771
·
verified ·
1 Parent(s): 5264ad9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -65
app.py CHANGED
@@ -431,72 +431,8 @@ with gr.Blocks(
431
  inputs=[blue_threshold1, masks_state, image_state],
432
  outputs=[viability_overlay1, live_count_output1, dead_count_output1, viability_percent_output1, viability_info1]
433
  )
434
-
435
- with gr.Tab("Manual Coordinates"):
436
- gr.Markdown("### Upload image and run segmentation")
437
 
438
- with gr.Row():
439
- with gr.Column():
440
- image_input = gr.Image(type="pil", label="Microscopy Image")
441
- model_dropdown2 = gr.Dropdown(
442
- choices=list(MODEL_OPTIONS.keys()),
443
- label="Select Model",
444
- value="Hemocytometer Model"
445
- )
446
- coord_input = gr.Textbox(
447
- label="Crop Coordinates (optional)",
448
- placeholder="e.g., 100,100,400,400",
449
- info="Format: x_min,y_min,x_max,y_max"
450
- )
451
- segment_btn2 = gr.Button("🔬 Run Segmentation", variant="primary", size="lg")
452
-
453
- with gr.Column():
454
- cell_count_output2 = gr.Number(label="Total Cells Detected", precision=0)
455
- confluency_output2 = gr.Number(label="Confluency (%)", precision=1)
456
- overlay_output2 = gr.Image(type="pil", label="Segmentation Result")
457
- info_output2 = gr.Textbox(label="Processing Info", lines=4)
458
-
459
- # Viability Assessment Section
460
- with gr.Group(visible=False) as viability_section2:
461
- gr.Markdown("### Viability Assessment (Trypan Blue)")
462
- gr.Markdown("Adjust the threshold to classify cells as live (green) or dead (red).")
463
-
464
- with gr.Row():
465
- with gr.Column():
466
- blue_threshold2 = gr.Slider(
467
- minimum=0,
468
- maximum=100,
469
- value=25,
470
- step=1,
471
- label="Blue Threshold (%)",
472
- info="Higher values = more selective for blue cells"
473
- )
474
-
475
- with gr.Column():
476
- live_count_output2 = gr.Number(label="Live Cells (Green)", precision=0)
477
- dead_count_output2 = gr.Number(label="Dead Cells (Red)", precision=0)
478
-
479
- viability_overlay2 = gr.Image(type="pil", label="Viability Assessment (Green=Live, Red=Dead)")
480
- viability_percent_output2 = gr.Number(label="Viability (%)", precision=1)
481
- viability_info2 = gr.Textbox(label="Analysis Results", lines=5)
482
-
483
- # Event handlers
484
- segment_btn2.click(
485
- fn=run_segmentation_manual,
486
- inputs=[image_input, model_dropdown2, coord_input],
487
- outputs=[cell_count_output2, overlay_output2, info_output2, viability_section2, masks_state, image_state, confluency_output2]
488
- ).then( # Chain the initial viability assessment after segmentation
489
- fn=update_viability_realtime,
490
- inputs=[blue_threshold2, masks_state, image_state],
491
- outputs=[viability_overlay2, live_count_output2, dead_count_output2, viability_percent_output2, viability_info2]
492
- )
493
-
494
- # Slider changes update viability in real-time
495
- blue_threshold2.change(
496
- fn=update_viability_realtime,
497
- inputs=[blue_threshold2, masks_state, image_state],
498
- outputs=[viability_overlay2, live_count_output2, dead_count_output2, viability_percent_output2, viability_info2]
499
- )
500
 
501
  # Instructions
502
  with gr.Accordion("Instructions", open=False):
 
431
  inputs=[blue_threshold1, masks_state, image_state],
432
  outputs=[viability_overlay1, live_count_output1, dead_count_output1, viability_percent_output1, viability_info1]
433
  )
 
 
 
434
 
435
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
436
 
437
  # Instructions
438
  with gr.Accordion("Instructions", open=False):