darragh commited on
Commit
487d9cd
·
1 Parent(s): 68facde

Update app inputs

Browse files
Files changed (1) hide show
  1. app.py +13 -9
app.py CHANGED
@@ -54,7 +54,7 @@ def create_dl(test_files):
54
  return loader
55
 
56
  # Inference and video generation
57
- def generate_dicom_video(selected_file):
58
 
59
  test_file = input_files[selected_file]
60
  test_files = [{'image': test_file}]
@@ -92,21 +92,25 @@ def generate_dicom_video(selected_file):
92
  return 'dicom.mp4'
93
 
94
 
95
- '''
96
- test_file = glob.glob('pmrc/SwinUNETR/BTCV/dataset/imagesSampleTs/*.nii.gz')[0]
97
- generate_dicom_video(test_file)
98
- '''
99
 
100
- demo = gr.Blocks()
101
-
102
- with demo:
103
  selected_dicom_key = gr.inputs.Dropdown(
104
  choices=sorted(input_files),
105
  type="value",
106
  label="Select a dicom file")
 
107
  button_gen_video = gr.Button("Generate Video")
108
  output_interpolation = gr.Video(label="Generated Video")
109
- button_gen_video.click(fn=generate_dicom_video, inputs=selected_dicom_key, outputs=output_interpolation)
 
 
 
 
 
110
 
111
  demo.launch(debug=True, enable_queue=True)
112
 
 
54
  return loader
55
 
56
  # Inference and video generation
57
+ def generate_dicom_video(selected_file, n_frames):
58
 
59
  test_file = input_files[selected_file]
60
  test_files = [{'image': test_file}]
 
92
  return 'dicom.mp4'
93
 
94
 
95
+ theme = 'dark-peach'
96
+ with gr.Blocks(theme=theme) as demo:
 
 
97
 
98
+ gr.Markdown('''<center><h1>SwinUnetr BTCV</h1></center>
99
+ This is a Gradio Blocks app of the winning transformer in the Beyond the Cranial Vault (BTCV) Segmentation Challenge, <a href="https://github.com/darraghdog/Project-MONAI-research-contributions/tree/main/SwinUNETR/BTCV">SwinUnetr (tiny version).</a>.
100
+ ''')
101
  selected_dicom_key = gr.inputs.Dropdown(
102
  choices=sorted(input_files),
103
  type="value",
104
  label="Select a dicom file")
105
+ n_frames = gr.Slider(1, 100, value=32, label="Number of dicom slices")
106
  button_gen_video = gr.Button("Generate Video")
107
  output_interpolation = gr.Video(label="Generated Video")
108
+ gr.Markdown(
109
+ '<center><img src="https://visitor-badge.glitch.me/badge?page_id=gradio-blocks.anime-biggan" alt="visitor badge"/></center>'
110
+ )
111
+ button_gen_video.click(fn=generate_dicom_video,
112
+ inputs=[selected_dicom_key, n_frames],
113
+ outputs=output_interpolation)
114
 
115
  demo.launch(debug=True, enable_queue=True)
116