The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.
Allow regular single image Empty Latent Image node to be used with H3. (#15677)
comfyanonymous0696f61dced6
diff --git a/comfy/latent_formats.py b/comfy/latent_formats.pyindex dc737fc7d..ed5167075 100644--- a/comfy/latent_formats.py+++ b/comfy/latent_formats.py@@ -1,4 +1,5 @@import torch+import comfy.nested_tensorclass LatentFormat:scale_factor = 1.0@@ -17,6 +18,9 @@ class LatentFormat:def process_out(self, latent):return latent / self.scale_factor+ def fix_empty_latent(self, latent):+ return latent+class SD15(LatentFormat):def __init__(self, scale_factor=0.18215):self.scale_factor = scale_factor@@ -606,6 +610,19 @@ class MiniMaxH3AV(MiniMaxH3Video):# max channels across the two streams (video 24, audio 32) so per-stream slices keep both streams wholelatent_channels = 32+ def fix_empty_latent(self, latent):+ video_latent_channels = MiniMaxH3Video.latent_channels+ audio_latent_channels = 32+ audio_channels = 2+ frames_per_token = (1, 4, 4, 4, 4)+ audio_frame_rescale = 5.0 / 3.0++ video = latent[:, :video_latent_channels].clone()+ frame_count = sum(frames_per_token[i % len(frames_per_token)] for i in range(video.shape[2]))+ audio_t = round(frame_count * audio_frame_rescale)+ audio = latent.new_zeros((latent.shape[0], audio_latent_channels, audio_channels, audio_t))+ return comfy.nested_tensor.NestedTensor((video, audio))+class HunyuanVideo(LatentFormat):latent_channels = 16latent_dimensions = 3diff --git a/comfy/sample.py b/comfy/sample.pyindex 617816882..4ebad9666 100644--- a/comfy/sample.py+++ b/comfy/sample.py@@ -45,7 +45,7 @@ def prepare_empty_noise(latent_image):def fix_empty_latent_channels(model, latent_image, downscale_ratio_spacial=None, downscale_ratio_temporal=None):if latent_image.is_nested:return latent_image- latent_format = model.get_model_object("latent_format") #Resize the empty latent image so it has the right number of channels+ latent_format = model.get_model_object("latent_format")is_empty = torch.count_nonzero(latent_image) == 0if is_empty:if latent_format.latent_channels != latent_image.shape[1]:@@ -64,6 +64,9 @@ def fix_empty_latent_channels(model, latent_image, downscale_ratio_spacial=None,new_t = max(1, round(latent_image.shape[2] * ratio))latent_image = comfy.utils.repeat_to_batch_size(latent_image, new_t, dim=2)+ if is_empty:+ latent_image = latent_format.fix_empty_latent(latent_image)+return latent_imagedef prepare_sampling(model, noise_shape, positive, negative, noise_mask):