lemonaddie
commited on
Commit
•
c78bfdd
1
Parent(s):
ede989c
Update app.py
Browse files
app.py
CHANGED
@@ -162,108 +162,109 @@ def run_demo_server(pipe):
|
|
162 |
render=False,
|
163 |
)
|
164 |
|
165 |
-
demo_3d = gr.Row(render=False)
|
166 |
-
with demo_3d:
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
|
263 |
blocks_settings_depth = [ensemble_size, denoise_steps, processing_res]
|
264 |
-
blocks_settings_3d = [plane_near, plane_far, embossing, size_longest_px, size_longest_cm, filter_size,
|
265 |
-
|
266 |
-
blocks_settings = blocks_settings_depth + blocks_settings_3d
|
|
|
267 |
map_id_to_default = {b._id: b.value for b in blocks_settings}
|
268 |
|
269 |
inputs = [
|
@@ -323,8 +324,8 @@ def run_demo_server(pipe):
|
|
323 |
cache_examples=True,
|
324 |
)
|
325 |
|
326 |
-
demo_3d_header.render()
|
327 |
-
demo_3d.render()
|
328 |
|
329 |
def clear_fn():
|
330 |
out = []
|
@@ -343,50 +344,50 @@ def run_demo_server(pipe):
|
|
343 |
inputs=[],
|
344 |
outputs=blocks_settings + [
|
345 |
submit_btn,
|
346 |
-
submit_3d,
|
347 |
input_image,
|
348 |
input_output_16bit,
|
349 |
input_output_fp32,
|
350 |
input_output_vis,
|
351 |
output_slider,
|
352 |
files,
|
353 |
-
viewer_3d,
|
354 |
-
files_3d,
|
355 |
],
|
356 |
)
|
357 |
|
358 |
-
def submit_3d_fn(*args):
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
submit_3d.click(
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
)
|
381 |
-
|
382 |
-
def clear_3d_fn():
|
383 |
-
|
384 |
-
|
385 |
-
clear_3d.click(
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
)
|
390 |
|
391 |
demo.queue(
|
392 |
api_open=False,
|
|
|
162 |
render=False,
|
163 |
)
|
164 |
|
165 |
+
# demo_3d = gr.Row(render=False)
|
166 |
+
# with demo_3d:
|
167 |
+
# with gr.Column():
|
168 |
+
# with gr.Accordion("3D printing demo: Main options", open=True):
|
169 |
+
# plane_near = gr.Slider(
|
170 |
+
# label="Relative position of the near plane (between 0 and 1)",
|
171 |
+
# minimum=0.0,
|
172 |
+
# maximum=1.0,
|
173 |
+
# step=0.001,
|
174 |
+
# value=0.0,
|
175 |
+
# )
|
176 |
+
# plane_far = gr.Slider(
|
177 |
+
# label="Relative position of the far plane (between near and 1)",
|
178 |
+
# minimum=0.0,
|
179 |
+
# maximum=1.0,
|
180 |
+
# step=0.001,
|
181 |
+
# value=1.0,
|
182 |
+
# )
|
183 |
+
# embossing = gr.Slider(
|
184 |
+
# label="Embossing level",
|
185 |
+
# minimum=0,
|
186 |
+
# maximum=100,
|
187 |
+
# step=1,
|
188 |
+
# value=20,
|
189 |
+
# )
|
190 |
+
# with gr.Accordion("3D printing demo: Advanced options", open=False):
|
191 |
+
# size_longest_px = gr.Slider(
|
192 |
+
# label="Size (px) of the longest side",
|
193 |
+
# minimum=256,
|
194 |
+
# maximum=1024,
|
195 |
+
# step=256,
|
196 |
+
# value=512,
|
197 |
+
# )
|
198 |
+
# size_longest_cm = gr.Slider(
|
199 |
+
# label="Size (cm) of the longest side",
|
200 |
+
# minimum=1,
|
201 |
+
# maximum=100,
|
202 |
+
# step=1,
|
203 |
+
# value=10,
|
204 |
+
# )
|
205 |
+
# filter_size = gr.Slider(
|
206 |
+
# label="Size (px) of the smoothing filter",
|
207 |
+
# minimum=1,
|
208 |
+
# maximum=5,
|
209 |
+
# step=2,
|
210 |
+
# value=3,
|
211 |
+
# )
|
212 |
+
# frame_thickness = gr.Slider(
|
213 |
+
# label="Frame thickness",
|
214 |
+
# minimum=0,
|
215 |
+
# maximum=100,
|
216 |
+
# step=1,
|
217 |
+
# value=5,
|
218 |
+
# )
|
219 |
+
# frame_near = gr.Slider(
|
220 |
+
# label="Frame's near plane offset",
|
221 |
+
# minimum=-100,
|
222 |
+
# maximum=100,
|
223 |
+
# step=1,
|
224 |
+
# value=1,
|
225 |
+
# )
|
226 |
+
# frame_far = gr.Slider(
|
227 |
+
# label="Frame's far plane offset",
|
228 |
+
# minimum=1,
|
229 |
+
# maximum=10,
|
230 |
+
# step=1,
|
231 |
+
# value=1,
|
232 |
+
# )
|
233 |
+
# with gr.Row():
|
234 |
+
# submit_3d = gr.Button(value="Create 3D", variant="primary")
|
235 |
+
# clear_3d = gr.Button(value="Clear 3D")
|
236 |
+
# gr.Markdown(
|
237 |
+
# """
|
238 |
+
# <h5 align="center">Pro Tips</h5>
|
239 |
+
# <ol>
|
240 |
+
# <li><b>Re-render with new parameters</b>: Click "Clear 3D" and then "Create 3D".</li>
|
241 |
+
# <li><b>Adjust 3D scale and cut-off focus</b>: Set the frame's near plane offset to the
|
242 |
+
# minimum and use 3D preview to evaluate depth scaling. Repeat until the scale is correct and
|
243 |
+
# everything important is in the focus. Set the optimal value for frame's near
|
244 |
+
# plane offset as a last step.</li>
|
245 |
+
# <li><b>Increase details</b>: Decrease size of the smoothing filter (also increases noise).</li>
|
246 |
+
# </ol>
|
247 |
+
# """
|
248 |
+
# )
|
249 |
+
|
250 |
+
# with gr.Column():
|
251 |
+
# viewer_3d = gr.Model3D(
|
252 |
+
# camera_position=(75.0, 90.0, 1.25),
|
253 |
+
# elem_classes="viewport",
|
254 |
+
# label="3D preview (low-res, relief highlight)",
|
255 |
+
# interactive=False,
|
256 |
+
# )
|
257 |
+
# files_3d = gr.Files(
|
258 |
+
# label="3D model outputs (high-res)",
|
259 |
+
# elem_id="download",
|
260 |
+
# interactive=False,
|
261 |
+
# )
|
262 |
|
263 |
blocks_settings_depth = [ensemble_size, denoise_steps, processing_res]
|
264 |
+
# blocks_settings_3d = [plane_near, plane_far, embossing, size_longest_px, size_longest_cm, filter_size,
|
265 |
+
# frame_thickness, frame_near, frame_far]
|
266 |
+
# blocks_settings = blocks_settings_depth + blocks_settings_3d
|
267 |
+
blocks_settings = blocks_settings_depth
|
268 |
map_id_to_default = {b._id: b.value for b in blocks_settings}
|
269 |
|
270 |
inputs = [
|
|
|
324 |
cache_examples=True,
|
325 |
)
|
326 |
|
327 |
+
# demo_3d_header.render()
|
328 |
+
# demo_3d.render()
|
329 |
|
330 |
def clear_fn():
|
331 |
out = []
|
|
|
344 |
inputs=[],
|
345 |
outputs=blocks_settings + [
|
346 |
submit_btn,
|
347 |
+
#submit_3d,
|
348 |
input_image,
|
349 |
input_output_16bit,
|
350 |
input_output_fp32,
|
351 |
input_output_vis,
|
352 |
output_slider,
|
353 |
files,
|
354 |
+
#viewer_3d,
|
355 |
+
#files_3d,
|
356 |
],
|
357 |
)
|
358 |
|
359 |
+
# def submit_3d_fn(*args):
|
360 |
+
# out = list(process_3d(*args))
|
361 |
+
# out = [gr.Button(interactive=False)] + out
|
362 |
+
# return out
|
363 |
+
|
364 |
+
# submit_3d.click(
|
365 |
+
# fn=submit_3d_fn,
|
366 |
+
# inputs=[
|
367 |
+
# input_image,
|
368 |
+
# files,
|
369 |
+
# size_longest_px,
|
370 |
+
# size_longest_cm,
|
371 |
+
# filter_size,
|
372 |
+
# plane_near,
|
373 |
+
# plane_far,
|
374 |
+
# embossing,
|
375 |
+
# frame_thickness,
|
376 |
+
# frame_near,
|
377 |
+
# frame_far,
|
378 |
+
# ],
|
379 |
+
# outputs=[submit_3d, viewer_3d, files_3d],
|
380 |
+
# concurrency_limit=1,
|
381 |
+
# )
|
382 |
+
|
383 |
+
# def clear_3d_fn():
|
384 |
+
# return [gr.Button(interactive=True), None, None]
|
385 |
+
|
386 |
+
# clear_3d.click(
|
387 |
+
# fn=clear_3d_fn,
|
388 |
+
# inputs=[],
|
389 |
+
# outputs=[submit_3d, viewer_3d, files_3d],
|
390 |
+
# )
|
391 |
|
392 |
demo.queue(
|
393 |
api_open=False,
|