Update app.py
Browse files
app.py
CHANGED
|
@@ -2,6 +2,7 @@ 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:
|
|
@@ -19,6 +20,12 @@ def run_generate(dicom_file):
|
|
| 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 |
|
|
@@ -68,4 +75,10 @@ with gr.Blocks(title="MRI Brain Report Generator") as app:
|
|
| 68 |
outputs=[report_box, download_btn]
|
| 69 |
)
|
| 70 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
app.launch()
|
|
|
|
| 2 |
import os
|
| 3 |
from utils import load_dicom
|
| 4 |
from model import generate_report
|
| 5 |
+
from utils import load_dicom, generate_pdf
|
| 6 |
|
| 7 |
def process_scan(dicom_file):
|
| 8 |
if dicom_file is None:
|
|
|
|
| 20 |
|
| 21 |
return report, gr.DownloadButton(visible=True)
|
| 22 |
|
| 23 |
+
def download_report(report_text):
|
| 24 |
+
if not report_text or not report_text.strip():
|
| 25 |
+
gr.Warning("No report to download yet.")
|
| 26 |
+
return None
|
| 27 |
+
return generate_pdf(report_text)
|
| 28 |
+
|
| 29 |
# Build the UI
|
| 30 |
with gr.Blocks(title="MRI Brain Report Generator") as app:
|
| 31 |
|
|
|
|
| 75 |
outputs=[report_box, download_btn]
|
| 76 |
)
|
| 77 |
|
| 78 |
+
download_btn.click(
|
| 79 |
+
fn=download_report,
|
| 80 |
+
inputs=report_out,
|
| 81 |
+
outputs=download_btn
|
| 82 |
+
)
|
| 83 |
+
|
| 84 |
app.launch()
|