Python
added LTX-2 frames injection
DeepBeepMeep0403f4d33468
diff --git a/README.md b/README.mdindex acd0458..45ebeb8 100644--- a/README.md+++ b/README.md@@ -33,7 +33,7 @@ WanGP supports the Wan (and derived models) but also Hunyuan Video, Flux, Qwen,## 🔥 Latest Updates :-### March 10th 2026: WanGP v10.9871, Prompt Enhancer has just Been Abliterated+### March 10th 2026: WanGP v10.9872, Prompt Enhancer has just Been Abliterated- **Qwen3.5 VL Abliterated Prompt Enhancer**: new choice of Prompt Enhancer* Based on widely acclaimed *Qwen3.5 model* that has just been released@@ -42,12 +42,15 @@ WanGP supports the Wan (and derived models) but also Hunyuan Video, Flux, Qwen,* *vllm accelerated* x5 faster, if Flash Attention 2 & Triton are installed (please check docs/INSTALLATION.md)* *Think Mode*: for complex prompt queries+ Also you can now expand or override a *System Prompt prompt Enhancer* with add @ or @@ (check new doc *PROMPTS.md*)+- **GGUF CUDA Kernels**: 15% speed gain when using GGUF on Diffusion Video Models & x3 speed with GGUF LLM (*Qwen 3.5 VL GGUF* for instance). GGUF Kernels are for the moment only available for Windows (please check docs/INSTALLATION.md).- **LTX2.3 Improvements*** *End Frame without Start Frame*: you know how your story ends but want to see how it started, just give an End Frame (no start Frame)- * New GGUF Checkpoints- * VAE Decoding hopefully should expose less banding+ * New GGUF Checkpoints+ * VAE Decoding hopefully should expose less banding+ * *Multiple Frames Injections*: inject at different positions the reference frames of your choice (works for LTX-2.0 too)- **WanGP API**: rejoice developers (or agents) among you ! WanGP offers now an internal API that allows you to use WanGP as a backend for your apps. It is subject to compliance to the terms & conditions of WanGP license and more specifically to inform the users of your app that WanGP is working behind the scene.@@ -58,6 +61,7 @@ WanGP supports the Wan (and derived models) but also Hunyuan Video, Flux, Qwen,Also note as people preferred mataynone v1 over v2 I have added an option to select matanyone version in the Config / Extension tab*update 10.9871*: Improved Qwen3.5 GGUF Prompt Enhancer Output Quality & added Think mode+*update 10.9872*: Added LTX 2.0/2.3 frames injection### March 7th 2026: WanGP v10.981, Expecting an Update ?diff --git a/models/ltx2/ltx2.py b/models/ltx2/ltx2.pyindex 4beec4f..8bd83d5 100644--- a/models/ltx2/ltx2.py+++ b/models/ltx2/ltx2.py@@ -729,8 +729,10 @@ class LTX2:prefix_frames_count: int = 0,input_frames=None,input_frames2=None,+ input_ref_images=None,input_masks=None,input_masks2=None,+ frames_relative_positions_list=None,masking_strength: float | None = None,input_video_strength: float | None = None,return_latent_slice=None,@@ -769,6 +771,18 @@ class LTX2:image_start = _coerce_image_list(image_start)image_end = _coerce_image_list(image_end)+ if input_ref_images is None:+ input_ref_images = []+ elif isinstance(input_ref_images, (list, tuple)):+ input_ref_images = list(input_ref_images)+ else:+ input_ref_images = [input_ref_images]+ if frames_relative_positions_list is None:+ frames_relative_positions_list = []+ elif isinstance(frames_relative_positions_list, (list, tuple)):+ frames_relative_positions_list = list(frames_relative_positions_list)+ else:+ frames_relative_positions_list = [frames_relative_positions_list]prefix_frames_count = int(prefix_frames_count or 0)video_prompt_type = video_prompt_type or ""@@ -834,7 +848,8 @@ class LTX2:video_conditioning = Nonemasking_source = None- if input_frames is not None or input_frames2 is not None:+ injected_ref_count = min(len(input_ref_images), len(frames_relative_positions_list))+ if input_frames is not None or input_frames2 is not None or injected_ref_count > 0:control_start_frame = int(prefix_frames_count)expected_guide_frames = max(1, int(frame_num) - control_start_frame + (1 if prefix_frames_count > 1 else 0))if prefix_frames_count > 1:@@ -857,6 +872,8 @@ class LTX2:conditioning_entries.append((input_frames, control_start_frame, control_strength))if input_frames2 is not None:conditioning_entries.append((input_frames2, control_start_frame, control_strength))+ for ref_image, frame_idx in zip(input_ref_images[:injected_ref_count], frames_relative_positions_list[:injected_ref_count]):+ conditioning_entries.append((ref_image, int(frame_idx), control_strength))if conditioning_entries:video_conditioning = conditioning_entriesif masking_strength > 0.0:diff --git a/models/ltx2/ltx2_handler.py b/models/ltx2/ltx2_handler.pyindex 302e41d..80a82b3 100644--- a/models/ltx2/ltx2_handler.py+++ b/models/ltx2/ltx2_handler.py@@ -133,6 +133,7 @@ class family_handler:if distilled:audio_prompt_labels["K"] = "Generate Video based on Control Video + its Audio Track and Text Prompt"+extra_model_def = {"text_encoder_folder": _GEMMA_FOLDER,"text_encoder_URLs": [@@ -168,16 +169,17 @@ class family_handler:extra_model_def["extra_control_frames"] = 1extra_model_def["dont_cat_preguide"] = Trueextra_model_def["input_video_strength"] = "Image / Source Video Strength (you may try values lower value than 1 to get more motion)"- if distilled:- extra_model_def["guide_preprocessing"] = {- "selection": ["", "PVG", "DVG", "EVG", "VG"],- "labels": {- "PVG": "Transfer Human Motion",- "DVG": "Transfer Depth",- "EVG": "Transfer Canny Edges",- "VG": "Use LTX-2 raw format",- },- }++ control_choices = [("No Video Process", ""), ("Transfer Human Motion", "PVG") , ("Transfer Depth", "DVG") , ("Transfer Canny Edges", "EVG"), ("Use LTX-2 raw format Control Video", "VG")] if distilled else []+ control_choices += [("Inject Frames", "KFI")]+ extra_model_def["guide_custom_choices"] = {+ "choices": control_choices,+ "letters_filter": "PDEVGKFI",+ "label": "Control Video / Frames Injection"+ }++ extra_model_def["custom_frames_injection"] = True+extra_model_def["mask_preprocessing"] = {"selection": ["", "A", "NA", "XA", "XNA"],}@@ -218,6 +220,19 @@ class family_handler:extra_model_def["guidance_max_phases"] = 2extra_model_def["visible_phases"] = 0 if distilled else 1extra_model_def["lock_guidance_phases"] = True++ # extra_model_def["custom_video_selection"] = {+ # "choices":[+ # ("None", ""),+ # ("Inject Frames", "FI"),+ # ],+ # "label": "Inject Frames",+ # "type": "checkbox",+ # "letters_filter": "FI",+ # "show_label" : False,+ # "scale": 1,+ # }+return extra_model_def@staticmethoddiff --git a/wgp.py b/wgp.pyindex 4a2ac34..15aa50c 100644--- a/wgp.py+++ b/wgp.py@@ -98,7 +98,7 @@ AUTOSAVE_TEMPLATE_PATH = AUTOSAVE_FILENAMECONFIG_FILENAME = "wgp_config.json"PROMPT_VARS_MAX = 10target_mmgp_version = "3.7.6"-WanGP_version = "10.9871"+WanGP_version = "10.9872"settings_version = 2.55max_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@@ -586,6 +586,10 @@ def end_frames_option_visible(model_def, image_prompt_type):return end_frames_always_enabled(model_def) or any_letters(image_prompt_type or "", "SVL")+def injected_frames_positions_visible(video_prompt_type):+ return "F" in (video_prompt_type or "")++def parse_custom_setting_typed_value(raw_value, setting_type):if raw_value is None:return None, None@@ -5930,7 +5934,7 @@ def generate_video(if attn == "auto":attn = get_auto_attention()elif not attn in attention_modes_supported:- send_cmd("info", f"You have selected attention mode '{attention_mode}'. However it is not installed or supported on your system. You should either install it or switch to the default 'sdpa' attention.")+ send_cmd("info", f"You have selected attention mode '{attn}'. However it is not installed or supported on your system. You should either install it or switch to the default 'sdpa' attention.")send_cmd("exit")return True@@ -6101,9 +6105,9 @@ def generate_video(# Image Ref (non background and non positioned frames) are boxed in a white canvas in order to keep their own width/height ratioframes_to_inject = []any_background_ref = 0+ custom_frames_injection = model_def.get("custom_frames_injection", False) and image_refs is not None and len(image_refs)if "K" in video_prompt_type:- any_background_ref = 2 if model_def.get("all_image_refs_are_background_ref", False) else 1-+ any_background_ref = 2 if model_def.get("all_image_refs_are_background_ref", False) or custom_frames_injection else 1outpainting_dims = get_outpainting_dims(video_guide_outpainting)fit_canvas = server_config.get("fit_canvas", 0)fit_crop = fit_canvas == 2@@ -6301,6 +6305,7 @@ def generate_video(window_no += 1gen["window_no"] = window_noreturn_latent_slice = None+ frames_relative_positions_list = []if reuse_frames > 0:return_latent_slice = slice(- max(1, (reuse_frames + discard_last_frames ) // latent_size) , None if discard_last_frames == 0 else -(discard_last_frames // latent_size) )refresh_preview = {"image_guide" : image_guide, "image_mask" : image_mask} if image_mode >= 1 else {}@@ -6380,11 +6385,13 @@ def generate_video(else:frames_positions_list.append(int(pos)-1 + alignment_shift)frames_positions_list = frames_positions_list[:len(image_refs)]- nb_frames_positions = len(frames_positions_list)+ nb_frames_positions = len(frames_positions_list) if not custom_frames_injection else 0if nb_frames_positions > 0:frames_to_inject = [None] * (max(frames_positions_list) + 1)for i, pos in enumerate(frames_positions_list):frames_to_inject[pos] = image_refs[i]+ if custom_frames_injection:+ frames_relative_positions_list= [ i -aligned_window_start_frame for i in frames_positions_list if aligned_window_start_frame <= i < aligned_window_start_frame + current_video_length ]video_guide_processed = video_mask_processed = video_guide_processed2 = video_mask_processed2 = sparse_video_image = None@@ -6710,7 +6717,8 @@ def generate_video(top_p=top_p,top_k=top_k,set_progress_status=set_progress_status,- loras_selected=loras_selected,+ loras_selected=loras_selected,+ frames_relative_positions_list = frames_relative_positions_list,)except Exception as e:if len(control_audio_tracks) > 0 or len(source_audio_tracks) > 0:@@ -8061,7 +8069,7 @@ def prepare_inputs_dict(target, inputs, model_type = None, model_filename = Noneif not model_def.get("any_image_refs_relative_size", False):pop += ["image_refs_relative_size"]- if not vace:+ if not "F" in video_prompt_type:pop += ["frames_positions"]if model_def.get("control_net_weight_name", None) is None:@@ -9056,7 +9064,7 @@ def refresh_video_prompt_type_image_refs(state, video_prompt_type, video_prompt_any_outpainting= image_mode in model_def.get("video_guide_outpainting", [])rm_bg_visible= visible and not model_def.get("no_background_removal", False)img_rel_size_visible = visible and model_def.get("any_image_refs_relative_size", False)- return video_prompt_type, gr.update(visible = visible),gr.update(visible = rm_bg_visible), gr.update(visible = img_rel_size_visible), gr.update(visible = visible and "F" in video_prompt_type_image_refs), gr.update(visible= ("F" in video_prompt_type_image_refs or "K" in video_prompt_type_image_refs or "V" in video_prompt_type) and any_outpainting )+ return video_prompt_type, gr.update(visible = visible),gr.update(visible = rm_bg_visible), gr.update(visible = img_rel_size_visible), gr.update(visible = visible and injected_frames_positions_visible(video_prompt_type_image_refs)), gr.update(visible= ("F" in video_prompt_type_image_refs or "K" in video_prompt_type_image_refs or "V" in video_prompt_type) and any_outpainting )def update_image_mask_guide(state, image_mask_guide):img = image_mask_guide["background"]@@ -9148,7 +9156,7 @@ def refresh_video_prompt_type_video_guide(state, filter_type, video_prompt_type,custom_options = Truecustom_checkbox = custom_video_selection.get("type","") == "checkbox"mask_strength_always_enabled = model_def.get("mask_strength_always_enabled", False)- return video_prompt_type, gr.update(visible = visible and not image_outputs), image_guide, gr.update(visible = keep_frames_video_guide_visible), gr.update(visible = visible and "G" in video_prompt_type), gr.update(visible = mask_visible and( mask_strength_always_enabled or "G" in video_prompt_type)), gr.update(visible= (visible or "F" in video_prompt_type or "K" in video_prompt_type) and any_outpainting), gr.update(visible= visible and mask_selector_visible and not "U" in video_prompt_type ) , gr.update(visible= mask_visible and not image_outputs), image_mask, image_mask_guide, gr.update(visible= mask_visible), gr.update(visible = ref_images_visible ), gr.update(visible= custom_options and not custom_checkbox ), gr.update(visible= custom_options and custom_checkbox )+ return video_prompt_type, gr.update(visible = visible and not image_outputs), image_guide, gr.update(visible = keep_frames_video_guide_visible), gr.update(visible = visible and "G" in video_prompt_type), gr.update(visible = mask_visible and( mask_strength_always_enabled or "G" in video_prompt_type)), gr.update(visible= (visible or injected_frames_positions_visible(video_prompt_type) or "K" in video_prompt_type) and any_outpainting), gr.update(visible= visible and mask_selector_visible and not "U" in video_prompt_type ) , gr.update(visible= mask_visible and not image_outputs), image_mask, image_mask_guide, gr.update(visible= mask_visible), gr.update(visible = ref_images_visible ), gr.update(visible = injected_frames_positions_visible(video_prompt_type)), gr.update(visible= custom_options and not custom_checkbox ), gr.update(visible= custom_options and custom_checkbox )def refresh_video_prompt_type_video_custom_dropbox(state, video_prompt_type, video_prompt_type_video_custom_dropbox):model_type = get_state_model_type(state)@@ -10944,8 +10952,8 @@ def generate_video_tab(update_form = False, state_dict = None, ui_defaults = Nonimage_prompt_type_radio.change(fn=refresh_image_prompt_type_radio, inputs=[state, image_prompt_type, image_prompt_type_radio], outputs=[image_prompt_type, image_start_row, image_end_row, video_source, input_video_strength, keep_frames_video_source, image_prompt_type_endcheckbox], show_progress="hidden" )image_prompt_type_endcheckbox.change(fn=refresh_image_prompt_type_endcheckbox, inputs=[state, image_prompt_type, image_prompt_type_radio, image_prompt_type_endcheckbox], outputs=[image_prompt_type, image_end_row] )video_prompt_type_image_refs.input(fn=refresh_video_prompt_type_image_refs, inputs = [state, video_prompt_type, video_prompt_type_image_refs,image_mode], outputs = [video_prompt_type, image_refs_row, remove_background_images_ref, image_refs_relative_size, frames_positions,video_guide_outpainting_col], show_progress="hidden")- video_prompt_type_video_guide.input(fn=refresh_video_prompt_type_video_guide, inputs = [state, gr.State(""), video_prompt_type, video_prompt_type_video_guide, image_mode, image_mask_guide, image_guide, image_mask], outputs = [video_prompt_type, video_guide, image_guide, keep_frames_video_guide, denoising_strength, masking_strength, video_guide_outpainting_col, video_prompt_type_video_mask, video_mask, image_mask, image_mask_guide, mask_expand, image_refs_row, video_prompt_type_video_custom_dropbox, video_prompt_type_video_custom_checkbox], show_progress="hidden")- video_prompt_type_video_guide_alt.input(fn=refresh_video_prompt_type_video_guide, inputs = [state, gr.State("alt"),video_prompt_type, video_prompt_type_video_guide_alt, image_mode, image_mask_guide, image_guide, image_mask], outputs = [video_prompt_type, video_guide, image_guide, keep_frames_video_guide, denoising_strength, masking_strength, video_guide_outpainting_col, video_prompt_type_video_mask, video_mask, image_mask, image_mask_guide, mask_expand, image_refs_row, video_prompt_type_video_custom_dropbox, video_prompt_type_video_custom_checkbox], show_progress="hidden")+ video_prompt_type_video_guide.input(fn=refresh_video_prompt_type_video_guide, inputs = [state, gr.State(""), video_prompt_type, video_prompt_type_video_guide, image_mode, image_mask_guide, image_guide, image_mask], outputs = [video_prompt_type, video_guide, image_guide, keep_frames_video_guide, denoising_strength, masking_strength, video_guide_outpainting_col, video_prompt_type_video_mask, video_mask, image_mask, image_mask_guide, mask_expand, image_refs_row, frames_positions, video_prompt_type_video_custom_dropbox, video_prompt_type_video_custom_checkbox], show_progress="hidden")+ video_prompt_type_video_guide_alt.input(fn=refresh_video_prompt_type_video_guide, inputs = [state, gr.State("alt"),video_prompt_type, video_prompt_type_video_guide_alt, image_mode, image_mask_guide, image_guide, image_mask], outputs = [video_prompt_type, video_guide, image_guide, keep_frames_video_guide, denoising_strength, masking_strength, video_guide_outpainting_col, video_prompt_type_video_mask, video_mask, image_mask, image_mask_guide, mask_expand, image_refs_row, frames_positions, video_prompt_type_video_custom_dropbox, video_prompt_type_video_custom_checkbox], show_progress="hidden")# video_prompt_type_video_guide_alt.input(fn=refresh_video_prompt_type_video_guide_alt, inputs = [state, video_prompt_type, video_prompt_type_video_guide_alt, image_mode, image_mask_guide, image_guide, image_mask], outputs = [video_prompt_type, video_guide, image_guide, image_refs_row, denoising_strength, masking_strength, video_mask, mask_expand, image_mask_guide, image_guide, image_mask, keep_frames_video_guide ], show_progress="hidden")video_prompt_type_video_custom_dropbox.input(fn= refresh_video_prompt_type_video_custom_dropbox, inputs=[state, video_prompt_type, video_prompt_type_video_custom_dropbox], outputs = video_prompt_type)video_prompt_type_video_custom_checkbox.input(fn= refresh_video_prompt_type_video_custom_checkbox, inputs=[state, video_prompt_type, video_prompt_type_video_custom_checkbox], outputs = video_prompt_type)