Commit Graph
525 Commits
Author SHA1 Message Date
digital-garbageandClaude Sonnet 4.6 7fca7dbc2b Diagnose whether transformer_options patches reach the model
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-22 21:48:23 +03:00
digital-garbageandClaude Sonnet 4.6 a449ceda27 Add stage-by-stage diagnostics to trace wrapper installation and execution
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-22 21:43:40 +03:00
digital-garbageandClaude Sonnet 4.6 ef3a421bd4 Fix capture_buf=None when no refinement key, remove _model_ref from closure
Two bugs:
1. capture_buf was None when refinement_key was empty, so block replacements
   never captured anything and the lazy inject snapshot check always failed
   silently. capture_buf is now always created when has_i2v is True.
2. _model_ref=model was left in the sigma tracker closure from a previous
   refactor - a direct model reference sitting inside model.model_options,
   causing the "potential memory leak" warning. Removed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-22 21:38:48 +03:00
digital-garbageandClaude Sonnet 4.6 45c6b9d60d Fix reference extraction - use first generation step instead of separate pass
Running apply_fn with a different x tensor causes shape mismatches because
the conditioning in args["c"] was prepared for the actual generation's
input shape, not our reference tensor.

New approach: no separate forward pass. The block capture already runs
during every denoising step. After the first actual step completes,
snapshot capture_buf into the lazy inject objects. From step 2 onwards
injection is active with the step-1 reference maps.

This is shape-safe, model-type agnostic, and requires zero extra inference.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-22 21:33:13 +03:00
digital-garbageandClaude Sonnet 4.6 fc96cda54e Fix reference extraction for ModelPatcherDynamic - use apply_fn not apply_model
ModelPatcherDynamic (dynamic VRAM loading) has no apply_model method.
Use apply_fn from the wrapper instead - it's the base model function
and works with all patcher types.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-22 21:30:17 +03:00
digital-garbageandClaude Sonnet 4.6 5d9d45eea8 Fix i2v detection threshold: LTX uses mask = 1 - strength, not 0
LTX i2v sets the image frame mask to (1 - strength), e.g. 0.3 at
strength=0.7. Our threshold of < 0.1 was too tight and missed all
real-world i2v latents. Changed to < 0.95 - any frame below 1.0
indicates a reference image is present.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-22 21:27:54 +03:00
digital-garbageandClaude Sonnet 4.6 73314041ac Expand diagnostics: show mask min/max/frame0 values
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-22 21:23:28 +03:00
digital-garbageandClaude Sonnet 4.6 fa26f76239 Add diagnostic logging to reference map detection
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-22 21:21:19 +03:00
digital-garbageandClaude Sonnet 4.6 ebc794c5e9 Fix reference map extraction - use real conditioning via wrapper
The previous approach called model.apply_model with empty conditioning {},
which fails silently for LTX2 (text conditioning required). Reference maps
were never actually populated.

New approach:
- _LazyInject holder: blocks receive a placeholder that starts empty and gets
  populated on the first denoising step. No injection until maps are ready.
- _run_reference_extraction: called from _sigma_tracker on the first model
  call, where args["c"] contains the real conditioning. Temporarily installs
  capture patches, calls model.apply_model at sigma=0.03 with actual
  conditioning, collects hidden states, populates lazy inject objects, then
  restores all patches.
- Generation proceeds normally from step 1 with injection active.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-22 21:15:59 +03:00
digital-garbageandClaude Sonnet 4.6 f7b2906230 Never fall back to blessed maps when i2v latent is provided
When an i2v reference is connected, old blessed maps from prior runs
(which may represent a completely different character) must not inject.
If reference map extraction fails, injection is simply skipped rather
than falling back to stale appearance data.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-22 21:07:50 +03:00
digital-garbageandClaude Sonnet 4.6 0f6a6fd674 Extract reference maps from i2v latent for automatic appearance consistency
When an i2v latent is connected (noise_mask with protected first frame),
FunPack now automatically extracts hidden state maps from the reference
image at blocks 14, 19, 21, 26, 31 via a single forward pass at sigma=0.03.
These maps are injected during generation to anchor character appearance
without requiring any prior rated runs.

Priority: reference maps from i2v > blessed maps from prior rated run.
T2v latents (no noise_mask or mask=1 throughout) are detected and skipped
cleanly - no injection happens and generation is unaffected.

