Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions hy3dgen/shapegen/pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,13 @@ def __init__(
self.conditioner = conditioner
self.image_processor = image_processor
self.kwargs = kwargs
self.components = {
'vae': vae,
'model': model,
'scheduler': scheduler,
'conditioner': conditioner,
'image_processor': image_processor
}
self.to(device, dtype)

def compile(self):
Expand Down
14 changes: 8 additions & 6 deletions hy3dgen/shapegen/schedulers.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,11 @@ def step(
self._init_step_index(timestep)

# Upcast to avoid precision issues when computing prev_sample
sample = sample.to(torch.float32)
device = model_output.device
sample = sample.to(device=device, dtype=torch.float32)

sigma = self.sigmas[self.step_index]
sigma_next = self.sigmas[self.step_index + 1]
sigma = self.sigmas[self.step_index].to(device=device, dtype=torch.float32)
sigma_next = self.sigmas[self.step_index + 1].to(device=device, dtype=torch.float32)

prev_sample = sample + (sigma_next - sigma) * model_output

Expand Down Expand Up @@ -457,10 +458,11 @@ def step(
if self.step_index is None:
self._init_step_index(timestep)

sample = sample.to(torch.float32)
device = model_output.device
sample = sample.to(device=device, dtype=torch.float32)

sigma = self.sigmas_[self.step_index]
sigma_next = self.sigmas_[self.step_index + 1]
sigma = self.sigmas_[self.step_index].to(device=device, dtype=torch.float32)
sigma_next = self.sigmas_[self.step_index + 1].to(device=device, dtype=torch.float32)

prev_sample = sample + (sigma_next - sigma) * model_output
prev_sample = prev_sample.to(model_output.dtype)
Expand Down
4 changes: 4 additions & 0 deletions hy3dgen/texgen/utils/uv_warp_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ def mesh_uv_wrap(mesh):
if isinstance(mesh, trimesh.Scene):
mesh = mesh.dump(concatenate=True)

# Optimization: Decimate extremely dense meshes to prevent xatlas hang
if len(mesh.faces) > 100000:
mesh = mesh.simplify_quadric_decimation(face_count=80000)

if len(mesh.faces) > 500000000:
raise ValueError("The mesh has more than 500,000,000 faces, which is not supported.")

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ trimesh
pymeshlab
pygltflib
xatlas
fast-simplification
#kornia
#facexlib

Expand Down