lemonaddie commited on
Commit
0243d32
1 Parent(s): 6837c13

Update app1.py

Browse files
Files changed (1) hide show
  1. app1.py +15 -126
app1.py CHANGED
@@ -19,14 +19,11 @@ def process(
19
  ensemble_size,
20
  denoise_steps,
21
  processing_res,
 
22
  path_out_16bit=None,
23
  path_out_fp32=None,
24
  path_out_vis=None,
25
- _input_3d_plane_near=None,
26
- _input_3d_plane_far=None,
27
- _input_3d_embossing=None,
28
- _input_3d_filter_size=None,
29
- _input_3d_frame_near=None,
30
  ):
31
  if path_out_vis is not None:
32
  return (
@@ -41,6 +38,7 @@ def process(
41
  ensemble_size=ensemble_size,
42
  denoising_steps=denoise_steps,
43
  processing_res=processing_res,
 
44
  batch_size=1 if processing_res == 0 else 0,
45
  show_progress_bar=True,
46
  )
@@ -143,6 +141,15 @@ def run_demo_server(pipe):
143
  label="Processing resolution",
144
  value=768,
145
  )
 
 
 
 
 
 
 
 
 
146
  input_output_16bit = gr.File(
147
  label="Predicted depth (16-bit)",
148
  visible=False,
@@ -174,121 +181,8 @@ def run_demo_server(pipe):
174
  interactive=False,
175
  )
176
 
177
- demo_3d_header = gr.Markdown(
178
- """
179
- <h3 align="center">3D Printing Depth Maps</h3>
180
- <p align="justify">
181
- This part of the demo uses Marigold depth maps estimated in the previous step to create a
182
- 3D-printable model. The models are watertight, with correct normals, and exported in the STL format.
183
- We recommended creating the first model with the default parameters and iterating on it until the best
184
- result (see Pro Tips below).
185
- </p>
186
- """,
187
- render=False,
188
- )
189
-
190
- demo_3d = gr.Row(render=False)
191
- with demo_3d:
192
- with gr.Column():
193
- with gr.Accordion("3D printing demo: Main options", open=True):
194
- plane_near = gr.Slider(
195
- label="Relative position of the near plane (between 0 and 1)",
196
- minimum=0.0,
197
- maximum=1.0,
198
- step=0.001,
199
- value=0.0,
200
- )
201
- plane_far = gr.Slider(
202
- label="Relative position of the far plane (between near and 1)",
203
- minimum=0.0,
204
- maximum=1.0,
205
- step=0.001,
206
- value=1.0,
207
- )
208
- embossing = gr.Slider(
209
- label="Embossing level",
210
- minimum=0,
211
- maximum=100,
212
- step=1,
213
- value=20,
214
- )
215
- with gr.Accordion("3D printing demo: Advanced options", open=False):
216
- size_longest_px = gr.Slider(
217
- label="Size (px) of the longest side",
218
- minimum=256,
219
- maximum=1024,
220
- step=256,
221
- value=512,
222
- )
223
- size_longest_cm = gr.Slider(
224
- label="Size (cm) of the longest side",
225
- minimum=1,
226
- maximum=100,
227
- step=1,
228
- value=10,
229
- )
230
- filter_size = gr.Slider(
231
- label="Size (px) of the smoothing filter",
232
- minimum=1,
233
- maximum=5,
234
- step=2,
235
- value=3,
236
- )
237
- frame_thickness = gr.Slider(
238
- label="Frame thickness",
239
- minimum=0,
240
- maximum=100,
241
- step=1,
242
- value=5,
243
- )
244
- frame_near = gr.Slider(
245
- label="Frame's near plane offset",
246
- minimum=-100,
247
- maximum=100,
248
- step=1,
249
- value=1,
250
- )
251
- frame_far = gr.Slider(
252
- label="Frame's far plane offset",
253
- minimum=1,
254
- maximum=10,
255
- step=1,
256
- value=1,
257
- )
258
- with gr.Row():
259
- submit_3d = gr.Button(value="Create 3D", variant="primary")
260
- clear_3d = gr.Button(value="Clear 3D")
261
- gr.Markdown(
262
- """
263
- <h5 align="center">Pro Tips</h5>
264
- <ol>
265
- <li><b>Re-render with new parameters</b>: Click "Clear 3D" and then "Create 3D".</li>
266
- <li><b>Adjust 3D scale and cut-off focus</b>: Set the frame's near plane offset to the
267
- minimum and use 3D preview to evaluate depth scaling. Repeat until the scale is correct and
268
- everything important is in the focus. Set the optimal value for frame's near
269
- plane offset as a last step.</li>
270
- <li><b>Increase details</b>: Decrease size of the smoothing filter (also increases noise).</li>
271
- </ol>
272
- """
273
- )
274
-
275
- with gr.Column():
276
- viewer_3d = gr.Model3D(
277
- camera_position=(75.0, 90.0, 1.25),
278
- elem_classes="viewport",
279
- label="3D preview (low-res, relief highlight)",
280
- interactive=False,
281
- )
282
- files_3d = gr.Files(
283
- label="3D model outputs (high-res)",
284
- elem_id="download",
285
- interactive=False,
286
- )
287
-
288
  blocks_settings_depth = [ensemble_size, denoise_steps, processing_res]
