lemonaddie commited on
Commit
2afefb7
1 Parent(s): 8aa4d1f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -168
app.py CHANGED
@@ -69,7 +69,7 @@ def run_demo_server(pipe):
69
 
70
  with gr.Blocks(
71
  analytics_enabled=False,
72
- title="Marigold Depth Estimation",
73
  css="""
74
  #download {
75
  height: 118px;
@@ -149,121 +149,7 @@ def run_demo_server(pipe):
149
  interactive=False,
150
  )
151
 
152
- demo_3d_header = gr.Markdown(
153
- """
154
- <h3 align="center">3D Printing Depth Maps</h3>
155
- <p align="justify">
156
- This part of the demo uses Marigold depth maps estimated in the previous step to create a
157
- 3D-printable model. The models are watertight, with correct normals, and exported in the STL format.
158
- We recommended creating the first model with the default parameters and iterating on it until the best
159
- result (see Pro Tips below).
160
- </p>
161
- """,
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
 
@@ -275,11 +161,6 @@ def run_demo_server(pipe):
275
  input_output_16bit,
276
  input_output_fp32,
277
  input_output_vis,
278
- #plane_near,
279
- #plane_far,
280
- #embossing,
281
- #filter_size,
282
- #frame_near,
283
  ]
284
  outputs = [
285
  submit_btn,
@@ -312,11 +193,6 @@ def run_demo_server(pipe):
312
  "files/bee_depth_16bit.png",
313
  "files/bee_depth_fp32.npy",
314
  "files/bee_depth_colored.png",
315
- #0.0, # plane_near
316
- #0.5, # plane_far
317
- #20, # embossing
318
- #3, # filter_size
319
- #0, # frame_near
320
  ],
321
  ],
322
  inputs=inputs,
@@ -324,16 +200,12 @@ def run_demo_server(pipe):
324
  cache_examples=True,
325
  )
326
 
327
- # demo_3d_header.render()
328
- # demo_3d.render()
329
-
330
  def clear_fn():
331
  out = []
332
  for b in blocks_settings:
333
  out.append(map_id_to_default[b._id])
334
  out += [
335
  gr.Button(interactive=True),
336
- #gr.Button(interactive=True),
337
  gr.Image(value=None, interactive=True),
338
  None, None, None, None, None, None, None,
339
  ]
@@ -351,44 +223,9 @@ def run_demo_server(pipe):
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,
394
  ).launch(
@@ -397,8 +234,6 @@ def run_demo_server(pipe):
397
  )
398
 
399
 
400
-
401
-
402
  def main():
403
 
404
  REPO_URL = "https://github.com/lemonaddie/geowizard.git"
@@ -411,7 +246,6 @@ def main():
411
  repo = git.Repo.clone_from(REPO_URL, REPO_DIR)
412
  sys.path.append(os.path.join(os.getcwd(), REPO_DIR))
413
 
414
-
415
  from pipeline.depth_normal_pipeline_clip_cfg import DepthNormalEstimationPipeline
416
 
417
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
@@ -430,4 +264,3 @@ def main():
430
 
431
  if __name__ == "__main__":
432
  main()
433
- # 1
 
69
 
70
  with gr.Blocks(
71
  analytics_enabled=False,
72
+ title="GeoWizard Depth and Normal Estimation",
73
  css="""
74
  #download {
75
  height: 118px;
 
149
  interactive=False,
150
  )
151
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152
  blocks_settings_depth = [ensemble_size, denoise_steps, processing_res]
 
 
 
153
  blocks_settings = blocks_settings_depth
154
  map_id_to_default = {b._id: b.value for b in blocks_settings}
155
 
 
161
  input_output_16bit,
162
  input_output_fp32,
163
  input_output_vis,
 
 
 
 
 
164
  ]
165
  outputs = [
166
  submit_btn,
 
193
  "files/bee_depth_16bit.png",
194
  "files/bee_depth_fp32.npy",
195
  "files/bee_depth_colored.png",
 
 
 
 
 
196
  ],
197
  ],
198
  inputs=inputs,
 
200
  cache_examples=True,
201
  )
202
 
 
 
 
203
  def clear_fn():
204
  out = []
205
  for b in blocks_settings:
206
  out.append(map_id_to_default[b._id])
207
  out += [
208
  gr.Button(interactive=True),
 
209
  gr.Image(value=None, interactive=True),
210
  None, None, None, None, None, None, None,
211
  ]
 
223
  input_output_vis,
224
  output_slider,
225
  files,
 
 
226
  ],
227
  )
228
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
229
  demo.queue(
230
  api_open=False,
231
  ).launch(
 
234
  )
235
 
236
 
 
 
237
  def main():
238
 
239
  REPO_URL = "https://github.com/lemonaddie/geowizard.git"
 
246
  repo = git.Repo.clone_from(REPO_URL, REPO_DIR)
247
  sys.path.append(os.path.join(os.getcwd(), REPO_DIR))
248
 
 
249
  from pipeline.depth_normal_pipeline_clip_cfg import DepthNormalEstimationPipeline
250
 
251
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
 
264
 
265
  if __name__ == "__main__":
266
  main()