JasonYinnnn commited on
Commit
5bfe88a
·
1 Parent(s): 7ac329c

add main()

Browse files
Files changed (1) hide show
  1. app.py +59 -22
app.py CHANGED
@@ -60,27 +60,27 @@ sam_segmentator = AutoModelForMaskGeneration.from_pretrained(segmenter_id).to(
60
  DEVICE, DTYPE
61
  )
62
 
63
- ############## 3D-Fixer model
64
- model_dir = 'HorizonRobotics/3D-Fixer'
65
- pipeline = ThreeDFixerPipeline.from_pretrained(
66
- model_dir, compile=False
67
- )
68
- pipeline.to(device=DEVICE)
69
- ############## 3D-Fixer model
70
-
71
- rot = np.array([
72
- [-1.0, 0.0, 0.0, 0.0],
73
- [ 0.0, 0.0, 1.0, 0.0],
74
- [ 0.0, 1.0, 0.0, 0.0],
75
- [ 0.0, 0.0, 0.0, 1.0],
76
- ], dtype=np.float32)
77
-
78
- c2w = torch.tensor([
79
- [1.0, 0.0, 0.0, 0.0],
80
- [0.0, 0.0, -1.0, 0.0],
81
- [0.0, 1.0, 0.0, 0.0],
82
- [0.0, 0.0, 0.0, 1.0],
83
- ], dtype=torch.float32, device=DEVICE)
84
 
85
  save_projected_colored_pcd = lambda pts, pts_color, fpath: trimesh.PointCloud(pts.reshape(-1, 3), pts_color.reshape(-1, 3)).export(fpath)
86
 
@@ -881,5 +881,42 @@ with gr.Blocks() as demo:
881
  outputs=[download_single_glb],
882
  )
883
 
 
 
 
 
 
 
 
884
 
885
- demo.launch(allowed_paths=[TMP_DIR, EXAMPLE_DIR])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  DEVICE, DTYPE
61
  )
62
 
63
+ # ############## 3D-Fixer model
64
+ # model_dir = 'HorizonRobotics/3D-Fixer'
65
+ # pipeline = ThreeDFixerPipeline.from_pretrained(
66
+ # model_dir, compile=False
67
+ # )
68
+ # pipeline.to(device=DEVICE)
69
+ # ############## 3D-Fixer model
70
+
71
+ # rot = np.array([
72
+ # [-1.0, 0.0, 0.0, 0.0],
73
+ # [ 0.0, 0.0, 1.0, 0.0],
74
+ # [ 0.0, 1.0, 0.0, 0.0],
75
+ # [ 0.0, 0.0, 0.0, 1.0],
76
+ # ], dtype=np.float32)
77
+
78
+ # c2w = torch.tensor([
79
+ # [1.0, 0.0, 0.0, 0.0],
80
+ # [0.0, 0.0, -1.0, 0.0],
81
+ # [0.0, 1.0, 0.0, 0.0],
82
+ # [0.0, 0.0, 0.0, 1.0],
83
+ # ], dtype=torch.float32, device=DEVICE)
84
 
85
  save_projected_colored_pcd = lambda pts, pts_color, fpath: trimesh.PointCloud(pts.reshape(-1, 3), pts_color.reshape(-1, 3)).export(fpath)
86
 
 
881
  outputs=[download_single_glb],
882
  )
883
 
884
+ if __name__ == '__main__':
885
+
886
+ work_space = None
887
+ dpt_pack = None
888
+ generated_object_map = {}
889
+
890
+ DEVICE = "cuda"
891
 
892
+ # Prepare models
893
+ ## Grounding SAM
894
+ segmenter_id = "facebook/sam-vit-base"
895
+ sam_processor = AutoProcessor.from_pretrained(segmenter_id)
896
+ sam_segmentator = AutoModelForMaskGeneration.from_pretrained(segmenter_id).to(
897
+ DEVICE, DTYPE
898
+ )
899
+
900
+ ############## 3D-Fixer model
901
+ model_dir = 'HorizonRobotics/3D-Fixer'
902
+ pipeline = ThreeDFixerPipeline.from_pretrained(
903
+ model_dir, compile=False
904
+ )
905
+ pipeline.to(device=DEVICE)
906
+ ############## 3D-Fixer model
907
+
908
+ rot = np.array([
909
+ [-1.0, 0.0, 0.0, 0.0],
910
+ [ 0.0, 0.0, 1.0, 0.0],
911
+ [ 0.0, 1.0, 0.0, 0.0],
912
+ [ 0.0, 0.0, 0.0, 1.0],
913
+ ], dtype=np.float32)
914
+
915
+ c2w = torch.tensor([
916
+ [1.0, 0.0, 0.0, 0.0],
917
+ [0.0, 0.0, -1.0, 0.0],
918
+ [0.0, 1.0, 0.0, 0.0],
919
+ [0.0, 0.0, 0.0, 1.0],
920
+ ], dtype=torch.float32, device=DEVICE)
921
+
922
+ demo.launch(allowed_paths=[TMP_DIR, EXAMPLE_DIR])