xinjie.wang commited on
Commit
be7eba9
·
1 Parent(s): b75f769
Files changed (2) hide show
  1. asset3d_gen/models/gs_model.py +4 -1
  2. common.py +10 -8
asset3d_gen/models/gs_model.py CHANGED
@@ -137,6 +137,7 @@ class GaussianBase:
137
  cls,
138
  path: str,
139
  gamma: float = 1.0,
 
140
  ) -> "GaussianBase":
141
  plydata = PlyData.read(path)
142
  xyz = torch.stack(
@@ -241,6 +242,7 @@ class GaussianBase:
241
  _quats=rots,
242
  _features_dc=features_dc,
243
  _features_rest=features_extra,
 
244
  )
245
 
246
  def save_to_ply(
@@ -454,8 +456,9 @@ class GaussianOperator(GaussianBase):
454
  real_height: float = None,
455
  instance_pose: np.ndarray = None,
456
  sh_degree: int = 0,
 
457
  ) -> None:
458
- gs_model = GaussianOperator.load_from_ply(in_ply, sh_degree)
459
 
460
  if instance_pose is not None:
461
  gs_model = gs_model.get_gaussians(instance_pose=instance_pose)
 
137
  cls,
138
  path: str,
139
  gamma: float = 1.0,
140
+ device: str = "cuda",
141
  ) -> "GaussianBase":
142
  plydata = PlyData.read(path)
143
  xyz = torch.stack(
 
242
  _quats=rots,
243
  _features_dc=features_dc,
244
  _features_rest=features_extra,
245
+ device=device,
246
  )
247
 
248
  def save_to_ply(
 
456
  real_height: float = None,
457
  instance_pose: np.ndarray = None,
458
  sh_degree: int = 0,
459
+ device: str = "cuda",
460
  ) -> None:
461
+ gs_model = GaussianOperator.load_from_ply(in_ply, sh_degree, device=device)
462
 
463
  if instance_pose is not None:
464
  gs_model = gs_model.get_gaussians(instance_pose=instance_pose)
common.py CHANGED
@@ -83,16 +83,16 @@ DELIGHT = DelightingModel()
83
  IMAGESR_MODEL = ImageRealESRGAN(outscale=4)
84
 
85
 
86
- def inverse_softplus(x):
87
- return x + torch.log(-torch.expm1(-x))
 
88
 
89
- def build_covariance_from_scaling_rotation(scaling, scaling_modifier, rotation):
90
- L = build_scaling_rotation(scaling_modifier * scaling, rotation)
91
- actual_covariance = L @ L.transpose(1, 2)
92
- symm = strip_symmetric(actual_covariance)
93
- return symm
94
 
95
- def patched_setup_functions(self):
96
  if self.scaling_activation_type == "exp":
97
  self.scaling_activation = torch.exp
98
  self.inverse_scaling_activation = torch.log
@@ -514,6 +514,7 @@ def extract_3d_representations_v2(
514
  in_ply=gs_path,
515
  out_ply=aligned_gs_path,
516
  instance_pose=pose,
 
517
  )
518
  print("debug5")
519
  color_path = os.path.join(user_dir, "color.png")
@@ -601,6 +602,7 @@ def extract_urdf(
601
  in_ply=gs_path,
602
  out_ply=out_gs,
603
  real_height=real_height,
 
604
  )
605
 
606
  # Quality check and update .urdf file.
 
83
  IMAGESR_MODEL = ImageRealESRGAN(outscale=4)
84
 
85
 
86
+ def patched_setup_functions(self):
87
+ def inverse_softplus(x):
88
+ return x + torch.log(-torch.expm1(-x))
89
 
90
+ def build_covariance_from_scaling_rotation(scaling, scaling_modifier, rotation):
91
+ L = build_scaling_rotation(scaling_modifier * scaling, rotation)
92
+ actual_covariance = L @ L.transpose(1, 2)
93
+ symm = strip_symmetric(actual_covariance)
94
+ return symm
95
 
 
96
  if self.scaling_activation_type == "exp":
97
  self.scaling_activation = torch.exp
98
  self.inverse_scaling_activation = torch.log
 
514
  in_ply=gs_path,
515
  out_ply=aligned_gs_path,
516
  instance_pose=pose,
517
+ device="cpu",
518
  )
519
  print("debug5")
520
  color_path = os.path.join(user_dir, "color.png")
 
602
  in_ply=gs_path,
603
  out_ply=out_gs,
604
  real_height=real_height,
605
+ device="cpu",
606
  )
607
 
608
  # Quality check and update .urdf file.