Single words like "next", "suddenly", "later", "finally" etc. fire on
normal prompt text and cause spurious scene splits. Removed the entire
single-word temporal markers block. Shortest triggers are now two words
minimum. Also removes "and suddenly" and "and next" which were similarly
too vague.
Stray article-comma cleanup ("the, next" -> "the next") also applied when
building transition segments to handle commas left by the split.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When the stacking fix merges a pure-transition segment into the next one,
it now uses a space instead of ", " if the segment ends with an article
(a/an/the). This prevents "the scene then cuts to the, next view" when
"next" is also a transition word and the segments get merged mid-phrase.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
If a prompt ends with a transition phrase plus nothing (or just a lone
article like "the"), the last segment is now dropped rather than kept
as a near-empty scene. Covers cases like "...K/DA Kai'Sa, the scene
then cuts to the" where the user did not complete the transition.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Shortcuts and Transitions: saved entries collapse to a summary row (name +
on/off badge); click to expand, Collapse button to close without saving
- Transition summary also shows trigger phrase in italic next to the name
- Shortcuts: replacement is no longer required; blank/missing defaults to [""]
which removes the matched phrase (same as explicit empty replacement)
- Shortcuts: name falls back to first activation word when left blank
- New summary row CSS: badge-on/badge-off, label, trigger styles
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Shortcuts: allow empty string as a valid replacement to remove matched phrases
from prompts; post-pass cleans up orphaned commas/spaces left by removals
- Shortcuts: add cross-shortcut longer-phrase-wins test confirming ordered
alternation handles multiple shortcuts with overlapping triggers correctly
- Transitions: new user-editable transition word list stored in transitions.json;
custom triggers extend the built-in split pattern at runtime, keyed by name
- Transitions: Studio JS gets a dedicated Transitions tab (name, trigger, enabled)
with Add/Refresh/Import/Export toolbar
- Transitions: four API routes mirroring shortcuts (GET, export, save/delete, import)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When image_latent is connected, scene noise is added ON TOP of the
reference image's latent rather than replacing it. Output goes to
KSamplerAdvanced latent_image with add_noise=disable.
For i2v: connect your image-encoder latent to both 'latent' (shape ref)
and 'image_latent' (the actual i2v anchor).
For t2v: leave image_latent disconnected, use an empty latent for 'latent'.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
With split_by_transitions outputting a single conditioning, the contrastive
conditioning math has nothing to act on. Removed from Refiner V2 inputs,
refine_v2 signature, Studio JSON settings, Studio popup UI.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Multi-entry conditioning without a working per-window routing mechanism
accumulates all scene conditionings onto every frame, which confuses the
model. The model already places scene cuts naturally from transition words
in the full prompt - splitting the conditioning breaks this.
split_by_transitions now:
- Detects scene segments and shows them in encoded_prompts (transparency)
- Outputs a SINGLE full-prompt conditioning (model uses natural cuts)
- Status shows "Transition split: N scenes detected"
- encoded_prompts shows "Detected scenes" for use with FunPack Scene Noise
FunPackSceneCutWindows still works independently: it reads num_scenes from
conditioning entries, so with single conditioning it stays inactive (safe).
FunPackSceneNoise still seeds noise per temporal region from the seed.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Anchor fix: use the ENTIRE first segment (before the first transition word)
as the character anchor for all windows. Previous code split at the first
comma, which broke prompts like "In this anime video, Character is a..."
by using "In this anime video" as the anchor and losing the character desc
from all subsequent windows.
i2v fix: in FunPackSceneCutWindows, scene N>0 tokens now have access to
scene 0's tokens as key/value (in addition to their own scene). The i2v
guide frame lives in the early temporal positions (scene 0 region), so
blocking it from later scenes caused the reference image to be ignored.
Scenes 1 and 2+ remain isolated from each other.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ComfyUI already has a built-in manual context windows node for long-video
windowed denoising. FunPackContextTransitionWindows duplicated that
functionality without adding anything unique, and never worked correctly
for the scene-cut use case (LTXAV's packed latent format was incompatible).
Remaining nodes:
- FunPackSceneCutWindows: attention-level scene masking (MODEL in/out)
- FunPackSceneNoise: per-scene seeded noise (LATENT out, pairs with KSamplerAdvanced)
context_transition.py is now ~180 lines vs ~320 before.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
FunPackSceneCutWindows: correct scene-cut approach for LTXAV and LTXV.
Instead of context windows (which slice x_in and fail for LTXAV's packed
format), this node patches optimized_attention at the attention level.
All frames denoised in one forward pass; self-attention is blocked across
scene boundaries (tokens in scene i can only attend to tokens in scene i).
Cross-attention to text conditioning is unchanged.
Works by: (1) FunPackSceneCutHandler reads num_scenes from conds in
should_use_context and returns False (no context windowing); (2) a
model_function_wrapper temporarily replaces optimized_attention with a
per-scene version before each model forward, then restores it.
FunPackSceneNoise: generates initial noise with a different seed per
temporal scene region. Pair with KSamplerAdvanced (add_noise=disable)
or alongside FunPackSceneCutWindows for additional bias toward scene
boundaries. Scene count auto-detected from positive conditioning entries.
Seed auto-detectable from Studio/Refiner V2 seed output.
FunPackContextTransitionWindows: kept for long-video windowed denoising
(non-LTXAV, standard-format latents only); description updated to note
LTXAV incompatibility.
Also in this commit:
- Phrase stacking fix: merged pure-transition segments with next segment
(direction was backwards - was appending to prev, now prepends to next)
- New phrases: 'the scene begins with', 'after a brief scene cut',
'as the scene transitions', 'in the next scene', 'the video concludes',
'another scene shows', 'later another scene shows', 'the final scene',
'the last scene'
- Add scene ordinals 'the final scene' / 'the last scene'
- Diagnostic log in should_use_context for context windows
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
New phrases: 'the scene begins with', 'after a brief scene cut',
'as the scene transitions', 'in the next scene', 'later another scene
shows', 'another scene shows', 'the video concludes'.
Stacking fix: when two transition phrases are adjacent ('after a brief
scene cut, in the next scene...'), the pure-transition intermediate
segment is prepended to the following segment rather than left as an
empty conditioning fragment. Fixed direction (was appending to previous,
now prepends to next).
Diagnostic log: context_transition.py now logs cond group sizes,
num_windows, detected dim, and x_in shape at INFO level on every
should_use_context call to confirm routing is working.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
conds = [uncond_list, cond_list] - conds[0] is the negative conditioning
which always has exactly 1 entry. Reading len(conds[0]) always gave
num_windows=1, so the schedule produced a single window covering all
frames, and split_conds_to_windows picked the middle scene's conditioning
for the entire video (center_ratio≈0.5 → region 1 of 3).
Fix: max(len(c) for c in conds) correctly reads the positive conditioning
(3 entries for 3 scenes) and creates 3 isolated windows.
Also added 'the final scene' and 'the last scene' to transition phrases.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
For each context window, apply:
window_i = general + contrast × (scene_i − general)
where general = the full-prompt conditioning (refined, with memory
applied). The character description cancels in the delta because it
appears in both scene_i and general; the push focuses on what is
unique to each scene (action, environment).
- contrast=1.0 → plain scene encoding (original behaviour)
- contrast=1.5 → default, 50% extra push toward scene content
- contrast=2.0 → classic contrastive (2×scene − general)
New parameter: transition_contrast (FLOAT, default 1.5, range 1.0-4.0)
on Refiner V2 and in Studio popup Refiner tab.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Transition phrase list: add 'the scene then cuts to', 'the scene cuts to',
'the scene transitions to', 'the scene fades to', 'the scene dissolves to',
and short forms ('the scene then cuts', 'the scene cuts').
encoded_prompts output: when split_by_transitions is active, append a
'Per-window prompts' section showing the exact text encoded for each
context window. Example:
Window 1: A woman in red, walking in a park
Window 2: A woman in red, then sitting on a bench
Window 3: A woman in red, suddenly she runs away
Also updated _v2_encode_per_window_conditionings to return (conditionings,
window_texts) tuple instead of conditionings only.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Each scene segment is exactly one window covering all its frames.
No sub-windowing, no overlap between scenes, no temporal carryover.
Character consistency is maintained through the shared character
description in each window's conditioning, not through frame bleed.
Also fixed _detect_temporal_dim min_size check: was using
context_overlap+1 which would be 1 with overlap=0, leaving size<=1
dims rejected but nothing else guaranteed to pass. Now simply >1.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Transition words ('then', 'suddenly', 'cut to', etc.) are now kept at
the START of the new scene's conditioning text rather than discarded.
They are valuable tokens that signal a scene change to the model.
Example: 'A woman in red, walking, then sitting on a bench, suddenly runs'
Window 0: 'A woman in red, walking'
Window 1: 'A woman in red, then sitting on a bench'
Window 2: 'A woman in red, suddenly runs'
Also added ordinal scene markers to the detection list:
'the first scene' ... 'the tenth scene'
'scene one' ... 'scene ten'
This lets users explicitly label scenes in the prompt.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Context Transition Windows: auto-detect temporal dim by scanning
x_in's axes for a size that's > overlap and <= 4096. Search order:
dim 2 (standard [B,C,T,H,W]), dim 1, dim 0 (LTXAV packs frames at 0),
then remaining dims. Skip windowing entirely when no suitable dim is
found (packed formats where no axis maps to frame count).
Studio JS: fix 'Split by transitions' toggle showing 'undefined' -
was appending splitToggle.container which doesn't exist; corrected
to splitToggle.wrap (the actual property returned by toggleEl).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
All configuration is now auto-computed at sampling time - no user-facing
settings except the optional total_frames INT. Window count is derived
from the number of conditioning entries Refiner/Studio outputs. Window
size is total_frames (or actual latent size) / num_windows. Boundaries
are placed at equal intervals. split_conds_to_windows always on.
Studio: move split_by_transitions from direct node input to the Refiner
tab in the popup editor. Removed direct input, added toggle + hint text.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Studio now exposes split_by_transitions as an optional BOOLEAN
input on the node face, giving direct control without editing
the raw settings JSON. The direct input takes precedence over
the popup JSON setting when connected.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Refiner V2 and Studio: new split_by_transitions option detects
transition words in the final prompt (then, suddenly, cut to, etc.),
extracts the character description (text before the first comma),
and encodes one conditioning per scene window with the character
description prepended to each segment. Returns a multi-entry
conditioning list that routes per-window via split_conds_to_windows.
Context Transition Windows: new total_frames optional input.
When > 0 and split_conds_to_windows is enabled, context_length
is auto-computed at sampling time as total_frames / num_cond_entries
so windows size themselves to match Refiner's segment count.
Also fixes pre-existing bugs: early error return in refine_v2 was
missing video_latent (7th return value), and test unpacking was stale.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Three bugs causing i2v latent to be lost:
1. eff_key and prev_reward were defined inside 'if patched_model is not
None' but used outside it. NameError was silently caught but could
cause unexpected behavior. Moved both definitions before the block.
2. load_and_apply_creativity_mask returned bare {'samples': ...} dropping
all other keys from the original latent (noise_mask, type, batch_index,
etc.). Now copies the full original dict and only replaces 'samples'.
3. Modified samples were left on CPU (detached earlier) while the original
latent samples may be on CUDA. Now moves modified tensor to match the
original device and dtype before returning.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Two bugs:
1. 'LTXV' in 'LTXAV' == False - substring search silently missed LTXAV.
Fixed with explicit set membership: cls_name in {'LTXV', 'LTXAV'}.
2. model_config is on model.model (BaseModel), not on the ModelPatcher
itself - so the unet_config fallback path also never fired.
Fixed by reading inner.model_config instead of model.model_config.
LTX-2.3 (22b) loads as LTXAV. Both LTXV and LTXAV now correctly detected.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
refine_v2: initialise video_latent = latent instead of None so the connected
input passes through even when no key is set or mask computation is skipped.
Mask result only overwrites when it returns something non-None.
load_and_apply_creativity_mask: track explicit_latent separately from the
disk-loaded source. All early-exit and error paths return explicit_latent
(the connected input unchanged) instead of None, preserving the i2v or
previous-generation latent through the node when mask has nothing to add.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sits between Perfect (1.0) and Missing details (0.35). For when the output
looks great and you'd keep it, but it took creative liberty with the prompt
(man grabbed woman's hand instead of the other way - still a hand grab, still
loved, but not word-for-word correct).
Behaviour vs Perfect:
- axis_feedback: same - no missing/wrong axes, repair cleared
- good_streak: increments (same as Perfect)
- liked_dir: updated (quality direction was good)
- liked_conditioning average: NOT updated (intent drift - only Perfect locks in)
- phrase memory: delta 0.35x vs Perfect's 0.55x; category weights +0.08 vs +0.13
- preferred context: base_delta 0.65 vs 1.0
- phrase forgiven_count: -0.10 vs -0.18
- LoRA weights: quality/style +0.44x, action/character +0.24x (vs Perfect's 0.55x flat)
- Attention anchors: blessed (composition was good regardless of prompt fidelity)
- Advisor: not treated as perfect execution - repair signal still possible
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Removed reward >= 0.8 early returns from build_creativity_mask and
load_and_apply_creativity_mask. The global floor formula already handles
high reward correctly: at 1.0 it produces 0.0 floor, leaving only gentle
spatial variance (0-8% of latent std). A Perfect-rated latent is the best
possible reference - discarding it was wrong.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
clear_refinement_data() removes temp attention maps, blessed attention
maps, and creativity latent for the refinement key. Called from
_v2_load_state() at the start of a reset before fresh state is written.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Action LoRAs can carry micro-movement details tied to the action itself
(subtle motion blur, fluid dynamics, small camera adjustments). Previously
they only responded to the action axis, so 'Missing details' ratings never
adjusted their weight. Now mirrors character type which already had both.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Removed from LORA_BLOCK_TYPE_PROFILES, LORA_TYPE_BLOCK_ZONES,
LORA_REFINER_TYPE_PROFILES, ACTION_LORA_TYPES, the validation
special-case, and the Studio JS LORA_TYPES dropdown.
normalize_lora_type() keeps the concept->action mapping for silent
backwards compatibility with any existing saved stacks.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- _is_ltx_model() checks inner model class name, unet_config image_model
key (ltxv/ltxav), and model_type string. build_enhancements() returns
the model unchanged with a console note when a non-LTX model is detected
(e.g. WAN2.2) - generation continues normally, only the LTX patches skip.
- Update model input tooltip in FunPackVideoRefinerV2 to state LTX-2/LTXAV
family requirement and pass-through behavior for other models.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
apply_model takes (x, t, **c) not (args_dict). Both wrapper call
sites were passing the whole dict as x, leaving t unfilled.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add ltx_enhancements.py with four automatic generation improvements
driven by the refiner rating system:
Technique 2 - Per-block attention temperature: sharper (colder) attention
on semantic anchor blocks 14/19 when quality/concept is missing; softer
on early blocks when details are missing. Capped at 0.72-1.22x range.
Technique 3 - Temporal RoPE style: frame_rate manipulation via
model_function_wrapper. Selector exposed in FunPackVideoRefinerV2 node
(optional input) and in Studio popup Refiner tab.
natural=no change, accelerate=+35% fps, decelerate=-28% fps,
loop/freeze=experimental coordinate tricks.
Technique 4 - Denoise creativity mask: spatial noise weighting derived
from latent variance; high-variance regions get more denoising freedom
scaled by reward. Built but applied by downstream latent consumers.
Technique 5 - Attention anchor transfer: hidden states at anchor blocks
14 and 19 are captured via patches_replace["dit"] on every run and saved
to refinements/attn_maps/temp_{key}.pt. When the user rates a run
Perfect, bless_attention_maps() promotes the temp file to a blessed file.
Subsequent runs inject the blessed maps at 5-28% strength scaled by
reward, transferring semantic structure from good outputs onto new runs.
All enhancements are composable with existing attn2 direction patches
and STG/PAG blocks via patches_replace composition.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add LORA_TYPE_BLOCK_ZONES: type-aware block zones that suppress bad-fit
blocks to 0.0 and mildly boost good-zone blocks per LoRA type
- Add SEMANTIC_ANCHOR_BLOCKS {14, 19}: confirmed semantic focal points
(PAG default=14, STG defaults=14,19) protected from all suppression
- Add _semantic_anchor_quality: uses LoRA energy share in blocks 14+19
as a quality signal, scaling all block weights 0.92-1.08x accordingly
- Stack priority: weaker LoRA keeps base scale on anchor blocks instead
of being damped, letting the dominant signal carry semantic content
- Fix range display: status line now shows effective weights (model_weight
* scale) instead of raw multipliers; adds zeroed= and anchor_q= fields
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>