289
- blocks_settings_3d = [plane_near, plane_far, embossing, size_longest_px, size_longest_cm, filter_size,
290
- frame_thickness, frame_near, frame_far]
291
- blocks_settings = blocks_settings_depth + blocks_settings_3d
292
  map_id_to_default = {b._id: b.value for b in blocks_settings}
293
 
294
  inputs = [
@@ -296,14 +190,11 @@ def run_demo_server(pipe):
296
  ensemble_size,
297
  denoise_steps,
298
  processing_res,
 
299
  input_output_16bit,
300
  input_output_fp32,
301
  input_output_vis,
302
- plane_near,
303
- plane_far,
304
- embossing,
305
- filter_size,
306
- frame_near,
307
  ]
308
  outputs = [
309
  submit_btn,
@@ -347,8 +238,6 @@ def run_demo_server(pipe):
347
  cache_examples=True,
348
  )
349
 
350
- demo_3d_header.render()
351
- demo_3d.render()
352
 
353
  def clear_fn():
354
  out = []
 
19
  ensemble_size,
20
  denoise_steps,
21
  processing_res,
22
+ domain,
23
  path_out_16bit=None,
24
  path_out_fp32=None,
25
  path_out_vis=None,
26
+ normal_out_vis=None,
 
 
 
 
27
  ):
28
  if path_out_vis is not None:
29
  return (
 
38
  ensemble_size=ensemble_size,
39
  denoising_steps=denoise_steps,
40
  processing_res=processing_res,
41
+ domain=domain,
42
  batch_size=1 if processing_res == 0 else 0,
43
  show_progress_bar=True,
44
  )
 
141
  label="Processing resolution",
142
  value=768,
143
  )
144
+ domain = gr.Radio(
145
+ [
146
+ ("indoor", "indoor"),
147
+ ("outdoor", "outdoor"),
148
+ ("object", "object"),
149
+ ],
150
+ label="scene type",
151
+ value='indoor',
152
+ )
153
  input_output_16bit = gr.File(
154
  label="Predicted depth (16-bit)",
155
  visible=False,
 
181
  interactive=False,
182
  )
183
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
184
  blocks_settings_depth = [ensemble_size, denoise_steps, processing_res]
185
+ blocks_settings = blocks_settings_depth
 
 
186
  map_id_to_default = {b._id: b.value for b in blocks_settings}
187
 
188
  inputs = [
 
190
  ensemble_size,
191
  denoise_steps,
192
  processing_res,
193
+ domain,
194
  input_output_16bit,
195
  input_output_fp32,
196
  input_output_vis,
197
+
 
 
 
 
198
  ]
199
  outputs = [
200
  submit_btn,
 
238
  cache_examples=True,
239
  )
240
 
 
 
241
 
242
  def clear_fn():
243
  out = []