Update app.py
Browse files
app.py
CHANGED
|
@@ -84,7 +84,8 @@ processed_mask = None
|
|
| 84 |
def segment_button_click(file):
|
| 85 |
global processed_image, processed_mask
|
| 86 |
processed_image, processed_mask, output_path = process_file(file)
|
| 87 |
-
|
|
|
|
| 88 |
|
| 89 |
def update_visualization(slice_index):
|
| 90 |
if processed_image is None or processed_mask is None:
|
|
@@ -107,11 +108,11 @@ with gr.Blocks() as iface:
|
|
| 107 |
download_output = gr.File(label="Download Binary Mask (.tif)")
|
| 108 |
|
| 109 |
with gr.Row():
|
| 110 |
-
slice_slider = gr.Slider(minimum=0, maximum=
|
| 111 |
visualization_output = gr.Plot(label="2D Slice Visualization")
|
| 112 |
|
| 113 |
# Button click triggers segmentation
|
| 114 |
-
segment_button.click(segment_button_click, inputs=file_input, outputs=[status_output, download_output])
|
| 115 |
|
| 116 |
# Slider changes trigger visualization updates
|
| 117 |
slice_slider.change(update_visualization, inputs=slice_slider, outputs=visualization_output)
|
|
|
|
| 84 |
def segment_button_click(file):
|
| 85 |
global processed_image, processed_mask
|
| 86 |
processed_image, processed_mask, output_path = process_file(file)
|
| 87 |
+
num_slices = processed_image.shape[2]
|
| 88 |
+
return "Segmentation completed! Use the slider to explore slices.", output_path, gr.update(visible=True, maximum=num_slices - 1)
|
| 89 |
|
| 90 |
def update_visualization(slice_index):
|
| 91 |
if processed_image is None or processed_mask is None:
|
|
|
|
| 108 |
download_output = gr.File(label="Download Binary Mask (.tif)")
|
| 109 |
|
| 110 |
with gr.Row():
|
| 111 |
+
slice_slider = gr.Slider(minimum=0, maximum=100, step=1, label="Slice Index", interactive=True, visible=False)
|
| 112 |
visualization_output = gr.Plot(label="2D Slice Visualization")
|
| 113 |
|
| 114 |
# Button click triggers segmentation
|
| 115 |
+
segment_button.click(segment_button_click, inputs=file_input, outputs=[status_output, download_output, slice_slider])
|
| 116 |
|
| 117 |
# Slider changes trigger visualization updates
|
| 118 |
slice_slider.change(update_visualization, inputs=slice_slider, outputs=visualization_output)
|