Reference map injection uses fixed moderate strength (anchor 22%, identity
10%) since there is no reward signal to scale against. Blessed maps continue
to scale with reward as before.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-22 21:07:08 +03:00
digital-garbageandClaude Sonnet 4.6 35abb66169 Add identity block injection (21, 26, 31) for character appearance consistency
Extends the attention anchor system with three representative blocks from
the concept-formation/identity zone (20-35) which handles character
appearance, body proportions, and distinguishing visual traits.

- IDENTITY_BLOCKS = [21, 26, 31]: evenly spaced across the identity zone
- sigma gate (0.2, 0.55): mid-sigma window where identity is being formed,
  slightly later than semantic anchors (0.2, 0.5)
- max inject strength 12% (vs 28% for semantic anchors): lighter touch to
  preserve appearance without overriding scene-specific action/composition
- Same blessed map file, same capture/bless/inject infrastructure
- _sigma_gated_strength now takes configurable sigma_high/sigma_low params
- _build_block_replacement takes sigma_gate tuple per block

Fix pre-existing test failures from single-word transition removal:
"suddenly" replaced with "cut to" in transition-related test prompts.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-22 20:53:44 +03:00
digital-garbageandClaude Sonnet 4.6 15e4c0e764 Normalize continuation scene audio amplitude to match overlap context
Audio continuation chunks mix real latents (overlap context from prev
scene, low std) with template noise (new frames, std ~1). The model
denoises new frames anchored by the low-amplitude context, producing
quieter audio in every scene after the first.

After sampling each continuation scene, measure the RMS of the overlap
audio frames (known good amplitude from previous scene) and the RMS of
the newly generated frames. If the discrepancy is >10%, rescale the new
frames to match the overlap RMS before blending.

Scene 1 is unaffected (no overlap, no adjustment). Video latents are
never touched.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-22 20:41:10 +03:00
digital-garbageandClaude Sonnet 4.6 0a5875b1b4 Gate attention anchor injection to early high-sigma steps
Injection from blessed maps (Perfect/Loved it runs) at blocks 14 and 19
now concentrates in the anatomy/physics formation phase:
- sigma >= 0.5: full inject_strength (early structure steps)
- 0.2 <= sigma < 0.5: linear fade to zero
- sigma < 0.2: no injection (detail refinement phase, leave alone)

A lightweight sigma_tracker wrapper updates shared sigma_state before
each model call so block replacements always have the current timestep.
The tracker is only installed when blessed maps exist (zero overhead
otherwise).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-22 20:31:00 +03:00
digital-garbageandClaude Sonnet 4.6 6836db202b Bump version to 2.7.2 in pyproject.toml
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-22 19:58:27 +03:00
digital-garbageandClaude Sonnet 4.6 f90dec7780 Release 2.7.2
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-22 19:57:48 +03:00
digital-garbageandClaude Sonnet 4.6 223e60e832 Add silent transition placement - split without outputting the trigger
New placement option 'silent': the transition phrase marks the scene
boundary but is stripped from the output entirely. Neither the previous
nor the next segment contains it. Available globally and as a per-entry
override on custom transitions.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-22 19:38:29 +03:00
digital-garbageandClaude Sonnet 4.6 239d5a763e Fix custom transition triggers ending with punctuation not matching
Trailing \b after a non-word character (like '.') never matches since
\b requires a word char on one side. Custom triggers ending with
punctuation now use (?=\s|$) as the end boundary instead, so
"Scene cut." correctly splits prompts.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-22 19:11:57 +03:00
digital-garbageandClaude Sonnet 4.6 5e1aa4a6c3 Add transition placement control (start/end of segment)
- Global setting in Studio Refiner tab: "Transition placement" (start/end).
  start = transition opens the new segment (existing default behavior).
  end = transition closes the previous segment instead.
- Per-entry placement override in Transitions tab (global/start/end).
  Custom transitions can pin their placement regardless of the global setting.
- transition items gain a placement field (global/start/end, defaults to global).
- load_custom_transition_triggers returns {trigger_lower: placement|None} so
  the split function can do per-trigger lookups efficiently.
