Compare commits

...

4 Commits

Author SHA1 Message Date
Nicolas Stepien
4361f56e1a
Merge aadccd28ca into bbe2c13a70 2026-01-30 03:42:53 -05:00
comfyanonymous
bbe2c13a70
Make empty hunyuan latent 1.0 work with the 1.5 model. (#12171)
Some checks are pending
Execution Tests / test (macos-latest) (push) Waiting to run
Execution Tests / test (ubuntu-latest) (push) Waiting to run
Execution Tests / test (windows-latest) (push) Waiting to run
Python Linting / Run Ruff (push) Waiting to run
Test server launches without errors / test (push) Waiting to run
Python Linting / Run Pylint (push) Waiting to run
Unit Tests / test (macos-latest) (push) Waiting to run
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.10, [self-hosted Linux], stable) (push) Waiting to run
Unit Tests / test (ubuntu-latest) (push) Waiting to run
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.11, [self-hosted Linux], stable) (push) Waiting to run
Unit Tests / test (windows-2022) (push) Waiting to run
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.12, [self-hosted Linux], stable) (push) Waiting to run
Full Comfy CI Workflow Runs / test-unix-nightly (12.1, , linux, 3.11, [self-hosted Linux], nightly) (push) Waiting to run
2026-01-29 23:52:22 -05:00
Nicolas Stepien
aadccd28ca fix ResizeAndPadImage as well 2026-01-27 19:44:45 +00:00
Nicolas Stepien
46e6d07cfd Fix shorter/longer edge resize for square images 2026-01-27 19:03:43 +00:00
3 changed files with 20 additions and 7 deletions

View File

@ -644,9 +644,13 @@ class ResizeImagesByShorterEdgeNode(ImageProcessingNode):
if w < h:
new_w = shorter_edge
new_h = int(h * (shorter_edge / w))
else:
elif h < w:
new_h = shorter_edge
new_w = int(w * (shorter_edge / h))
else:
# Square image: set both dimensions directly to avoid precision loss from float operations
new_w = shorter_edge
new_h = shorter_edge
img = img.resize((new_w, new_h), Image.Resampling.LANCZOS)
return pil_to_tensor(img)
@ -674,9 +678,13 @@ class ResizeImagesByLongerEdgeNode(ImageProcessingNode):
if w > h:
new_w = longer_edge
new_h = int(h * (longer_edge / w))
else:
elif h > w:
new_h = longer_edge
new_w = int(w * (longer_edge / h))
else:
# Square image: set both dimensions directly to avoid precision loss from float operations
new_w = longer_edge
new_h = longer_edge
img = img.resize((new_w, new_h), Image.Resampling.LANCZOS)
resized_images.append(pil_to_tensor(img))
return torch.cat(resized_images, dim=0)

View File

@ -56,7 +56,7 @@ class EmptyHunyuanLatentVideo(io.ComfyNode):
@classmethod
def execute(cls, width, height, length, batch_size=1) -> io.NodeOutput:
latent = torch.zeros([batch_size, 16, ((length - 1) // 4) + 1, height // 8, width // 8], device=comfy.model_management.intermediate_device())
return io.NodeOutput({"samples":latent})
return io.NodeOutput({"samples": latent, "downscale_ratio_spacial": 8})
generate = execute # TODO: remove
@ -73,7 +73,7 @@ class EmptyHunyuanVideo15Latent(EmptyHunyuanLatentVideo):
def execute(cls, width, height, length, batch_size=1) -> io.NodeOutput:
# Using scale factor of 16 instead of 8
latent = torch.zeros([batch_size, 32, ((length - 1) // 4) + 1, height // 16, width // 16], device=comfy.model_management.intermediate_device())
return io.NodeOutput({"samples": latent})
return io.NodeOutput({"samples": latent, "downscale_ratio_spacial": 16})
class HunyuanVideo15ImageToVideo(io.ComfyNode):

View File

@ -395,10 +395,15 @@ class ResizeAndPadImage(IO.ComfyNode):
scale_w = target_width / orig_width
scale_h = target_height / orig_height
scale = min(scale_w, scale_h)
new_width = int(orig_width * scale)
new_height = int(orig_height * scale)
# When aspect ratios match, scale directly to target to avoid precision loss from float multiplication
if scale_w == scale_h:
new_width = target_width
new_height = target_height
else:
scale = min(scale_w, scale_h)
new_width = int(orig_width * scale)
new_height = int(orig_height * scale)
image_permuted = image.permute(0, 3, 1, 2)