tokenid commited on
Commit
e18e089
1 Parent(s): 54ea108

glb mirror

Browse files
Files changed (2) hide show
  1. app.py +3 -4
  2. src/utils/mesh_util.py +7 -0
app.py CHANGED
@@ -234,11 +234,9 @@ def make3d(images):
234
 
235
  vertices, faces, vertex_colors = mesh_out
236
  vertices = vertices[:, [1, 2, 0]]
237
- vertices[:, -1] *= -1
238
- faces = faces[:, [2, 1, 0]]
239
-
240
- save_obj(vertices, faces, vertex_colors, mesh_fpath)
241
  save_glb(vertices, faces, vertex_colors, mesh_glb_fpath)
 
242
 
243
  print(f"Mesh saved to {mesh_fpath}")
244
 
@@ -350,6 +348,7 @@ with gr.Blocks() as demo:
350
  label="Output Model (GLB Format)",
351
  interactive=False,
352
  )
 
353
 
354
  with gr.Row():
355
  gr.Markdown('''Try a different <b>seed value</b> if the result is unsatisfying (Default: 42).''')
 
234
 
235
  vertices, faces, vertex_colors = mesh_out
236
  vertices = vertices[:, [1, 2, 0]]
237
+
 
 
 
238
  save_glb(vertices, faces, vertex_colors, mesh_glb_fpath)
239
+ save_obj(vertices, faces, vertex_colors, mesh_fpath)
240
 
241
  print(f"Mesh saved to {mesh_fpath}")
242
 
 
348
  label="Output Model (GLB Format)",
349
  interactive=False,
350
  )
351
+ gr.Markdown("Note: The model shown here has a darker appearance. Download to get correct results.")
352
 
353
  with gr.Row():
354
  gr.Markdown('''Try a different <b>seed value</b> if the result is unsatisfying (Default: 42).''')
src/utils/mesh_util.py CHANGED
@@ -16,6 +16,10 @@ from PIL import Image
16
 
17
 
18
  def save_obj(pointnp_px3, facenp_fx3, colornp_px3, fpath):
 
 
 
 
19
  mesh = trimesh.Trimesh(
20
  vertices=pointnp_px3,
21
  faces=facenp_fx3,
@@ -25,6 +29,9 @@ def save_obj(pointnp_px3, facenp_fx3, colornp_px3, fpath):
25
 
26
 
27
  def save_glb(pointnp_px3, facenp_fx3, colornp_px3, fpath):
 
 
 
28
  mesh = trimesh.Trimesh(
29
  vertices=pointnp_px3,
30
  faces=facenp_fx3,
 
16
 
17
 
18
  def save_obj(pointnp_px3, facenp_fx3, colornp_px3, fpath):
19
+
20
+ pointnp_px3 = pointnp_px3 @ np.array([[1, 0, 0], [0, 1, 0], [0, 0, -1]])
21
+ facenp_fx3 = facenp_fx3[:, [2, 1, 0]]
22
+
23
  mesh = trimesh.Trimesh(
24
  vertices=pointnp_px3,
25
  faces=facenp_fx3,
 
29
 
30
 
31
  def save_glb(pointnp_px3, facenp_fx3, colornp_px3, fpath):
32
+
33
+ pointnp_px3 = pointnp_px3 @ np.array([[-1, 0, 0], [0, 1, 0], [0, 0, -1]])
34
+
35
  mesh = trimesh.Trimesh(
36
  vertices=pointnp_px3,
37
  faces=facenp_fx3,