Spaces:
Sleeping
Sleeping
Linted code
Browse files- demo/src/gui.py +17 -9
demo/src/gui.py
CHANGED
@@ -78,13 +78,15 @@ class WebUI:
|
|
78 |
path = mesh_file_name.name
|
79 |
curr = path.split("/")[-1]
|
80 |
self.extension = ".".join(curr.split(".")[1:])
|
81 |
-
self.filename =
|
|
|
|
|
82 |
run_model(
|
83 |
path,
|
84 |
model_path=os.path.join(self.cwd, "resources/models/"),
|
85 |
task=self.class_names[self.class_name],
|
86 |
name=self.result_names[self.class_name],
|
87 |
-
output_filename=self.filename + "." + self.extension
|
88 |
)
|
89 |
LOGGER.info("Converting prediction NIfTI to OBJ...")
|
90 |
nifti_to_obj(path=self.filename + "." + self.extension)
|
@@ -93,13 +95,17 @@ class WebUI:
|
|
93 |
self.images = load_ct_to_numpy(path)
|
94 |
|
95 |
LOGGER.info("Loading prediction volume to numpy..")
|
96 |
-
self.pred_images = load_pred_volume_to_numpy(
|
|
|
|
|
97 |
|
98 |
return "./prediction.obj"
|
99 |
-
|
100 |
def download_prediction(self):
|
101 |
if (not self.filename) or (not self.extension):
|
102 |
-
LOGGER.error(
|
|
|
|
|
103 |
return self.filename + "." + self.extension
|
104 |
|
105 |
def get_img_pred_pair(self, k):
|
@@ -156,7 +162,9 @@ class WebUI:
|
|
156 |
btn_clear_logs.click(flush_logs, [], [])
|
157 |
|
158 |
file_output = gr.File(
|
159 |
-
file_count="single",
|
|
|
|
|
160 |
)
|
161 |
file_output.upload(
|
162 |
self.upload_file, file_output, file_output
|
@@ -225,8 +233,8 @@ class WebUI:
|
|
225 |
visible=True,
|
226 |
elem_id="model-2d",
|
227 |
color_map={self.class_name: "#ffae00"},
|
228 |
-
#height=512,
|
229 |
-
#width=512,
|
230 |
)
|
231 |
self.slider.input(
|
232 |
self.get_img_pred_pair,
|
@@ -236,7 +244,7 @@ class WebUI:
|
|
236 |
|
237 |
self.slider.render()
|
238 |
|
239 |
-
with gr.Group():
|
240 |
self.volume_renderer.render()
|
241 |
|
242 |
# sharing app publicly -> share=True:
|
|
|
78 |
path = mesh_file_name.name
|
79 |
curr = path.split("/")[-1]
|
80 |
self.extension = ".".join(curr.split(".")[1:])
|
81 |
+
self.filename = (
|
82 |
+
curr.split(".")[0] + "-" + self.class_names[self.class_name]
|
83 |
+
)
|
84 |
run_model(
|
85 |
path,
|
86 |
model_path=os.path.join(self.cwd, "resources/models/"),
|
87 |
task=self.class_names[self.class_name],
|
88 |
name=self.result_names[self.class_name],
|
89 |
+
output_filename=self.filename + "." + self.extension,
|
90 |
)
|
91 |
LOGGER.info("Converting prediction NIfTI to OBJ...")
|
92 |
nifti_to_obj(path=self.filename + "." + self.extension)
|
|
|
95 |
self.images = load_ct_to_numpy(path)
|
96 |
|
97 |
LOGGER.info("Loading prediction volume to numpy..")
|
98 |
+
self.pred_images = load_pred_volume_to_numpy(
|
99 |
+
self.filename + "." + self.extension
|
100 |
+
)
|
101 |
|
102 |
return "./prediction.obj"
|
103 |
+
|
104 |
def download_prediction(self):
|
105 |
if (not self.filename) or (not self.extension):
|
106 |
+
LOGGER.error(
|
107 |
+
"The prediction is not available or ready to download. Wait until the result is available in the 3D viewer."
|
108 |
+
)
|
109 |
return self.filename + "." + self.extension
|
110 |
|
111 |
def get_img_pred_pair(self, k):
|
|
|
162 |
btn_clear_logs.click(flush_logs, [], [])
|
163 |
|
164 |
file_output = gr.File(
|
165 |
+
file_count="single",
|
166 |
+
elem_id="upload",
|
167 |
+
scale=3,
|
168 |
)
|
169 |
file_output.upload(
|
170 |
self.upload_file, file_output, file_output
|
|
|
233 |
visible=True,
|
234 |
elem_id="model-2d",
|
235 |
color_map={self.class_name: "#ffae00"},
|
236 |
+
# height=512,
|
237 |
+
# width=512,
|
238 |
)
|
239 |
self.slider.input(
|
240 |
self.get_img_pred_pair,
|
|
|
244 |
|
245 |
self.slider.render()
|
246 |
|
247 |
+
with gr.Group(): # gr.Box():
|
248 |
self.volume_renderer.render()
|
249 |
|
250 |
# sharing app publicly -> share=True:
|