Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import os
|
| 3 |
from utils import load_dicom
|
|
|
|
| 4 |
|
| 5 |
def process_scan(dicom_file):
|
| 6 |
if dicom_file is None:
|
|
@@ -9,6 +10,15 @@ def process_scan(dicom_file):
|
|
| 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:
|
| 14 |
|
|
@@ -52,4 +62,10 @@ with gr.Blocks(title="MRI Brain Report Generator") as app:
|
|
| 52 |
outputs=[scan_display, generate_btn]
|
| 53 |
)
|
| 54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
app.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import os
|
| 3 |
from utils import load_dicom
|
| 4 |
+
from model import generate_report
|
| 5 |
|
| 6 |
def process_scan(dicom_file):
|
| 7 |
if dicom_file is None:
|
|
|
|
| 10 |
image = load_dicom(dicom_file.name)
|
| 11 |
return image, gr.Button(interactive=True)
|
| 12 |
|
| 13 |
+
def run_generate(dicom_file):
|
| 14 |
+
if dicom_file is None:
|
| 15 |
+
return "", gr.DownloadButton(visible=False)
|
| 16 |
+
|
| 17 |
+
image = load_dicom(dicom_file.name)
|
| 18 |
+
report = generate_report(image)
|
| 19 |
+
|
| 20 |
+
return report, gr.DownloadButton(visible=True)
|
| 21 |
+
|
| 22 |
# Build the UI
|
| 23 |
with gr.Blocks(title="MRI Brain Report Generator") as app:
|
| 24 |
|
|
|
|
| 62 |
outputs=[scan_display, generate_btn]
|
| 63 |
)
|
| 64 |
|
| 65 |
+
generate_btn.click(
|
| 66 |
+
fn=run_generate,
|
| 67 |
+
inputs=upload_btn,
|
| 68 |
+
outputs=[report_box, download_btn]
|
| 69 |
+
)
|
| 70 |
+
|
| 71 |
app.launch()
|