This commit is contained in:
Haoming 2026-05-29 11:34:10 +08:00
parent 0989cc040b
commit 9cd96dc7e7
2 changed files with 17 additions and 0 deletions

View File

@ -92,6 +92,13 @@ class Wan(ForgeDiffusionEngine):
end_image = self.end_image.movedim(1, -1)
_, h, w, _ = end_image.shape
if self.start_image is not None and self.end_image is not None:
memory_management.logger.info("[Wan] FirstLastFrameToVideo")
elif self.start_image is not None and self.end_image is None:
memory_management.logger.info("[Wan] ImageToVideo")
elif self.start_image is None and self.end_image is not None:
memory_management.logger.info("[Wan] LastFrameToVideo")
image = torch.ones((length, h, w, 3), device="cpu", dtype=torch.float32).mul(0.5)
mask = torch.ones((1, 1, latent_shape[2] * 4, latent_shape[-2], latent_shape[-1]), device="cpu", dtype=torch.float32)

View File

@ -329,7 +329,14 @@ def forge_model_reload():
timer = Timer()
_last_frame: torch.Tensor = None
# maintain the end_image so that FirstLastFrame is not broken
# when reloading Wan 2.2 models via Refiner
if model_data.sd_model is not None:
if getattr(model_data.sd_model, "end_image", None) is not None:
_last_frame = model_data.sd_model.end_image.clone()
model_data.sd_model = None
model_data.forge_hash = ""
memory_management.unload_all_models()
@ -370,6 +377,9 @@ def forge_model_reload():
sd_model.sd_model_hash = checkpoint_info.calculate_shorthash()
timer.record("calculate hash")
if _last_frame is not None:
setattr(sd_model, "end_image", _last_frame)
shared.opts.data["sd_checkpoint_hash"] = checkpoint_info.sha256
model_data.set_sd_model(sd_model)