Update app.py
Browse files
app.py
CHANGED
|
@@ -3,11 +3,11 @@ import os
|
|
| 3 |
from utils import load_dicom
|
| 4 |
|
| 5 |
def process_scan(dicom_file):
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
image = load_dicom(dicom_file.name)
|
| 10 |
-
return image
|
| 11 |
|
| 12 |
# Build the UI
|
| 13 |
with gr.Blocks(title="MRI Brain Report Generator") as app:
|
|
@@ -38,14 +38,18 @@ with gr.Blocks(title="MRI Brain Report Generator") as app:
|
|
| 38 |
|
| 39 |
# Buttons row
|
| 40 |
with gr.Row():
|
| 41 |
-
generate_btn = gr.Button(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
download_btn = gr.DownloadButton("Download PDF", visible=False)
|
| 43 |
|
| 44 |
-
#
|
| 45 |
upload_btn.change(
|
| 46 |
fn=process_scan,
|
| 47 |
inputs=upload_btn,
|
| 48 |
-
outputs=scan_display
|
| 49 |
)
|
| 50 |
|
| 51 |
app.launch()
|
|
|
|
| 3 |
from utils import load_dicom
|
| 4 |
|
| 5 |
def process_scan(dicom_file):
|
| 6 |
+
if dicom_file is None:
|
| 7 |
+
return None, gr.Button(interactive=False)
|
| 8 |
+
|
| 9 |
image = load_dicom(dicom_file.name)
|
| 10 |
+
return image, gr.Button(interactive=True)
|
| 11 |
|
| 12 |
# Build the UI
|
| 13 |
with gr.Blocks(title="MRI Brain Report Generator") as app:
|
|
|
|
| 38 |
|
| 39 |
# Buttons row
|
| 40 |
with gr.Row():
|
| 41 |
+
generate_btn = gr.Button(
|
| 42 |
+
"Generate Report",
|
| 43 |
+
variant="primary",
|
| 44 |
+
interactive=False # disabled by default
|
| 45 |
+
)
|
| 46 |
download_btn = gr.DownloadButton("Download PDF", visible=False)
|
| 47 |
|
| 48 |
+
# When file is uploaded → show preview AND enable generate button
|
| 49 |
upload_btn.change(
|
| 50 |
fn=process_scan,
|
| 51 |
inputs=upload_btn,
|
| 52 |
+
outputs=[scan_display, generate_btn]
|
| 53 |
)
|
| 54 |
|
| 55 |
app.launch()
|