Python
fixed chrono edit
DeepBeepMeep6ac594ebee85
diff --git a/README.md b/README.mdindex 44bc3de..5dc6d6b 100644--- a/README.md+++ b/README.md@@ -36,7 +36,7 @@ WanGP supports the Wan (and derived models), Hunyuan Video and LTV Video models-----## 🔥 Latest Updates :-### November 12 2025: WanGP v9.5, And there was motion+### November 21 2025: WanGP v9.51, And there was motionIn this release WanGP turns you into a Motion Master:- **Motion Designer**: this new preinstalled home made Graphical Plugin will let you design trajectories for *Vace* and for *Wan 2.2 i2v Time to Move*.@@ -51,6 +51,8 @@ In this release WanGP turns you into a Motion Master:- **Nexus 1.3B**: this is an incredible *Wan 2.1 1.3B* finetune made by @Nexus. It is specialized in *Human Motion* (dance, fights, gym, ...). It is fast as it is already *Causvid* accelerated. Try it with the *Prompt Enhancer* at 720p.+*update 9.51*: Fixed Chrono Edit Output, added Temporal Reasoning Video\+### November 12 2025: WanGP v9.44, Free Lunch**VAE Upsampler** for Wan 2.1/2.2 Text 2 Image and Qwen Image: *spacepxl* has tweaked the VAE Decoder used by *Wan* & *Qwen* so that it can decode and upsample x2 at the same time. The end Result is a Fast High Quality Image Upsampler (much better than Lanczos). Check the *Postprocessing Tab* / *Spatial Upsampling* Dropdown box. Unfortunately this will work only with Image Generation, no support yet for Video Generation. I have also added a VAE Refiner that keeps the existing resolution but slightly improves the details.diff --git a/docs/FINETUNES.md b/docs/FINETUNES.mdindex b161096..b9cf0cf 100644--- a/docs/FINETUNES.md+++ b/docs/FINETUNES.md@@ -70,6 +70,8 @@ be able to reduce the number of generation steps to 10- *auto_quantize*: if set to True and no quantized model URL is provided, WanGP will perform on the fly quantization if the user expects a quantized model-*visible* : by default assumed to be true. If set to false the model will no longer be visible. This can be useful if you create a finetune to override a default model and hide it.-*image_outputs* : turn any model that generates a video into a model that generates images. In fact it will adapt the user interface for image generation and ask the model to generate a video with a single frame.+-*video_prompt_enhancer_instructions* : this allows you override the system prompt used by the Prompt Enhancer when generating a Video with this finetune+-*image_prompt_enhancer_instructions* : this allows you override the system prompt used by the Prompt Enhancer when generating an Image with this finetuneIn order to favor reusability the properties of *URLs*, *modules*, *loras* and *preload_URLs* can contain instead of a list of URLs a single text which corresponds to the id of a finetune or default model to reuse. Instead of:```diff --git a/models/wan/any2video.py b/models/wan/any2video.pyindex fb3a5ff..8a3ff7f 100644--- a/models/wan/any2video.py+++ b/models/wan/any2video.py@@ -529,15 +529,11 @@ class WanAny2V:start_step_no = 0ref_images_count = 0trim_frames = 0- last_latent_output = False+ last_latent_preview = Falseextended_overlapped_latents = clip_image_start = clip_image_end = image_mask_latents = latent_slice = freqs = Noneno_noise_latents_injection = infinitetalktimestep_injection = False- if chrono_edit:- frame_num = 29- last_latent_output = True-lat_frames = int((frame_num - 1) // self.vae_stride[0]) + 1extended_input_dim = 0ref_images_before = False@@ -641,6 +637,14 @@ class WanAny2V:lat_y = input_video = Nonekwargs.update({ 'y': y})+ # Chrono Edit+ if chrono_edit:+ if frame_num == 5:+ freq0, freq7 = get_nd_rotary_pos_embed( (0, 0, 0), (1, lat_h // 2, lat_w // 2)), get_nd_rotary_pos_embed( (7, 0, 0), (8, lat_h // 2, lat_w // 2))+ freqs = ( torch.cat([freq0[0], freq7[0]]), torch.cat([freq0[1],freq7[1]]))+ freq0 = freq7 = None+ last_latent_preview = image_outputs+# Animateif animate:pose_pixels = input_frames * input_masks@@ -938,7 +942,10 @@ class WanAny2V:return Noneif sample_scheduler != None:- scheduler_kwargs = {} if isinstance(sample_scheduler, FlowMatchScheduler) else {"generator": seed_g}+ if isinstance(sample_scheduler, FlowMatchScheduler) or sample_solver == 'unipc_hf':+ scheduler_kwargs = {}+ else:+ scheduler_kwargs = {"generator": seed_g}# b, c, lat_f, lat_h, lat_wlatents = torch.randn(batch_size, *target_shape, dtype=torch.float32, device=self.device, generator=seed_g)if "G" in video_prompt_type: randn = latents@@ -1144,7 +1151,7 @@ class WanAny2V:latents_preview = latentsif ref_images_before and ref_images_count > 0: latents_preview = latents_preview[:, :, ref_images_count: ]if trim_frames > 0: latents_preview= latents_preview[:, :,:-trim_frames]- if image_outputs: latents_preview= latents_preview[:, :,-1:] if last_latent_output else latents_preview[:, :,:1]+ if image_outputs: latents_preview= latents_preview[:, :,-1:] if last_latent_preview else latents_preview[:, :,:1]if len(latents_preview) > 1: latents_preview = latents_preview.transpose(0,2)callback(i, latents_preview[0], False, denoising_extra =denoising_extra )latents_preview = None@@ -1163,8 +1170,19 @@ class WanAny2V:if chipmunk:self.model.release_chipmunk() # need to add it at every exit when in prod+ if chrono_edit:+ if frame_num == 5 :+ videos = self.vae.decode(x0, VAE_tile_size)+ else:+ videos_edit = self.vae.decode([x[:, [0,-1]] for x in x0 ], VAE_tile_size)+ videos = self.vae.decode([x[:, :-1] for x in x0 ], VAE_tile_size)+ videos = [ torch.cat([video, video_edit[:, 1:]], dim=1) for video, video_edit in zip(videos, videos_edit)]+ if image_outputs:+ return torch.cat([video[:,-1:] for video in videos], dim=1) if len(videos) > 1 else videos[0][:,-1:]+ else:+ return videos[0]if image_outputs :- x0 = [x[:,-1:] if last_latent_output else x[:,:1] for x in x0 ]+ x0 = [x[:,:1] for x in x0 ]videos = self.vae.decode(x0, VAE_tile_size)any_vae2= self.vae2 is not None@@ -1185,16 +1203,16 @@ class WanAny2V:elif color_reference_frame is not None:videos = match_and_blend_colors(videos.unsqueeze(0), color_reference_frame.unsqueeze(0), color_correction_strength).squeeze(0)- BGRA_frames = None+ ret = { "x" : videos, "latent_slice" : latent_slice}if alpha_class:+ BGRA_frames = Nonefrom .alpha.utils import render_video, from_BRGA_numpy_to_RGBA_torchvideos, BGRA_frames = render_video(videos[None], videos2[None])if image_outputs:videos = from_BRGA_numpy_to_RGBA_torch(BGRA_frames)BGRA_frames = None- if return_latent_slice != None or BGRA_frames != None:- return { "x" : videos, "latent_slice" : latent_slice, "BGRA_frames" : BGRA_frames }- return videos+ if BGRA_frames is not None: ret["BGRA_frames"] = BGRA_frames+ return retdef get_loras_transformer(self, get_model_recursive_prop, base_model_type, model_type, video_prompt_type, model_mode, **kwargs):if base_model_type == "animate":diff --git a/models/wan/wan_handler.py b/models/wan/wan_handler.pyindex 9e12e47..baa7912 100644--- a/models/wan/wan_handler.py+++ b/models/wan/wan_handler.py@@ -372,7 +372,18 @@ class family_handler():"default": 0,"label" : "Ditto Process"}-++ if base_model_type in ["chrono_edit"]:+ extra_model_def["model_modes"] = {+ "choices": [+ ("Fast Image Transformation", 0),+ ("Long Image Transformation", 1),+ ("Temporal Reasoning Video", 2),],+ "default": 0,+ "label" : "Chrono Edit Process"+ }+ extra_model_def["custom_video_length"] = True+if (not vace_class) and standin:extra_model_def["v2i_switch_supported"] = True@@ -769,9 +780,14 @@ class family_handler():inputs["video_prompt_type"] = video_prompt_type- if base_model_type in ["vace_standin_14B", "vace_lynx_14B"]:+ elif base_model_type in ["vace_standin_14B", "vace_lynx_14B"]:image_refs = inputs["image_refs"]video_prompt_type = inputs["video_prompt_type"]if image_refs is not None and len(image_refs) == 1 and "K" in video_prompt_type:gr.Info("Warning, Ref Image that contains the Face to transfer is Missing: if 'Landscape and then People or Objects' is selected beside the Landscape Image Ref there should be another Image Ref that contains a Face.")++ elif base_model_type in ["chrono_edit"]:+ model_mode = inputs["model_mode"]+ inputs["video_length"] = 5 if model_mode==0 else 29+ inputs["image_mode"] = 0 if model_mode==2 else 1diff --git a/wgp.py b/wgp.pyindex 71d41ea..9d1f481 100644--- a/wgp.py+++ b/wgp.py@@ -82,7 +82,7 @@ global_queue_ref = []AUTOSAVE_FILENAME = "queue.zip"PROMPT_VARS_MAX = 10target_mmgp_version = "3.6.8"-WanGP_version = "9.5"+WanGP_version = "9.51"settings_version = 2.40max_source_video_frames = 3000prompt_enhancer_image_caption_model, prompt_enhancer_image_caption_processor, prompt_enhancer_llm_model, prompt_enhancer_llm_tokenizer = None, None, None, None@@ -5042,10 +5042,11 @@ def generate_video(if set_video_prompt_type is not None:video_prompt_type = add_to_sequence(video_prompt_type, set_video_prompt_type)if is_image:- if min_frames_if_references >= 1000:- video_length = min_frames_if_references - 1000- else:- video_length = min_frames_if_references if "I" in video_prompt_type or "V" in video_prompt_type else 1+ if not model_def.get("custom_video_length", False):+ if min_frames_if_references >= 1000:+ video_length = min_frames_if_references - 1000+ else:+ video_length = min_frames_if_references if "I" in video_prompt_type or "V" in video_prompt_type else 1else:batch_size = 1temp_filenames_list = []@@ -5972,7 +5973,7 @@ def generate_video(if prompt_enhancer_image_caption_model != None and prompt_enhancer !=None and len(prompt_enhancer)>0:configs["enhanced_prompt"] = "\n".join(prompts)configs["generation_time"] = round(end_time-start_time)- # if is_image: configs["is_image"] = True+ # if sample_is_image: configs["is_image"] = Truemetadata_choice = server_config.get("metadata_type","metadata")video_path = [video_path] if not isinstance(video_path, list) else video_pathfor no, path in enumerate(video_path):