Spaces:
Running
on
Zero
Running
on
Zero
FrancescoLR
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -229,6 +229,7 @@ interface = gr.Interface(
|
|
229 |
description="Upload a skull-stripped FLAIR image (.nii.gz) to generate a binary segmentation of multiple sclerosis lesions.",
|
230 |
)
|
231 |
|
|
|
232 |
# Markdown content as a string
|
233 |
markdown_content = """
|
234 |
**If you find this tool useful, please consider citing:**
|
@@ -257,6 +258,7 @@ with gr.Blocks() as demo:
|
|
257 |
with gr.Row():
|
258 |
with gr.Column(scale=1): # Input column
|
259 |
flair_input = gr.File(label="Upload FLAIR Image (.nii.gz)")
|
|
|
260 |
with gr.Column(scale=2): # Output column
|
261 |
seg_output = gr.File(label="Download Segmentation Mask")
|
262 |
input_img = gr.Image(label="Input: FLAIR image")
|
@@ -265,6 +267,13 @@ with gr.Blocks() as demo:
|
|
265 |
# References
|
266 |
gr.Markdown(markdown_content)
|
267 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
268 |
# Debugging GPU environment
|
269 |
if torch.cuda.is_available():
|
270 |
print(f"GPU is available: {torch.cuda.get_device_name(0)}")
|
@@ -272,8 +281,6 @@ else:
|
|
272 |
print("No GPU available. Falling back to CPU.")
|
273 |
os.system("nvidia-smi") # Check if NVIDIA tools are available
|
274 |
|
275 |
-
#
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
demo.launch(share=True)
|
|
|
229 |
description="Upload a skull-stripped FLAIR image (.nii.gz) to generate a binary segmentation of multiple sclerosis lesions.",
|
230 |
)
|
231 |
|
232 |
+
# Markdown content as a string
|
233 |
# Markdown content as a string
|
234 |
markdown_content = """
|
235 |
**If you find this tool useful, please consider citing:**
|
|
|
258 |
with gr.Row():
|
259 |
with gr.Column(scale=1): # Input column
|
260 |
flair_input = gr.File(label="Upload FLAIR Image (.nii.gz)")
|
261 |
+
submit_button = gr.Button("Submit")
|
262 |
with gr.Column(scale=2): # Output column
|
263 |
seg_output = gr.File(label="Download Segmentation Mask")
|
264 |
input_img = gr.Image(label="Input: FLAIR image")
|
|
|
267 |
# References
|
268 |
gr.Markdown(markdown_content)
|
269 |
|
270 |
+
# Link submit button to the function
|
271 |
+
submit_button.click(
|
272 |
+
fn=run_nnunet_predict,
|
273 |
+
inputs=[flair_input],
|
274 |
+
outputs=[seg_output, input_img, output_img]
|
275 |
+
)
|
276 |
+
|
277 |
# Debugging GPU environment
|
278 |
if torch.cuda.is_available():
|
279 |
print(f"GPU is available: {torch.cuda.get_device_name(0)}")
|
|
|
281 |
print("No GPU available. Falling back to CPU.")
|
282 |
os.system("nvidia-smi") # Check if NVIDIA tools are available
|
283 |
|
284 |
+
# Launch the app
|
285 |
+
if __name__ == "__main__":
|
286 |
+
demo.launch(share=True)
|
|
|
|