diff --git a/hyvideo/diffusion/pipelines/pipeline_hunyuan_video.py b/hyvideo/diffusion/pipelines/pipeline_hunyuan_video.py index fe93443..6a623ef 100644 --- a/hyvideo/diffusion/pipelines/pipeline_hunyuan_video.py +++ b/hyvideo/diffusion/pipelines/pipeline_hunyuan_video.py @@ -684,6 +684,9 @@ class HunyuanVideoPipeline(DiffusionPipeline): if self.interrupt: continue + if image_cond_latents is not None and i2v_condition_type == "token_replace": + latents = torch.concat([original_image_latents, latents[:, :, 1:, :, :]], dim=2) + latent_model_input = latents input_prompt_embeds = prompt_embeds input_prompt_mask = prompt_mask @@ -730,8 +733,8 @@ class HunyuanVideoPipeline(DiffusionPipeline): t_expand = t.repeat(latent_model_input.shape[0]) - #if leapfusion_img2vid: - # latent_model_input[:, :, [0,], :, :] = original_latents[:, :, [0,], :, :].to(latent_model_input) + if leapfusion_img2vid: + latent_model_input[:, :, [0,], :, :] = original_latents[:, :, [0,], :, :].to(latent_model_input) if image_cond_latents is not None and not use_context_schedule: if i2v_condition_type == "latent_concat": @@ -739,11 +742,6 @@ class HunyuanVideoPipeline(DiffusionPipeline): i2v_mask = torch.cat([i2v_mask] * 2) if cfg_enabled else i2v_mask latent_image_input = torch.cat([latent_image_input, i2v_mask], dim=1) latent_model_input = torch.cat([latent_model_input, latent_image_input], dim=1) - elif i2v_condition_type == "token_replace" or leapfusion_img2vid: - latent_image_input = (torch.cat([original_image_latents] * 2) if cfg_enabled else original_image_latents) - latent_model_input = torch.cat([latent_image_input, latent_model_input[:, :, 1:, :, :]], dim=2) - else: - latent_model_input = torch.cat([latent_model_input, latent_image_input], dim=1) if self.transformer.guidance_embed: if cfg_enabled: