crevelop commited on
Commit
8717a68
·
unverified ·
1 Parent(s): 5fade3c

revert logs and fill holes

Browse files
Files changed (2) hide show
  1. app.py +1 -0
  2. trellis/utils/postprocessing_utils.py +6 -9
app.py CHANGED
@@ -113,6 +113,7 @@ def image_to_3d(
113
  simplify=mesh_simplify,
114
  texture_size=min(texture_size, 1024), # Limit texture size
115
  verbose=False,
 
116
  debug=False
117
  )
118
  glb.export(glb_path)
 
113
  simplify=mesh_simplify,
114
  texture_size=min(texture_size, 1024), # Limit texture size
115
  verbose=False,
116
+ fill_holes=False, # Disable hole filling to save memory
117
  debug=False
118
  )
119
  glb.export(glb_path)
trellis/utils/postprocessing_utils.py CHANGED
@@ -440,10 +440,6 @@ def to_glb(
440
 
441
  # bake texture
442
  observations, extrinsics, intrinsics = render_multiview(app_rep, resolution=1024, nviews=100)
443
- print("Observation stats:")
444
- print(f"Min: {min([o.min() for o in observations])}")
445
- print(f"Max: {max([o.max() for o in observations])}")
446
- print(f"Mean: {np.mean([o.mean() for o in observations])}")
447
  masks = [np.any(observation > 0, axis=-1) for observation in observations]
448
  extrinsics = [extrinsics[i].cpu().numpy() for i in range(len(extrinsics))]
449
  intrinsics = [intrinsics[i].cpu().numpy() for i in range(len(intrinsics))]
@@ -455,12 +451,13 @@ def to_glb(
455
  verbose=verbose
456
  )
457
  texture = Image.fromarray(texture)
458
- print("Texture stats:")
459
- print(f"Min: {texture.min()}")
460
- print(f"Max: {texture.max()}")
461
- print(f"Mean: {texture.mean()}")
462
 
463
  # rotate mesh (from z-up to y-up)
464
  vertices = vertices @ np.array([[1, 0, 0], [0, 0, -1], [0, 1, 0]])
465
- mesh = trimesh.Trimesh(vertices, faces, visual=trimesh.visual.TextureVisuals(uv=uvs, image=texture))
 
 
 
 
 
466
  return mesh
 
440
 
441
  # bake texture
442
  observations, extrinsics, intrinsics = render_multiview(app_rep, resolution=1024, nviews=100)
 
 
 
 
443
  masks = [np.any(observation > 0, axis=-1) for observation in observations]
444
  extrinsics = [extrinsics[i].cpu().numpy() for i in range(len(extrinsics))]
445
  intrinsics = [intrinsics[i].cpu().numpy() for i in range(len(intrinsics))]
 
451
  verbose=verbose
452
  )
453
  texture = Image.fromarray(texture)
 
 
 
 
454
 
455
  # rotate mesh (from z-up to y-up)
456
  vertices = vertices @ np.array([[1, 0, 0], [0, 0, -1], [0, 1, 0]])
457
+ material = trimesh.visual.material.PBRMaterial(
458
+ roughnessFactor=1.0,
459
+ baseColorTexture=texture,
460
+ baseColorFactor=np.array([255, 255, 255, 255], dtype=np.uint8)
461
+ )
462
+ mesh = trimesh.Trimesh(vertices, faces, visual=trimesh.visual.TextureVisuals(uv=uvs, material=material))
463
  return mesh