Spaces:
Build error
Build error
Fix example logic
Browse files
app.py
CHANGED
@@ -84,6 +84,7 @@ post_transforms = Compose(
|
|
84 |
]
|
85 |
)
|
86 |
|
|
|
87 |
# Define the predict function for the demo
|
88 |
def predict(input_file, z_axis, model=model, device=device):
|
89 |
# Load and process data in MONAI format
|
@@ -115,6 +116,7 @@ def predict(input_file, z_axis, model=model, device=device):
|
|
115 |
|
116 |
return [t1c, t1, t2, flair], [tc, wt, et]
|
117 |
|
|
|
118 |
# Use blocks to set up a more complex demo
|
119 |
with gr.Blocks() as demo:
|
120 |
|
@@ -128,13 +130,6 @@ with gr.Blocks() as demo:
|
|
128 |
|
129 |
# Show the button with custom label
|
130 |
button = gr.Button("Segment Tumor!")
|
131 |
-
|
132 |
-
# Show examples for the user to try
|
133 |
-
gr.Markdown("Try some examples from MONAI's Decathlon Dataset:")
|
134 |
-
examples = gr.Examples(
|
135 |
-
examples=examples,
|
136 |
-
inputs=[gr.File(), gr.Slider()]
|
137 |
-
)
|
138 |
|
139 |
# Show the input image with different MR sequences
|
140 |
input_image = gr.Gallery(label='input MRI sequences (T1+, T1, T2, FLAIR)')
|
@@ -146,9 +141,19 @@ with gr.Blocks() as demo:
|
|
146 |
inputs=[input_file, z_axis],
|
147 |
outputs=[input_image, output_segmentation]
|
148 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
|
150 |
# Show references at the bottom of the demo
|
151 |
gr.Markdown(references)
|
152 |
|
|
|
153 |
# Launch the demo
|
154 |
demo.launch()
|
|
|
84 |
]
|
85 |
)
|
86 |
|
87 |
+
|
88 |
# Define the predict function for the demo
|
89 |
def predict(input_file, z_axis, model=model, device=device):
|
90 |
# Load and process data in MONAI format
|
|
|
116 |
|
117 |
return [t1c, t1, t2, flair], [tc, wt, et]
|
118 |
|
119 |
+
|
120 |
# Use blocks to set up a more complex demo
|
121 |
with gr.Blocks() as demo:
|
122 |
|
|
|
130 |
|
131 |
# Show the button with custom label
|
132 |
button = gr.Button("Segment Tumor!")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
|
134 |
# Show the input image with different MR sequences
|
135 |
input_image = gr.Gallery(label='input MRI sequences (T1+, T1, T2, FLAIR)')
|
|
|
141 |
inputs=[input_file, z_axis],
|
142 |
outputs=[input_image, output_segmentation]
|
143 |
)
|
144 |
+
|
145 |
+
# Have some example for the user to try out
|
146 |
+
examples = gr.Examples(
|
147 |
+
examples=examples,
|
148 |
+
inputs=[input_file, z_axis],
|
149 |
+
outputs=[input_image, output_segmentation],
|
150 |
+
fn=predict,
|
151 |
+
cache_examples=True
|
152 |
+
)
|
153 |
|
154 |
# Show references at the bottom of the demo
|
155 |
gr.Markdown(references)
|
156 |
|
157 |
+
|
158 |
# Launch the demo
|
159 |
demo.launch()
|