Skip to content

Commit

Permalink
fix instant3d
Browse files Browse the repository at this point in the history
  • Loading branch information
yf1019 committed May 27, 2024
1 parent 6c9fd0f commit 95239f7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion configs/mesh-fitting-instantmesh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ system:
shape_init: ???
shape_init_params: 1.0
radius: 1.0 # consistent with coarse
shape_init_mesh_up: "-z"
shape_init_mesh_up: "+z"
shape_init_mesh_front: "+x"
is_instantmesh: true
material_type: "no-material"
material:
n_output_dims: 3
Expand Down
6 changes: 5 additions & 1 deletion threestudio/models/geometry/obj_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Config(BaseExplicitGeometry.Config):
shape_init_params: Optional[Any] = None
shape_init_mesh_up: str = "+z"
shape_init_mesh_front: str = "+x"
is_instantmesh: bool = False

cfg: Config

Expand All @@ -43,6 +44,9 @@ def configure(self) -> None:
# centroid = mesh.vertices.mean(0)
# mesh.vertices = mesh.vertices - centroid

if self.cfg.is_instantmesh:
mesh.vertices = mesh.vertices @ np.array([[1, 0, 0], [0, 1, 0], [0, 0, -1]])

# align to up-z and front-x
dirs = ["+x", "+y", "+z", "-x", "-y", "-z"]
dir2vec = {
Expand Down Expand Up @@ -75,7 +79,7 @@ def configure(self) -> None:
# scaling
# scale = np.abs(mesh.vertices).max()
# mesh.vertices = mesh.vertices / scale * self.cfg.shape_init_params
# mesh.vertices = np.dot(mesh2std, mesh.vertices.T).T
mesh.vertices = np.dot(mesh2std, mesh.vertices.T).T

self.normal = torch.tensor(mesh.vertex_normals, dtype=torch.float32).to(self.device).contiguous()

Expand Down

0 comments on commit 95239f7

Please sign in to comment.