hujiecpp commited on
Commit
6cfb019
·
1 Parent(s): d579507

init project

Browse files
Files changed (1) hide show
  1. app.py +19 -21
app.py CHANGED
@@ -519,23 +519,21 @@ def get_reconstructed_scene(outdir, filelist, schedule, niter, min_conf_thr,
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,
524
- mask_sky, clean_depth, transparent_cams, cam_size):
525
-
526
- device = 'cuda' if torch.cuda.is_available() else 'cpu'
527
 
528
- texts = [text]
529
- inputs = pe3r.siglip_tokenizer(text=texts, padding="max_length", return_tensors="pt")
530
- inputs = {key: value.to(device) for key, value in inputs.items()}
531
- with torch.no_grad():
532
- text_feats =pe3r.siglip.get_text_features(**inputs)
533
- text_feats = text_feats / text_feats.norm(dim=-1, keepdim=True)
534
- scene.render_image(text_feats, threshold)
535
- scene.ori_imgs = scene.rendered_imgs
536
- outfile = get_3D_model_from_scene(outdir, scene, min_conf_thr, as_pointcloud, mask_sky,
537
- clean_depth, transparent_cams, cam_size)
538
- return outfile
539
 
540
 
541
  def set_scenegraph_options(inputfiles, winsize, refid, scenegraph_type):
@@ -562,7 +560,7 @@ def set_scenegraph_options(inputfiles, winsize, refid, scenegraph_type):
562
  with tempfile.TemporaryDirectory(suffix='pe3r_gradio_demo') as tmpdirname:
563
  recon_fun = functools.partial(get_reconstructed_scene, tmpdirname)
564
  model_from_scene_fun = functools.partial(get_3D_model_from_scene, tmpdirname)
565
- get_3D_object_from_scene_fun = functools.partial(get_3D_object_from_scene, tmpdirname)
566
 
567
  with gradio.Blocks(css=""".gradio-container {margin: 0 !important; min-width: 100%};""", title="PE3R Demo") as demo:
568
  # scene state is save so that you can change conf_thr, cam_size... without rerunning the inference
@@ -648,8 +646,8 @@ with tempfile.TemporaryDirectory(suffix='pe3r_gradio_demo') as tmpdirname:
648
  inputs=[scene, min_conf_thr, as_pointcloud, mask_sky,
649
  clean_depth, transparent_cams, cam_size],
650
  outputs=outmodel)
651
- find_btn.click(fn=get_3D_object_from_scene_fun,
652
- inputs=[text_input, threshold, scene, min_conf_thr, as_pointcloud, mask_sky,
653
- clean_depth, transparent_cams, cam_size],
654
- outputs=outmodel)
655
  demo.launch(show_error=True, share=None, server_name=None, server_port=None)
 
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,
524
+ # mask_sky, clean_depth, transparent_cams, cam_size):
 
 
525
 
526
+ # texts = [text]
527
+ # inputs = pe3r.siglip_tokenizer(text=texts, padding="max_length", return_tensors="pt")
528
+ # inputs = {key: value.to(device) for key, value in inputs.items()}
529
+ # with torch.no_grad():
530
+ # text_feats =pe3r.siglip.get_text_features(**inputs)
531
+ # text_feats = text_feats / text_feats.norm(dim=-1, keepdim=True)
532
+ # scene.render_image(text_feats, threshold)
533
+ # scene.ori_imgs = scene.rendered_imgs
534
+ # outfile = get_3D_model_from_scene(outdir, scene, min_conf_thr, as_pointcloud, mask_sky,
535
+ # clean_depth, transparent_cams, cam_size)
536
+ # return outfile
537
 
538
 
539
  def set_scenegraph_options(inputfiles, winsize, refid, scenegraph_type):
 
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)
563
+ # get_3D_object_from_scene_fun = functools.partial(get_3D_object_from_scene, tmpdirname)
564
 
565
  with gradio.Blocks(css=""".gradio-container {margin: 0 !important; min-width: 100%};""", title="PE3R Demo") as demo:
566
  # scene state is save so that you can change conf_thr, cam_size... without rerunning the inference
 
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],
652
+ # outputs=outmodel)
653
  demo.launch(show_error=True, share=None, server_name=None, server_port=None)