Jie Hu
commited on
Commit
·
61e5f12
1
Parent(s):
b9e0a6a
init project
Browse files
app.py
CHANGED
@@ -498,26 +498,8 @@ def get_reconstructed_scene(outdir, filelist, schedule, niter, min_conf_thr,
|
|
498 |
outfile = get_3D_model_from_scene(outdir, scene, min_conf_thr, as_pointcloud, mask_sky,
|
499 |
clean_depth, transparent_cams, cam_size)
|
500 |
torch.cuda.empty_cache()
|
501 |
-
|
502 |
-
|
503 |
-
# we apply the jet colormap on the confidence maps
|
504 |
-
# rgbimg = scene.imgs
|
505 |
-
# depths = to_numpy(scene.get_depthmaps())
|
506 |
-
# confs = to_numpy([c for c in scene.im_conf])
|
507 |
-
# # confs = to_numpy([c for c in scene.conf_2])
|
508 |
-
# cmap = pl.get_cmap('jet')
|
509 |
-
# depths_max = max([d.max() for d in depths])
|
510 |
-
# depths = [d / depths_max for d in depths]
|
511 |
-
# confs_max = max([d.max() for d in confs])
|
512 |
-
# confs = [cmap(d / confs_max) for d in confs]
|
513 |
-
|
514 |
-
# imgs = []
|
515 |
-
# for i in range(len(rgbimg)):
|
516 |
-
# imgs.append(rgbimg[i])
|
517 |
-
# imgs.append(rgb(depths[i]))
|
518 |
-
# imgs.append(rgb(confs[i]))
|
519 |
-
|
520 |
-
return scene, outfile #, imgs
|
521 |
|
522 |
# @spaces.GPU(duration=180)
|
523 |
# def get_3D_object_from_scene(outdir, text, threshold, scene, min_conf_thr, as_pointcloud,
|
@@ -536,27 +518,6 @@ def get_reconstructed_scene(outdir, filelist, schedule, niter, min_conf_thr,
|
|
536 |
# return outfile
|
537 |
|
538 |
|
539 |
-
def set_scenegraph_options(inputfiles, winsize, refid, scenegraph_type):
|
540 |
-
num_files = len(inputfiles) if inputfiles is not None else 1
|
541 |
-
max_winsize = max(1, math.ceil((num_files - 1) / 2))
|
542 |
-
if scenegraph_type == "swin":
|
543 |
-
winsize = gradio.Slider(label="Scene Graph: Window Size", value=max_winsize,
|
544 |
-
minimum=1, maximum=max_winsize, step=1, visible=True)
|
545 |
-
refid = gradio.Slider(label="Scene Graph: Id", value=0, minimum=0,
|
546 |
-
maximum=num_files - 1, step=1, visible=False)
|
547 |
-
elif scenegraph_type == "oneref":
|
548 |
-
winsize = gradio.Slider(label="Scene Graph: Window Size", value=max_winsize,
|
549 |
-
minimum=1, maximum=max_winsize, step=1, visible=False)
|
550 |
-
refid = gradio.Slider(label="Scene Graph: Id", value=0, minimum=0,
|
551 |
-
maximum=num_files - 1, step=1, visible=True)
|
552 |
-
else:
|
553 |
-
winsize = gradio.Slider(label="Scene Graph: Window Size", value=max_winsize,
|
554 |
-
minimum=1, maximum=max_winsize, step=1, visible=False)
|
555 |
-
refid = gradio.Slider(label="Scene Graph: Id", value=0, minimum=0,
|
556 |
-
maximum=num_files - 1, step=1, visible=False)
|
557 |
-
return winsize, refid
|
558 |
-
|
559 |
-
|
560 |
with tempfile.TemporaryDirectory(suffix='pe3r_gradio_demo') as tmpdirname:
|
561 |
recon_fun = functools.partial(get_reconstructed_scene, tmpdirname)
|
562 |
# model_from_scene_fun = functools.partial(get_3D_model_from_scene, tmpdirname)
|
@@ -607,45 +568,14 @@ with tempfile.TemporaryDirectory(suffix='pe3r_gradio_demo') as tmpdirname:
|
|
607 |
# find_btn = gradio.Button("Find")
|
608 |
|
609 |
outmodel = gradio.Model3D()
|
610 |
-
# outgallery = gradio.Gallery(label='rgb,depth,confidence', columns=3, height="100%",
|
611 |
-
# visible=False)
|
612 |
-
|
613 |
# events
|
614 |
-
|
615 |
-
inputs=[inputfiles, winsize, refid, scenegraph_type],
|
616 |
-
outputs=[winsize, refid])
|
617 |
-
inputfiles.change(set_scenegraph_options,
|
618 |
-
inputs=[inputfiles, winsize, refid, scenegraph_type],
|
619 |
-
outputs=[winsize, refid])
|
620 |
run_btn.click(fn=recon_fun,
|
621 |
inputs=[inputfiles, schedule, niter, min_conf_thr, as_pointcloud,
|
622 |
mask_sky, clean_depth, transparent_cams, cam_size,
|
623 |
scenegraph_type, winsize, refid],
|
624 |
outputs=[scene, outmodel]) # , outgallery
|
625 |
-
|
626 |
-
# inputs=[scene, min_conf_thr, as_pointcloud, mask_sky,
|
627 |
-
# clean_depth, transparent_cams, cam_size],
|
628 |
-
# outputs=outmodel)
|
629 |
-
# cam_size.change(fn=model_from_scene_fun,
|
630 |
-
# inputs=[scene, min_conf_thr, as_pointcloud, mask_sky,
|
631 |
-
# clean_depth, transparent_cams, cam_size],
|
632 |
-
# outputs=outmodel)
|
633 |
-
# as_pointcloud.change(fn=model_from_scene_fun,
|
634 |
-
# inputs=[scene, min_conf_thr, as_pointcloud, mask_sky,
|
635 |
-
# clean_depth, transparent_cams, cam_size],
|
636 |
-
# outputs=outmodel)
|
637 |
-
# mask_sky.change(fn=model_from_scene_fun,
|
638 |
-
# inputs=[scene, min_conf_thr, as_pointcloud, mask_sky,
|
639 |
-
# clean_depth, transparent_cams, cam_size],
|
640 |
-
# outputs=outmodel)
|
641 |
-
# clean_depth.change(fn=model_from_scene_fun,
|
642 |
-
# inputs=[scene, min_conf_thr, as_pointcloud, mask_sky,
|
643 |
-
# clean_depth, transparent_cams, cam_size],
|
644 |
-
# outputs=outmodel)
|
645 |
-
# transparent_cams.change(model_from_scene_fun,
|
646 |
-
# inputs=[scene, min_conf_thr, as_pointcloud, mask_sky,
|
647 |
-
# clean_depth, transparent_cams, cam_size],
|
648 |
-
# outputs=outmodel)
|
649 |
# find_btn.click(fn=get_3D_object_from_scene_fun,
|
650 |
# inputs=[text_input, threshold, scene, min_conf_thr, as_pointcloud, mask_sky,
|
651 |
# clean_depth, transparent_cams, cam_size],
|
|
|
498 |
outfile = get_3D_model_from_scene(outdir, scene, min_conf_thr, as_pointcloud, mask_sky,
|
499 |
clean_depth, transparent_cams, cam_size)
|
500 |
torch.cuda.empty_cache()
|
501 |
+
|
502 |
+
return scene, outfile
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
503 |
|
504 |
# @spaces.GPU(duration=180)
|
505 |
# def get_3D_object_from_scene(outdir, text, threshold, scene, min_conf_thr, as_pointcloud,
|
|
|
518 |
# return outfile
|
519 |
|
520 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
521 |
with tempfile.TemporaryDirectory(suffix='pe3r_gradio_demo') as tmpdirname:
|
522 |
recon_fun = functools.partial(get_reconstructed_scene, tmpdirname)
|
523 |
# model_from_scene_fun = functools.partial(get_3D_model_from_scene, tmpdirname)
|
|
|
568 |
# find_btn = gradio.Button("Find")
|
569 |
|
570 |
outmodel = gradio.Model3D()
|
|
|
|
|
|
|
571 |
# events
|
572 |
+
|
|
|
|
|
|
|
|
|
|
|
573 |
run_btn.click(fn=recon_fun,
|
574 |
inputs=[inputfiles, schedule, niter, min_conf_thr, as_pointcloud,
|
575 |
mask_sky, clean_depth, transparent_cams, cam_size,
|
576 |
scenegraph_type, winsize, refid],
|
577 |
outputs=[scene, outmodel]) # , outgallery
|
578 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
579 |
# find_btn.click(fn=get_3D_object_from_scene_fun,
|
580 |
# inputs=[text_input, threshold, scene, min_conf_thr, as_pointcloud, mask_sky,
|
581 |
# clean_depth, transparent_cams, cam_size],
|