Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -269,6 +269,9 @@ def run_nnunet_predict(nifti_file,hd_bet=False):
|
|
269 |
image = extract_middle_slices(input_path, input_slice_path, center=center)
|
270 |
labeled_mask = extract_middle_slices(new_output_file, output_slice_path, center=center, label_components=True)
|
271 |
|
|
|
|
|
|
|
272 |
# Return paths for the Gradio interface
|
273 |
return new_output_file, input_slice_path, output_slice_path
|
274 |
else:
|
@@ -300,7 +303,8 @@ with gr.Blocks() as demo:
|
|
300 |
with gr.Column(scale=2):
|
301 |
seg_output = gr.File(label="Download the Lesion Segmentation Mask")
|
302 |
input_img = gr.Image(label="Input: FLAIR image")
|
303 |
-
output_img = gr.Image(label="Output: Lesion Mask")
|
|
|
304 |
|
305 |
gr.Markdown("""
|
306 |
**If you find this tool useful, please consider citing:**
|
@@ -319,7 +323,7 @@ with gr.Blocks() as demo:
|
|
319 |
submit_button.click(
|
320 |
fn=run_nnunet_predict,
|
321 |
inputs=[flair_input, hd_bet],
|
322 |
-
outputs=[seg_output, input_img, output_img]
|
323 |
)
|
324 |
|
325 |
# Debugging GPU environment
|
|
|
269 |
image = extract_middle_slices(input_path, input_slice_path, center=center)
|
270 |
labeled_mask = extract_middle_slices(new_output_file, output_slice_path, center=center, label_components=True)
|
271 |
|
272 |
+
labeled_mask_path = os.path.join(OUTPUT_DIR, f"{base_filename}_LabeledClusters.nii.gz")
|
273 |
+
nib.save(nib.Nifti1Image(labeled_mask.astype(np.int16), img.affine), labeled_mask_path)
|
274 |
+
|
275 |
# Return paths for the Gradio interface
|
276 |
return new_output_file, input_slice_path, output_slice_path
|
277 |
else:
|
|
|
303 |
with gr.Column(scale=2):
|
304 |
seg_output = gr.File(label="Download the Lesion Segmentation Mask")
|
305 |
input_img = gr.Image(label="Input: FLAIR image")
|
306 |
+
output_img = gr.Image(label="Output: Binary Lesion Mask")
|
307 |
+
clusters_output = gr.Image(label="Output: Labeled Lesion Mask")
|
308 |
|
309 |
gr.Markdown("""
|
310 |
**If you find this tool useful, please consider citing:**
|
|
|
323 |
submit_button.click(
|
324 |
fn=run_nnunet_predict,
|
325 |
inputs=[flair_input, hd_bet],
|
326 |
+
outputs=[seg_output, input_img, output_img, clusters_output]
|
327 |
)
|
328 |
|
329 |
# Debugging GPU environment
|