- refine_v2 and Studio.run() wired with split_transition_placement parameter.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-22 19:10:13 +03:00
digital-garbageandClaude Sonnet 4.6 8063566aba Fix _GENERIC_SCENE_LABEL_PATTERN matching scene as noun
The [a-z][\w-]* alternative matched any word after "scene", turning
"scene proceeds", "scene features", "scene shows" etc. into false
transition split points. Removed the over-broad alternative - the
pattern now only matches numbered scenes (scene 1, scene -2) and
"scene minus <label>" forms.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-22 19:00:45 +03:00
digital-garbageandClaude Sonnet 4.6 39dba21f9f Remove single-word transition markers from builtin list
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>
2026-05-22 18:45:29 +03:00
digital-garbageandClaude Sonnet 4.6 9b8948dc77 Fix stray comma after article in merged transition segments
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>
2026-05-22 18:43:11 +03:00
digital-garbageandClaude Sonnet 4.6 28eabefe51 Drop dangling trailing transition segments with no real content
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>
2026-05-22 18:34:06 +03:00
digital-garbageandClaude Sonnet 4.6 acdc4c41d6 Collapsible shortcut/transition rows, optional replacement, name fallback
- 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>
2026-05-22 18:16:59 +03:00
digital-garbageandClaude Sonnet 4.6 889e4dc2c8 Add shortcuts empty replacement, custom transitions, and longer-phrase-wins tests
- 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>
2026-05-22 17:47:55 +03:00
digital-garbage 3434d1efa2 Add global scene shortcuts 2026-05-22 16:38:33 +03:00
digital-garbage 24b1d86698 Document manual scene conditioning support 2026-05-21 16:32:08 +03:00
digital-garbage 7e31e1f168 Release 2.7.1 2026-05-21 16:24:27 +03:00
digital-garbage 46950de187 Add successful seed memory for scene chains 2026-05-21 16:21:27 +03:00
digital-garbage b9f1dad772 Fix i2v guide mask broadcasting 2026-05-21 01:20:48 +03:00
digital-garbage f396cf6866 Make i2v guide carry opt-in 2026-05-21 01:15:55 +03:00
digital-garbage c83fe43156 Carry i2v guides through scene chain 2026-05-21 01:02:23 +03:00
digital-garbage 155f56a302 Prepare 2.7.0 release docs 2026-05-21 00:34:48 +03:00
digital-garbage 3b6ef3c803 Expand scene camera transition phrases 2026-05-21 00:28:36 +03:00
digital-garbage 0a5eb94db6 Add scene transition phrases 2026-05-21 00:23:27 +03:00
digital-garbage 87db442476 Fix order-only scene splitting 2026-05-21 00:14:45 +03:00
digital-garbage 0ce4645529 Treat declared scene intro as prefix 2026-05-20 20:08:38 +03:00
digital-garbage 9352c5f556 Add LTXAV scene chain sampler 2026-05-20 19:51:06 +03:00
digital-garbage e8f0b0f83f Remove standalone scene transition nodes 2026-05-20 19:29:33 +03:00
digital-garbageandClaude Sonnet 4.6 74b50174d7 FunPackSceneNoise: add image_latent input for i2v compatibility
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>
2026-05-20 18:57:53 +03:00
digital-garbageandClaude Sonnet 4.6 56f0f30b7a Remove transition_contrast - no longer needed
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>
2026-05-20 18:52:43 +03:00
digital-garbageandClaude Sonnet 4.6 f5434693d9 Revert split_by_transitions to single conditioning; keep scene detection
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>
2026-05-20 18:51:08 +03:00
digital-garbageandClaude Sonnet 4.6 7fa2afb90c Fix window anchor extraction and i2v guide-frame attention
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>
2026-05-20 18:44:25 +03:00
digital-garbageandClaude Sonnet 4.6 9b9271be21 Remove FunPackContextTransitionWindows; keep Scene Cut Windows + Scene Noise
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>
2026-05-20 18:39:39 +03:00
digital-garbageandClaude Sonnet 4.6 d255b13cc8 Add FunPack Scene Cut Windows + Scene Noise; fix stacking; add phrases
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>
2026-05-20 18:35:19 +03:00
digital-garbageandClaude Sonnet 4.6 326444db2d Add scene phrases, fix stacking, add diagnostic log
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>
2026-05-20 18:18:33 +03:00
digital-garbageandClaude Sonnet 4.6 3e152e865c Fix critical bug: was reading conds[0] (negative) instead of max across all groups
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>
2026-05-20 16:29:16 +03:00
digital-garbageandClaude Sonnet 4.6 a8cda301c9 Add contrastive scene conditioning to sharpen transition cuts
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>
2026-05-20 16:14:24 +03:00
digital-garbageandClaude Sonnet 4.6 1261db1a75 Add 'the scene then cuts' variants + per-window prompts in encoded_prompts
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>
2026-05-20 16:02:20 +03:00
digital-garbageandClaude Sonnet 4.6 2985592731 Context windows: fully isolated scenes, zero overlap, zero stride
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>
2026-05-20 15:54:32 +03:00