Linted code
Browse files- demo/app.py +1 -2
- demo/src/convert.py +1 -5
- demo/src/gui.py +5 -15
- demo/src/inference.py +2 -10
demo/app.py
CHANGED
@@ -16,8 +16,7 @@ def main():
|
|
16 |
"--share",
|
17 |
type=int,
|
18 |
default=0,
|
19 |
-
help="Whether to enable the app to be accessible online"
|
20 |
-
"-> setups a public link which requires internet access.",
|
21 |
)
|
22 |
args = parser.parse_args()
|
23 |
|
|
|
16 |
"--share",
|
17 |
type=int,
|
18 |
default=0,
|
19 |
+
help="Whether to enable the app to be accessible online" "-> setups a public link which requires internet access.",
|
|
|
20 |
)
|
21 |
args = parser.parse_args()
|
22 |
|
demo/src/convert.py
CHANGED
@@ -28,8 +28,4 @@ def nifti_to_obj(path, output="prediction.obj"):
|
|
28 |
thefile.write("vn {0} {1} {2}\n".format(item[0], item[1], item[2]))
|
29 |
|
30 |
for item in faces:
|
31 |
-
thefile.write(
|
32 |
-
"f {0}//{0} {1}//{1} {2}//{2}\n".format(
|
33 |
-
item[0], item[1], item[2]
|
34 |
-
)
|
35 |
-
)
|
|
|
28 |
thefile.write("vn {0} {1} {2}\n".format(item[0], item[1], item[2]))
|
29 |
|
30 |
for item in faces:
|
31 |
+
thefile.write("f {0}//{0} {1}//{1} {2}//{2}\n".format(item[0], item[1], item[2]))
|
|
|
|
|
|
|
|
demo/src/gui.py
CHANGED
@@ -141,17 +141,11 @@ class WebUI:
|
|
141 |
[sidebar_left, sidebar_state],
|
142 |
)
|
143 |
|
144 |
-
btn_clear_logs = gr.Button(
|
145 |
-
"Clear logs", elem_id="logs-button"
|
146 |
-
)
|
147 |
btn_clear_logs.click(flush_logs, [], [])
|
148 |
|
149 |
-
file_output = gr.File(
|
150 |
-
|
151 |
-
)
|
152 |
-
file_output.upload(
|
153 |
-
self.upload_file, file_output, file_output
|
154 |
-
)
|
155 |
|
156 |
model_selector = gr.Dropdown(
|
157 |
list(self.class_names.keys()),
|
@@ -203,9 +197,7 @@ class WebUI:
|
|
203 |
with gr.Box():
|
204 |
with gr.Column():
|
205 |
# create dummy image to be replaced by loaded images
|
206 |
-
t = gr.AnnotatedImage(
|
207 |
-
visible=True, elem_id="model-2d"
|
208 |
-
).style(
|
209 |
color_map={self.class_name: "#ffae00"},
|
210 |
height=512,
|
211 |
width=512,
|
@@ -226,6 +218,4 @@ class WebUI:
|
|
226 |
# https://gradio.app/sharing-your-app/
|
227 |
# inference times > 60 seconds -> need queue():
|
228 |
# https://github.com/tloen/alpaca-lora/issues/60#issuecomment-1510006062
|
229 |
-
demo.queue().launch(
|
230 |
-
server_name="0.0.0.0", server_port=7860, share=self.share
|
231 |
-
)
|
|
|
141 |
[sidebar_left, sidebar_state],
|
142 |
)
|
143 |
|
144 |
+
btn_clear_logs = gr.Button("Clear logs", elem_id="logs-button")
|
|
|
|
|
145 |
btn_clear_logs.click(flush_logs, [], [])
|
146 |
|
147 |
+
file_output = gr.File(file_count="single", elem_id="upload")
|
148 |
+
file_output.upload(self.upload_file, file_output, file_output)
|
|
|
|
|
|
|
|
|
149 |
|
150 |
model_selector = gr.Dropdown(
|
151 |
list(self.class_names.keys()),
|
|
|
197 |
with gr.Box():
|
198 |
with gr.Column():
|
199 |
# create dummy image to be replaced by loaded images
|
200 |
+
t = gr.AnnotatedImage(visible=True, elem_id="model-2d").style(
|
|
|
|
|
201 |
color_map={self.class_name: "#ffae00"},
|
202 |
height=512,
|
203 |
width=512,
|
|
|
218 |
# https://gradio.app/sharing-your-app/
|
219 |
# inference times > 60 seconds -> need queue():
|
220 |
# https://github.com/tloen/alpaca-lora/issues/60#issuecomment-1510006062
|
221 |
+
demo.queue().launch(server_name="0.0.0.0", server_port=7860, share=self.share)
|
|
|
|
demo/src/inference.py
CHANGED
@@ -61,9 +61,7 @@ def run_model(
|
|
61 |
os.path.join(model_path, task, "pipeline.json"),
|
62 |
)
|
63 |
rads_config.add_section("Runtime")
|
64 |
-
rads_config.set(
|
65 |
-
"Runtime", "reconstruction_method", "thresholding"
|
66 |
-
) # thresholding, probabilities
|
67 |
rads_config.set("Runtime", "reconstruction_order", "resample_first")
|
68 |
rads_config.set("Runtime", "use_preprocessed_data", "False")
|
69 |
|
@@ -77,13 +75,7 @@ def run_model(
|
|
77 |
|
78 |
# rename and move final result
|
79 |
os.rename(
|
80 |
-
"./result/prediction-"
|
81 |
-
+ splits[0]
|
82 |
-
+ "/T0/"
|
83 |
-
+ splits[0]
|
84 |
-
+ "-t1gd_annotation-"
|
85 |
-
+ name
|
86 |
-
+ ".nii.gz",
|
87 |
"./prediction.nii.gz",
|
88 |
)
|
89 |
# Clean-up
|
|
|
61 |
os.path.join(model_path, task, "pipeline.json"),
|
62 |
)
|
63 |
rads_config.add_section("Runtime")
|
64 |
+
rads_config.set("Runtime", "reconstruction_method", "thresholding") # thresholding, probabilities
|
|
|
|
|
65 |
rads_config.set("Runtime", "reconstruction_order", "resample_first")
|
66 |
rads_config.set("Runtime", "use_preprocessed_data", "False")
|
67 |
|
|
|
75 |
|
76 |
# rename and move final result
|
77 |
os.rename(
|
78 |
+
"./result/prediction-" + splits[0] + "/T0/" + splits[0] + "-t1gd_annotation-" + name + ".nii.gz",
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
"./prediction.nii.gz",
|
80 |
)
|
81 |
# Clean-up
|