Spaces:
Running
Running
Only use one AnnotatedImage and replace
Browse files- demo/src/gui.py +20 -18
demo/src/gui.py
CHANGED
@@ -20,7 +20,7 @@ class WebUI:
|
|
20 |
self.pred_images = []
|
21 |
|
22 |
# @TODO: This should be dynamically set based on chosen volume size
|
23 |
-
self.nb_slider_items =
|
24 |
|
25 |
self.model_name = model_name
|
26 |
self.cwd = cwd
|
@@ -39,8 +39,8 @@ class WebUI:
|
|
39 |
|
40 |
# define widgets not to be rendered immediantly, but later on
|
41 |
self.slider = gr.Slider(
|
42 |
-
1,
|
43 |
-
self.nb_slider_items,
|
44 |
value=1,
|
45 |
step=1,
|
46 |
label="Which 2D slice to show",
|
@@ -74,14 +74,19 @@ class WebUI:
|
|
74 |
|
75 |
self.images = load_ct_to_numpy(path)
|
76 |
self.pred_images = load_pred_volume_to_numpy("./prediction.nii.gz")
|
|
|
77 |
return "./prediction.obj"
|
78 |
|
79 |
def get_img_pred_pair(self, k):
|
80 |
-
k = int(k)
|
81 |
-
out =
|
82 |
-
out[k] = gr.AnnotatedImage.update(
|
83 |
self.combine_ct_and_seg(self.images[k], self.pred_images[k]),
|
84 |
visible=True,
|
|
|
|
|
|
|
|
|
|
|
85 |
)
|
86 |
return out
|
87 |
|
@@ -139,20 +144,17 @@ class WebUI:
|
|
139 |
with gr.Row():
|
140 |
with gr.Box():
|
141 |
with gr.Column():
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
width=512,
|
151 |
-
)
|
152 |
-
image_boxes.append(t)
|
153 |
|
154 |
self.slider.input(
|
155 |
-
self.get_img_pred_pair, self.slider,
|
156 |
)
|
157 |
|
158 |
self.slider.render()
|
|
|
20 |
self.pred_images = []
|
21 |
|
22 |
# @TODO: This should be dynamically set based on chosen volume size
|
23 |
+
self.nb_slider_items = 820
|
24 |
|
25 |
self.model_name = model_name
|
26 |
self.cwd = cwd
|
|
|
39 |
|
40 |
# define widgets not to be rendered immediantly, but later on
|
41 |
self.slider = gr.Slider(
|
42 |
+
minimum=1,
|
43 |
+
maximum=self.nb_slider_items,
|
44 |
value=1,
|
45 |
step=1,
|
46 |
label="Which 2D slice to show",
|
|
|
74 |
|
75 |
self.images = load_ct_to_numpy(path)
|
76 |
self.pred_images = load_pred_volume_to_numpy("./prediction.nii.gz")
|
77 |
+
|
78 |
return "./prediction.obj"
|
79 |
|
80 |
def get_img_pred_pair(self, k):
|
81 |
+
k = int(k)
|
82 |
+
out = gr.AnnotatedImage(
|
|
|
83 |
self.combine_ct_and_seg(self.images[k], self.pred_images[k]),
|
84 |
visible=True,
|
85 |
+
elem_id="model-2d",
|
86 |
+
).style(
|
87 |
+
color_map={self.class_name: "#ffae00"},
|
88 |
+
height=512,
|
89 |
+
width=512,
|
90 |
)
|
91 |
return out
|
92 |
|
|
|
144 |
with gr.Row():
|
145 |
with gr.Box():
|
146 |
with gr.Column():
|
147 |
+
# create dummy image to be replaced by loaded images
|
148 |
+
t = gr.AnnotatedImage(
|
149 |
+
visible=True, elem_id="model-2d"
|
150 |
+
).style(
|
151 |
+
color_map={self.class_name: "#ffae00"},
|
152 |
+
height=512,
|
153 |
+
width=512,
|
154 |
+
)
|
|
|
|
|
|
|
155 |
|
156 |
self.slider.input(
|
157 |
+
self.get_img_pred_pair, self.slider, t,
|
158 |
)
|
159 |
|
160 |
self.slider.render()
|