Neemah commited on
Commit
e526d9b
·
verified ·
1 Parent(s): 32256b0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -7
app.py CHANGED
@@ -3,11 +3,11 @@ import os
3
  from utils import load_dicom
4
 
5
  def process_scan(dicom_file):
6
- """
7
- Takes uploaded DICOM file, returns image to display.
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("Generate Report", variant="primary")
 
 
 
 
42
  download_btn = gr.DownloadButton("Download PDF", visible=False)
43
 
44
- # Connect uploadimage preview
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()