Skip to content

Commit 921b0d7

Browse files
committed
version bump
1 parent 875b0b0 commit 921b0d7

File tree

5 files changed

+23
-10
lines changed

5 files changed

+23
-10
lines changed

hy3dgen/shapegen/models/autoencoders/volume_decoders.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from .attention_processors import FlashVDMCrossAttentionProcessor, FlashVDMTopMCrossAttentionProcessor
2626
from ...utils import logger
2727

28+
from comfy.utils import ProgressBar
2829

2930
def extract_near_surface_volume_fn(input_tensor: torch.Tensor, alpha: float):
3031
device = input_tensor.device
@@ -318,7 +319,7 @@ def __call__(
318319
for i, resolution in enumerate(resolutions[1:]):
319320
resolutions[i + 1] = resolutions[0] * 2 ** (i + 1)
320321

321-
logger.info(f"FlashVDMVolumeDecoding Resolution: {resolutions}")
322+
#logger.info(f"FlashVDMVolumeDecoding Resolution: {resolutions}")
322323

323324
# 1. generate query points
324325
if isinstance(bounds, float):
@@ -354,6 +355,7 @@ def __call__(
354355
)
355356
batch_logits = []
356357
num_batchs = max(num_chunks // xyz_samples.shape[1], 1)
358+
comfy_pbar = ProgressBar(xyz_samples.shape[0])
357359
for start in tqdm(range(0, xyz_samples.shape[0], num_batchs),
358360
desc=f"FlashVDM Volume Decoding", disable=not enable_pbar):
359361
queries = xyz_samples[start: start + num_batchs, :]
@@ -362,13 +364,17 @@ def __call__(
362364
processor.topk = True
363365
logits = geo_decoder(queries=queries, latents=batch_latents)
364366
batch_logits.append(logits)
367+
comfy_pbar.update(num_chunks)
368+
365369
grid_logits = torch.cat(batch_logits, dim=0).reshape(
366370
mini_grid_num, mini_grid_num, mini_grid_num,
367371
mini_grid_size, mini_grid_size,
368372
mini_grid_size
369373
).permute(0, 3, 1, 4, 2, 5).contiguous().view(
370374
(batch_size, grid_size[0], grid_size[1], grid_size[2])
371-
)
375+
)
376+
377+
372378

373379
for octree_depth_now in resolutions[1:]:
374380
grid_size = np.array([octree_depth_now + 1] * 3)

hy3dgen/shapegen/models/conditioner.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ def forward(self, image, mask=None, value_range=(-1, 1), view_dict=None):
112112
image = (image - low) / (high - low)
113113

114114
image = image.to(self.model.device, dtype=self.model.dtype)
115+
print("image shape", image.shape)
115116

116117
if mask is not None:
117118
mask = mask.to(image)

hy3dgen/shapegen/pipelines.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ def from_single_file(
206206
config['model']['params']['attention_mode'] = attention_mode
207207
#config['vae']['params']['attention_mode'] = attention_mode
208208

209-
if cublas_ops:
210-
config['vae']['params']['cublas_ops'] = True
209+
#if cublas_ops:
210+
# config['vae']['params']['cublas_ops'] = True
211211

212212
with init_empty_weights():
213213
model = instantiate_from_config(config['model'])

nodes.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,6 +1086,7 @@ def INPUT_TYPES(s):
10861086
"optional": {
10871087
"mask": ("MASK", ),
10881088
"scheduler": (["FlowMatchEulerDiscreteScheduler", "ConsistencyFlowMatchEulerDiscreteScheduler"],),
1089+
"force_offload": ("BOOLEAN", {"default": True, "tooltip": "Offloads the model to the offload device once the process is done."}),
10891090
}
10901091
}
10911092

@@ -1094,7 +1095,8 @@ def INPUT_TYPES(s):
10941095
FUNCTION = "process"
10951096
CATEGORY = "Hunyuan3DWrapper"
10961097

1097-
def process(self, pipeline, image, steps, guidance_scale, seed, mask=None, front=None, back=None, left=None, right=None, scheduler="FlowMatchEulerDiscreteScheduler"):
1098+
def process(self, pipeline, image, steps, guidance_scale, seed, mask=None, front=None, back=None, left=None, right=None,
1099+
scheduler="FlowMatchEulerDiscreteScheduler", force_offload=True):
10981100

10991101
mm.unload_all_models()
11001102
mm.soft_empty_cache()
@@ -1136,8 +1138,9 @@ def process(self, pipeline, image, steps, guidance_scale, seed, mask=None, front
11361138
torch.cuda.reset_peak_memory_stats(device)
11371139
except:
11381140
pass
1139-
1140-
pipeline.to(offload_device)
1141+
1142+
if not force_offload:
1143+
pipeline.to(offload_device)
11411144

11421145
return (latents, )
11431146

@@ -1254,6 +1257,8 @@ def INPUT_TYPES(s):
12541257
},
12551258
"optional": {
12561259
"enable_flash_vdm": ("BOOLEAN", {"default": True}),
1260+
"force_offload": ("BOOLEAN", {"default": True, "tooltip": "Offloads the model to the offload device once the process is done."}),
1261+
12571262
}
12581263
}
12591264

@@ -1262,7 +1267,7 @@ def INPUT_TYPES(s):
12621267
FUNCTION = "process"
12631268
CATEGORY = "Hunyuan3DWrapper"
12641269

1265-
def process(self, vae, latents, box_v, octree_resolution, mc_level, num_chunks, mc_algo, enable_flash_vdm=True):
1270+
def process(self, vae, latents, box_v, octree_resolution, mc_level, num_chunks, mc_algo, enable_flash_vdm=True, force_offload=True):
12661271
device = mm.get_torch_device()
12671272
offload_device = mm.unet_offload_device()
12681273

@@ -1283,7 +1288,8 @@ def process(self, vae, latents, box_v, octree_resolution, mc_level, num_chunks,
12831288
octree_resolution=octree_resolution,
12841289
mc_algo=mc_algo,
12851290
)[0]
1286-
vae.to(offload_device)
1291+
if force_offload:
1292+
vae.to(offload_device)
12871293

12881294
outputs.mesh_f = outputs.mesh_f[:, ::-1]
12891295
mesh_output = Trimesh.Trimesh(outputs.mesh_v, outputs.mesh_f)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[project]
22
name = "comfyui-hunyan3dwrapper"
33
description = "Wrapper nodes for https://github.com/Tencent/Hunyuan3D-2, additional installation steps needed, please check the github repository"
4-
version = "1.0.4"
4+
version = "1.0.5"
55
license = {file = "LICENSE"}
66
dependencies = ["trimesh", "diffusers>=0.31.0","accelerate","huggingface_hub","einops","opencv-python","transformers","xatlas","pymeshlab","pygltflib","scikit-learn","scikit-image","pybind11"]
77

0 commit comments

Comments
 (0)