Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
rot
Browse files- gradio_demo.py +5 -3
gradio_demo.py
CHANGED
@@ -89,7 +89,8 @@ def mesh_gen(tmp_dir, simplify, num_inference_steps):
|
|
89 |
|
90 |
mesh = trimesh.load_mesh(f"{tmp_dir}/mesh.ply")
|
91 |
vertex_normals = mesh.vertex_normals
|
92 |
-
theta = np.radians(
|
|
|
93 |
cos_theta = np.cos(theta)
|
94 |
sin_theta = np.sin(theta)
|
95 |
rotation_matrix = np.array([
|
@@ -98,9 +99,10 @@ def mesh_gen(tmp_dir, simplify, num_inference_steps):
|
|
98 |
[0, 0, 1]
|
99 |
])
|
100 |
rotated_normal = np.dot(vertex_normals, rotation_matrix.T)
|
101 |
-
rotated_normal = rotated_normal / np.linalg.norm(rotated_normal)
|
102 |
colors = (-rotated_normal + 1) / 2.0
|
103 |
-
colors = (
|
|
|
104 |
# print(colors.shape)
|
105 |
mesh.visual.vertex_colors = colors[..., [2, 1, 0]] # RGB -> BGR
|
106 |
mesh.export(f"{tmp_dir}/mesh_normal.ply", file_type="ply")
|
|
|
89 |
|
90 |
mesh = trimesh.load_mesh(f"{tmp_dir}/mesh.ply")
|
91 |
vertex_normals = mesh.vertex_normals
|
92 |
+
theta = np.radians(180) # Rotation angle in radians
|
93 |
+
# Create rotation matrix
|
94 |
cos_theta = np.cos(theta)
|
95 |
sin_theta = np.sin(theta)
|
96 |
rotation_matrix = np.array([
|
|
|
99 |
[0, 0, 1]
|
100 |
])
|
101 |
rotated_normal = np.dot(vertex_normals, rotation_matrix.T)
|
102 |
+
# rotated_normal = rotated_normal / np.linalg.norm(rotated_normal)
|
103 |
colors = (-rotated_normal + 1) / 2.0
|
104 |
+
# colors = (-vertex_normals + 1) / 2.0
|
105 |
+
colors = (colors * 255).clip(0, 255).astype(np.uint8) # Convert to 8-bit color
|
106 |
# print(colors.shape)
|
107 |
mesh.visual.vertex_colors = colors[..., [2, 1, 0]] # RGB -> BGR
|
108 |
mesh.export(f"{tmp_dir}/mesh_normal.ply", file_type="ply")
|