Free, open-source AI video generator for Mac. Run LTX-2.5 and MiniMax H3 (Hailuo) locally on Apple Silicon: text-to-video and image-to-video with sound, lip-sync, character LoRA training, songs from lyrics (YuE2) and image editing (Qwen-Image-Edit). One-click install via Pinokio. Offline: no cloud, no API key, no NVIDIA GPU.
Python ai-filmmakingai-videoai-video-generatorapple-siliconhailuoimage-to-videolip-synclocal-ailora-trainingltx-2ltx-2-5ltx-videomacosminimax-h3mlxmusic-generationoffline-aipinokiotext-to-videovideo-generation
release(v3.3.0): Remix wave — Ingredients, Control, Colorize, Ingredients×Character, A2V + a sample character
mrbizarro733e37ff1499
diff --git a/README.md b/README.mdindex 591c261..c03f25f 100644--- a/README.md+++ b/README.md@@ -1,3 +1,22 @@+## About this fork++This fork adds audio-to-video mode for low memory pipeline.++Adds A2V Distilled Pipeline (a2vid_distilled.py) in phosphene root for+Q4-distilled audio-to-video generation. No ltx-2-mlx modifications+required — imports from stock ltx-pipelines-mlx package.++Key differences from the standard A2V path:+- a2vid_distilled.py lives in phosphene root (not inside ltx-2-mlx)+- mlx_warm_helper.py imports from the local a2vid_distilled module+- Distilled path (generate_a2v_distilled) passes audio_conditioning_scale+ (built into a2vid_distilled.py)+- Non-distilled path (generate_a2v) omits audio_conditioning_scale+ (upstream A2VidPipelineTwoStage does not accept it)+- patch_ltx_codec.py is unchanged (codec patch only)+++<p align="center"><img src="assets/phosphene_banner.png" alt="Phosphene" width="100%"></p>diff --git a/VERSION b/VERSIONindex 406ebcb..15a2799 100644--- a/VERSION+++ b/VERSION@@ -1 +1 @@-3.2.7+3.3.0diff --git a/a2vid_distilled.py b/a2vid_distilled.pynew file mode 100644index 0000000..7a36138--- /dev/null+++ b/a2vid_distilled.py@@ -0,0 +1,371 @@+"""A2V Distilled Pipeline — audio-to-video with the distilled model.++Mirrors the upstream ``DistilledPipeline`` approach: two-stage generation+(half-res → upscale → full-res refine) with the distilled transformer+and no CFG guidance. Handles audio conditioning from an input audio file.++Requires only the distilled checkpoint (``transformer-distilled.safetensors``+or ``transformer.safetensors``) — no dev model needed. Q4 compatible.+"""++from __future__ import annotations++from pathlib import Path+import tempfile++import mlx.core as mx++from ltx_core_mlx.components.patchifiers import compute_video_latent_shape+from ltx_core_mlx.conditioning.types.latent_cond import LatentState+from ltx_core_mlx.model.audio_vae import encode_audio+from ltx_core_mlx.model.transformer.model import X0Model+from ltx_core_mlx.utils.audio import load_audio+from ltx_core_mlx.utils.memory import aggressive_cleanup+from ltx_core_mlx.utils.positions import (+ compute_audio_positions,+ compute_audio_token_count,+ compute_video_positions,+)++from ltx_pipelines_mlx.a2vid_two_stage import A2VidPipelineTwoStage+from ltx_pipelines_mlx.scheduler import DISTILLED_SIGMAS, STAGE_2_SIGMAS+from ltx_pipelines_mlx.utils.helpers import create_noised_state+from ltx_pipelines_mlx.utils.progress import phase+from ltx_pipelines_mlx.utils.samplers import denoise_loop++_materialize = getattr(mx, "eval")+++class A2VidDistilledPipeline(A2VidPipelineTwoStage):+ """Audio-to-video two-stage pipeline using the distilled model.++ Uses the distilled transformer directly — no dev model, no CFG,+ no LoRA fusion. Two-stage: half-res distilled -> upscale -> full-res+ refine. Q4 compatible.++ Args:+ model_dir: Path to model weights or HuggingFace repo ID. Must+ contain the distilled checkpoint (``transformer.safetensors``+ or ``transformer-distilled.safetensors``).+ gemma_model_id: Gemma model for text encoding.+ low_memory: Aggressive memory management.+ low_ram_streaming: Stream transformer blocks from disk.+ """++ def load(self) -> None:+ """Load distilled DiT + upsampler (skip VAE encoder, skip decoders).++ VAE encoder is loaded on demand by ``image_conditioner`` callbacks+ during I2V conditioning and upscale steps — pre-loading it here+ would waste ~800 MB peak memory for no benefit.+ """+ if self._loaded:+ return++ if self.dit is None:+ transformer_path = self.model_dir / "transformer.safetensors"+ if not transformer_path.exists():+ transformer_path = self.model_dir / "transformer-distilled.safetensors"+ self.dit = self._load_transformer_with_optional_streaming(transformer_path)++ if self.upsampler is None:+ self._load_upsampler()+ self._loaded = True++ def generate_and_save(+ self,+ prompt: str,+ output_path: str,+ audio_path: str | Path | None = None,+ height: int = 480,+ width: int = 704,+ num_frames: int = 97,+ *,+ frame_rate: float,+ seed: int = 42,+ stage1_steps: int | None = None,+ stage2_steps: int | None = None,+ image: str | None = None,+ images=None,+ audio_start_time: float = 0.0,+ audio_max_duration: float | None = None,+ audio_conditioning_scale: float = 1.0,+ ) -> str:+ """Generate audio-to-video using the distilled pipeline.++ Two-stage: half-res distilled -> upscale -> full-res refine.+ Audio conditioning from the input file (frozen in stage 1,+ denoised in stage 2). Original audio muxed into output for+ maximum fidelity.++ Args:+ prompt: Text prompt.+ output_path: Path to output video file.+ audio_path: Path to input audio file (required).+ height: Video height.+ width: Video width.+ num_frames: Number of frames.+ frame_rate: Frame rate.+ seed: Random seed.+ stage1_steps: Stage 1 steps (default: full DISTILLED_SIGMAS = 8).+ stage2_steps: Stage 2 steps (default: full STAGE_2_SIGMAS = 3).+ image: Optional reference image for I2V conditioning (first frame).+ audio_start_time: Start time in seconds for audio.+ audio_max_duration: Max audio duration.+ audio_conditioning_scale: Amplify audio tokens before DiT (default: 1.0).+ Higher values increase audio adhesion at the cost of visual flexibility.++ Returns:+ Path to the output video file.+ """+ if self.low_memory:+ mx.set_cache_limit(0)++ if audio_path is None:+ raise ValueError("audio_path is required for A2VidDistilledPipeline")++ if audio_max_duration is None:+ audio_max_duration = num_frames / frame_rate++ # --- Encode audio ---+ self._load_audio_encoder()+ assert self.audio_encoder is not None+ assert self.audio_processor is not None++ audio_data = load_audio(+ audio_path,+ target_sample_rate=16000,+ start_time=audio_start_time,+ max_duration=audio_max_duration,+ )+ if audio_data is None:+ raise ValueError(f"No audio found in {audio_path}")++ audio_latent = encode_audio(+ audio_data.waveform,+ audio_data.sample_rate,+ self.audio_encoder,+ self.audio_processor,+ )++ audio_T = compute_audio_token_count(num_frames, frame_rate)+ audio_latent = audio_latent[:, :, :audio_T, :]+ audio_tokens, _ = self.audio_patchifier.patchify(audio_latent)+ if audio_conditioning_scale != 1.0:+ audio_tokens = audio_tokens * audio_conditioning_scale+ mx.synchronize()+ audio_T_actual = audio_tokens.shape[1]++ if self.low_memory:+ self.audio_conditioner.free()++ # --- Text encoding (positive only, no CFG) ---+ self._load_text_encoder()+ with phase("Encoding prompt", verbose=self.verbose):+ video_embeds, audio_embeds = self._encode_text(prompt)+ _materialize(video_embeds, audio_embeds)+ if self.low_memory:+ self.prompt_encoder.free()+ aggressive_cleanup()++ # --- Load distilled DiT + upsampler (VAE encoder on demand) ---+ self.load()+ assert self.dit is not None+ assert self.upsampler is not None++ # --- Stage 1: half resolution ---+ half_h, half_w = height // 2, width // 2+ F, H_half, W_half = compute_video_latent_shape(num_frames, half_h, half_w)+ video_shape = (1, F * H_half * W_half, 128)++ video_positions_1 = compute_video_positions(F, H_half, W_half, frame_rate=frame_rate)+ audio_positions = compute_audio_positions(audio_T_actual)++ # I2V conditioning at half resolution+ from ltx_pipelines_mlx.utils._orchestration import combined_image_conditionings+ from ltx_pipelines_mlx.utils.args import ImageConditioningInput++ enc_h_half = H_half * 32+ enc_w_half = W_half * 32+ resolved_images = list(images) if images else []+ if image is not None and not resolved_images:+ resolved_images = [ImageConditioningInput(path=image, frame_idx=0, strength=1.0)]+ conditionings_1: list = []+ if resolved_images:++ def _encode_combined(encoder):+ conds = combined_image_conditionings(+ resolved_images,+ enc_h=enc_h_half,+ enc_w=enc_w_half,+ spatial_dims=(F, H_half, W_half),+ video_encoder=encoder,+ frame_rate=frame_rate,+ )+ mx.synchronize()+ return conds++ conditionings_1 = self.image_conditioner(_encode_combined, free_after=self.low_memory)+ if self.low_memory:+ aggressive_cleanup()++ # Video: noisy state. Audio: frozen from input (denoise_mask=0)+ video_state_1 = create_noised_state(+ base_shape=video_shape,+ conditionings=conditionings_1,+ spatial_dims=(F, H_half, W_half),+ positions=video_positions_1,+ seed=seed,+ sigma=1.0,+ initial_latent=None,+ legacy_scalar_blend=True,+ )++ audio_state_1 = LatentState(+ latent=audio_tokens,+ clean_latent=audio_tokens,+ denoise_mask=mx.zeros((1, audio_tokens.shape[1], 1), dtype=mx.bfloat16),+ positions=audio_positions,+ )++ sigmas_1 = DISTILLED_SIGMAS[: stage1_steps + 1] if stage1_steps else DISTILLED_SIGMAS+ x0_model = X0Model(self.dit)++ self._pre_denoise_flush(video_state_1, audio_state_1)+ output_1 = denoise_loop(+ model=x0_model,+ video_state=video_state_1,+ audio_state=audio_state_1,+ video_text_embeds=video_embeds,+ audio_text_embeds=audio_embeds,+ sigmas=sigmas_1,+ )+ if self.low_memory:+ aggressive_cleanup()++ # --- Upscale (denorm/upsample/renorm) ---+ gen_tokens_1 = output_1.video_latent[:, : F * H_half * W_half, :]+ video_half = self.video_patchifier.unpatchify(gen_tokens_1, (F, H_half, W_half))+ H_full = H_half * 2+ W_full = W_half * 2++ def _upscale_and_optionally_encode(encoder):+ v_mlx = video_half.transpose(0, 2, 3, 4, 1)+ v_denorm = encoder.denormalize_latent(v_mlx).transpose(0, 4, 1, 2, 3)+ v_up = self.upsampler(v_denorm)+ v_up_renorm = encoder.normalize_latent(v_up.transpose(0, 2, 3, 4, 1)).transpose(0, 4, 1, 2, 3)+ mx.synchronize()+ conds: list = []+ if resolved_images:+ enc_h_full = H_full * 32+ enc_w_full = W_full * 32+ conds = combined_image_conditionings(+ resolved_images,+ enc_h=enc_h_full,+ enc_w=enc_w_full,+ spatial_dims=(F, H_full, W_full),+ video_encoder=encoder,+ frame_rate=frame_rate,+ )+ return v_up_renorm, conds++ video_upscaled, conditionings_2 = self.image_conditioner(+ _upscale_and_optionally_encode, free_after=self.low_memory+ )+ if self.low_memory:+ self.upsampler = None+ aggressive_cleanup()++ # --- Stage 2: full resolution refine (no LoRA swap, already distilled) ---+ video_tokens, _ = self.video_patchifier.patchify(video_upscaled)++ sigmas_2 = STAGE_2_SIGMAS[: stage2_steps + 1] if stage2_steps else STAGE_2_SIGMAS+ start_sigma = sigmas_2[0]++ video_positions_2 = compute_video_positions(F, H_full, W_full, frame_rate=frame_rate)++ video_state_2 = create_noised_state(+ base_shape=video_tokens.shape,+ conditionings=conditionings_2,+ spatial_dims=(F, H_full, W_full),+ positions=video_positions_2,+ seed=seed + 2,+ sigma=start_sigma,+ initial_latent=video_tokens,+ legacy_scalar_blend=True,+ )++ audio_state_2 = create_noised_state(+ base_shape=audio_tokens.shape,+ conditionings=[],+ spatial_dims=(F, H_full, W_full),+ positions=audio_positions,+ seed=seed + 2,+ sigma=start_sigma,+ initial_latent=audio_tokens,+ )++ self._pre_denoise_flush(video_state_2, audio_state_2)+ output_2 = denoise_loop(+ model=x0_model,+ video_state=video_state_2,+ audio_state=audio_state_2,+ video_text_embeds=video_embeds,+ audio_text_embeds=audio_embeds,+ sigmas=sigmas_2,+ )+ if self.low_memory:+ aggressive_cleanup()++ gen_tokens_2 = output_2.video_latent[:, : F * H_full * W_full, :]+ video_latent = self.video_patchifier.unpatchify(gen_tokens_2, (F, H_full, W_full))++ # --- Decode and save (mux original audio for max fidelity) ---+ # Free DiT before loading decoders — saves ~11 GB peak.+ self.dit = None+ self._loaded = False+ aggressive_cleanup()++ self._load_decoders()++ video_duration = num_frames / frame_rate+ audio_data_48k = load_audio(+ audio_path,+ target_sample_rate=48000,+ start_time=audio_start_time,+ max_duration=video_duration,+ )+ if audio_data_48k is not None:+ max_samples = int(video_duration * 48000)+ waveform_48k = audio_data_48k.waveform[:, :, :max_samples]+ with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as _tmp:+ temp_audio = _tmp.name+ self._save_waveform(waveform_48k, temp_audio, sample_rate=48000)+ else:+ temp_audio = None++ self.video_decoder_block.decode_and_stream(+ video_latent,+ output_path,+ frame_rate=frame_rate,+ audio_path=temp_audio,+ )++ if temp_audio is not None:+ Path(temp_audio).unlink(missing_ok=True)++ # Free all remaining Metal buffers so 24GB systems recover fully.+ # Without this, VAE decoder (~1 GB), audio decoder + vocoder+ # (~500 MB), and upsampler (~200 MB) stay pinned in Metal memory+ # until process exit.+ self.video_decoder_block.free()+ self.audio_decoder_block.free()+ self.upsampler = None+ self.dit = None+ self._loaded = False+ aggressive_cleanup()++ return output_path+++__all__ = ["A2VidDistilledPipeline"]diff --git a/docs/STATE.md b/docs/STATE.mdindex 693df0a..f6db01c 100644--- a/docs/STATE.md+++ b/docs/STATE.md@@ -4,6 +4,65 @@Current `dev` head: see `git log -1` for the live SHA. `dev` tracks `beta/main` (private repo — see §1).+> ## ⏭️ SHIPPING TOMORROW (2026-07-24) — the Remix wave. Read this first.+> **v3.2.7 shipped public 2026-07-23** (`0220e19`, tagged) = fixes only. Public VERSION is **3.2.7**; beta/dev is at **2775165**. The Remix wave is the NEXT release.+>+> **✅ Ship gate ALREADY PASSED — fresh-install weight-manifest audit (the mosaic bug class).**+> Every weight the new features load was checked against the download manifests:+> - `ltx-2.3-22b-ic-lora-ingredients-0.9` · `ltx-2.3-22b-ic-lora-union-control-ref0.5` · `LTX-2.3-22b-IC-LoRA-Colorizer-0.9` → present in **both** `install.js` and `update.js` ✅+> - `spatial_upscaler_x2_v1_1` → present in install.js + update.js + download_q8.js ✅+> - `transformer-dev` + `ltx-2.3-22b-distilled-lora-384` → in **`download_q8.js`**, which is correct: `_kf_pipe` (keyframe interp) and `_a2v_pipe` (A2V Q8, PR #29) are Q8-tier pipelines. Not a gap. ✅+> - `audio_vae` (A2V) → in install.js Q4 manifest ✅+> **No missing-weight gap. This is the check that would have caught the 7-week Q4 mosaic bug.**+>+> **✅ DONE 2026-07-23 — shippable sample character (kills the #1 barrier: "must train a LoRA before you can try Remix").**+> - `bizarrotrn_v2.safetensors` (817 MB, the exact character from the demo clip) hosted as a **public GitHub release asset**: `https://github.com/mrbizarro/phosphene/releases/tag/sample-character-bizarro` (HTTP 200 verified; sha256 `a52e648a…`). Visual LoRA only (no voice) — the audio sibling is optional per `list_characters()`.+> - **In-app one-click** "Get a sample character (Bizarro)" button in BOTH empty states (Character-mode strip `charsEmpty` + standalone Characters grid `charactersEmpty`). Backend: `POST /characters/download-sample` (202 + bg thread, atomic .partial→rename, sha256-verified, **refuses to overwrite** an existing `bizarrotrn_v2`) + `GET /characters/download-sample/status` poll. Commit `033acb5` (beta). Verified live end-to-end (both buttons render + click cleanly; already-installed path; character discovered as "Bizarro").+> - Remix draft post (`~/AI/projects/phosphene/launch/remix_launch_post_DRAFT.md`) updated to explain the Character requirement + point at the one-click sample.+> - ⚠️ **HF hosting was NOT possible** — this machine's HF token is READ-only (salocharly). If Mr Bizarro wants it mirrored on Hugging Face too, that needs a WRITE token he provides. GitHub release is the shipped path.+>+> **REMAINING before pushing Remix public:**+> 1. **From-zero fresh-Pinokio-install run** — the manifest audit is static analysis; still do one real clean install + one render per new mode (Ingredients / Control / Colorize / Ingredients×Character / A2V). This is the last hard gate ([[feedback_validate_from_zero]]).+> 2. **Q4-character label — DECIDED, NOT YET IMPLEMENTED.** Decision: character stays UNLOCKED on Q4 (check-in data: 8 GB = 20%, 16 GB = 25% of users → locking out 45% costs more than a softer face). Add a short "Q4 fallback — identity is approximate; Q8 gives faithful faces" note near the character quality strip. Relevant code: `setMode()` character branch ~`mlx_ltx_panel.py:23745`, quality chips ~20903/21131, `_validate_character_quality` ~5607 (server already allows Q4). Reversible one-liner if Mr Bizarro disagrees.+> 3. **Publish the staged Remix post WITH the release** — full text + live `assets.pinokio.co` media URLs backed up at `~/AI/projects/phosphene/launch/remix_launch_post_DRAFT.md`. ⚠️ The Pinokio composer AUTO-SAVES and the browser draft was overwritten by the v3.2.7 post — use the backup file, not the composer draft.+> 4. Bump VERSION (3.2.13 → 3.3.0 suggested; it's a feature wave, not a patch) + tag.+> 5. saved-j's training validation — a real train run to confirm the precision fix (#35/#36) end-to-end.+++> **Session 2026-07-20 — Pinokio notifications + GitHub triage + #35/#36 training fix + identity scrub (beta `3164512`, still v3.2.13, NOT public):**+> - **Pinokio inbox → zero.** Answered all 3 substantive @bizarro posts: **@hottboytank** (auto-titled "python3.11 NOT FOUND", but the real blocker is **macOS 13 Ventura** — `mlx 0.31.1` has no `macosx_13_0` wheel, so `ltx_core_mlx` never installs; also 8 GB M1, under floor → told him to upgrade to macOS 14+); **@fardad_resin** (#showcase resin-pendant Reel prompt → 3 tips: Q8 for macro detail, video can't render legible calligraphy, image→video for the hero shot); **@shaurya11** (transformers-5.13.0 crash, self-resolved → warm close). Marked all read.+> - **GitHub: PR queue emptied, every open issue answered.** **PR #29** (@anton-vsh A2V distilled) adopted onto beta (was already in `d335c7c`) + **closed** as adopted. Issues: **#43** (samuellzengkang) = the harmless stats-403 → replied + FIXED (below); **#36** (@saved-j) → replied owning the 6-day silence + real diagnosis + immediate workaround; **#34** circle-back (auto-close in a few days if silent); #35 kept open (tracks the training fix); #30/#24/#21 unchanged.+> - **🔧 #35/#36 training fix on beta (`6da73bf`), NOT public — needs a clean-install train-run validation first.** `_patch_loader_prefer_dev_transformer` only checked the dev file *existed*, not its precision → a **4-bit quantized dev (~11 GB)** in the Q4 dir got loaded → near-zero LoRA (exactly @saved-j's #36). Now **size-aware**: full dev ~19 GB vs quantized ~11 GB; prefers the largest dev ≥15 GB across the Q4 dir + Q8 sibling, warns loudly on a shadowing quantized one. Error msg corrected 11→19 GB. **@saved-j's voice-LoRA regression is SEPARATE** (voice never touches the dev transformer) — asked him for the first ~40 train-log lines. **TODO: reproduce from a clean install with saved-j's attached Archive.zip, then promote.**+> - **🔒 Identity scrub (`b04fc8b`)**: `elontrn`/`Eltrumpo` (politically-loaded) appeared in **8 internal comments across ROADMAP.md + train_character.py + mlx_ltx_panel.py — and were ALREADY in PUBLIC v3.2.6.** Renamed to neutral `chartest`; comment-only, no logic change. Reaches public with the next promote.+> - **🔧 #43 stats-noise fix (`3164512`)**: the stats-dashboard fetch 403 (token scope / rate limit) was pushed as "stats: fetch failed" every cycle → users filed it as a bug. Now warns **once**, phrased as a harmless maintainer-only refresh skip, re-arms on the next success.+> - **PUBLIC-PROMOTE PUNCH-LIST (all gated on Mr Bizarro's OK + from-zero validation):** (1) **character-on-Q4 face decision** — PR #29 relaxed the Q8-forced-character gate so 16 GB users get character on Q4 at a softer-identity cost; the Q8 reference face is rendered (`mlx_outputs/cinematic_waist_up_medium_close_up.mp4`), the Q4 side is still un-rendered → DECISION NEEDED before promote. (2) validate the #35/#36 train fix on a clean install (saved-j's data). (3) **macOS-14 installer preflight** still TODO (promised @hottboytank) — fail early with a clear "needs macOS 14+" instead of the cryptic mlx-wheel error.++> **Session 2026-07-10 — P0 install-breaker fix + full GitHub triage + triage-automation repair + /stats issues board:**+> - **🔴 P0 (public): `transformers 5.13.0` breaks EVERY fresh install.** `mlx-lm 0.31.1` requires `transformers>=5.0.0` (no upper bound); after 5.13.0 dropped (~Jul 9) it broke `mlx_lm.tokenizer_utils` → Gemma encoder silently no-ops → every generation crashes (`'str' object has no attribute '__module__'` / "Model not loaded"). 4 reports (#40/#38/#37/#33). **Fixed:** pinned `transformers>=5.0.0,<5.13.0` on the mlx-lm `uv pip install` step in `install.js` (beta `e5ef1b3`). Known-good: 5.7.0 (our build) + 5.12.x. Existing users' manual unblock: `cd ltx-2-mlx && uv pip install --python env/bin/python 'transformers>=5.0.0,<5.13.0'`. **NOT yet on public main** — needs the OK to cherry-pick + push (users have the workaround). #40 kept open as the tracker; #33/#37/#38 closed as dups.+> - **GitHub backlog fully triaged:** replied to all; closed #33/#37/#38 (transformers dups) + PR #39 (mode-bar CSS, superseded by the beta Remix rework). #34 replied (empty body, awaiting details). **#35 + #36 kept open, tracking a code fix:** the trainer's `_patch_loader_prefer_dev_transformer` picks the **Q4-quantized** `transformer-dev.safetensors` (~11 GB in the q4 dir) over the **full-precision Q8 dev** (~20 GB in the q8 dir) → near-zero LoRA weights (root cause of "trained LoRA doesn't apply"). FIX TODO (validate with a real train run): prefer the full/Q8 dev + placement-aware integrity (warn on a quantized dev in the q4 dir; verify `spatial_upscaler_x2_v1_1.safetensors` present; size-check vs expected). PRs #31/#29 already reviewed (ADOPT-WITH-CHANGES).+> - **Triage automation repaired.** It wasn't just "launchd disabled" — the launchd job was retired Jul 8 and replaced by a Claude Routine (`phosphene-morning-triage`, enabled, 8am) that (a) silently no-op'd (fetch failed in the unattended env — PATH/`gh`) and (b) was **drafts-only by design** → contributors never got answered. Fixed both: (1) hardened `~/AI/projects/phosphene/notes/triage/fetch_morning_brief.sh` — 3-try network retry + absolute `GH=$(command -v gh || …)`; (2) rewrote `~/.claude/scheduled-tasks/phosphene-morning-triage/SKILL.md` into a **gated posting spec** modeled on the working Bloom triage: reply-on-playbook-match / label / close-dup, **escalate anything new, NEVER push code**, ≤6 posts/run, skeleton-brief-first, always leaves a brief. Reads `issue_triage_playbook.md`. Armed for next 8am.+> - **/stats now lists issues + PRs.** New "Needs attention" board (open issues | open PRs, newest-first, author/age/labels/badge) — `scripts/fetch_repo_stats.py` gains `fetch_open_items()`, `panel_assets/stats.html` gains the board section (beta `709850d`). Data in the gitignored `state/stats-data.jsonl` (non-sensitive fields only); /stats stays 127.0.0.1-only. Reads at request time (no restart needed).+> - Stats snapshot: 92★ (nearing 100), 14 forks, ~4.3k users, 95 clones/day.++> **Session 2026-07-06 — Remix launch assets + full GitHub triage (no code ship; beta unchanged at v3.2.13):**+> - **Remix launch post STAGED on Pinokio** — composer draft under @bizarro, **NOT published** (gated on the public promote). Media-first: recipe graphic + 26s demo video + panel UX shot, all re-hosted on `assets.pinokio.co`. Leads with "character LoRA × ingredients." The recipe (both graphic AND demo) shows the FULL ingredient set per gag: **[trained face] + [location] + [wardrobe] = clip** (bizarrotrn + glacier + red bikini · + desert + fur coat · + beach + ski jacket).+> - **"Funny wardrobe" hero clips → `state/hero_demo/funny/clips_v2/`** (bizarro dressed wrong for 3 climates). Framing fix that mattered: chest-up WITH headroom — the old "face filling the *upper* frame" prompt literally cropped the head off — plus exaggerated comedic action (shiver/fan/sweat) for motion. char strength **1.4**, **121f (5.0s) = single-pass clean**, two-stage 1536×896, ~11 min/clip.+> - **Wardrobe product shots → `state/hero_demo/funny/wardrobe/`** via `mflux-generate-qwen-edit` **gray-canvas text-to-image trick** (Lightning-4step LoRA, `-q 8`, ~39 GB peak → STOP the panel first). Prompt shape: "Completely replace the plain gray image. Generate a clean product photograph of <garment>, laid flat and centered on a soft light-gray studio background…". Reusable for any product/ingredient image.+> - **Pinokio media injection (the method that works — see memory `phosphene_pinokio_posting`):** `file_upload` MCP rejects self-generated files ("only files the user shared"); instead b64→clipboard→paste into an in-page sink `<textarea>`→`atob`→`File`→set on the composer's `input[type=file]`→dispatch `change`. Composer uploads to its CDN and inserts markdown **at the body textarea's cursor** (must `setSelectionRange(end)` on the body first, or nothing inserts). Then rewrite the whole body via the native value setter to place media exactly. Video embeds as `[video](url.mp4 "poster.webp")` with an auto-poster; videos → 720p, ≤25 MB.+> - **GitHub fully triaged (mrbizarro/phosphene):** all 6 issues answered; **#32/#28/#27 closed**; #30 open (tracks PR #31); #24/#21 open (FR backlog). **#32** (character-LoRA-zero-effect, near-zero weights) = the **distilled-vs-dev transformer trap** — already fixed in v3.2.5's `_patch_loader_prefer_dev_transformer` (forces `transformer-dev.safetensors`, hard-fails if missing); reporter was on an older build. **PRs #31 (48 GB memory) + #29 (A2V distilled)** both deep-reviewed → **ADOPT-WITH-CHANGES**, review comments posted, public merge **held for Mr Bizarro**. Key #31 catch: its `full_training` caps (7000 steps / 768 px) are applied **globally** → would silently cap documented 20k-step / 1024px-widescreen runs on 64/128 GB Macs; asked to scope to <64 GB.+> - **OPEN:** fresh-install-from-zero validation of the Remix wave → then Mr Bizarro's OK to promote public `main` + hit Publish on the staged post.++> **Latest dev (2026-06-28, on `beta/main`, NOT yet public) — the IC-LoRA feature wave:**+> The ltx-community IC-LoRAs that ride the in-context pipeline Phosphene already vendors (the one powering HDR) are now wired as first-class modes. **BETA only — none public yet**; each gated behind fresh-Pinokio-install validation + Mr Bizarro's explicit OK before promote + a Pinokio post. `dev`/beta is at **v3.2.11** (public is still v3.1.1).+> - **v3.2.6 — STG slider** (spatio-temporal guidance; off by default).+> - **v3.2.7 — Q4 "mosaic" root-cause fix + 2 more.** The Q4 mosaic was `spatial_upscaler_x2` missing from the Q4 manifest block (listed only under Q8) AND a Verify blind spot (it iterates each repo's `files[]`, so never noticed). Added the upscaler to q4 `files[]`+`download_include`. Plus: Ideogram silently dropping stacked LoRAs (guard only matched "qwen" in the filename → others forwarded to mflux-generate-ideogram4 → 0 keys matched + false success; now `fam=="ideogram"` drops ALL non-native LoRAs); and a latent `generate_hdr` dispatch bug (called non-existent `helper.send()/wait_done()` → `HELPER.run`).+> - **v3.2.8 — Colorize restore mode** (community DoctorDiffusion weight; B&W clip → colorized; off by default, kept minimal).+> - **v3.2.9 — Ingredients (flagship multi-reference IC-LoRA).** 2–8 reference images (face + prop + location) → one recomposed clip. The recompose lever is reference **STRENGTH** (not conditioning-attention — a CAS sweep was flat): 0.0 lets the fused LoRA carry the subjects so the model composes a NEW scene instead of copying the 2×2 sheet (MAD 4→86 across strength 1.0→0.0; only 0.0 = clean single shot). Single-stage Q4, generate at 2×. Un-gated mirror of the official weight (DeepBeepMeep/LTX-2, targeted single-file fetch — never a snapshot of the 708 GB mega-repo).+> - **v3.2.10 — Control (Union) mode.** Official UN-gated Lightricks Union-Control IC-LoRA; a control clip drives motion/structure/composition on the reference channel at FOLLOW strength (~1.0 — inverse of Ingredients' 0.0). Two-stage, Q4.+> - **v3.2.11 — Ingredients × Character (the differentiator).** Optional **Character** dropdown in Ingredients mode stacks a trained character LoRA ON TOP of the Ingredients IC-LoRA, so the SAME trained face lands in every composed scene — identity from the LoRA (cranked above the ingredients weight; relative weight is the lever), composition from the references, ref-strength stays 0.0 so the scene still recomposes. The character's trigger rides a hidden field; the server prepends it to the action if missing. Nobody upstream has shipped this. **Validated end-to-end through the real panel queue** (POST `/queue/add` urlencoded → `make_job` allowlist → dispatch stack): bizarrotrn rendered in a red puffer + neon alley, face tight, via the dropdown. Hero demo (3 scenes — guitar/neon, jacket/summit, husky/dunes; same face across all) in `state/hero_demo/` (off-repo) with an `index.html` report. References generated by Phosphene's OWN qwen-image-edit (gray-canvas text-to-image trick) — Ideogram-4/HiDream aren't downloaded on the dev box. Code: `make_job` allowlist `ingredient_char_lora`/`_strength`/`_trigger`; dispatch stacks into `ingredients_loras`; UI `#ingredientCharWrap` + `populateIngredientCharLoras()` (filters `_knownUserLoras` kind=train_character). Memory: `phosphene_ic_lora_opportunity`, `feedback_phosphene_faces_priority`.+> - **v3.2.12 — Remix IA consolidation + the "hallucination" fix + cross-Mac.** (a) **Remix mode** — the 3 IC-LoRA pills (Colorize/Ingredients/Control) were cluttering the mode bar (9 pills); collapsed into ONE **Remix** parent pill + a second-level sub-row (`#remixSubGroup`: Ingredients/Control/Colorize). Pure UI grouping — backend modes stay ingredients/control/restore (`REMIX_MODES` + a `remix` pseudo-mode in setMode that resumes the last sub-tool; sub-pills set the real mode; parent pill lit for any sub-mode; sub-row hidden off-Remix). Browser-validated end-to-end (Remix→sub-row+Ingredients, Control switches section, Text hides the row). Mode bar 9→7 pills. (b) **The dreamy "hallucination" look was SINGLE-STAGE, not Q4** — A/B proved it: running the 2nd (refine+2x-upscale) stage cleans it AND outputs 1536x896. Wired into the quality pills: **Quick/Draft = single-stage** (fast, the dreamy look on purpose); **Balanced (default)/Standard/High = two-stage** (clean, full-res). Q8 deliberately NOT used for Ingredients — it sharpened faces but tripped the bizarrotrn gold-sparkle artifact and is off-spec for the Q4-trained IC-LoRA (the right "Q8" is dev-transformer + distilled-lora-384, validated in `state/hero_demo/q8_experiment/` but parked). (c) **Cross-Mac**: all 3 Remix dispatches already clamp gen size via `tier_max_dim("i2v")` → small Macs auto-render ≤768px (no OOM); the quality pills are the memory/quality dial (Quick = lightest); High hidden on Q4 tier. Heroes re-rendered two-stage (clean, 1536x896) in `state/hero_demo/clean/`. Open follow-up: a Q8/dev "max-face" path for Ingredients as the mosaic-Mac fallback (parked — sparkle caveat + plumbing).+> - **NEXT:** fresh-install-from-zero validation of the wave; then explicit OK to promote public + the Pinokio post (leads with character × ingredients). Inpaint/Outpaint IC-LoRAs remain (need the `conditioning_attention_mask` param; the outpaint weight is already on disk).+>> **Latest dev (2026-06-11, on `beta/main`, NOT yet public):**> - **LoRA/character fixes — SHIPPED PUBLIC as `v3.0.13`** (beta `f4f992e` → cherry-picked to prod `ce03139`, release commit `814dc2d`, tag `v3.0.13`, 2026-06-11). Two bugs @claude3d reported on v3.0.12, fixed + validated live in the dev panel: (1) a character LoRA whose filename contains a **space** (e.g. `Annie Phosphene_v2.safetensors`) was misclassified as style-only / "No trained characters yet" even with a correct sidecar — `_CHARACTERS_ID_RE` rejected spaces and gated `list_characters()` *before* the sidecar was read. Widened the regex to `[A-Za-z0-9 _-]+` and made `_character_safe_id` URL-decode so spaced ids resolve in the `/characters/<id>/{preview,generate,delete,rename}` routes (unquote-then-validate stays traversal-safe). (2) Character tab could silently render plain T2V — a **UI desync** left the avatar's `.active` ring ON after the hidden `character_id` was cleared on a mode switch, so Generate shipped `character_id=""` → no LoRA. ("Params shows Text" is by design — `character_id` drives the LoRA stack, not the mode field.) The ring now re-renders in lockstep with the cleared selection. Plus a latent `enhancePrompt` wrong-element-id fix. **Deliberately NOT bundled with the Ideogram work below** so the fixes can ship without waiting on the gate. Validation: `/characters` lists a spaced-name char; in-browser pick→switch-away→switch-back leaves the ring OFF + field empty, re-pick ships `character_id`.> - **Ideogram 4 engine + visual text-placement canvas — SHIPPED PUBLIC as `v3.1.0`** (2026-06-11). Open-weight 9.3B text-rendering model + a client-side bbox text-placement canvas. mflux 0.18 `mflux-generate-ideogram4`; gated `ideogram-ai/ideogram-4-fp8` (~26 GB; user needs a HF **Read** token + accept the license). **Root-caused + fixed the gated-download 401 that would have hit every user:** the image-engine mflux subprocess inherits `os.environ`, but the panel never exported its configured token there, so huggingface_hub fell back to a stale `hf auth login` cache (a different/unauthorized account) → 401. `_sync_hf_token_to_env()` now pushes the settings token → `HF_TOKEN` env (wins over the cache) at boot + per image job. Proven clean-room (fresh empty env: old path 401s, fix authenticates). Validated end-to-end: an 8-text-element field-guide poster rendered clean with every label placed per its bbox. Gate-error message reworded to name a wrong-account token instead of telling users to re-accept the license. Memory: `phosphene_hf_ideogram_account` + `feedback_fixes_must_reach_users`.diff --git a/image_engine.py b/image_engine.pyindex 46a7cdc..da1b8ff 100644--- a/image_engine.py+++ b/image_engine.py@@ -902,7 +902,21 @@ def _generate_mflux(prompt: str, n: int, width: int, height: int,# (and their paired scales, kept index-aligned) up front and log it._lora_paths_in = list(config.mflux_lora_paths or [])_lora_scales_in = list(config.mflux_lora_scales or [])- if fam != "qwen_edit" and _lora_paths_in:+ if fam == "ideogram" and _lora_paths_in:+ # Ideogram 4 CANNOT consume external LoRAs: its transformer key+ # names share zero overlap with Qwen/FLUX LoRA keys, so mflux's+ # loader matches 0/2304 keys yet prints "applied successfully" — a+ # silent no-LoRA render that makes users blame Ideogram for ignoring+ # their character. Drop ALL user LoRAs (not just Qwen ones) and log+ # honestly. This one chokepoint covers every entry path: the picker,+ # a selection carried over from an engine switch, and /image/agent.+ for _lp in _lora_paths_in:+ if on_log is not None:+ try: on_log(f"[lora] Ideogram cannot use external LoRAs — ignoring: {_lp}")+ except Exception: # noqa: BLE001+ pass+ _lora_paths_in, _lora_scales_in = [], []+ elif fam != "qwen_edit" and _lora_paths_in:_kept_p: list = []_kept_s: list = []for _i, _lp in enumerate(_lora_paths_in):diff --git a/install.js b/install.jsindex 1949982..27b9fbc 100644--- a/install.js+++ b/install.js@@ -390,6 +390,77 @@ module.exports = {}},+ // ---- Colorize IC-LoRA (~0.3 GB, un-gated community weights) -----------+ // Powers the Colorize restore mode (B&W clip → color). UN-GATED, so no+ // HF token is needed — but BEST-EFFORT regardless: a network hiccup (or a+ // future gating change) must NEVER fail the core video install. The panel+ // surfaces the same Repair path if the file didn't land, and the worker+ // falls back to resolving the repo id at first use. Lands the file at+ // mlx_models/loras/ic/ (matches required_files.json → repos[ic_colorize]+ // + CURATED_LORAS["colorize"].local_path).+ {+ method: "shell.run",+ params: {+ venv: "env",+ path: "ltx-2-mlx",+ env: { HF_HUB_ENABLE_HF_TRANSFER: "1" },+ message: [+ "echo 'Fetching the Colorize IC-LoRA (restore mode, ~0.3 GB, optional)…' && \\",+ "hf download DoctorDiffusion/LTX-2.3-IC-LoRA-Colorizer --local-dir ../mlx_models/loras/ic --include 'LTX-2.3-22b-IC-LoRA-Colorizer-0.9.safetensors' \\",+ "|| echo 'WARN: Colorize IC-LoRA fetch failed — video + image still work; the Colorize mode will fetch it on first use, or click Repair.'"+ ].join("\n")+ }+ },++ // ---- Ingredients IC-LoRA (~1.3 GB, un-gated mirror) -------------------+ // Powers the flagship Ingredients mode (2-8 refs → one composed clip).+ // The official Lightricks weight is GATED; DeepBeepMeep/LTX-2 carries the+ // BYTE-IDENTICAL file un-gated, so no HF token is needed. BEST-EFFORT: a+ // hiccup must never fail the core video install. CRITICAL: --include pulls+ // ONLY the one ingredients file — DeepBeepMeep/LTX-2 is a ~708 GB mega-repo,+ // so a bare `hf download` of it would be catastrophic. The worker falls+ // back to a targeted single-file fetch at first use; the panel surfaces+ // Repair. Lands the file at mlx_models/loras/ic/ (matches+ // required_files.json → repos[ic_ingredients] ++ // CURATED_LORAS["ingredients"].local_path).+ {+ method: "shell.run",+ params: {+ venv: "env",+ path: "ltx-2-mlx",+ env: { HF_HUB_ENABLE_HF_TRANSFER: "1" },+ message: [+ "echo 'Fetching the Ingredients IC-LoRA (multi-reference mode, ~1.3 GB, optional)…' && \\",+ "hf download DeepBeepMeep/LTX-2 --local-dir ../mlx_models/loras/ic --include 'ltx-2.3-22b-ic-lora-ingredients-0.9.safetensors' \\",+ "|| echo 'WARN: Ingredients IC-LoRA fetch failed — video + image still work; the Ingredients mode will fetch it on first use, or click Repair.'"+ ].join("\n")+ }+ },++ // ---- Control (Union) IC-LoRA (~0.65 GB, OFFICIAL + un-gated) ----------+ // Powers the Control mode (drive motion/structure/composition from a+ // control video). This is the OFFICIAL Lightricks weight AND it is UN-GATED+ // + public, so — unlike Ingredients — no token, no mirror, no mega-repo+ // workaround: a plain single-file `hf download --include`, exactly like the+ // Colorize fetch above. BEST-EFFORT: a hiccup must never fail the core+ // video install. The worker falls back to resolving the repo id at first+ // use; the panel surfaces Repair. Lands the file at mlx_models/loras/ic/+ // (matches required_files.json → repos[ic_union_control] ++ // CURATED_LORAS["union-control"].local_path).+ {+ method: "shell.run",+ params: {+ venv: "env",+ path: "ltx-2-mlx",+ env: { HF_HUB_ENABLE_HF_TRANSFER: "1" },+ message: [+ "echo 'Fetching the Control IC-LoRA (Union, control mode, ~0.65 GB, optional)…' && \\",+ "hf download Lightricks/LTX-2.3-22b-IC-LoRA-Union-Control --local-dir ../mlx_models/loras/ic --include 'ltx-2.3-22b-ic-lora-union-control-ref0.5.safetensors' \\",+ "|| echo 'WARN: Control IC-LoRA fetch failed — video + image still work; the Control mode will fetch it on first use, or click Repair.'"+ ].join("\n")+ }+ },+// ---- Done -------------------------------------------------------------{method: "notify",diff --git a/lora_lab/train_character.py b/lora_lab/train_character.pyindex 7cf69ee..f17c836 100644--- a/lora_lab/train_character.py+++ b/lora_lab/train_character.py@@ -132,6 +132,21 @@ _PREPROCESS_FIXED_S = 90.0 # model load + Gemma init_PREPROCESS_PER_IMAGE_S = 2.0 # VAE encode per image+def _normalize_target_modules(value: Any) -> list[str]:+ """Accept panel-supplied LoRA target modules while keeping a safe allowlist."""+ if value is None:+ return list(TARGET_MODULES)+ if isinstance(value, str):+ raw = [x.strip() for x in value.split(",") if x.strip()]+ elif isinstance(value, (list, tuple)):+ raw = [str(x).strip() for x in value if str(x).strip()]+ else:+ raw = []+ allowed = set(TARGET_MODULES)+ mods = [m for m in raw if m in allowed]+ return mods or list(TARGET_MODULES)++def resolve_preset(preset: str, advanced: dict[str, Any] | None) -> dict[str, Any]:"""Merge a preset with optional `advanced` overrides. None values fall through."""if preset not in PRESETS:@@ -141,6 +156,10 @@ def resolve_preset(preset: str, advanced: dict[str, Any] | None) -> dict[str, Anfor k, v in advanced.items():if v is not None and k in cfg:cfg[k] = v+ if advanced.get("target_modules") is not None:+ cfg["target_modules"] = _normalize_target_modules(advanced.get("target_modules"))+ if "target_modules" not in cfg:+ cfg["target_modules"] = list(TARGET_MODULES)return cfg@@ -235,7 +254,7 @@ def load_spec(spec_path: Path) -> dict[str, Any]:spec["advanced"] = {}for k in ("rank", "alpha", "steps", "lr", "resolution","width", "height",- "caption_strategy", "crop_strategy"):+ "target_modules", "caption_strategy", "crop_strategy"):if k in spec and k not in spec["advanced"]:spec["advanced"][k] = spec[k]cs = spec["advanced"].get("caption_strategy")@@ -553,7 +572,7 @@ def build_trainer_config("rank": int(cfg["rank"]),"alpha": int(cfg["alpha"]),"dropout": 0.0,- "target_modules": list(TARGET_MODULES),+ "target_modules": _normalize_target_modules(cfg.get("target_modules")),},"optimization": {"learning_rate": float(cfg["lr"]),@@ -737,6 +756,7 @@ def write_sidecar("height": int(cfg.get("height") or cfg.get("resolution") or 576),"image_count": image_count,"caption_strategy": cfg["caption_strategy"],+ "target_modules": _normalize_target_modules(cfg.get("target_modules")),"training_wall_seconds": round(float(training_wall_s), 1),"created_at": _dt.datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"),"base_model": "Lightricks/LTX-2.3 (dgrauet/ltx-2.3-mlx-q4 dev transformer)",diff --git a/mlx_ltx_panel.py b/mlx_ltx_panel.pyindex 273839f..62d0dfd 100644--- a/mlx_ltx_panel.py+++ b/mlx_ltx_panel.py@@ -732,16 +732,113 @@ CURATED_LORAS: dict[str, dict] = {"is_curated": True,"is_hdr_toggle": False,},+ # Control (Union) — drives a render's motion / structure / composition from+ # a control video. This is the OFFICIAL Lightricks weight and — unlike the+ # other official IC-LoRAs (Ingredients/Colorize gated or community-mirrored)+ # — it is UN-GATED + public (verified gated:False, single 654,465,352-byte+ # safetensors), so it downloads token-less exactly like Colorize. Drives the+ # "Control" mode, not the LoRA picker — `is_control_lora` keeps it out of the+ # user-facing curated list the way `is_restore_lora` hides Colorize. The+ # worker injects it by `local_path` when mode=="control".+ #+ # Recon gate (2026-06-27) PROVED raw RGB on the IC reference channel at+ # STRENGTH 1.0 transfers the driving clip's structure/composition onto the+ # prompted subject (A/B causation confirmed vs no-control). Unlike Ingredients+ # (ref strength 0.0 to RECOMPOSE), Control WANTS to follow the driver, so the+ # reference is held near-pristine at ~1.0. Trained against the Q4 distilled+ # checkpoint, so Control forces Q4 like Colorize/Ingredients/HDR. The weight+ # carries reference_downscale_factor=2 → the IC encoder halves the reference+ # and the pipeline generates at the requested dims (handled in iclora_utils;+ # the panel feeds output dims and lets the encoder do the /2)."union-control": {"id": "union-control","name": "Union Control",- "description": "Lightricks IC-LoRA combining multiple control signals "- "(depth, edges, pose) into one network.",+ "description": "Official Lightricks IC-LoRA combining multiple control "+ "signals (depth, edges, pose) into one network. Drives "+ "the Control mode; takes the control clip on the IC "+ "reference channel at follow-strength. Un-gated official "+ "weight — no HF token needed.","repo_id": "Lightricks/LTX-2.3-22b-IC-LoRA-Union-Control",+ # Local file the installer fetches (see required_files.json →+ # repos[ic_union_control] + install.js/update.js). Preferred over repo_id+ # so the helper fuses a local .safetensors with no snapshot_download.+ "local_path": str(LORAS_DIR / "ic" / "ltx-2.3-22b-ic-lora-union-control-ref0.5.safetensors"),"default_strength": 1.0,"trigger_words": [],"is_curated": True,"is_hdr_toggle": False,+ "is_control_lora": True, # hide from the LoRA picker (mode-driven)+ },+ # Colorize — the first real IC-LoRA feature, on UN-GATED community weights+ # (DoctorDiffusion/LTX-2.3-IC-LoRA-Colorizer). Drives the "Colorize"+ # (restore) mode, not the LoRA picker — `is_restore_lora` keeps it out of+ # the user-facing curated list the way `is_hdr_toggle` hides HDR. The+ # worker injects it by `local_path` when mode=="restore". The LoRA was+ # trained against the Q4 distilled checkpoint, so restore forces Q4.+ "colorize": {+ "id": "colorize",+ "name": "Colorize",+ "description": "Community IC-LoRA that adds natural color to a B&W / "+ "desaturated source clip. Drives the Colorize restore "+ "mode; takes the source video on the IC reference "+ "channel. Un-gated — no HF token needed.",+ "repo_id": "DoctorDiffusion/LTX-2.3-IC-LoRA-Colorizer",+ # Local file the installer fetches (see required_files.json →+ # repos[ic_colorize] + install.js/update.js). Preferred over repo_id so+ # the helper fuses a local .safetensors with no snapshot_download.+ "local_path": str(LORAS_DIR / "ic" / "LTX-2.3-22b-IC-LoRA-Colorizer-0.9.safetensors"),+ "default_strength": 1.0,+ "trigger_words": [],+ "is_curated": True,+ "is_hdr_toggle": False,+ "is_restore_lora": True, # hide from the LoRA picker (mode-driven)+ },+ # Ingredients — the FLAGSHIP multi-reference IC-LoRA. 2-8 reference images+ # (a face + a prop + a location) are tiled into ONE "reference sheet", the+ # sheet is repeated to N frames as the IC video_conditioning, and the model+ # composes them into one new clip. Drives the "Ingredients" mode, not the+ # LoRA picker — `is_ingredients_lora` keeps it out of the user-facing list+ # the way `is_restore_lora` hides Colorize. Worker injects it by+ # `local_path` when mode=="ingredients".+ #+ # WEIGHT: the OFFICIAL Lightricks weight is GATED (auto-approve). The+ # un-gated community mirror DeepBeepMeep/LTX-2 carries the BYTE-IDENTICAL+ # file (same 1,308,778,338-byte size; sha256+ # 515e4e139001ac6282357a5b35372e42e98b3affd5fcc886a52242abeed19559;+ # token-less download verified). BUT that mirror is a 708 GB mega-repo of+ # 71 safetensors — NEVER hand its bare repo_id to _resolve_lora_path+ # (snapshot_download would try to pull all 708 GB). So we set `repo_file`+ # to the exact filename and the worker fetches that ONE file with+ # hf_hub_download. `local_path` (installer-fetched) is always preferred.+ #+ # Recipe is the public Space ltx-community/ltx-2.3-ingredients-distilled:+ # LoRA fuse strength 1.4 (NOT 1.0), single-stage (skip_stage_2=True), the+ # sheet rides video_conditioning at strength 1.0, prompt is+ # "Reference sheet: <desc>\n\nGenerated video: <action>". Trained against+ # the Q4 distilled checkpoint → ingredients forces Q4 like Colorize/HDR.+ "ingredients": {+ "id": "ingredients",+ "name": "Ingredients",+ "description": "Official-equivalent IC-LoRA that composes 2-8 reference "+ "images (a face + a prop + a location) into one new "+ "video. Drives the Ingredients mode; the references are "+ "tiled into a sheet and ride the IC reference channel. "+ "Un-gated mirror — no HF token needed.",+ # Un-gated mirror that carries the byte-identical official weight.+ "repo_id": "DeepBeepMeep/LTX-2",+ # Exact file WITHIN that mega-repo — the worker fetches ONLY this file+ # (hf_hub_download), never the whole 708 GB repo.+ "repo_file": "ltx-2.3-22b-ic-lora-ingredients-0.9.safetensors",+ # Local file the installer fetches (see required_files.json →+ # repos[ic_ingredients] + install.js/update.js). Preferred over repo_id+ # so the helper fuses a local .safetensors with no download.+ "local_path": str(LORAS_DIR / "ic" / "ltx-2.3-22b-ic-lora-ingredients-0.9.safetensors"),+ # Public-Space fuse strength for the Ingredients LoRA (1.4, not 1.0).+ "default_strength": 1.4,+ "trigger_words": [],+ "is_curated": True,+ "is_hdr_toggle": False,+ "is_ingredients_lora": True, # hide from the LoRA picker (mode-driven)},}@@ -856,12 +953,12 @@ LORA_LAB_RUN_SH = Path(# Quality preset → training hyperparams. lora_lab/train_character.py reads# these out of the spec JSON; the values here are the contract surface.#-# Step counts are NOT hardcoded — they're derived from `epochs × image_count`-# at job-build time (see make_job). The validated v2 recipe was 5000 steps-# at 50 images = 100 epochs; that ratio is what each preset preserves as-# the dataset grows. 79 images on "high" → 7900 steps, not 5000. Power-# users can override per-run via the advanced "steps" field in the Train-# tab — make_job honors form["steps"] when present.+# Step counts are derived from `epochs × image_count` at job-build time+# (see make_job), then capped by the active hardware training profile.+# Unbounded epoch scaling made a 47-image Quick run launch 1410 full LTX+# backward passes on a 48 GB Mac, which pushed MLX into swap and produced+# a bogus multi-hour ETA. Presets now carry `max_steps`, and make_job also+# clamps stale advanced form values server-side.## `seconds_per_step` is the per-step wall-time measurement on M4 Max at the# preset's rank/resolution (1.75 s/step at rank-8 / 512×320 — see@@ -871,12 +968,14 @@ TRAIN_PRESETS = {"seconds_per_step": 1.5, "ram_peak_gb": 12,"label": "Quick","subtitle": "~30 epochs · rank 8 · 512px",- "checkpoint_interval": 500},+ "checkpoint_interval": 500,+ "max_steps": 8000},"medium": {"epochs": 60, "rank": 16, "lr": 1e-4, "resolution": 576,"seconds_per_step": 2.2, "ram_peak_gb": 18,"label": "Medium","subtitle": "~60 epochs · rank 16 · 576px",- "checkpoint_interval": 500},+ "checkpoint_interval": 500,+ "max_steps": 12000},# high tier mirrors the validated CLI recipe (rank 32 / 100 epochs /# lr 1e-4 / 512px) — at 50 images that's the legacy 5000 steps. The# earlier 5e-5 LR was a mistake; 1e-4 is the proven default@@ -886,7 +985,8 @@ TRAIN_PRESETS = {"seconds_per_step": 2.0, "ram_peak_gb": 28,"label": "High","subtitle": "~100 epochs · rank 32 · 512px (validated v2 recipe)",- "checkpoint_interval": 250},+ "checkpoint_interval": 250,+ "max_steps": 20000},}# Style LoRA presets — parallel to TRAIN_PRESETS but tuned for aesthetic@@ -908,32 +1008,142 @@ TRAIN_STYLE_PRESETS = {"seconds_per_step": 1.5, "ram_peak_gb": 12,"label": "Quick","subtitle": "~30 epochs · rank 16 · 512px",- "checkpoint_interval": 500},+ "checkpoint_interval": 500,+ "max_steps": 8000},"medium": {"epochs": 60, "rank": 32, "lr": 1e-4, "resolution": 512,"seconds_per_step": 2.0, "ram_peak_gb": 18,"label": "Medium","subtitle": "~60 epochs · rank 32 · 512px",- "checkpoint_interval": 500},+ "checkpoint_interval": 500,+ "max_steps": 12000},"high": {"epochs": 100, "rank": 32, "lr": 1e-4, "resolution": 512,"seconds_per_step": 2.0, "ram_peak_gb": 28,"label": "High","subtitle": "~100 epochs · rank 32 · 512px",- "checkpoint_interval": 250},+ "checkpoint_interval": 250,+ "max_steps": 20000},}+TRAIN_TARGET_MODULES_DEFAULT = ["to_q", "to_k", "to_v", "to_out"]+TRAIN_TARGET_MODULES_COMPACT = ["to_q", "to_v"]++def _preset_steps_for(preset_cfg: dict, image_count: int) -> int:"""Compute steps for a preset given the dataset size.- `epochs × image_count` is the contract. Floor of 1 (so a degenerate- image_count=0 doesn't yield zero-step training, which would just- skip the loop and emit a useless artifact). No upper bound here —- if a power user uploads 200 images to a "high" preset and wants- 20000 steps (~11h), the system honors that. The Train tab's wall-- time chip surfaces the cost up-front so it's their informed call.+ `epochs × image_count` is the baseline. Floor of 1 (so a degenerate+ image_count=0 doesn't yield zero-step training), then cap by the+ preset's `max_steps` when present. The cap is deliberately part of the+ server contract: old browser JS and hand-written API calls must not be+ able to enqueue a multi-thousand-step run on a memory-constrained Mac+ by accident."""epochs = int(preset_cfg.get("epochs", 0))- return max(1, epochs * max(1, int(image_count or 0)))+ steps = max(1, epochs * max(1, int(image_count or 0)))+ try:+ max_steps = int(preset_cfg.get("max_steps") or 0)+ except (TypeError, ValueError):+ max_steps = 0+ if max_steps > 0:+ steps = min(steps, max_steps)+ return steps+++def _select_train_profile(total_ram_gb: float, tier_key: str) -> dict:+ """Mutate Train presets for hardware-sensitive LoRA training.++ Video rendering and LoRA training have different memory shapes. A 48 GB+ Mac can run the regular Q4/Q8 video modes, but full 512px LTX LoRA+ training still materializes backward activations for the dev transformer+ and falls into heavy swap. The compact profile trades capacity for a run+ that finishes: lower canvas, lower rank, fewer target modules, and capped+ steps. The clamps are mirrored in make_job so stale forms cannot bypass+ them.+ """+ if 0 < float(total_ram_gb or 0) < 64:+ compact_modules = list(TRAIN_TARGET_MODULES_COMPACT)+ TRAIN_PRESETS.update({+ "quick": {"epochs": 2, "rank": 4, "lr": 1e-4, "resolution": 384,+ "seconds_per_step": 14.0, "ram_peak_gb": 38,+ "label": "Quick",+ "subtitle": "~2 epochs · rank 4 · 384px · max 120 steps",+ "checkpoint_interval": 100,+ "max_steps": 120, "max_rank": 4, "max_resolution": 384,+ "target_modules": compact_modules},+ "medium": {"epochs": 5, "rank": 8, "lr": 1e-4, "resolution": 384,+ "seconds_per_step": 16.0, "ram_peak_gb": 40,+ "label": "Medium",+ "subtitle": "~5 epochs · rank 8 · 384px · max 300 steps",+ "checkpoint_interval": 100,+ "max_steps": 300, "max_rank": 8, "max_resolution": 384,+ "target_modules": compact_modules},+ "high": {"epochs": 10, "rank": 8, "lr": 1e-4, "resolution": 448,+ "seconds_per_step": 20.0, "ram_peak_gb": 44,+ "label": "High",+ "subtitle": "~10 epochs · rank 8 · 448px · max 500 steps",+ "checkpoint_interval": 100,+ "max_steps": 500, "max_rank": 8, "max_resolution": 448,+ "target_modules": compact_modules},+ })+ TRAIN_STYLE_PRESETS.update({+ "quick": {"epochs": 2, "rank": 8, "lr": 1e-4, "resolution": 384,+ "seconds_per_step": 14.0, "ram_peak_gb": 38,+ "label": "Quick",+ "subtitle": "~2 epochs · rank 8 · 384px · max 120 steps",+ "checkpoint_interval": 100,+ "max_steps": 120, "max_rank": 8, "max_resolution": 384,+ "target_modules": compact_modules},+ "medium": {"epochs": 5, "rank": 8, "lr": 1e-4, "resolution": 384,+ "seconds_per_step": 16.0, "ram_peak_gb": 40,+ "label": "Medium",+ "subtitle": "~5 epochs · rank 8 · 384px · max 300 steps",+ "checkpoint_interval": 100,+ "max_steps": 300, "max_rank": 8, "max_resolution": 384,+ "target_modules": compact_modules},+ "high": {"epochs": 10, "rank": 8, "lr": 1e-4, "resolution": 448,+ "seconds_per_step": 20.0, "ram_peak_gb": 44,+ "label": "High",+ "subtitle": "~10 epochs · rank 8 · 448px · max 500 steps",+ "checkpoint_interval": 100,+ "max_steps": 500, "max_rank": 8, "max_resolution": 448,+ "target_modules": compact_modules},+ })+ return {+ "key": "compact_training",+ "label": "48 GB safe training",+ "ram_gb": round(float(total_ram_gb or 0), 1),+ "tier": tier_key,+ "compact": True,+ "max_rank": 8,+ "max_resolution": 448,+ "max_steps": 500,+ "target_modules": compact_modules,+ "note": (+ "Training uses compact LoRA settings on 48 GB-class Macs to "+ "avoid MLX swap thrash."+ ),+ }+ return {+ "key": "full_training",+ "label": "Full training",+ "ram_gb": round(float(total_ram_gb or 0), 1),+ "tier": tier_key,+ "compact": False,+ # >=64 GB: these are generous *ceilings*, not a throttle. Memory-+ # constrained Macs are already protected by the compact profile above;+ # on big-memory machines the caps only catch runaway/stale values, so+ # documented power-user runs still work — the 1024x576 widescreen recipe+ # and long high-step runs (the old "20000 steps honored" behavior).+ # (Adopting @anubissbe's PR #31 — its full_training caps were 768px /+ # 7000 steps and applied to every ≥64 GB machine; scoped up here.)+ "max_rank": 64,+ "max_resolution": 1024,+ "max_steps": 20000,+ "target_modules": list(TRAIN_TARGET_MODULES_DEFAULT),+ }++# Train-type values accepted by /train/start and stamped onto job params.TRAIN_TYPES = ("character", "style")@@ -1956,6 +2166,100 @@ def list_characters() -> list[dict]:return out+# ---- Shipped sample character ------------------------------------------------+# So a new user can try Character / Remix WITHOUT training a LoRA first (the #1+# barrier to trying the feature — nobody wants to spend an hour training before+# they know it even works). Hosted as a GitHub release asset on the public repo.+# The SERVER owns the URL — clients only trigger the fetch; this is not a generic+# downloader. Lands in mlx_models/loras/ where list_characters() discovers it by+# the <trigger>_v2.safetensors convention (→ shows up as "Bizarro").+SAMPLE_CHARACTER = {+ "trigger": "bizarrotrn",+ "name": "Bizarro (sample)",+ "filename": "bizarrotrn_v2.safetensors",+ "url": ("https://github.com/mrbizarro/phosphene/releases/download/"+ "sample-character-bizarro/bizarrotrn_v2.safetensors"),+ "sha256": "a52e648a4e3edccd279363acdc85337d1d9813ca5dab30f8948f79393a4ba615",+ "size_bytes": 855966824,+}++_sample_char_lock = threading.Lock()+# status: idle | downloading | done | error+_sample_char_state: dict = {"status": "idle", "mb": 0,+ "total_mb": SAMPLE_CHARACTER["size_bytes"] // (1 << 20),+ "error": None}+++def _set_sample_state(**kw) -> None:+ """Rebind-free state update (mutate in place under the lock) so no route+ needs a `global` declaration."""+ with _sample_char_lock:+ _sample_char_state.clear()+ _sample_char_state.update(kw)+++def _sample_character_present() -> bool:+ # Existence-only (NOT a size match): if any bizarrotrn_v2.safetensors is on+ # disk — ours or a user's own — the character already shows in the picker,+ # and we must never overwrite it.+ try:+ return (_safe_loras_dir() / SAMPLE_CHARACTER["filename"]).is_file()+ except OSError:+ return False+++def _download_sample_character_bg() -> None:+ """Stream the sample character LoRA into mlx_models/loras/ in a daemon+ thread. Atomic (.partial → rename) + sha256-verified, so a mid-download kill+ or a corrupt transfer never leaves a file list_characters() would pick up."""+ import urllib.request+ import hashlib+ spec = SAMPLE_CHARACTER+ total_mb = spec["size_bytes"] // (1 << 20)+ tmp: Path | None = None+ try:+ loras_dir = _safe_loras_dir()+ loras_dir.mkdir(parents=True, exist_ok=True)+ target = loras_dir / spec["filename"]+ if target.is_file():+ # Never clobber an existing bizarrotrn_v2 (ours from a prior run, or+ # a user who trained their own with that trigger). It already lists.+ _set_sample_state(status="done", mb=total_mb, total_mb=total_mb, error=None)+ return+ tmp = target.with_suffix(target.suffix + ".partial")+ push(f"[sample-character] downloading {spec['name']} (~{total_mb} MB)…")+ req = urllib.request.Request(spec["url"], headers={"User-Agent": "Phosphene"})+ h = hashlib.sha256()+ written = 0+ last_log = 0.0+ with urllib.request.urlopen(req, timeout=60) as resp, open(tmp, "wb") as fh:+ while True:+ chunk = resp.read(1 << 20)+ if not chunk:+ break+ fh.write(chunk)+ h.update(chunk)+ written += len(chunk)+ now = time.time()+ if now - last_log > 2.5:+ _set_sample_state(status="downloading", mb=written // (1 << 20),+ total_mb=total_mb, error=None)+ last_log = now+ if h.hexdigest() != spec["sha256"]:+ raise RuntimeError("checksum mismatch (download corrupt) — please retry")+ tmp.replace(target)+ _set_sample_state(status="done", mb=total_mb, total_mb=total_mb, error=None)+ push(f"[sample-character] installed → character '{spec['trigger']}' ({spec['name']})")+ except Exception as e: # noqa: BLE001+ if tmp is not None:+ try:+ tmp.unlink()+ except OSError:+ pass+ _set_sample_state(status="error", mb=0, total_mb=total_mb, error=str(e)[:200])+ push(f"[sample-character] FAILED: {e}")++def _character_lora_basenames() -> set[str]:"""Collect basenames of files that belong to a TRAINED character bundle —face LoRA, audio LoRA, voice clip. Used by the Manual-tab LoRA picker to@@ -3832,7 +4136,9 @@ CAPABILITIES: dict[str, dict] = {},},"standard": {- # 48–79 GB. 64 GB M-Studio is the canonical hardware here.+ # 48–79 GB. 64 GB M-Studio is the canonical video-render baseline,+ # but 48 GB systems still need a separate compact profile for LoRA+ # training because backward activations are heavier than inference."label": "Comfortable","ram_label": "48–79 GB","tagline": "Every mode works · larger modes capped at 768 px",@@ -3844,14 +4150,14 @@ CAPABILITIES: dict[str, dict] = {"allows_keyframe": True,"allows_extend": True,"blurb": (- "This is the 64 GB tier — the panel was built and tuned on "- "exactly this hardware. Every mode works. Text-to-video and "- "image-to-video run at the full 1280×704. The two biggest "- "modes (first-last-frame interpolation and extending an "- "existing clip) cap their video size at 768 pixels on the "- "longer side because the bigger model behind them runs out "- "of memory above that. 768 is a sweet-spot working size; "- "you can run a separate upscaler afterwards if you need 720p+."+ "This Mac has 48–79 GB of unified memory. Every video mode "+ "works. Text-to-video and image-to-video run at the full "+ "1280×704. The two biggest modes (first-last-frame "+ "interpolation and extending an existing clip) cap their "+ "video size at 768 pixels on the longer side because the "+ "bigger model behind them runs out of memory above that. "+ "48 GB machines use a compact LoRA training profile so "+ "training does not fall into multi-hour swap thrash."),# Times are measured wall clocks for a 5 s render (121 frames @ 24 fps)# at Exact speed, on the canonical Comfortable hardware (M-Studio /@@ -3953,6 +4259,21 @@ CAPABILITIES: dict[str, dict] = {}+def _detect_total_ram_gb() -> float:+ """Return physical unified memory in GiB, or 0.0 when unavailable."""+ try:+ out = subprocess.run(+ ["sysctl", "-n", "hw.memsize"],+ capture_output=True, text=True, timeout=1,+ ).stdout.strip()+ return int(out) / 1024**3+ except Exception:+ return 0.0+++SYSTEM_RAM_GB = _detect_total_ram_gb()++def _detect_tier() -> str:"""Pick a tier based on `hw.memsize`. Cached at module load — RAM isfixed at boot. LTX_TIER_OVERRIDE env var lets advanced users force a@@ -3960,13 +4281,8 @@ def _detect_tier() -> str:override = os.environ.get("LTX_TIER_OVERRIDE", "").strip().lower()if override in CAPABILITIES:return override- try:- out = subprocess.run(- ["sysctl", "-n", "hw.memsize"],- capture_output=True, text=True, timeout=1,- ).stdout.strip()- gb = int(out) / 1024**3- except Exception:+ gb = SYSTEM_RAM_GB+ if gb <= 0:return "standard" # safe defaultif gb < 48: return "base"if gb < 80: return "standard"@@ -3976,6 +4292,116 @@ def _detect_tier() -> str:SYSTEM_TIER = _detect_tier()SYSTEM_CAPS = CAPABILITIES[SYSTEM_TIER]+TRAIN_PROFILE = _select_train_profile(SYSTEM_RAM_GB, SYSTEM_TIER)+++def _select_generation_profile(total_ram_gb: float, tier_key: str) -> dict:+ """Hardware profile for video generation, separate from render tier labels.++ A 48 GB M5 Pro can run the model, but long native 24 fps clips plus large+ LoRA stacks push unified memory into swap. The regular `standard` tier is+ still correct for feature availability; this profile only changes how new+ T2V/I2V jobs are shaped so they do not start in the pathological state the+ current live render hit.+ """+ if 0 < float(total_ram_gb or 0) < 64:+ return {+ "key": "m5pro48_generation",+ "label": "48 GB fast generation",+ "ram_gb": round(float(total_ram_gb or 0), 1),+ "tier": tier_key,+ "compact": True,+ "max_dim": 1024,+ "auto_temporal_after_frames": 241,+ "warn_loras": 6,+ "note": (+ "Long Q4 T2V/I2V renders use 12->24 fps generation on "+ "48 GB-class Macs to avoid MLX swap thrash."+ ),+ }+ return {+ "key": "full_generation",+ "label": "Full generation",+ "ram_gb": round(float(total_ram_gb or 0), 1),+ "tier": tier_key,+ "compact": False,+ "max_dim": 0,+ "auto_temporal_after_frames": 0,+ "warn_loras": 0,+ }+++GENERATION_PROFILE = _select_generation_profile(SYSTEM_RAM_GB, SYSTEM_TIER)+++def _scale_dims_to_max(width: int, height: int, max_dim: int,+ *, align: int = 32) -> tuple[int, int]:+ """Scale dimensions down to max_dim while preserving aspect and alignment."""+ if max_dim <= 0 or max(width, height) <= max_dim:+ return width, height+ scale = max_dim / float(max(width, height))+ new_w = max(align, int(round((width * scale) / align)) * align)+ new_h = max(align, int(round((height * scale) / align)) * align)+ return new_w, new_h+++def _apply_generation_profile_to_job(job: dict) -> None:+ """Clamp new video jobs for the active generation profile.++ This is intentionally server-side. The browser may be stale, Load Params+ can replay older sidecars, and external callers can post directly to+ /queue/add. Any of those paths must still avoid a 48 GB machine accepting+ a long native 24 fps render that immediately falls into swap.+ """+ profile = GENERATION_PROFILE+ params = job.get("params") or {}+ params["generation_profile"] = profile.get("key")+ params["generation_profile_label"] = profile.get("label")+ if not profile.get("compact"):+ return+ mode = (params.get("mode") or "").lower()+ quality = (params.get("quality") or "balanced").lower()+ if mode not in ("t2v", "i2v", "i2v_clean_audio", "a2v"):+ return+ notes: list[str] = list(params.get("generation_clamp_notes") or [])+ new_notes: list[str] = []+ try:+ width = int(params.get("width") or 0)+ height = int(params.get("height") or 0)+ frames = int(params.get("frames") or 0)+ except (TypeError, ValueError):+ return++ # Q4 one-stage jobs are the common fast path and support Long Clip Boost.+ # Q8 High has a different sampler and does not support the 12->24 fps path,+ # so leave High alone rather than silently changing requested quality.+ if quality != "high":+ max_dim = int(profile.get("max_dim") or 0)+ new_w, new_h = _scale_dims_to_max(width, height, max_dim)+ if (new_w, new_h) != (width, height):+ params["width"], params["height"] = new_w, new_h+ new_notes.append(f"resolution {width}x{height} -> {new_w}x{new_h}")++ auto_after = int(profile.get("auto_temporal_after_frames") or 0)+ if (mode in ("t2v", "i2v") and auto_after and frames > auto_after+ and (params.get("temporal_mode") or "native") == "native"):+ params["temporal_mode"] = "fps12_interp24"+ approx = round(_frames_to_model_duration(frames, FPS), 1)+ new_notes.append(+ f"Long Clip Boost auto-enabled for {frames}f (~{approx}s)"+ )++ warn_loras = int(profile.get("warn_loras") or 0)+ lora_count = len(params.get("loras") or [])+ if warn_loras and lora_count > warn_loras:+ new_notes.append(+ f"{lora_count} LoRAs selected; large stacks are slower on 48 GB"+ )+ for note in new_notes:+ if note not in notes:+ notes.append(note)+ if notes:+ params["generation_clamp_notes"] = notesdef tier_max_dim(kind: str) -> int:@@ -4192,6 +4618,139 @@ def _ensure_downscaled(src: Path, max_dim: int = 768, align: int = 32) -> Path:return cached+# ============================================================================+# Ingredients (multi-reference) — sheet compositing + conditioning clip+# ============================================================================+# The Ingredients IC-LoRA conditions on a single "reference sheet" image: the+# 2-8 subject images tiled into one frame. That sheet, repeated to N frames, is+# the IC `video_conditioning`. Both helpers below are faithful ports of the+# public Space ltx-community/ltx-2.3-ingredients-distilled (compose_sheet /+# _fit_contain / _sheet_to_video) — the SAME 1536x896 canvas, ceil(sqrt(N))+# grid, 16px gutter, aspect-preserving contain-pad (nothing cropped). The only+# deviation: we loop the sheet PNG into the clip with ffmpeg (the panel's+# resolver) instead of imageio, which isn't in the venv.++def _fit_contain_cell(im, cw: int, ch: int, bg=(0, 0, 0)):+ """Scale `im` to fit fully inside (cw, ch) keeping aspect, center on a+ padded cell. Unlike a cover-crop, nothing is cropped off. Port of the+ Space's `_fit_contain`."""+ from PIL import Image, ImageOps+ fitted = ImageOps.contain(im, (cw, ch), Image.LANCZOS)+ cell = Image.new("RGB", (cw, ch), bg)+ cell.paste(fitted, ((cw - fitted.width) // 2, (ch - fitted.height) // 2))+ return cell+++def _compose_ingredient_sheet(image_paths: list[str], out_path: Path) -> Path:+ """Tile 2-8 reference images into ONE sheet PNG at `out_path`.++ Faithful port of the Space's `compose_sheet`: 1536x896 black canvas,+ cols = ceil(sqrt(N)), rows = ceil(N/cols), 16px gutter, each cell+ aspect-preserved + centered (no crop). A single image is written through+ unchanged (resized only by the conditioning step). Returns `out_path`."""+ import math+ from PIL import Image+ paths = [p for p in (image_paths or []) if p and Path(p).exists()]+ if not paths:+ raise RuntimeError(+ "Ingredients needs at least one reference image. Upload 2-8 "+ "subjects (a face + a prop + a location) in the Ingredients picker."+ )+ imgs = [Image.open(p).convert("RGB") for p in paths]+ out_path.parent.mkdir(parents=True, exist_ok=True)+ if len(imgs) == 1:+ imgs[0].save(out_path, format="PNG")+ return out_path+ BG = (0, 0, 0)+ CW, CH = 1536, 896+ canvas = Image.new("RGB", (CW, CH), BG)+ cols = math.ceil(math.sqrt(len(imgs)))+ rows = math.ceil(len(imgs) / cols)+ g = 16+ cw = (CW - g * (cols + 1)) // cols+ ch = (CH - g * (rows + 1)) // rows+ for i, im in enumerate(imgs):+ r, c = divmod(i, cols)+ canvas.paste(_fit_contain_cell(im, cw, ch, BG),+ (g + c * (cw + g), g + r * (ch + g)))+ canvas.save(out_path, format="PNG")+ return canvas if False else out_path+++def _sheet_to_conditioning_clip(sheet_png: Path, width: int, height: int,+ num_frames: int, out_path: Path) -> Path:+ """Resize the sheet PNG to (width, height) and loop it into an N-frame+ lossless mp4 at `out_path` — the IC `video_conditioning` the Ingredients+ LoRA reads. Port of the Space's `_sheet_to_video` (sheet repeated to+ num_frames), written via ffmpeg instead of imageio.++ yuv444p + crf 0 matches the panel's lossless reference codec so the+ conditioning frames aren't chroma-subsampled. Atomic .partial rename."""+ out_path.parent.mkdir(parents=True, exist_ok=True)+ partial = out_path.with_suffix(out_path.suffix + ".partial")+ # `-loop 1 -framerate FPS -i sheet.png -frames:v N` emits exactly N+ # identical frames. `-f mp4` is mandatory because of the .partial suffix+ # (same ffmpeg autodetect gotcha as _ensure_downscaled).+ cmd = [str(FFMPEG), "-y",+ "-loop", "1", "-framerate", str(int(FPS)), "-i", str(sheet_png),+ "-t", f"{max(1, num_frames) / float(FPS):.4f}",+ "-frames:v", str(max(1, int(num_frames))),+ "-vf", f"scale={int(width)}:{int(height)}",+ "-c:v", "libx264", "-pix_fmt", "yuv444p", "-crf", "0",+ "-preset", "veryfast",+ "-f", "mp4",+ str(partial)]+ try:+ subprocess.run(cmd, check=True, capture_output=True, timeout=180)+ os.replace(partial, out_path)+ except Exception:+ try:+ partial.unlink()+ except FileNotFoundError:+ pass+ raise+ return out_path+++def _ensure_ingredients_lora() -> str:+ """Return a local path to the Ingredients IC-LoRA .safetensors.++ Resolution order:+ 1. The installer-fetched local file (CURATED_LORAS["ingredients"]+ .local_path) — the fast path on a complete install.+ 2. A TARGETED single-file fetch of just the ingredients weight from the+ un-gated mirror (DeepBeepMeep/LTX-2 → repo_file) via hf_hub_download,+ copied into mlx_models/loras/ic/. This is the self-heal path when the+ install/update best-effort fetch didn't land.++ Critically, this NEVER hands the bare mirror repo_id to the helper's+ _resolve_lora_path, because DeepBeepMeep/LTX-2 is a ~708 GB mega-repo and a+ snapshot_download of it (largest-file pick) would try to pull everything.+ Returns a filesystem path the helper can fuse directly."""+ meta = CURATED_LORAS["ingredients"]+ local = meta.get("local_path") or ""+ if local and Path(local).exists() and Path(local).stat().st_size > 1024:+ return local+ repo_id = meta["repo_id"]+ repo_file = meta["repo_file"]+ dest_dir = LORAS_DIR / "ic"+ dest_dir.mkdir(parents=True, exist_ok=True)+ dest = dest_dir / repo_file+ if dest.exists() and dest.stat().st_size > 1024:+ return str(dest)+ push(f"Ingredients IC-LoRA not on disk — fetching just {repo_file} "+ f"(~1.3 GB) from {repo_id} (un-gated)…")+ from huggingface_hub import hf_hub_download+ # Pull ONLY this one file. local_dir places it directly under ic/ so it+ # matches local_path on the next run (no symlink-into-cache surprise).+ got = hf_hub_download(+ repo_id=repo_id,+ filename=repo_file,+ local_dir=str(dest_dir),+ )+ return str(got)++def list_uploads(limit: int = 40) -> list[dict]:"""Return recent panel_uploads/* images sorted by mtime descending.@@ -5177,25 +5736,16 @@ def _new_job_id() -> str:def _validate_character_quality(form: dict[str, list[str]] | dict[str, str]) -> str | None:- """Defense-in-depth: when a character_id is set, the job must route- through the Q8 HQ pipeline (quality=high). Q4 distilled inference- fuses dev-trained character LoRAs into the wrong base (mismatched- sigma schedule) and produces a generic-everyone-looks-vaguely-like- -them result — confirmed empirically 2026-05-17 with the chartest- Q4-Balanced runs.-- The UI already prevents the bad combination by swapping the quality- strip to Q8-only when a character chip is selected, but a stale- form payload, a scripted /queue/batch caller, or a future tab that- forgets the chip-swap logic could submit the broken combo. Returning- an error keeps the trainer-base contract honest at the API boundary.-- Also catches the loras=[] back-door: a scripted POST with a raw- train_character-kind LoRA in the `loras` JSON array (no character_id)- + quality=balanced would otherwise bypass this check — the UI's- updateQualityChipsForLora handles it client-side but the server- must enforce the same rule.-+ """Character mode is available on Q4 — LoRAs fuse into the distilled+ base (identity match is mediocre per 2026-05-17 empirical test with+ the chartest Q4-Balanced runs, but the render completes). When Q8 is+ installed and the user picks quality=high, the Q8 HQ pipeline is used+ and yields faithful identity.++ This function still catches the loras=[] back-door: a scripted POST+ with a raw train_character-kind LoRA in the `loras` JSON array (no+ character_id) + a non-high quality asserts a character LoRA against+ the Q4 base, which produces the same mediocre-identity result.Returns None when valid, or an error string to surface as a 400."""def _f(name: str, default: str = "") -> str:v = form.get(name, default)@@ -5205,21 +5755,15 @@ def _validate_character_quality(form: dict[str, list[str]] | dict[str, str]) ->quality = _f("quality", "balanced").lower()cid = _f("character_id", "")if cid:- if quality != "high":- return (- f"character {cid!r} requires quality=high (Q8 HQ pipeline). "- f"Got quality={quality!r}. Character LoRAs are trained against "- f"the Q8 dev transformer's sigma schedule; the Q4 distilled "- f"pipeline fuses them into the wrong base and produces "- f"identity-mushed output. Pick Q8 Pro or Q8 Draft in the "- f"Character quality strip."- )+ # Character mode on Q4 submits with Quick/Balanced/Standard.+ # The identity match is imperfect but it renders and does not+ # error. Q8 users who pick quality=high get the full fidelity+ # path — no enforcement needed.return None# No character_id — but a raw train_character LoRA in `loras` triggers- # the same incompatibility. Resolve each entry's sidecar and refuse if- # any one of them is kind == "train_character" and quality != high.- if quality == "high":- return None # the only outcome that needs to fail is non-high here+ # the same quality concern. 2026-06-26: we allow it on Q4 (same+ # mediocre-identity trade-off the user accepted by enabling character+ # mode). Log a note but do not block.try:loras = parse_loras_from_form(form)except Exception:@@ -5233,13 +5777,8 @@ def _validate_character_quality(form: dict[str, list[str]] | dict[str, str]) ->except Exception:continueif (meta.get("kind") or "") == "train_character":- return (- f"a character LoRA ({p.name!r}) requires quality=high "- f"(Q8 HQ pipeline). Got quality={quality!r}. Character LoRAs "- f"are trained against the Q8 dev transformer's sigma schedule; "- f"the Q4 distilled pipeline fuses them into the wrong base "- f"and produces identity-mushed output. Pick Q8 Pro or Q8 Draft."- )+ log_push(f"[character] raw train_character LoRA {p.name!r} at quality={quality!r} "+ f"on Q4 base — identity match may be imperfect")return None@@ -5313,6 +5852,52 @@ def make_job(form: dict[str, list[str]] | dict[str, str], *,resolution = _int_or("resolution", cfg["resolution"])train_width = _int_or("width", 0) or resolutiontrain_height = _int_or("height", 0) or resolution+ clamp_notes: list[str] = []+ # Hardware training profile clamps. These are server-side on purpose:+ # a stale browser tab can still post the old 512px/rank-32/10000-step+ # advanced values. Without this guard a 48 GB Mac accepts the request,+ # then spends hours in MLX/Metal swap thrash.+ try:+ max_rank = int(cfg.get("max_rank") or TRAIN_PROFILE.get("max_rank") or 0)+ except (TypeError, ValueError):+ max_rank = 0+ if max_rank > 0 and rank > max_rank:+ clamp_notes.append(f"rank {rank} -> {max_rank}")+ rank = max_rank+ try:+ max_steps = int(cfg.get("max_steps") or TRAIN_PROFILE.get("max_steps") or 0)+ except (TypeError, ValueError):+ max_steps = 0+ if max_steps > 0 and steps > max_steps:+ clamp_notes.append(f"steps {steps} -> {max_steps}")+ steps = max_steps+ try:+ max_resolution = int(cfg.get("max_resolution") or+ TRAIN_PROFILE.get("max_resolution") or 0)+ except (TypeError, ValueError):+ max_resolution = 0+ if max_resolution > 0 and max(train_width, train_height, resolution) > max_resolution:+ old_dims = (train_width, train_height)+ if train_width == train_height:+ train_width = train_height = max_resolution+ else:+ scale = max_resolution / float(max(train_width, train_height))+ align = 32+ train_width = max(align, int(round((train_width * scale) / align)) * align)+ train_height = max(align, int(round((train_height * scale) / align)) * align)+ resolution = min(resolution, max_resolution)+ clamp_notes.append(+ f"resolution {old_dims[0]}x{old_dims[1]} -> {train_width}x{train_height}"+ )+ raw_modules = cfg.get("target_modules") or TRAIN_PROFILE.get("target_modules")+ allowed_modules = set(TRAIN_TARGET_MODULES_DEFAULT)+ if isinstance(raw_modules, str):+ target_modules = [x.strip() for x in raw_modules.split(",") if x.strip()]+ else:+ target_modules = list(raw_modules or TRAIN_TARGET_MODULES_DEFAULT)+ target_modules = [m for m in target_modules if m in allowed_modules]+ if not target_modules:+ target_modules = list(TRAIN_TARGET_MODULES_DEFAULT)caption_strategy = (f("caption_strategy", "trigger_simple")or "trigger_simple").lower()# Crop strategy for the training preprocess.@@ -5373,11 +5958,16 @@ def make_job(form: dict[str, list[str]] | dict[str, str], *,"preset": preset,"trigger": trigger,"rank": rank,+ "alpha": rank,"steps": steps,"lr": lr,"resolution": resolution,"width": train_width,"height": train_height,+ "target_modules": target_modules,+ "train_profile": TRAIN_PROFILE.get("key"),+ "train_profile_label": TRAIN_PROFILE.get("label"),+ "train_clamp_notes": clamp_notes,"caption_strategy": caption_strategy,"crop_strategy": crop_strategy,"image_count": image_count,@@ -5558,6 +6148,32 @@ def make_job(form: dict[str, list[str]] | dict[str, str], *,"audio": f("audio", str(AUDIO_DEFAULT)),# extend mode params"video_path": f("video_path", ""),+ # restore (Colorize) mode — the B&W source clip to colorize. MUST+ # be in this allowlist or the path silently no-ops on /queue/add+ # (the known make_job allowlist trap — see CLAUDE.md).+ "restore_video_path": f("restore_video_path", ""),+ # ingredients (multi-reference) mode — JSON list of 2-8 uploaded+ # image paths + the action description. SAME allowlist trap: both+ # MUST be here or they silently no-op on /queue/add (the panel UI+ # posts there). `prompt` above carries the SHEET description.+ "ingredient_images_json": f("ingredient_images_json", ""),+ "ingredient_action": f("ingredient_action", ""),+ # Ingredients × Character — OPTIONAL trained character LoRA stacked+ # ON TOP of the Ingredients IC-LoRA so the SAME trained face lands in+ # every composed scene (identity from the LoRA, not a face photo).+ # The differentiating feature — see the ingredients dispatch where+ # these get fused into `ingredients_loras` at char strength while+ # ref-strength stays 0.0. SAME allowlist trap: must be here or they+ # silently no-op on /queue/add. Empty `ingredient_char_lora` = the+ # plain (no-character) path, byte-identical to before.+ "ingredient_char_lora": f("ingredient_char_lora", ""),+ "ingredient_char_strength": f("ingredient_char_strength", "1.3"),+ "ingredient_char_trigger": f("ingredient_char_trigger", ""),+ # control (Union) mode — the RAW-RGB control clip whose+ # motion/structure/composition drives the render. SAME allowlist+ # trap: this MUST be here or it silently no-ops on /queue/add (the+ # panel UI posts there). `prompt` carries the new subject/scene.+ "control_video_path": f("control_video_path", ""),"extend_frames": max(1, int(f("extend_frames", "5") or 5)),"extend_direction": f("extend_direction", "after"),"extend_steps": max(1, int(f("extend_steps", "8") or 8)),@@ -5635,12 +6251,31 @@ def make_job(form: dict[str, list[str]] | dict[str, str], *,# 48-79 GB tier to dodge boundary OOM). User can override# explicitly to "full" or "off" via this form field."stage2_image_conditioning": f("stage2_image_conditioning", "") or "",+ "audio_conditioning_scale": float(f("audio_conditioning_scale", "1.0") or 1.0),},"command": None,"raw_path": None,"output_path": None,"error": None,}+ # STG (Spatio-Temporal Guidance) — "detail guidance" slider. Only stamp+ # `stg_scale` onto params when the form actually sent a value, so each+ # dispatch keeps its OWN default when the user didn't touch the slider:+ # - generate_hq reads p.get("stg_scale", 0.0) → HQ STG off by default+ # - generate_a2v reads p.get("stg_scale", 1.0) → A2V STG on by default+ # Forcing a key here would clobber the A2V default to 0.0 and silently+ # turn A2V STG off — hence the conditional. STG only acts on the Q8 CFG+ # pipelines (HQ / A2V); the Q4 distilled paths (Quick/Standard/Balanced)+ # run X0Model with no guider and ignore it entirely. Clamp to the guider's+ # sane band 0.0–4.0. This key MUST be set on params or it silently no-ops+ # on /queue/add (the known allowlist trap), which is exactly why the panel+ # JS only sends it on quality=high and we mirror that intent here.+ _stg_raw = f("stg_scale", "")+ if _stg_raw != "":+ try:+ job["params"]["stg_scale"] = max(0.0, min(4.0, float(_stg_raw)))+ except (TypeError, ValueError):+ pass# Attach Characters-origin metadata only when the form actually carried# it. Keeps the params shape unchanged for every other entry point.if _source == "characters" and _character_id:@@ -5722,6 +6357,8 @@ def make_job(form: dict[str, list[str]] | dict[str, str], *,# exact slider value (defaults to 1.0 on the picker).job["params"].setdefault("character_strength", char_strength)+ _apply_generation_profile_to_job(job)+lora_artifact_neg = _lora_artifact_negative_prompt(job["params"].get("loras") or [])if lora_artifact_neg:existing_neg = str(job["params"].get("negative_prompt") or "").strip()@@ -6202,6 +6839,16 @@ def run_train_job_inner(job: dict) -> None:trigger = p.get("trigger") or _suggest_trigger_token()caption_strategy = p.get("caption_strategy", "trigger_simple")preset_table = TRAIN_STYLE_PRESETS if is_style else TRAIN_PRESETS+ clamp_notes = p.get("train_clamp_notes") or []+ profile_label = p.get("train_profile_label") or TRAIN_PROFILE.get("label")+ if profile_label:+ push(f"[train] profile: {profile_label}")+ if clamp_notes:+ push("[train] hardware clamps applied: " + "; ".join(map(str, clamp_notes)))+ target_modules = p.get("target_modules") or preset_table.get(preset, {}).get("target_modules")+ if not target_modules:+ target_modules = list(TRAIN_TARGET_MODULES_DEFAULT)+ push("[train] LoRA target modules: " + ", ".join(map(str, target_modules)))# ---- Captions -------------------------------------------------------# Two paths into this block:@@ -6314,8 +6961,12 @@ def run_train_job_inner(job: dict) -> None:"trigger": trigger,"preset": preset,"rank": p.get("rank"),+ "alpha": p.get("alpha") or p.get("rank"),"steps": p.get("steps"),"lr": p.get("lr"),+ "target_modules": target_modules,+ "train_profile": p.get("train_profile"),+ "train_profile_label": profile_label,# `resolution` is the legacy v2 field — keep it for back-compat# (some external tools still read it). For widescreen training# we just write the width into this slot; consumers reading@@ -6770,10 +7421,13 @@ def run_job_inner(job: dict) -> None:return run_image_job_inner(job)if mode == "train":return run_train_job_inner(job)+ _apply_generation_profile_to_job(job)+ for note in p.get("generation_clamp_notes") or []:+ push(f"[generation] {p.get('generation_profile_label')}: {note}")quality = p.get("quality", "standard")if p.get("accel") not in ("off", "boost", "turbo"):p["accel"] = "off"- if quality == "high" or mode in ("extend", "keyframe", "a2v"):+ if quality == "high" or mode in ("extend", "keyframe", "a2v", "restore", "ingredients", "control"):p["accel"] = "off"# Guard: Q4 distilled hardcoded 9-sigma schedule needs the full walk to@@ -6784,7 +7438,7 @@ def run_job_inner(job: dict) -> None:# - extend / keyframe use stage1_steps + stage2_steps via two-stage path# - high quality uses two-stage HQ with its own schedule# - a2v uses A2VidPipelineTwoStage's stage1/stage2 walks- if mode not in ("extend", "keyframe", "a2v") and quality != "high" and int(p.get("steps", 8)) < 8:+ if mode not in ("extend", "keyframe", "a2v", "restore", "ingredients", "control") and quality != "high" and int(p.get("steps", 8)) < 8:raise RuntimeError(f"steps={p.get('steps')} is below the 8-step minimum for the Q4 distilled ""schedule. Fewer steps truncates the sigma walk and leaves >70% noise in "@@ -6908,6 +7562,469 @@ def run_job_inner(job: dict) -> None:subprocess.run(["open", str(final_out)], check=False)return+ if mode == "control":+ # Control (Union) — drive a render's motion / structure / composition+ # from a control video, via the OFFICIAL un-gated Union-Control IC-LoRA.+ # Structurally IDENTICAL to the Colorize (restore) branch — validate a+ # source clip, force the Q4 distilled folder (the LoRA was trained+ # against Q4 distilled), inject the curated union-control LoRA, ride the+ # control clip on the IC reference channel, dispatch via+ # HELPER.run(generate_restore) (two-stage). The ONE deliberate+ # difference vs Ingredients: the reference STRENGTH is a FOLLOW value+ # (~1.0), NOT the 0.0 Ingredients uses. Control WANTS to follow the+ # driving structure (recon A/B proved raw RGB @1.0 transfers+ # composition); Ingredients wants to RECOMPOSE away from its sheet.+ # Default off — no other mode changes.+ src = p.get("control_video_path") or ""+ if not src or not Path(src).exists():+ raise RuntimeError(+ f"control video not found: {src!r}. Pick a clip in the Control "+ "video picker (or paste a path) whose motion/structure should "+ "drive the render."+ )+ # Resolution clamp — same shape as Colorize/Extend. Control runs the+ # distilled two-stage walk; keep the source within the tier's max side+ # so the VAE encode + denoise fits memory. Cached by target dims.+ original_src = Path(src)+ res_max = tier_max_dim("i2v")+ if res_max:+ downscaled_src = _ensure_downscaled(original_src, max_dim=res_max)+ if downscaled_src != original_src:+ push(f"Control: control clip {original_src.name} downscaled to "+ f"{downscaled_src.name} (≤{res_max} max-side, "+ f"{SYSTEM_CAPS['label']} tier).")+ src = str(downscaled_src)+ # Match the output canvas to the (possibly downscaled) control clip so+ # the IC reference and the generated frames line up. The Union weight+ # carries reference_downscale_factor=2 — the IC encoder halves the+ # reference internally (iclora_utils), so we feed the FULL output dims+ # here (the encoder does the /2), exactly as Colorize does. Same+ # ffprobe wrapper the rest of the panel uses (returns (0,0) on failure+ # → fall back to the form's width/height). Runs BEFORE the shared+ # width/height/frames locals further down, so read straight off `p`.+ req_w = int(p.get("width") or 0)+ req_h = int(p.get("height") or 0)+ req_frames = int(p.get("frames") or 0) or 49+ sw, sh = _probe_video_dims(src)+ # LTX requires width/height multiples of 32 and frames % 8 == 1.+ ctl_w = max(32, (int(sw) // 32) * 32) if sw else max(32, req_w)+ ctl_h = max(32, (int(sh) // 32) * 32) if sh else max(32, req_h)+ ctl_frames = req_frames+ if ctl_frames % 8 != 1:+ ctl_frames = max(9, ctl_frames - (ctl_frames % 8) + 1)+ ctl_meta = CURATED_LORAS["union-control"]+ strength = float(ctl_meta["default_strength"])+ # Prefer the local file the installer fetched; fall back to repo_id so+ # the helper's _resolve_lora_path can snapshot_download it on first use.+ # (Unlike Ingredients, the Union repo is a clean single-file un-gated+ # repo — no mega-repo workaround needed, so the repo_id fallback is safe.)+ control_lora_path = ctl_meta.get("local_path") or ""+ if not (control_lora_path and Path(control_lora_path).exists()):+ control_lora_path = ctl_meta["repo_id"]+ control_loras = list(p.get("loras") or []) + [{+ "path": control_lora_path,+ "strength": strength,+ }]+ # IC reference STRENGTH — the FOLLOW lever (second element of each+ # video_conditioning tuple). VideoConditionByReferenceLatent holds the+ # reference latent with mask_value = 1.0 - strength: 1.0 = control clip+ # pinned pristine (render FOLLOWS its structure), 0.0 = fully denoisable+ # (Ingredients' recompose). Recon proved raw RGB @1.0 drives the+ # composition. Default 1.0; tunable via LTX_CONTROL_REF_STRENGTH for a+ # looser "inspired-by" follow; clamped to [0.0, 1.0].+ try:+ ctl_ref_strength = float(+ os.environ.get("LTX_CONTROL_REF_STRENGTH", "1.0"))+ except (TypeError, ValueError):+ ctl_ref_strength = 1.0+ ctl_ref_strength = max(0.0, min(1.0, ctl_ref_strength))+ out_name = original_src.stem + f"_control_{stamp}.mp4"+ final_out = OUTPUT / out_name+ job["raw_path"] = str(final_out)+ # Force the Q4 distilled folder — same rule HDR / Colorize / Ingredients+ # use. The Union-Control IC-LoRA was trained against the distilled+ # checkpoint.+ control_model_dir = (str(MODELS_DIR / "ltx-2.3-mlx-q4")+ if (MODELS_DIR / "ltx-2.3-mlx-q4").is_dir()+ else str(MODELS_DIR))+ job_spec = {+ "action": "generate_restore",+ "id": job["id"],+ "params": {+ "model_dir": control_model_dir,+ "prompt": p["prompt"],+ "negative_prompt": p.get("negative_prompt", ""),+ "output_path": str(final_out),+ "height": ctl_h,+ "width": ctl_w,+ "frames": ctl_frames,+ "frame_rate": float(FPS),+ "seed": p["seed"],+ # The control clip rides the IC reference channel at FOLLOW+ # strength (~1.0) so the render inherits its structure/motion.+ "video_conditioning": [[src, ctl_ref_strength]],+ "loras": control_loras,+ # Two-stage distilled walk (same as Colorize; NOT single-stage+ # like Ingredients).+ "stage1_steps": int(p.get("stage1_steps", 8)),+ "stage2_steps": int(p.get("stage2_steps", 3)),+ },+ }+ push(f"Control via helper: id={job['id']} ctl={original_src.name} "+ f"{ctl_w}x{ctl_h} {ctl_frames}f (Q4 distilled + Union-Control "+ f"IC-LoRA, LoRA strength {strength}, "+ f"ref/follow strength {ctl_ref_strength})")+ result = HELPER.run(job_spec)+ if "seed_used" in result:+ push(f"seed used: {result['seed_used']}")+ p["seed_used"] = result["seed_used"]+ sidecar = {+ "output": str(final_out), "raw_output": str(final_out),+ "params": {**p, "command": "control"},+ "started": job.get("started_at"),+ "elapsed_sec": round(time.time() - job["started_ts"], 2) if job.get("started_ts") else None,+ "fps": FPS, "model": control_model_dir, "queue_id": job["id"],+ "helper_elapsed_sec": result.get("elapsed_sec"),+ "output_codec": output_codec_settings(),+ }+ write_sidecar(final_out.with_suffix(final_out.suffix + ".json"), sidecar)+ job["output_path"] = str(final_out)+ push(f"Control done in {sidecar['elapsed_sec']}s → {final_out.name}")+ if p.get("open_when_done"):+ subprocess.run(["open", str(final_out)], check=False)+ return++ if mode == "restore":+ # Restore (Colorize) — B&W / desaturated source clip → colorized clip,+ # via the community Colorize IC-LoRA. Modeled on the EXTEND branch:+ # validate a source video, force the Q4 distilled folder (the LoRA was+ # trained against Q4 distilled, NOT Q8), inject the curated colorize+ # LoRA, ride the source on the IC reference channel, dispatch via+ # HELPER.run(generate_restore). Default off — no other mode changes.+ src = p.get("restore_video_path") or ""+ if not src or not Path(src).exists():+ raise RuntimeError(+ f"source video for Colorize not found: {src!r}. Pick a B&W clip "+ "in the Colorize source picker (or paste a path)."+ )+ # Resolution clamp — same shape as Extend. Restore runs the distilled+ # two-stage walk; keep the source within the tier's max side so the+ # VAE encode + denoise fits memory. Cached by target dims.+ original_src = Path(src)+ res_max = tier_max_dim("i2v")+ if res_max:+ downscaled_src = _ensure_downscaled(original_src, max_dim=res_max)+ if downscaled_src != original_src:+ push(f"Colorize: source {original_src.name} downscaled to "+ f"{downscaled_src.name} (≤{res_max} max-side, "+ f"{SYSTEM_CAPS['label']} tier).")+ src = str(downscaled_src)+ # Match the output canvas to the (possibly downscaled) source so the+ # IC reference and the generated frames line up. _probe_video_dims is+ # the same ffprobe wrapper the rest of the panel uses (returns (0,0)+ # on failure → fall back to the form's width/height). This branch runs+ # BEFORE the shared width/height/frames locals are computed further+ # down run_job_inner, so read straight off `p`.+ req_w = int(p.get("width") or 0)+ req_h = int(p.get("height") or 0)+ req_frames = int(p.get("frames") or 0) or 49+ sw, sh = _probe_video_dims(src)+ # LTX requires width/height multiples of 32 and frames % 8 == 1.+ col_w = max(32, (int(sw) // 32) * 32) if sw else max(32, req_w)+ col_h = max(32, (int(sh) // 32) * 32) if sh else max(32, req_h)+ col_frames = req_frames+ if col_frames % 8 != 1:+ col_frames = max(9, col_frames - (col_frames % 8) + 1)+ strength = float(CURATED_LORAS["colorize"]["default_strength"])+ # Prefer the local file the installer fetched; fall back to repo_id so+ # the helper's _resolve_lora_path can snapshot_download it on first use.+ colorize_lora_path = CURATED_LORAS["colorize"].get("local_path") or ""+ if not (colorize_lora_path and Path(colorize_lora_path).exists()):+ colorize_lora_path = CURATED_LORAS["colorize"]["repo_id"]+ restore_loras = list(p.get("loras") or []) + [{+ "path": colorize_lora_path,+ "strength": strength,+ }]+ out_name = original_src.stem + f"_colorized_{stamp}.mp4"+ final_out = OUTPUT / out_name+ job["raw_path"] = str(final_out)+ # Force the Q4 distilled folder — same rule HDR uses. The Colorize+ # IC-LoRA was trained against transformer-distilled.safetensors.+ restore_model_dir = (str(MODELS_DIR / "ltx-2.3-mlx-q4")+ if (MODELS_DIR / "ltx-2.3-mlx-q4").is_dir()+ else str(MODELS_DIR))+ job_spec = {+ "action": "generate_restore",+ "id": job["id"],+ "params": {+ "model_dir": restore_model_dir,+ "prompt": p["prompt"],+ "negative_prompt": p.get("negative_prompt", ""),+ "output_path": str(final_out),+ "height": col_h,+ "width": col_w,+ "frames": col_frames,+ "frame_rate": float(FPS),+ "seed": p["seed"],+ # The source clip rides the IC reference channel.+ "video_conditioning": [[src, strength]],+ "loras": restore_loras,+ # Distilled two-stage defaults (same as the HDR IC path).+ "stage1_steps": int(p.get("stage1_steps", 8)),+ "stage2_steps": int(p.get("stage2_steps", 3)),+ },+ }+ push(f"Colorize via helper: id={job['id']} src={original_src.name} "+ f"{col_w}x{col_h} {col_frames}f (Q4 distilled + Colorize IC-LoRA)")+ result = HELPER.run(job_spec)+ if "seed_used" in result:+ push(f"seed used: {result['seed_used']}")+ p["seed_used"] = result["seed_used"]+ sidecar = {+ "output": str(final_out), "raw_output": str(final_out),+ "params": {**p, "command": "restore"},+ "started": job.get("started_at"),+ "elapsed_sec": round(time.time() - job["started_ts"], 2) if job.get("started_ts") else None,+ "fps": FPS, "model": restore_model_dir, "queue_id": job["id"],+ "helper_elapsed_sec": result.get("elapsed_sec"),+ "output_codec": output_codec_settings(),+ }+ write_sidecar(final_out.with_suffix(final_out.suffix + ".json"), sidecar)+ job["output_path"] = str(final_out)+ push(f"Colorize done in {sidecar['elapsed_sec']}s → {final_out.name}")+ if p.get("open_when_done"):+ subprocess.run(["open", str(final_out)], check=False)+ return++ if mode == "ingredients":+ # Ingredients (multi-reference) — the FLAGSHIP IC-LoRA feature. 2-8+ # subject images (a face + a prop + a location) are composed into ONE+ # reference sheet, the sheet is looped to N frames as the IC+ # video_conditioning, and the model composes them into one new clip.+ # Reuses the generate_restore HELPER surface (same ICLoraPipeline ++ # Q4 distilled + reference channel) — the only differences are the+ # injected LoRA (Ingredients, strength 1.4), the single-stage recipe+ # (skip_stage_2=True), and the two-field prompt. Default off; no other+ # mode changes. Recipe matches the public Space+ # ltx-community/ltx-2.3-ingredients-distilled.+ try:+ image_paths = json.loads(p.get("ingredient_images_json") or "[]")+ if not isinstance(image_paths, list):+ image_paths = []+ except (ValueError, TypeError):+ image_paths = []+ image_paths = [str(x) for x in image_paths if x]+ if len(image_paths) < 2:+ raise RuntimeError(+ f"Ingredients needs 2-8 reference images (got {len(image_paths)}). "+ "Upload a face + a prop + a location in the Ingredients picker."+ )+ if len(image_paths) > 8:+ # The sheet stays readable up to 8 cells; trim extras rather than+ # erroring so a user who over-selected still gets a render.+ push(f"Ingredients: {len(image_paths)} images selected; using the first 8.")+ image_paths = image_paths[:8]+ missing = [ip for ip in image_paths if not Path(ip).exists()]+ if missing:+ raise RuntimeError(+ f"Ingredients: {len(missing)} reference image(s) not found on disk, "+ f"e.g. {missing[0]!r}. Re-upload them in the Ingredients picker."+ )+ # The Ingredients prompt has two parts (Space's build_prompt):+ # "Reference sheet: <what's in the sheet>\n\nGenerated video: <action>"+ # The panel sends them as `prompt` (the SHEET description) and+ # `ingredient_action` (the action). If only one prompt was given, fall+ # back gracefully so a render still happens.+ sheet_desc = (p.get("prompt") or "").strip()+ action_desc = (p.get("ingredient_action") or "").strip()+ # Ingredients × Character — resolve the optional trained character LoRA+ # up front. Its trigger word MUST appear in the action or the fused+ # character delta won't fire, so prepend it when the user left it out+ # (the UI injects it client-side too; this is the server-side safety net).+ ing_char_lora = (p.get("ingredient_char_lora") or "").strip()+ ing_char_trigger = (p.get("ingredient_char_trigger") or "").strip()+ if ing_char_lora and ing_char_trigger:+ if action_desc and ing_char_trigger.lower() not in action_desc.lower():+ action_desc = f"{ing_char_trigger} {action_desc}"+ elif not action_desc:+ action_desc = ing_char_trigger+ if sheet_desc and action_desc:+ ing_prompt = f"Reference sheet: {sheet_desc}\n\nGenerated video: {action_desc}"+ elif action_desc:+ ing_prompt = f"Generated video: {action_desc}"+ else:+ ing_prompt = sheet_desc or "the subjects from the reference sheet, cinematic"+ # Geometry: the Space fixes 768x448 base and, because skip_stage_2 runs+ # a single stage, GENERATES at 2x (1536x896). Honor the form's frames+ # (49/73/97/121), clamped to the 8k+1 rule. The tier max-dim caps the+ # generated size so it fits memory on smaller Macs.+ SHEET_BASE_W, SHEET_BASE_H = 768, 448+ gen_w, gen_h = SHEET_BASE_W * 2, SHEET_BASE_H * 2 # skip_stage_2 → 2x+ res_max = tier_max_dim("i2v")+ if res_max and max(gen_w, gen_h) > res_max:+ scale = res_max / float(max(gen_w, gen_h))+ gen_w = max(32, (int(gen_w * scale) // 32) * 32)+ gen_h = max(32, (int(gen_h * scale) // 32) * 32)+ push(f"Ingredients: generated size clamped to {gen_w}x{gen_h} "+ f"({SYSTEM_CAPS['label']} tier).")+ ing_frames = int(p.get("frames") or 0) or 121+ if ing_frames % 8 != 1:+ ing_frames = max(9, ing_frames - (ing_frames % 8) + 1)+ # 1) Compose the sheet PNG, then 2) loop it into the conditioning clip.+ # The clip is authored at the BASE (half-gen) resolution, NOT the gen+ # size — exactly like the Space (`_sheet_to_video(sheet, 768, 448, …)`+ # at 1x, then generate at 2x). The IC encoder resizes the reference to+ # `height//2 × width//2` (ic_lora.py:365,378 → iclora_utils resize), so+ # authoring at the gen size made the encoder DOWNSCALE 2x and changed+ # the reference latent the model anchors on; authoring at half makes+ # that resize an identity, matching the Space byte-for-byte.+ cond_w = max(32, (gen_w // 2 // 32) * 32)+ cond_h = max(32, (gen_h // 2 // 32) * 32)+ UPLOADS.mkdir(parents=True, exist_ok=True)+ sheet_png = UPLOADS / f".ingredients_{job['id']}_{stamp}_sheet.png"+ cond_mp4 = UPLOADS / f".ingredients_{job['id']}_{stamp}_cond.mp4"+ _compose_ingredient_sheet(image_paths, sheet_png)+ _sheet_to_conditioning_clip(sheet_png, cond_w, cond_h, ing_frames, cond_mp4)+ push(f"Ingredients: composed {len(image_paths)}-image sheet → "+ f"{ing_frames}f conditioning clip at {cond_w}x{cond_h} "+ f"(generate {gen_w}x{gen_h}).")+ # Inject the Ingredients LoRA (prefer the installer-fetched local file;+ # fall back to a TARGETED single-file fetch from the un-gated mirror —+ # never a bare snapshot of the 708 GB mega-repo).+ ing_meta = CURATED_LORAS["ingredients"]+ ing_strength = float(ing_meta["default_strength"]) # 1.4+ ing_lora_path = _ensure_ingredients_lora()+ ingredients_loras = list(p.get("loras") or []) + [{+ "path": ing_lora_path,+ "strength": ing_strength,+ }]+ # Stack the optional trained character LoRA ON TOP of the Ingredients+ # IC-LoRA. Both fuse additively into the Q4 distilled transformer+ # (_fuse_loras loops every entry); the character carries identity while+ # ref-strength stays 0.0, so the scene still recomposes instead of+ # copying the sheet. STRENGTH IS A MOTION/IDENTITY TRADE-OFF, not "more+ # is better": cranked too high (~1.6+) the character LoRA over-constrains+ # the distilled video model and FREEZES the motion + smears distortion+ # into the frame (validated by motion-strip A/B — char 1.8 = near-static,+ # warped; char 1.0 = full natural camera motion but looser ID). The sweet+ # spot is ~1.3 — real motion AND a recognizable trained face. Clamp the+ # ceiling at 1.8 so a stray high value can't reintroduce the freeze.+ if ing_char_lora and Path(ing_char_lora).exists():+ try:+ _char_str = float(p.get("ingredient_char_strength") or 1.3)+ except (TypeError, ValueError):+ _char_str = 1.3+ _char_str = max(0.0, min(1.8, _char_str))+ ingredients_loras.append({"path": ing_char_lora, "strength": _char_str})+ push(f"Ingredients × Character: stacking {Path(ing_char_lora).name} "+ f"@ {_char_str} (trigger {ing_char_trigger!r}) on top of the "+ f"Ingredients IC-LoRA — identity from the LoRA, scene recomposed.")+ elif ing_char_lora:+ push(f"Ingredients × Character: selected character LoRA not found on "+ f"disk ({ing_char_lora!r}); rendering without it.")+ out_name = f"ingredients_{stamp}.mp4"+ final_out = OUTPUT / out_name+ job["raw_path"] = str(final_out)+ # Force Q4 distilled — the Ingredients LoRA was trained against+ # transformer-distilled.safetensors (same rule HDR / Colorize use).+ ing_model_dir = (str(MODELS_DIR / "ltx-2.3-mlx-q4")+ if (MODELS_DIR / "ltx-2.3-mlx-q4").is_dir()+ else str(MODELS_DIR))+ # IC reference STRENGTH — the composition lever. This is the second+ # element of each video_conditioning tuple, and it sets how clean the+ # reference latent is held during denoise (VideoConditionByReferenceLatent+ # uses mask_value = 1.0 - strength: 1.0 = reference pinned pristine,+ # 0.0 = reference fully denoisable). Ingredients must RECOMPOSE the+ # subjects into the prompted scene, NOT reproduce the reference sheet.+ # At strength 1.0 the looped sheet is held pristine and the model copies+ # it verbatim (measured MAD ~4.2/255, static 2x2 grid, prompted action+ # absent). Crucially, conditioning_attention_strength does NOT fix this:+ # an empirical CAS sweep is flat (MAD ~3.6-4.2 across CAS 0.0..1.0; even+ # CAS=0.0 reproduces the grid). The reference STRENGTH is the real knob —+ # MAD climbs 4.2(s=1.0) → 7.2(0.3) → 18(0.1) → 86(0.0), and only s=0.0+ # yields a clean single composed shot with motion and preserved identity+ # (the fused Ingredients LoRA carries the subjects when the literal sheet+ # latent is no longer pinned). Default 0.0; tunable via+ # LTX_INGREDIENTS_REF_STRENGTH for iteration; clamped to [0.0, 1.0].+ # Colorize keeps its own strength (curated default, pristine reference)+ # → byte-identical, this branch never touches it.+ try:+ ing_ref_strength = float(+ os.environ.get("LTX_INGREDIENTS_REF_STRENGTH", "0.0"))+ except (TypeError, ValueError):+ ing_ref_strength = 0.0+ ing_ref_strength = max(0.0, min(1.0, ing_ref_strength))+ # Quality → single-stage vs two-stage. The original Ingredients recipe+ # skipped stage 2 (the refine + 2x upscale), which is exactly what gave+ # the dreamy "hallucination" look at 768x448. Running the SECOND stage+ # cleans that up AND outputs at full 1536x896 — validated A/B: the trippy+ # look is SINGLE-STAGE, not Q4 itself (Q8 sharpened faces but tripped the+ # bizarrotrn gold-sparkle artifact and is off-spec for the Q4-trained+ # IC-LoRA, so it's deliberately NOT used here). Mapping: only Quick/Draft+ # stay single-stage (fast, smaller, the dreamy look on purpose);+ # Balanced (the default) / Standard / High run two-stage (clean, full+ # res). The per-tier res clamp above already caps gen size, so two-stage+ # stays memory-safe on smaller Macs (Quick is the low-memory escape).+ ing_quality = (p.get("quality") or "balanced").strip().lower()+ ing_skip_stage_2 = ing_quality in ("quick", "draft")+ job_spec = {+ "action": "generate_restore",+ "id": job["id"],+ "params": {+ "model_dir": ing_model_dir,+ "prompt": ing_prompt,+ "negative_prompt": p.get("negative_prompt", ""),+ "output_path": str(final_out),+ "height": gen_h,+ "width": gen_w,+ "frames": ing_frames,+ "frame_rate": float(FPS),+ "seed": p["seed"],+ # The reference SHEET clip rides the IC reference channel. Its+ # STRENGTH (not attention) is the composition lever — see above.+ # 0.0 lets the model compose from the LoRA instead of copying+ # the pinned sheet.+ "video_conditioning": [[str(cond_mp4), ing_ref_strength]],+ "loras": ingredients_loras,+ # Quality-driven: Quick/Draft = single-stage (fast, dreamy);+ # Balanced (default) / Standard / High = two-stage refine + 2x+ # upscale (clean, full 1536x896). See ing_skip_stage_2 above.+ "skip_stage_2": ing_skip_stage_2,+ "stage1_steps": int(p.get("stage1_steps", 8)),+ "stage2_steps": int(p.get("stage2_steps", 4)),+ },+ }+ push(f"Ingredients via helper: id={job['id']} refs={len(image_paths)} "+ f"{gen_w}x{gen_h} {ing_frames}f (Q4 distilled + Ingredients IC-LoRA, "+ f"{'single-stage' if ing_skip_stage_2 else 'two-stage refine'} "+ f"[{ing_quality}], LoRA strength {ing_strength}, "+ f"ref strength {ing_ref_strength}).")+ result = HELPER.run(job_spec)+ if "seed_used" in result:+ push(f"seed used: {result['seed_used']}")+ p["seed_used"] = result["seed_used"]+ # Best-effort cleanup of the scratch sheet + conditioning clip.+ for scratch in (sheet_png, cond_mp4):+ try:+ scratch.unlink()+ except OSError:+ pass+ sidecar = {+ "output": str(final_out), "raw_output": str(final_out),+ "params": {**p, "command": "ingredients"},+ "started": job.get("started_at"),+ "elapsed_sec": round(time.time() - job["started_ts"], 2) if job.get("started_ts") else None,+ "fps": FPS, "model": ing_model_dir, "queue_id": job["id"],+ "helper_elapsed_sec": result.get("elapsed_sec"),+ "output_codec": output_codec_settings(),+ }+ write_sidecar(final_out.with_suffix(final_out.suffix + ".json"), sidecar)+ job["output_path"] = str(final_out)+ push(f"Ingredients done in {sidecar['elapsed_sec']}s → {final_out.name}")+ if p.get("open_when_done"):+ subprocess.run(["open", str(final_out)], check=False)+ return+# Keyframe (FFLF) — two images bookend the clip, model interpolates.# Always uses Q8 dev transformer (the pipeline inherits two-stage), so we# require Q8 on disk and route to generate_keyframe regardless of quality@@ -7071,31 +8188,42 @@ def run_job_inner(job: dict) -> None:subprocess.run(["open", str(out_path)], check=False)return- # Audio → Video (A2VidPipelineTwoStage).+ # Audio → Video (A2VidPipelineTwoStage / A2VidDistilledPipeline).# Pipeline drives generation FROM the input audio waveform. Optional# reference image conditions frame 0 (single picture; pipeline cover-# crops to target). Original audio is muxed onto the output by the# pipeline itself — no panel-side mux needed (unlike i2v_clean_audio).- # Always Q8 dev + distilled LoRA stage 2 (the pipeline requires both).+ #+ # Two backends:+ # Q8 tier → A2VidPipelineTwoStage (dev + CFG + TeaCache)+ # Q4 tier → A2VidDistilledPipeline (distilled, no CFG, 8+3 steps)if mode == "a2v":- if not SYSTEM_CAPS["allows_q8"]:- raise RuntimeError(- f"Audio → Video isn't supported on the {SYSTEM_CAPS['label']} "- f"hardware tier — the Q8 dev transformer + audio VAE peak "- f"doesn't fit. Bump to 64+ GB."- )- a2v_missing = q8_missing_files()- if a2v_missing:- raise RuntimeError(- f"Audio → Video requires the full Q8 model at {Q8_LOCAL_PATH}. "- f"Missing {len(a2v_missing)} file(s): {', '.join(a2v_missing[:3])}"- f"{' …' if len(a2v_missing) > 3 else ''}. "- f"Run: hf download {MODEL_ID_HQ} --local-dir {Q8_LOCAL_PATH}"- )+ uses_q8 = SYSTEM_CAPS["allows_q8"]+ if uses_q8:+ a2v_missing = q8_missing_files()+ if a2v_missing:+ push(f"Q8 not available ({len(a2v_missing)} file(s) missing) "+ f"— falling back to Q4 distilled A2V pipeline")+ uses_q8 = False+ if uses_q8:+ action = "generate_a2v"+ model_dir = str(Q8_LOCAL_PATH)+ default_stage1 = 20+ default_stage2 = 3+ else:+ action = "generate_a2v_distilled"+ model_dir = str(Q4_LOCAL_PATH)+ default_stage1 = 8+ default_stage2 = 3audio_src = (p.get("audio") or "").strip()if not audio_src or not Path(audio_src).exists():raise RuntimeError(f"audio file not found: {audio_src}")width, height = int(p["width"]), int(p["height"])+ # Clamp resolution by tier cap (no-op when tier_max_dim returns 0).+ max_dim = tier_max_dim("t2v")+ if max_dim:+ width = min(width, max_dim)+ height = min(height, max_dim)frames = int(p["frames"])desc_stem = _descriptive_filename(p.get("label") or "", p.get("prompt") or "", fallback="a2v"@@ -7124,41 +8252,39 @@ def run_job_inner(job: dict) -> None:passif ref_image_path and not Path(ref_image_path).exists():ref_image_path = None- # LoRAs flow through unchanged — useful for character A2V.a2v_loras = list(p.get("loras") or [])if p.get("hdr"):a2v_loras.append({"path": CURATED_LORAS["hdr"]["repo_id"],"strength": float(CURATED_LORAS["hdr"]["default_strength"]),})- job_spec = {- "action": "generate_a2v",- "id": job["id"],- "params": {- "model_dir": str(Q8_LOCAL_PATH),- "prompt": p["prompt"],- "negative_prompt": p.get("negative_prompt", ""),- "output_path": str(out_path),- "audio_path": audio_src,- "image": ref_image_path,- "height": height,- "width": width,- "frames": frames,- "frame_rate": float(FPS),- "seed": p["seed"],- "stage1_steps": int(p.get("stage1_steps", 20)),- "stage2_steps": int(p.get("stage2_steps", 3)),- "cfg_scale": float(p.get("cfg_scale", 3.0)),- "stg_scale": float(p.get("stg_scale", 1.0)),- "loras": a2v_loras,- },+ a2v_params = {+ "model_dir": model_dir,+ "prompt": p["prompt"],+ "negative_prompt": p.get("negative_prompt", ""),+ "output_path": str(out_path),+ "audio_path": audio_src,+ "image": ref_image_path,+ "height": height,+ "width": width,+ "frames": frames,+ "frame_rate": float(FPS),+ "seed": p["seed"],+ "stage1_steps": int(p.get("stage1_steps", default_stage1)),+ "stage2_steps": int(p.get("stage2_steps", default_stage2)),+ "audio_conditioning_scale": float(p.get("audio_conditioning_scale", 1.0)),}+ if uses_q8:+ a2v_params["cfg_scale"] = float(p.get("cfg_scale", 3.0))+ a2v_params["stg_scale"] = float(p.get("stg_scale", 1.0))+ a2v_params["loras"] = a2v_loras+ job_spec = {"action": action, "id": job["id"], "params": a2v_params}push(- f"Run A2V via helper: id={job['id']} {width}x{height} {frames}f · "+ f"Run A2V ({'Q8' if uses_q8 else 'Q4-distilled'}) via helper: "+ f"id={job['id']} {width}x{height} {frames}f · "f"audio={Path(audio_src).name}"- f"{' image=' + Path(ref_image_path).name if ref_image_path else ''} · "- f"{len(a2v_loras)} LoRA"- f"{'s' if len(a2v_loras) != 1 else ''}"+ f"{' image=' + Path(ref_image_path).name if ref_image_path else ''}"+ f" scale={a2v_params['audio_conditioning_scale']}")result = HELPER.run(job_spec)if "seed_used" in result:@@ -7166,13 +8292,13 @@ def run_job_inner(job: dict) -> None:p["seed_used"] = result["seed_used"]sidecar = {"output": str(out_path), "raw_output": str(out_path),- "params": {**p, "command": "generate_a2v", "audio": audio_src,+ "params": {**p, "command": action, "audio": audio_src,"image": ref_image_path},"started": job.get("started_at"),"elapsed_sec": round(time.time() - job["started_ts"], 2)if job.get("started_ts") else None,"video_duration_sec": video_duration(frames),- "fps": FPS, "model": str(Q8_LOCAL_PATH), "queue_id": job["id"],+ "fps": FPS, "model": model_dir, "queue_id": job["id"],"helper_elapsed_sec": result.get("elapsed_sec"),"output_codec": output_codec_settings(),}@@ -7380,13 +8506,16 @@ def run_job_inner(job: dict) -> None:"stage2_steps": int(p.get("stage2_steps", 3)),},}- if helper:- push(f"Run HDR via helper: id={job['id']} {width}x{height} {frames}f")- helper.send(job_spec)- sidecar = helper.wait_done(job["id"])- push(f"HDR done in {sidecar['elapsed_sec']}s → {Path(raw_out).name}")- else:- raise RuntimeError("HDR requires the warm helper subprocess")+ # WarmHelper exposes only .run(job_spec) (it serializes the whole+ # round-trip and returns the done/error event) — the old+ # helper.send()/helper.wait_done() pair never existed on this class,+ # so this dispatch raised AttributeError if HDR were ever re-exposed.+ # Match the EXTEND / restore branches: one HELPER.run call.+ push(f"Run HDR via helper: id={job['id']} {width}x{height} {frames}f")+ result = HELPER.run(job_spec)+ if "seed_used" in result:+ p["seed_used"] = result["seed_used"]+ push(f"HDR done in {result.get('elapsed_sec')}s → {Path(raw_out).name}")# Post-process: same encode pass T2V/I2V get (mux audio, upscale,# write sidecar). Re-uses the standard tail of run_job_inner by# falling through to it — set up the bookkeeping fields the same@@ -7446,13 +8575,19 @@ def run_job_inner(job: dict) -> None:"stage1_steps": int(p.get("stage1_steps", 10)),"stage2_steps": int(p.get("stage2_steps", 3)),"cfg_scale": float(p.get("cfg_scale", 3.0)),- # Upstream HQ params (`LTX_2_3_HQ_PARAMS`) and the- # TwoStageHQPipeline signature both default stg_scale=0.0.- # HQ uses res_2s sampler with `stg_blocks=[]`, so STG is- # meant to be off — passing 1.0 burns one extra forward- # pass per outer step (~33% slower) for nothing. Was 1.0- # by mistake (copy from standard params); fixed here.- "stg_scale": 0.0,+ # STG (Spatio-Temporal Guidance) scale — driven by the+ # "detail guidance" slider (make_job clamps to 0.0–4.0;+ # default 0.0 = OFF). The TwoStageHQPipeline signature+ # defaults stg_scale=0.0 AND forces stg_blocks=[] when no+ # explicit guider params are passed, so a bare stg_scale>0+ # would burn an extra forward pass per outer step for zero+ # effect. The helper's generate_hq branch closes that gap:+ # when stg_scale>0 it builds explicit video/audio guider+ # params with stg_blocks=[28] (the block the one/two-stage+ # pipelines perturb) so the knob actually engages. At 0.0+ # the helper passes nothing extra → byte-identical to the+ # prior hardcoded-0.0 behaviour.+ "stg_scale": float(p.get("stg_scale", 0.0)),"enable_teacache": True,# HQ TeaCache default — see make_job comment. 1.8 is the# empirical sweet spot for character mode (revert from@@ -8611,6 +9746,10 @@ class Handler(BaseHTTPRequestHandler):"extend_max_dim": SYSTEM_CAPS["extend_max_dim"],"times": SYSTEM_CAPS.get("times", {}),}+ payload["train_profile"] = TRAIN_PROFILE+ payload["train_presets"] = TRAIN_PRESETS+ payload["train_style_presets"] = TRAIN_STYLE_PRESETS+ payload["generation_profile"] = GENERATION_PROFILE# Active model-download status — UI shows a progress strip when# this is set. last_line is the most recent hf output line so the# user gets live feedback even before opening the log panel.@@ -9221,7 +10360,10 @@ class Handler(BaseHTTPRequestHandler):if not _is_character_lora(l, blocked_names)]curated = [c for c in list_curated_loras()- if not c.get("is_hdr_toggle")]+ if not c.get("is_hdr_toggle")+ and not c.get("is_restore_lora")+ and not c.get("is_ingredients_lora")+ and not c.get("is_control_lora")]self._json({"user": user_loras,"curated": curated,@@ -9305,6 +10447,14 @@ class Handler(BaseHTTPRequestHandler):self._json({"characters": list_characters()})return+ # Progress poll for the one-click sample-character download.+ if parsed.path == "/characters/download-sample/status":+ with _sample_char_lock:+ st = dict(_sample_char_state)+ st["present"] = _sample_character_present()+ self._json(st)+ return+# Serve the sample training image for a character so the browser# can <img src="/characters/<id>/preview">. Path-traversal safe:# `id` is validated against [A-Za-z0-9_-]+ at parse time, and the@@ -9910,6 +11060,26 @@ class Handler(BaseHTTPRequestHandler):"/stats in ~15 s for fresh numbers"}, 202)return+ # One-click: fetch the shipped sample character so a user can try+ # Character / Remix without training their own first. ~817 MB, so it+ # runs in a background thread + returns 202; the UI polls+ # /characters/download-sample/status until status == done|error.+ if path == "/characters/download-sample":+ if _sample_character_present():+ self._json({"ok": True, "status": "done", "already": True,+ "character_id": SAMPLE_CHARACTER["trigger"]})+ return+ with _sample_char_lock:+ already_running = _sample_char_state.get("status") == "downloading"+ if not already_running:+ _set_sample_state(status="downloading", mb=0,+ total_mb=SAMPLE_CHARACTER["size_bytes"] // (1 << 20),+ error=None)+ threading.Thread(target=_download_sample_character_bg,+ daemon=True, name="phos-sample-char").start()+ self._json({"ok": True, "status": "downloading"}, 202)+ return+# Multipart uploadif path == "/upload" and ctype.startswith("multipart/form-data"):# Hard cap on body size so a misbehaving / malicious caller can't@@ -11154,11 +12324,11 @@ class Handler(BaseHTTPRequestHandler):}, 400)return# Make sure the form has the canonical image_count so make_job's- # estimate is right even if the JS forgot to set it.+ # estimate and step cap use the dataset on disk, not stale JS state.form["mode"] = ["train"]form["train_job_id"] = [train_job_id]form["train_type"] = [train_type]- form.setdefault("image_count", [str(len(image_files))])+ form["image_count"] = [str(len(image_files))]job = make_job(form)with QUEUE_COND:STATE["queue"].append(job)@@ -11208,13 +12378,17 @@ class Handler(BaseHTTPRequestHandler):f"{CAPTION_STATE.get('train_job_id')}",}, 409)return- # Refuse if a training job is in flight on the same- # dataset — captioning would race the training preprocess.+ # Refuse while ANY GPU job is in flight. This originally only+ # blocked training, which allowed Gemma auto-captioning to run+ # beside a long video render. On 48 GB Macs that pushes MLX+ # into compressor/swap, and the active render usually never+ # recovers speed mid-job even after Gemma exits.cur = STATE.get("current")- if cur and cur.get("params", {}).get("mode") == "train":+ if cur or _GPU_LOCK.locked():+ cur_mode = ((cur or {}).get("params") or {}).get("mode") or "render"self._json({- "error": "training is currently running — wait for "- "it to finish before auto-captioning",+ "error": f"GPU is busy with {cur_mode} — wait for the "+ "current job to finish before auto-captioning",}, 409)return# Reset state for this run.@@ -13059,6 +14233,12 @@ def page() -> str:"profile": PROFILE,"model_upscale_enabled": MODEL_UPSCALE_ENABLED,"pipersr_upscale_enabled": PIPERSR_UPSCALE_ENABLED,+ "train_presets": TRAIN_PRESETS,+ "train_style_presets": TRAIN_STYLE_PRESETS,+ "train_profile": TRAIN_PROFILE,+ "train_min_images": TRAIN_MIN_IMAGES,+ "train_max_images": TRAIN_MAX_IMAGES,+ "generation_profile": GENERATION_PROFILE,# Hardware-aware time estimates for the Quality pills. The pill HTML# ships with the Comfortable-tier defaults; on boot we rewrite the# subtext using the active tier's quality_times. Compact users see@@ -13579,12 +14759,6 @@ HTML = r"""<!doctype html>toggle (Pass 6) for quick non-character drafts. */body[data-cap-tier="q4"] #modeGroup [data-mode="keyframe"],body[data-cap-tier="q4"] #modeGroup [data-mode="extend"],- body[data-cap-tier="q4"] #modeGroup [data-mode="character"],- body[data-cap-tier="q4"] #manualCharactersPickerSlot,- body[data-cap-tier="q4"] #charactersPickerDivider,- body[data-cap-tier="q4"] #qualityGroupCharacter,- body[data-cap-tier="q4"] #charSkipstepToggleWrap,- body[data-cap-tier="q4"] #workflowTabs button[data-workflow="audio"],body[data-cap-tier="q4"] #qualityGroup [data-quality="high"] { display: none !important; }/* Quality strip becomes a 3-col grid (Quick/Balanced/Standard)since the 4th column ("High") is gone. */@@ -13615,6 +14789,19 @@ HTML = r"""<!doctype html>textarea { min-height: 84px; resize: vertical; font-family: inherit; }textarea.avoid-textarea { min-height: 54px; }+ /* Range slider strip (used in Audio Studio, etc.) */+ .range-strip {+ display: flex; align-items: center; gap: 10px;+ }+ .range-strip input[type="range"] {+ flex: 1 1 auto; accent-color: var(--accent, #2f81f7);+ padding: 0; border: none; background: none;+ }+ .range-val {+ min-width: 32px; text-align: center; font-size: 14px;+ font-weight: 600; color: var(--accent, #2f81f7);+ }+/* Pill button groups (mode/quality/aspect) */.pill-group {display: grid; gap: 6px; margin-bottom: 6px;@@ -17522,6 +18709,36 @@ HTML = r"""<!doctype html>.picker-recent-thumb:hover { border-color: var(--accent, #5a7cff); transform: translateY(-1px); }.picker-recent-thumb.selected { border-color: var(--success, #3fb950); }+ /* Ingredients (multi-reference) picker — drop tile + thumbnail grid. */+ .ingredients-drop { min-height: 96px; }+ .ingredients-thumbs {+ display: grid; gap: 8px; margin-top: 8px;+ grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));+ }+ .ingredients-thumbs:empty { margin-top: 0; }+ .ingredient-thumb {+ position: relative; aspect-ratio: 1 / 1; border-radius: 8px;+ overflow: hidden; border: 1px solid var(--border, #2a3140);+ background: rgba(255,255,255,0.04);+ }+ .ingredient-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }+ .ingredient-thumb-x {+ position: absolute; top: 4px; right: 4px;+ width: 22px; height: 22px; border-radius: 50%; border: none;+ display: flex; align-items: center; justify-content: center;+ background: rgba(0,0,0,0.62); color: #fff; cursor: pointer;+ transition: background 120ms ease;+ }+ .ingredient-thumb-x:hover { background: var(--danger, #d9534f); }+ .ingredient-thumb-x .ph { width: 12px; height: 12px; }+ .ingredient-thumb-n {+ position: absolute; bottom: 4px; left: 4px;+ min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px;+ display: flex; align-items: center; justify-content: center;+ font-size: 11px; font-weight: 600; line-height: 1;+ background: rgba(0,0,0,0.62); color: #fff;+ }+/* LoRA picker — collapsible <details>. Compact list rows (Y1.007).Distinct visual section so users notice it (Y1.008): wrapped in abordered container, separator dividers above/below, custom chevron@@ -17968,6 +19185,19 @@ HTML = r"""<!doctype html>}.chars-strip-empty a { color: var(--accent-bright); }+ /* Q4-tier honesty note under the character strip. Hidden by default so+ Q8-capable machines never see it; shown only when the page renders in+ the Q4 tier (16 GB / Q4 fallback), where a character fuses into the+ distilled base and identity comes out approximate vs. faithful on Q8. */+ .chars-q4-note { display: none; }+ body[data-cap-tier="q4"] .chars-q4-note {+ display: block;+ font-size: 11px; line-height: 1.5;+ color: var(--muted);+ padding: 4px 2px 2px;+ }+ body[data-cap-tier="q4"] .chars-q4-note b { color: var(--text); font-weight: 600; }+/* Manage characters modal — list view with rename + delete per row. */.chars-manage-list {display: flex; flex-direction: column;@@ -19563,6 +20793,15 @@ HTML = r"""<!doctype html>chooses any total anchor count from 3–8. --><button type="button" class="mode-chip pill-btn" data-mode="keyframe" data-kf-default="multi">Keyframes<span class="mc-sub sub">3–8 frames</span></button><button type="button" class="mode-chip pill-btn" data-mode="extend">Extend<span class="mc-sub sub">continue a clip</span></button>+ <!-- Remix — the IC-LoRA reference tools (Ingredients / Control / Colorize)+ grouped under ONE pill so the mode bar stays uncluttered. All three+ run on Q4 distilled (unlike FFLF/Extend/Character, which are Q8-only+ and hidden on the Q4 tier), so the parent is visible at every tier.+ Clicking it reveals #remixSubGroup and resumes the last-used tool+ (default Ingredients). The backend modes stay ingredients/control/+ restore — this is PURE UI grouping (see REMIX_MODES + setMode + the+ #remixSubGroup click wiring). -->+ <button type="button" class="mode-chip pill-btn" data-mode="remix">Remix<span class="mc-sub sub">your media → new video</span></button><!-- "Train" used to live here as a mode chip; promoted 2026-05-15 toa workflow tier (top tab strip). "Studio" (image generation) alsolived here until 2026-05-17 — Mr Bizarro flagged that mixing image gen@@ -19572,6 +20811,20 @@ HTML = r"""<!doctype html>after hiding the other panes. --></div>+ <!-- Remix sub-tools — second-level selector, visible ONLY when a Remix mode+ is active (toggled in setMode via REMIX_MODES). Each sub-pill sets the+ REAL backend mode (data-remix → setMode); the parent Remix pill above+ stays lit. Inline styles use var(--x, fallback) so they're safe whether+ or not the theme defines those vars. -->+ <div id="remixSubGroup" style="display:none;margin:-2px 0 12px;padding:9px 11px;border:1px solid var(--line,#262a33);border-left:3px solid var(--accent,#8b7bff);border-radius:11px;background:var(--accent-wash,rgba(139,123,255,.06))">+ <div style="font-size:11px;letter-spacing:.13em;text-transform:uppercase;color:var(--dim,#7a8194);margin-bottom:7px">Remix tool · bring your own media</div>+ <div class="mode-bar pill-group">+ <button type="button" class="mode-chip pill-btn" data-remix="ingredients">Ingredients<span class="mc-sub sub">2–8 refs → one clip</span></button>+ <button type="button" class="mode-chip pill-btn" data-remix="control">Control<span class="mc-sub sub">drive from a video</span></button>+ <button type="button" class="mode-chip pill-btn" data-remix="restore">Colorize<span class="mc-sub sub">B&W clip → color</span></button>+ </div>+ </div>+<form id="genForm"><input type="hidden" name="preset_label" id="preset_label" value=""><input type="hidden" name="mode" id="mode" value="t2v">@@ -19617,6 +20870,7 @@ HTML = r"""<!doctype html>title="Rescan mlx_models/characters/ for new bundles"onclick="refreshManualCharacters()"><svg class="ph" aria-hidden="true"><use href="#ph-arrow-clockwise-bold"/></svg></button></div>+ <div class="chars-q4-note"><b>Q4 fallback:</b> on this machine characters render on the fast (distilled) base — identity comes out <em>approximate</em>. A Q8-capable Mac renders faithful faces.</div><!-- One-liner that surfaces under the strip when a character isactive. Shows trigger word + a tiny strength control inline.charsSummaryMeta stays as a hidden carrier for legacy JS@@ -19626,7 +20880,12 @@ HTML = r"""<!doctype html><!-- Empty state — visible only when no bundles exist on disk. --><div class="chars-strip-empty" id="charsEmpty" hidden>No trained characters yet —- <a href="#" onclick="workflowSwitch('train'); return false;">train one in the Train tab</a>.+ <a href="#" onclick="workflowSwitch('train'); return false;">train one in the Train tab</a>,+ or+ <button type="button" class="ghost-btn js-get-sample-char" style="padding:2px 8px;font-size:12px"+ onclick="downloadSampleCharacter()">get a sample character (Bizarro)</button>+ to try it right now.+ <div class="js-get-sample-char-status" style="font-size:12px;opacity:.9;margin-top:6px" hidden></div></div><!-- Strength row carrier (kept in DOM for JS toggles; hiddenfrom view — the slider lives inside charsAppliedNote when a@@ -19796,6 +21055,83 @@ HTML = r"""<!doctype html><input type="hidden" name="extend_cfg" id="extend_cfg" value="1.0"><div class="hint">Each latent ≈ 8 frames (~0.33s). Q8 Pro runs the upstream Lightricks defaults but pushes 1280×704 into swap on 64 GB Macs (~2 hr/render). Stick with Q8 Draft unless you've got more RAM.</div></div>++ <!-- Colorize (restore) — source-video picker, cloned from the+ Extend block. The user picks a B&W / desaturated clip; the+ Colorize IC-LoRA rides it on the reference channel and paints+ in natural color. Q4 distilled (no Q8 needed). Shown/hidden by+ updateDerived() when currentMode === 'restore'. -->+ <div class="mode-only" id="restoreSection">+ <h2>Source video to colorize</h2>+ <select id="restoreSrcSelect" onchange="document.getElementById('restore_video_path').value=this.value"></select>+ <input name="restore_video_path" id="restore_video_path" placeholder="/path/to/blackandwhite.mp4" style="margin-top:6px">+ <div class="hint" style="margin-top:6px">Pick a black-and-white or washed-out clip. The prompt below describes the colors to paint in (e.g. "golden warm sunlight, blue sky, green grass"). Output matches the source's resolution + length. Runs on Q4 — no Q8 needed.</div>+ </div>++ <!-- Ingredients (multi-reference) — the flagship IC-LoRA. Pick 2-8+ subject images (a face + a prop + a location); they're tiled+ into one reference sheet and the model composes them into a new+ clip. The prompt below describes WHAT'S in the sheet; the Action+ field describes the shot. Q4 distilled. Shown/hidden by+ updateDerived() when currentMode === 'ingredients'. -->+ <div class="mode-only" id="ingredientsSection">+ <h2>Reference images <span class="hint" style="font-weight:400">· 2–8 (a face + a prop + a location)</span></h2>+ <div class="ingredients-picker">+ <div class="picker-drop ingredients-drop" id="ingredients_drop">+ <div class="picker-empty">+ <div class="picker-icon"><svg class="ph"><use href="#ph-image"/></svg></div>+ <div class="picker-cta">Drop images here, or <strong>click to browse</strong></div>+ <div class="hint">PNG / JPG / WEBP · pick 2–8 — they tile into one reference sheet</div>+ </div>+ </div>+ <input type="file" id="ingredients_file" accept="image/*" multiple style="display:none">+ <input type="hidden" name="ingredient_images_json" id="ingredient_images_json" value="[]">+ <div class="ingredients-thumbs" id="ingredients_thumbs"></div>+ <div class="picker-recent" id="ingredients_recent_wrap" style="display:none">+ <div class="picker-recent-label">Recent uploads · click to add</div>+ <div class="picker-recent-strip" id="ingredients_recent"></div>+ </div>+ </div>+ <h2 style="margin-top:14px">Action / shot to generate</h2>+ <textarea id="ingredient_action" name="ingredient_action" class="composer-prompt" style="min-height:64px"+ placeholder="What happens in the clip — e.g. the hedgehog waddles up and waves, the rabbit hops past with a spray bottle; warm acoustic jingle, cheerful voice, soft footsteps."></textarea>+ <div class="hint" style="margin-top:6px">The big prompt below describes WHAT'S in the reference sheet (each character, prop, and the location). This Action field describes the shot itself. Runs on Q4 — no Q8 needed.</div>++ <!-- Ingredients × Character — OPTIONAL trained character LoRA stacked+ on top of the Ingredients IC-LoRA so the SAME trained face lands+ in every composed scene. Options are filled from _knownUserLoras+ (kind=train_character) by populateIngredientCharLoras(). The+ selected character's trigger rides a hidden field; the server+ prepends it to the action if missing so the LoRA fires. -->+ <div id="ingredientCharWrap" style="margin-top:16px">+ <h2 style="margin-bottom:0">Character <span class="hint" style="font-weight:400">· optional — drop your trained face into every scene</span></h2>+ <select id="ingredient_char_lora" name="ingredient_char_lora" onchange="onIngredientCharChange()" style="margin-top:6px"></select>+ <input type="hidden" name="ingredient_char_strength" id="ingredient_char_strength" value="1.3">+ <input type="hidden" name="ingredient_char_trigger" id="ingredient_char_trigger" value="">+ <div id="ingredientCharEmpty" class="hint" style="margin-top:8px;display:none">No trained characters yet — train one in the <strong>Character</strong> tab and it appears here. Then your face composes into any scene you build.</div>+ <div id="ingredientCharTune" style="margin-top:8px;display:none">+ <div class="hint">Identity comes from the LoRA, not a face photo — so the same face holds across every scene (tighter than a reference image alone). The references still set the props, wardrobe, and location. <strong>Strength is a trade-off:</strong> higher = tighter face but stiffer motion; lower = freer, more natural motion. ~1.3 is the sweet spot.</div>+ <div style="margin-top:8px;display:flex;align-items:center;gap:10px">+ <span class="hint" style="white-space:nowrap">Identity strength <strong id="ingCharStrLabel">1.3</strong></span>+ <input type="range" min="0.8" max="1.8" step="0.1" value="1.3" id="ingCharStrSlider" oninput="onIngredientCharStrength(this.value)" style="flex:1;max-width:280px">+ </div>+ <div id="ingredientCharTrigHint" class="hint" style="margin-top:6px"></div>+ </div>+ </div>+ </div>++ <!-- Control (Union) — control-video picker, cloned from the Colorize+ (restore) source block. The user picks a RAW RGB clip; the Union+ IC-LoRA rides it on the reference channel at follow-strength so+ the render inherits its motion/structure/composition while the+ prompt swaps the subject/scene. Q4 distilled (no Q8 needed).+ Shown/hidden by updateDerived() when currentMode === 'control'. -->+ <div class="mode-only" id="controlSection">+ <h2>Control video</h2>+ <select id="controlSrcSelect" onchange="document.getElementById('control_video_path').value=this.value"></select>+ <input name="control_video_path" id="control_video_path" placeholder="/path/to/control.mp4" style="margin-top:6px">+ <div class="hint" style="margin-top:6px">Pick a clip whose <strong>motion, structure, and composition</strong> you want to drive the render. The prompt below describes the NEW subject/scene to paint onto that structure (e.g. "a red origami crane unfolding"). Raw video works — a depth/pose map is an optional precision upgrade, not required. Output matches the control clip's resolution + length. Runs on Q4 — no Q8 needed.</div>+ </div></div><!-- Prompt — hero textarea. No h2 (the composer-card itself@@ -20160,6 +21496,31 @@ HTML = r"""<!doctype html></div></div>+ <!-- STG (Spatio-Temporal Guidance) — "detail guidance". The Q8 HQ+ res_2s guider adds stg_scale·(cond - perturbed) to the+ prediction (guiders.py MultiModalGuider.calculate), which+ cleans up motion + fine detail at the cost of an extra forward+ pass per outer step (slower). 0.0 = OFF (default — the guider+ short-circuits at exactly 0.0). Only acts on the Q8 HQ path+ (quality=high); the Q4 distilled paths ignore STG entirely, so+ the row is revealed only when quality=high (same gating as the+ HQ-speed row above — _applyStgRowVisibility). The range input+ carries name="stg_scale" so FormData collects it; the submit+ handler also fd.set()s it explicitly. -->+ <div id="stgRow" class="cz-control" hidden>+ <div class="cz-label">STG — detail guidance+ <span class="cz-label-hint">cleaner motion & detail, slower · 0 = off · try 1–1.5</span>+ </div>+ <div class="characters-strength-control" style="display:flex;align-items:center;gap:10px;">+ <input type="range" name="stg_scale" id="stgScale"+ min="0" max="4" step="0.5" value="0"+ style="flex:1;width:auto"+ oninput="document.getElementById('stgScaleValue').textContent = (this.value==='0' ? 'Off' : (+this.value).toFixed(1));"+ title="0 = off (no quality/speed change). 1.0–1.5 is a sensible starting band for a visible detail/motion lift; higher = stronger but slower and can over-sharpen.">+ <span class="characters-strength-value" id="stgScaleValue">Off</span>+ </div>+ </div>+<!-- Long Clip Boost — asks LTX 2.3 to generate fewer semanticframes at 12fps, then exports a normal 24fps file withmotion interpolation. This is explicit because dialogue,@@ -20678,6 +22039,11 @@ HTML = r"""<!doctype html>once a <code><trigger>_v2.safetensors</code> LoRA lands in <code>mlx_models/loras/</code> it shows up here automatically.Add a matching <code>.audio.safetensors</code> for voice; without it the character is silent.</div>+ <div style="margin-top:16px;display:flex;flex-direction:column;align-items:center;gap:8px">+ <button type="button" class="primary-btn js-get-sample-char" onclick="downloadSampleCharacter()">Get a sample character (Bizarro)</button>+ <div style="font-size:12px;opacity:.7;max-width:34rem;line-height:1.5">Don't want to train one yet? Grab a ready-made character (~817 MB, one-time) and try Character & Remix right now.</div>+ <div class="js-get-sample-char-status" style="font-size:12px;opacity:.9" hidden></div>+ </div></div></div>@@ -21043,6 +22409,7 @@ HTML = r"""<!doctype html><span class="mf-label">Rank</span><select id="trainRank"><option value="">preset default</option>+ <option value="4">4</option><option value="8">8</option><option value="16">16</option><option value="32">32</option>@@ -21067,6 +22434,8 @@ HTML = r"""<!doctype html><span class="mf-label">Resolution</span><select id="trainResolution"><option value="">preset default</option>+ <option value="384">384²</option>+ <option value="448">448²</option><option value="512">512²</option><option value="576">576²</option><option value="768">768²</option>@@ -21269,48 +22638,57 @@ HTML = r"""<!doctype html><textarea id="audioStudioPrompt" class="composer-prompt" rows="4"placeholder="A photoreal medium close-up of a woman speaking to camera, soft daylight, shallow depth of field, natural skin pores"></textarea>+ <div class="composer-tools">+ <button type="button" class="ghost-btn" id="audioStudioEnhanceBtn" onclick="audioStudioEnhancePrompt()" title="Use Gemma to rewrite your prompt"><svg class="ph" aria-hidden="true" style="margin-right:6px"><use href="#ph-sparkle-fill"/></svg>Enhance</button>+ <span class="ct-spacer"></span>+ </div></div><div class="studio-status-row" style="margin: 6px 0 -4px;"><span id="audioStudioStatus" class="hint"></span></div>- <!-- Quick settings: aspect / duration / seed / quality.- Aspect maps to the same width/height table the Characters tab- uses (1024×576 high, 736×416 draft). Duration → frames at- 8k+1 cadence the model expects. -->+ <!-- Quick settings: width / height / duration / seed.+ Width/height are free-form; the panel snaps to 32 px multiple.+ Duration slider covers 1–30 s; JS rounds frames to 8k+1. --><div class="quick-settings"><div><div class="mini-fields"><div class="mf-cell">- <span class="mf-label">Aspect</span>- <select id="audioStudioAspect" style="padding:7px 9px;font-size:13px;">- <option value="16:9" selected>16:9 — 1024×576</option>- <option value="9:16">9:16 — 576×1024</option>- <option value="1:1">1:1 — 768×768</option>- <option value="4:3">4:3 — 832×608</option>- </select>+ <span class="mf-label">Width</span>+ <input type="number" id="audioStudioWidth" value="1024" min="256" max="1920" step="32"></div><div class="mf-cell">- <span class="mf-label">Duration</span>- <select id="audioStudioDuration" style="padding:7px 9px;font-size:13px;">- <option value="5">5 s</option>- <option value="7" selected>7 s</option>- <option value="10">10 s</option>- </select>+ <span class="mf-label">Height</span>+ <input type="number" id="audioStudioHeight" value="576" min="256" max="1920" step="32"></div><div class="mf-cell"><span class="mf-label">Seed</span><input type="number" id="audioStudioSeed" value="-1" placeholder="-1 = random"></div></div>+ <div class="mf-cell" style="margin-top:8px">+ <span class="mf-label">Duration</span>+ <div class="range-strip">+ <input type="range" id="audioStudioDuration" min="1" max="30" step="1" value="7"+ oninput="document.getElementById('audioStudioDurationVal').textContent=this.value + ' s'">+ <span id="audioStudioDurationVal" class="range-val">7 s</span>+ </div>+ </div>+ <div class="mf-cell" style="margin-top:8px">+ <span class="mf-label">Audio conditioning strength</span>+ <div class="range-strip">+ <input type="range" id="audioConditioningScale" min="0.5" max="5.0" step="0.1" value="1.0"+ oninput="document.getElementById('audioConditioningScaleVal').textContent=this.value">+ <span id="audioConditioningScaleVal" class="range-val">1.0</span>+ </div>+ <div class="hint" style="margin-top:2px">Higher = stronger audio adhesion, lower visual flexibility</div>+ </div></div></div>- <div class="hint" style="margin-top:8px">- Audio → Video uses the Q8 dev transformer with audio conditioning.- Wall time is similar to High-quality I2V (~7–9 min on a 64 GB M-Max- for a 7 s 1024×576 clip).+ <div class="hint" style="margin-top:8px" id="audioStudioHint">+ Audio → Video uses audio conditioning during generation (not post-hoc mux). Some seeds may not work properly — retry if the mouth doesn't move.</div><div class="form-action-footer" id="audioStudioFooter">@@ -22203,6 +23581,10 @@ let filterMode = 'visible';let activePath = null;let currentOutputs = [];let currentMode = 't2v';+// REMIX_MODES — the IC-LoRA reference tools grouped under the single "Remix"+// mode pill. These are REAL backend modes (the #mode field + the dispatch see+// them); "remix" itself is a UI-only pseudo-mode that resolves to one of these.+const REMIX_MODES = ['ingredients', 'control', 'restore'];// Main right-pane gallery kind filter (All / Videos / Photos). Independent// of `filterMode` (which is visible/hidden) and independent of@@ -22370,7 +23752,7 @@ function _autoMainOutputsFilterForMode(mode) {// Auto-set NEVER lands on 'all' — that's user-only, per spec.let target = null;if (mode === 'image') target = 'photos';- else if (mode === 't2v' || mode === 'i2v' || mode === 'keyframe' || mode === 'extend') target = 'videos';+ else if (mode === 't2v' || mode === 'i2v' || mode === 'keyframe' || mode === 'extend' || mode === 'restore' || mode === 'ingredients' || mode === 'control') target = 'videos';if (!target) return;// Same-filter early-return is conditional now: if the filter is already// on `target` but the visible list is empty AND we haven't loaded the@@ -22452,12 +23834,21 @@ function syncAvoidRowFromValue() {}function setMode(mode) {- // Capability guard — Q4 (sub-48GB) tier can't run FFLF, Extend, or- // Character (HQ-only pipelines + Q8 trainer-base contract). CSS already- // hides the chips, but a stale localStorage, charactersLoadParams(), or- // a JS caller could still try to switch. Snap to t2v with a console- // warning so we never end up in an unrenderable mode by accident.- if (window.PHOSPHENE_CAP_TIER === 'q4' && (mode === 'keyframe' || mode === 'extend' || mode === 'character')) {+ // "remix" is a UI GROUP, not a backend mode — clicking the parent Remix pill+ // resumes the last-used Remix tool (default Ingredients). Everything below+ // (and the backend) only ever sees a real mode from REMIX_MODES.+ if (mode === 'remix') mode = window._lastRemixMode || 'ingredients';+ // Capability guard — Q4 (sub-48GB) tier can't run FFLF or Extend+ // (Q8-only pipelines). CSS already hides the chips, but a stale+ // localStorage, charactersLoadParams(), or a JS caller could still try+ // to switch. Snap to t2v with a console warning so we never end up in an+ // unrenderable mode by accident. Character IS available on Q4 (the LoRA+ // fuses into the distilled base — identity match is mediocre but the+ // render completes), so it's deliberately NOT in this list.+ // NOTE: 'restore' (Colorize) is also NOT in this list — its IC-LoRA was+ // trained against the Q4 distilled checkpoint, so it RUNS on the Q4 tier.+ // Don't add either back here or you'll break the feature on sub-48GB.+ if (window.PHOSPHENE_CAP_TIER === 'q4' && (mode === 'keyframe' || mode === 'extend')) {console.warn(`setMode(${mode}): not available on Q4 tier — snapping to t2v`);mode = 't2v';}@@ -22499,9 +23890,10 @@ function setMode(mode) {}if (mode === 'character') {// Character is a UI intent, not a backend mode — the hidden #mode- // field still ships 't2v' on submit. make_job sees character_id +- // routes to Q8 HQ. CSS-only chrome (chip strip + Q8 quality strip)- // makes the cascade visible.+ // field still ships 't2v' on submit. make_job sees character_id and+ // expands it into face+audio LoRAs. On Q8, the quality strip swaps+ // to Q8 Draft/Pro; on Q4, the regular quality pills stay visible+ // and the LoRAs fuse into the distilled base.if (studio) studio.classList.remove('show');if (train) train.classList.remove('show');if (genForm) genForm.style.display = '';@@ -22591,10 +23983,24 @@ function setMode(mode) {document.querySelectorAll('#modeGroup .pill-btn').forEach(b => {if (mode === 'keyframe') {b.classList.toggle('active', isKeyframeModeChipActive(b, window._kfMode));+ } else if (b.dataset.mode === 'remix') {+ // The parent Remix pill stays lit for ANY of its sub-tools.+ b.classList.toggle('active', REMIX_MODES.indexOf(mode) !== -1);} else {b.classList.toggle('active', b.dataset.mode === mode);}});+ // Remix group: reveal the sub-tool row + light the active sub-pill when the+ // current mode is one of the Remix tools; hide the row otherwise. Remember+ // the last Remix tool so the parent pill resumes it next time it's clicked.+ const _inRemix = REMIX_MODES.indexOf(mode) !== -1;+ if (_inRemix) window._lastRemixMode = mode;+ const _remixBar = document.getElementById('remixSubGroup');+ if (_remixBar) _remixBar.style.display = _inRemix ? '' : 'none';+ if (_inRemix) {+ document.querySelectorAll('#remixSubGroup .pill-btn').forEach(b =>+ b.classList.toggle('active', b.dataset.remix === mode));+ }// Manual-tab Characters picker is T2V-only (Text-to-Video flow). Other// video modes (I2V, FFLF, Extend) have a different mental model — the// user is anchoring on a frame, not picking an actor.@@ -22618,6 +24024,12 @@ function setMode(mode) {updateAccelAvailability();updateTemporalAvailability();updateDerived();+ // Ingredients (multi-reference) — lazily wire the multi-image picker + load+ // the recent-uploads strip on first entry. Idempotent (guarded by __wired).+ if (mode === 'ingredients') {+ if (typeof ingredientPickerWire === 'function') ingredientPickerWire();+ if (typeof refreshIngredientRecent === 'function') refreshIngredientRecent();+ }// Refresh the inline models card immediately — switching to FFLF when// Q8 is missing should surface the Download Q8 CTA without waiting for// the next 1.5s poll tick.@@ -24588,6 +26000,24 @@ function audioStudioRenderSlots() {}}+async function audioStudioEnhancePrompt() {+ const ta = document.getElementById('audioStudioPrompt');+ const original = ta.value.trim();+ if (!original) { alert('Type a prompt before enhancing it.'); return; }+ const btn = document.getElementById('audioStudioEnhanceBtn');+ const originalLabel = btn.innerHTML;+ btn.disabled = true;+ btn.innerHTML = '<svg class="ph" aria-hidden="true" style="margin-right:6px;vertical-align:-2px"><use href="#ph-sparkle-fill"/></svg>Loading Gemma\u2026 (~15s)';+ try {+ const r = await fetch('/prompt/enhance', { method: 'POST', body: new URLSearchParams({ prompt: original, mode: 't2v' }) });+ const res = await r.json();+ if (res.error) { alert('Enhance failed: ' + res.error); return; }+ if (confirm('Original:\n' + res.original + '\n\nEnhanced:\n' + res.enhanced + '\n\nReplace your prompt with the enhanced version?'))+ { ta.value = res.enhanced; ta.dispatchEvent(new Event('input', { bubbles: true })); }+ } catch (e) { alert('Enhance request failed: ' + (e.message || e)); }+ finally { btn.disabled = false; btn.innerHTML = originalLabel; }+}+async function audioStudioGenerate() {if (AUDIO_STUDIO.busy) return;const status = document.getElementById('audioStudioStatus');@@ -24601,23 +26031,16 @@ async function audioStudioGenerate() {if (status) status.textContent = 'Prompt is required.';return;}- // Aspect → width/height map. Snapped to multiples of 32 so the latent- // grid is exact (LTX requires HW % 32 == 0; the panel checks this in- // make_job too but we pre-snap to keep the user's chosen ratio).- const aspect = (document.getElementById('audioStudioAspect').value || '16:9');- const aspectMap = {- '16:9': [1024, 576],- '9:16': [576, 1024],- '1:1': [768, 768],- '4:3': [832, 608],- };- const [w, h] = aspectMap[aspect] || aspectMap['16:9'];- // Duration → frames at 8k+1 cadence the model expects.+ // Width / height from free-form inputs; snap to 32 px multiple+ // (LTX latent grid requirement).+ const w = Math.max(32, Math.round(parseInt(document.getElementById('audioStudioWidth').value || '1024', 10) / 32) * 32);+ const h = Math.max(32, Math.round(parseInt(document.getElementById('audioStudioHeight').value || '576', 10) / 32) * 32);+ // Duration from slider → frames at 8k+1 cadence the model expects.const dur = parseInt(document.getElementById('audioStudioDuration').value || '7', 10);- // 24 fps → frames per second; snap to nearest 8k+1.const targetFrames = Math.max(1, Math.round(dur * 24));const frames = ((targetFrames - 1 + 7) >> 3 << 3) + 1; // round up to 8k+1const seed = parseInt(document.getElementById('audioStudioSeed').value || '-1', 10);+ const audioConditioningScale = parseFloat(document.getElementById('audioConditioningScale').value || '1.0');AUDIO_STUDIO.busy = true;if (btn) btn.disabled = true;@@ -24637,7 +26060,8 @@ async function audioStudioGenerate() {fd.set('height', String(h));fd.set('frames', String(frames));fd.set('seed', String(seed));- fd.set('quality', 'high'); // A2V is always Q8 dev-class+ fd.set('audio_conditioning_scale', String(audioConditioningScale));+ fd.set('quality', 'high'); // A2V is always pipeline-class (Q8 dev or Q4 distilled)// No accel, no enhance — A2V uses A2VidPipelineTwoStage's own walks.fd.set('accel', 'off');fd.set('enhance', 'off');@@ -24686,33 +26110,35 @@ const TRAIN = {// card hides for style; guidance + labels swap). Mirrors the server-side// TRAIN_TYPES tuple in mlx_ltx_panel.py.trainType: 'character',- // Local mirror of the preset table; server has the authoritative copy in- // TRAIN_PRESETS but the JS-side estimator is instant — saves a /status- // round-trip per keystroke. Keep these in sync with TRAIN_PRESETS in py.+ // Local mirror of the server preset table. BOOT carries the authoritative,+ // hardware-adjusted version so 48 GB Macs see the compact training profile+ // instead of the old 64 GB-class defaults. Static fallbacks below are only+ // for damaged/old boot payloads.//// Schema change 2026-05-19: presets describe EPOCHS, not steps. Actual// step count is computed from `epochs × image_count` at the consumer// (trainComputeSteps below) so the same preset auto-scales with// dataset size. Advanced trainSteps override still wins.- presets: {+ presets: BOOT.train_presets || {quick: { epochs: 30, rank: 8, resolution: 512, seconds_per_step: 1.5, ram_peak_gb: 12,- label: 'Quick', subtitle: '~30 epochs · rank 8 · 512px' },+ label: 'Quick', subtitle: '~30 epochs · rank 8 · 512px', max_steps: 3000 },medium: { epochs: 60, rank: 16, resolution: 576, seconds_per_step: 2.2, ram_peak_gb: 18,- label: 'Medium', subtitle: '~60 epochs · rank 16 · 576px' },+ label: 'Medium', subtitle: '~60 epochs · rank 16 · 576px', max_steps: 5000 },high: { epochs: 100, rank: 32, resolution: 512, seconds_per_step: 2.0, ram_peak_gb: 28,- label: 'High', subtitle: '~100 epochs · rank 32 · 512px (v2 recipe)' },+ label: 'High', subtitle: '~100 epochs · rank 32 · 512px (v2 recipe)', max_steps: 7000 },},// Mirror of the server-side TRAIN_STYLE_PRESETS. Style table differs from// character: quick uses rank 16 (not rank 8), and "high" adds epochs not// rank (rank 32 is the validated capacity ceiling for our LTX-2.3 stack).- stylePresets: {+ stylePresets: BOOT.train_style_presets || {quick: { epochs: 30, rank: 16, resolution: 512, seconds_per_step: 1.5, ram_peak_gb: 12,- label: 'Quick', subtitle: '~30 epochs · rank 16 · 512px' },+ label: 'Quick', subtitle: '~30 epochs · rank 16 · 512px', max_steps: 3000 },medium: { epochs: 60, rank: 32, resolution: 512, seconds_per_step: 2.0, ram_peak_gb: 18,- label: 'Medium', subtitle: '~60 epochs · rank 32 · 512px' },+ label: 'Medium', subtitle: '~60 epochs · rank 32 · 512px', max_steps: 5000 },high: { epochs: 100, rank: 32, resolution: 512, seconds_per_step: 2.0, ram_peak_gb: 28,- label: 'High', subtitle: '~100 epochs · rank 32 · 512px' },+ label: 'High', subtitle: '~100 epochs · rank 32 · 512px', max_steps: 7000 },},+ trainProfile: BOOT.train_profile || {},// Voice (optional) state. `voiceFile` is the server-saved record once// an upload completes; `voiceEnabled` mirrors the toggle.//@@ -24745,6 +26171,64 @@ function trainActivePresets() {return TRAIN.trainType === 'style' ? TRAIN.stylePresets : TRAIN.presets;}+function trainActivePreset() {+ const table = trainActivePresets();+ return table[TRAIN.preset] || table.quick || {};+}++function trainUpdatePresetButtons() {+ const table = trainActivePresets();+ document.querySelectorAll('#trainPresetGroup .pill-btn').forEach((b) => {+ const key = b.dataset.trainPreset;+ b.classList.toggle('active', key === TRAIN.preset);+ });+ const subIds = {+ quick: 'trainPresetQuickSub',+ medium: 'trainPresetMediumSub',+ high: 'trainPresetHighSub',+ };+ Object.keys(subIds).forEach((key) => {+ const el = document.getElementById(subIds[key]);+ const p = table[key];+ if (el && p && p.subtitle) el.textContent = p.subtitle;+ });+}++function trainDisableSelectAbove(selectId, maxValue) {+ const sel = document.getElementById(selectId);+ const max = Number(maxValue || 0);+ if (!sel || !max) return;+ Array.from(sel.options).forEach((opt) => {+ if (!opt.value) {+ opt.disabled = false;+ return;+ }+ const n = Number(opt.value);+ opt.disabled = Number.isFinite(n) && n > max;+ });+ const selected = Number(sel.value || 0);+ if (selected && selected > max) sel.value = '';+}++function trainApplyAdvancedLimits() {+ const preset = trainActivePreset();+ const maxRank = Number(preset.max_rank || TRAIN.trainProfile.max_rank || 0);+ const maxResolution = Number(preset.max_resolution || TRAIN.trainProfile.max_resolution || 0);+ const maxSteps = Number(preset.max_steps || TRAIN.trainProfile.max_steps || 0);+ if (maxRank) trainDisableSelectAbove('trainRank', maxRank);+ if (maxResolution) trainDisableSelectAbove('trainResolution', maxResolution);+ const stepsInput = document.getElementById('trainSteps');+ if (stepsInput && maxSteps) {+ stepsInput.max = String(maxSteps);+ const current = Number(stepsInput.value || 0);+ if (current && current > maxSteps) stepsInput.value = '';+ }+}++function trainUpdateAdvancedFields() {+ trainApplyAdvancedLimits();+}+// ============================================================================// CHARACTERS TAB — discover paired LoRAs, pick one, type the scene, ship.// ============================================================================@@ -24805,6 +26289,50 @@ const CHARACTERS_FRAMING_TEXT = Object.fromEntries(CHARACTERS_FRAMING.map(([v, , full]) => [v, full]));+async function downloadSampleCharacter() {+ // Class-based (not id) so the button can live in more than one empty state+ // (the Character-mode strip AND the standalone Characters grid) and both+ // update together.+ const btns = Array.from(document.querySelectorAll('.js-get-sample-char'));+ const statuses = Array.from(document.querySelectorAll('.js-get-sample-char-status'));+ if (!btns.length) return;+ const setStatus = (msg) => statuses.forEach(s => { s.hidden = false; s.textContent = msg; });+ const setDisabled = (v) => btns.forEach(b => { b.disabled = v; });+ setDisabled(true);+ setStatus('Starting… (~817 MB, one-time)');+ const finishOk = async (msg) => {+ setStatus(msg);+ // Re-init the picker(s) so the new character appears + the empty state hides.+ try { if (typeof charactersInit === 'function') await charactersInit(); } catch (_) {}+ try { if (typeof refreshManualCharacters === 'function') await refreshManualCharacters(); } catch (_) {}+ setDisabled(false);+ };+ try {+ const r = await fetch('/characters/download-sample', { method: 'POST' });+ const j = await r.json().catch(() => ({}));+ if (j && j.already) { await finishOk('Already installed — "Bizarro" is in your characters.'); return; }+ if (!r.ok && r.status !== 202) { throw new Error((j && j.error) || ('HTTP ' + r.status)); }+ const poll = setInterval(async () => {+ let s;+ try { s = await (await fetch('/characters/download-sample/status')).json(); }+ catch (_) { return; }+ if (s.status === 'downloading') {+ setStatus('Downloading… ' + (s.mb || 0) + ' / ' + (s.total_mb || '?') + ' MB');+ } else if (s.status === 'done' || s.present) {+ clearInterval(poll);+ await finishOk('Installed! "Bizarro" is in your characters now — pick it to start.');+ } else if (s.status === 'error') {+ clearInterval(poll);+ setStatus('Download failed: ' + (s.error || 'unknown') + ' — try again.');+ setDisabled(false);+ }+ }, 2500);+ } catch (e) {+ setStatus('Could not start: ' + (e.message || e));+ setDisabled(false);+ }+}+async function charactersInit() {// Idempotent. The grid is the default view; compose state only// appears after the user picks a card.@@ -25332,8 +26860,8 @@ async function charactersLoadParams(p) {// ============================================================================// TRAIN CHARACTER tab// ============================================================================-const TRAIN_MIN = 15;-const TRAIN_MAX = 50;+const TRAIN_MIN = Number(BOOT.train_min_images || 15);+const TRAIN_MAX = Number(BOOT.train_max_images || 50);function trainInit() {// Idempotent — safe to call on every setMode('train') without re-binding@@ -25362,6 +26890,8 @@ function trainInit() {trainUpdateEstimate();});}+ trainUpdatePresetButtons();+ trainUpdateAdvancedFields();trainRefreshLoraList();trainUpdateEstimate();trainUpdateButtonState();@@ -25623,6 +27153,7 @@ function trainWirePresetButtons() {TRAIN.preset = b.dataset.trainPreset;document.querySelectorAll('#trainPresetGroup .pill-btn').forEach(x =>x.classList.toggle('active', x === b));+ trainUpdateAdvancedFields();trainUpdateEstimate();});});@@ -25645,9 +27176,16 @@ function trainWireAdvancedFields() {['trainRank', 'trainSteps', 'trainLR', 'trainResolution', 'trainCaptionStrategy'].forEach(id => {const el = document.getElementById(id);- if (el) el.addEventListener('change', trainUpdateEstimate);- if (el) el.addEventListener('input', trainUpdateEstimate);+ if (el) el.addEventListener('change', () => {+ trainApplyAdvancedLimits();+ trainUpdateEstimate();+ });+ if (el) el.addEventListener('input', () => {+ trainApplyAdvancedLimits();+ trainUpdateEstimate();+ });});+ trainApplyAdvancedLimits();}async function trainUploadFiles(fileList) {@@ -26051,20 +27589,27 @@ function trainEffectiveSteps() {return Number.isFinite(n) && n > 0 ? n : null;}-// Mirrors py-side _preset_steps_for(): steps = epochs × image_count.+// Mirrors py-side _preset_steps_for(): steps = epochs × image_count, capped+// by preset.max_steps when the active hardware profile supplies one.// Used by trainUpdateEstimate to keep the ETA chip honest as the user// drops more photos in. Floor of 1 image so n=0 doesn't yield zero// steps (matches server behavior).function trainComputeSteps(preset, imageCount) {const epochs = parseInt(preset.epochs, 10) || 0;- return Math.max(1, epochs * Math.max(1, imageCount | 0));+ let steps = Math.max(1, epochs * Math.max(1, imageCount | 0));+ const maxSteps = Number(preset.max_steps || 0);+ if (maxSteps > 0) steps = Math.min(steps, maxSteps);+ return steps;}function trainUpdateEstimate() {- const preset = (trainActivePresets()[TRAIN.preset]) || trainActivePresets().quick;+ trainApplyAdvancedLimits();+ const preset = trainActivePreset();const stepOverride = trainEffectiveSteps();const n = TRAIN.images.length;- const steps = stepOverride || trainComputeSteps(preset, n);+ let steps = stepOverride || trainComputeSteps(preset, n);+ const maxSteps = Number(preset.max_steps || TRAIN.trainProfile.max_steps || 0);+ if (maxSteps > 0) steps = Math.min(steps, maxSteps);const sec = Math.round(3 * Math.max(0, n) + steps * preset.seconds_per_step + 30);// Estimate row is hidden until the user has dropped at least one// image. Before that, the row reads as missing data — not a useful@@ -26074,7 +27619,12 @@ function trainUpdateEstimate() {const ramRow = document.getElementById('trainEstimateRam');const timeRow = document.getElementById('trainEstimateTime');const outRow = document.getElementById('trainEstimateOut');- if (timeRow && n > 0) timeRow.textContent = trainFmtDuration(sec) + ` · ${steps} steps`;+ if (timeRow && n > 0) {+ const profile = TRAIN.trainProfile && TRAIN.trainProfile.label+ ? ` · ${TRAIN.trainProfile.label}`+ : '';+ timeRow.textContent = trainFmtDuration(sec) + ` · ${steps} steps${profile}`;+ }if (ramRow) ramRow.textContent = `~${preset.ram_peak_gb} GB peak`;if (outRow) {const trig = (document.getElementById('trainTrigger').value || 'mrz07');@@ -26567,6 +28117,9 @@ function setQuality(q) {if (typeof _applyHqSpeedRowVisibility === 'function') {try { _applyHqSpeedRowVisibility(); } catch (_) {}}+ if (typeof _applyStgRowVisibility === 'function') {+ try { _applyStgRowVisibility(); } catch (_) {}+ }if (LAST_STATUS) updateModelsCard(LAST_STATUS);}function setAccel(a) {@@ -26695,6 +28248,10 @@ function updatePromptPlaceholder() {prompt.placeholder = window._kfMode >= 3 ? keyframeMulti : keyframeTwo;} else if (currentMode === 'i2v') {prompt.placeholder = 'Describe how the reference image should move, plus sound cues. The image anchors frame 0; the prompt directs the full clip.';+ } else if (currentMode === 'ingredients') {+ prompt.placeholder = "Describe WHAT'S in the reference sheet — each character, prop, and the location. e.g. a friendly cartoon hedgehog with rounded chestnut fur; a green coiled garden hose; the bright interior of a 'Greenfield' garden store. (The Action field above describes the shot itself.)";+ } else if (currentMode === 'control') {+ prompt.placeholder = "Describe the NEW subject/scene to paint onto the control clip's motion and structure — plus sound cues. e.g. a red origami crane unfolding on a black table · soft paper rustle. The control video drives the composition; this prompt swaps what's in it.";} else {prompt.placeholder = base;}@@ -26711,6 +28268,12 @@ document.querySelectorAll('#modeGroup .pill-btn').forEach(b => b.onclick = () =>setKeyframeMode(def === 'multi' ? fallback : parseInt(def, 10));}});+// Remix sub-tool clicks set the REAL backend mode (ingredients/control/restore);+// setMode keeps the parent Remix pill lit + this sub-pill active + the section+// shown. Wired here alongside the #modeGroup handler so both rows behave alike.+document.querySelectorAll('#remixSubGroup .pill-btn').forEach(b => b.onclick = () => {+ setMode(b.dataset.remix);+});document.querySelectorAll('#qualityGroup .pill-btn').forEach(b => b.onclick = () => {// Disabled-but-actionable: the High pill becomes a "click to install Q8"// CTA when Q8 is missing. Routes to the Models modal so the user lands@@ -26941,6 +28504,21 @@ function updateDerived() {const inImageFlow = inI2V || currentMode === 'keyframe';document.getElementById('imageSection').classList.toggle('show', inI2V && currentMode !== 'keyframe');document.getElementById('extendSection').classList.toggle('show', currentMode === 'extend');+ // Colorize (restore) shows its own source-video picker. Unlike Extend it+ // KEEPS the sizing + quick-metrics rows below (the source's own dims/length+ // drive the output, but the prompt + seed still apply).+ const _restoreSection = document.getElementById('restoreSection');+ if (_restoreSection) _restoreSection.classList.toggle('show', currentMode === 'restore');+ // Ingredients (multi-reference) — its own multi-image picker + action field.+ // Like Colorize it KEEPS the sizing/quick-metrics rows (frames apply; the+ // sheet drives the rest).+ const _ingredientsSection = document.getElementById('ingredientsSection');+ if (_ingredientsSection) _ingredientsSection.classList.toggle('show', currentMode === 'ingredients');+ // Control (Union) — its own control-video picker. Like Colorize it KEEPS the+ // sizing/quick-metrics rows (the control clip drives dims/length; prompt ++ // seed still apply).+ const _controlSection = document.getElementById('controlSection');+ if (_controlSection) _controlSection.classList.toggle('show', currentMode === 'control');document.getElementById('keyframeSection').classList.toggle('show', currentMode === 'keyframe');// Keyframe toggle row — visible only in keyframe modeconst kfToggleRow = document.getElementById('kfToggleRow');@@ -27075,9 +28653,9 @@ function pickerSetImage(key, path, opts = {}) {// FFLF anchors framing on the start frame; I2V anchors on its single// image. End frame doesn't drive aspect (would override the start// frame). a2v_image lives in the Audio→Video tab which has its own- // aspect dropdown (#audioStudioAspect) — calling snapAspectToImage- // would change the GLOBAL #aspect selector, not the A2V one, so- // skip it for a2v_image to avoid silently mutating an unrelated mode.+ // width/height inputs — calling snapAspectToImage would change the+ // GLOBAL #aspect selector, not the A2V one, so skip it for a2v_image+ // to avoid silently mutating an unrelated mode.if ((key === 'image' || key === 'start_image') && opts.snapAspect !== false) {snapAspectToImage(path);}@@ -27177,6 +28755,122 @@ async function refreshUploadsStrip() {});}+// ====== Ingredients (multi-reference) picker ======+// Unlike the single-image pickers above, Ingredients holds an ORDERED LIST of+// 2-8 server-side paths. The list is mirrored into the hidden+// #ingredient_images_json input that make_job reads (and that's in the+// allowlist — see the make_job params dict). Uploads go through the same+// /upload endpoint; selecting from "Recent uploads" appends a path.+let _ingredientPaths = []; // array of server-side panel_uploads/* paths++function _ingredientSync() {+ const hidden = document.getElementById('ingredient_images_json');+ if (hidden) hidden.value = JSON.stringify(_ingredientPaths);+ _ingredientRenderThumbs();+ // Keep the recent strip's "added" highlight in sync.+ if (typeof refreshIngredientRecent === 'function') refreshIngredientRecent();+}++function _ingredientRenderThumbs() {+ const wrap = document.getElementById('ingredients_thumbs');+ if (!wrap) return;+ if (!_ingredientPaths.length) { wrap.innerHTML = ''; return; }+ wrap.innerHTML = _ingredientPaths.map((p, i) => `+ <div class="ingredient-thumb" data-idx="${i}">+ <img src="${escapeHtml(_thumbUrl('/image?path=' + encodeURIComponent(p), 160))}" alt="">+ <button type="button" class="ingredient-thumb-x" data-idx="${i}" title="Remove"><svg class="ph" aria-hidden="true"><use href="#ph-x-bold"/></svg></button>+ <span class="ingredient-thumb-n">${i + 1}</span>+ </div>+ `).join('');+ wrap.querySelectorAll('.ingredient-thumb-x').forEach(btn => {+ btn.addEventListener('click', (e) => {+ e.stopPropagation();+ const idx = parseInt(btn.dataset.idx, 10);+ _ingredientPaths.splice(idx, 1);+ _ingredientSync();+ });+ });+}++function ingredientAddPath(path) {+ if (!path) return;+ if (_ingredientPaths.includes(path)) return; // no dupes+ if (_ingredientPaths.length >= 8) { alert('Ingredients takes at most 8 images.'); return; }+ _ingredientPaths.push(path);+ _ingredientSync();+}++async function ingredientUploadFile(file) {+ const drop = document.getElementById('ingredients_drop');+ if (!file || !drop) return;+ let busy = drop.querySelector('.picker-uploading');+ if (!busy) {+ busy = document.createElement('div');+ busy.className = 'picker-uploading';+ drop.appendChild(busy);+ }+ busy.textContent = `Uploading ${file.name}…`;+ try {+ const fd = new FormData(); fd.append('image', file);+ const r = await fetch('/upload', { method: 'POST', body: fd });+ const data = await r.json();+ if (!data.ok) throw new Error(data.error || 'upload failed');+ ingredientAddPath(data.path);+ if (typeof refreshUploadsStrip === 'function') refreshUploadsStrip();+ } catch (e) {+ alert(`Upload failed: ${e.message || e}`);+ } finally {+ busy.remove();+ }+}++async function refreshIngredientRecent() {+ const wrap = document.getElementById('ingredients_recent_wrap');+ const strip = document.getElementById('ingredients_recent');+ if (!wrap || !strip) return;+ // Reuse the module-level uploads cache the single pickers already fill.+ let list = _uploadsCache;+ if (!list || !list.length) {+ try { const d = await api('/uploads?limit=24'); list = (d && d.uploads) || []; _uploadsCache = list; }+ catch (e) { list = []; }+ }+ if (!list.length) { wrap.style.display = 'none'; return; }+ wrap.style.display = '';+ strip.innerHTML = list.map(u => `+ <img class="picker-recent-thumb${_ingredientPaths.includes(u.path) ? ' selected' : ''}"+ src="${escapeHtml(_thumbUrl(u.url, 128))}"+ data-path="${escapeHtml(u.path)}"+ title="${escapeHtml(u.name)} · ${u.size_kb} KB"+ alt="">+ `).join('');+ strip.querySelectorAll('img').forEach(img => {+ img.addEventListener('click', () => ingredientAddPath(img.dataset.path));+ });+}++function ingredientPickerWire() {+ const drop = document.getElementById('ingredients_drop');+ const file = document.getElementById('ingredients_file');+ if (!drop || !file || drop.__wired) return;+ drop.__wired = true;+ drop.addEventListener('click', (e) => {+ if (e.target.closest('.ingredient-thumb-x')) return;+ file.click();+ });+ file.addEventListener('change', () => {+ Array.from(file.files || []).forEach(f => ingredientUploadFile(f));+ file.value = ''; // allow re-uploading the same file+ });+ drop.addEventListener('dragover', (e) => { e.preventDefault(); drop.classList.add('dragover'); });+ drop.addEventListener('dragleave', () => drop.classList.remove('dragover'));+ drop.addEventListener('drop', (e) => {+ e.preventDefault();+ drop.classList.remove('dragover');+ Array.from((e.dataTransfer && e.dataTransfer.files) || []).forEach(f => ingredientUploadFile(f));+ });+ _ingredientSync();+}+// ====== Format helpers ======// Memory badge formatting. 2026-05-20 — switched from "· swap N.N" to// "· N% pressure". macOS swap accounting is sticky: once swap pages are@@ -27923,8 +29617,15 @@ async function poll() {// .png as an Extend source (which would 400 server-side).const sel = document.getElementById('extendSrcSelect');const videoOutputs = currentOutputs.filter(o => !isPhotoOutputMain(o));- sel.innerHTML = '<option value="">— pick an output below or paste a path —</option>' ++ const _videoOpts = '<option value="">— pick an output below or paste a path —</option>' +videoOutputs.slice(0, 40).map(o => `<option value="${escapeHtml(o.path)}">${escapeHtml(o.name)}</option>`).join('');+ sel.innerHTML = _videoOpts;+ // Colorize (restore) source dropdown — same video-only list as Extend.+ const restoreSel = document.getElementById('restoreSrcSelect');+ if (restoreSel) restoreSel.innerHTML = _videoOpts;+ // Control (Union) control-video dropdown — same video-only list.+ const controlSel = document.getElementById('controlSrcSelect');+ if (controlSel) controlSel.innerHTML = _videoOpts;}// (The old "Hidden (N)" pill that lived here was retired with the// Visible/Hidden segmented control — the carousel-head comment above@@ -29438,6 +31139,22 @@ document.getElementById('genForm').addEventListener('submit', async e => {fd.delete('keyframe_count');}}+ // STG "detail guidance" — explicit fd.set so the value is unambiguous+ // and so it only rides along when it can actually do something. STG acts+ // only on the Q8 HQ path (quality=high); the Q4 distilled paths ignore it+ // entirely (DistilledPipeline runs no guider). On any non-high quality we+ // drop the field so a stale slider value can't reach the worker. The range+ // input already carries name="stg_scale", but the FormData copy is+ // post-processed here so this set() wins regardless of input order.+ {+ const _q = (fd.get('quality') || '').toString();+ const _stgEl = document.getElementById('stgScale');+ if (_q === 'high' && _stgEl) {+ fd.set('stg_scale', _stgEl.value || '0');+ } else {+ fd.delete('stg_scale');+ }+ }await api('/queue/add','POST',fd);} finally {// Re-enable on the next event-loop tick so the button visibly@@ -30518,6 +32235,62 @@ function setLoraStrength(path, strength) {_serializeLoras();}+// --- Ingredients × Character picker -------------------------------------+// Fills the optional character dropdown in Ingredients mode from the trained+// characters in _knownUserLoras (kind=train_character). Selecting one stacks+// the character LoRA on top of the Ingredients IC-LoRA server-side so the SAME+// trained face lands in every composed scene. The character's trigger word+// rides a hidden field; the server prepends it to the Action if missing.+function populateIngredientCharLoras() {+ const sel = document.getElementById('ingredient_char_lora');+ const empty = document.getElementById('ingredientCharEmpty');+ if (!sel) return;+ const chars = (Array.isArray(_knownUserLoras) ? _knownUserLoras : [])+ .filter(u => u && u.kind === 'train_character');+ const prev = sel.value;+ sel.innerHTML = '<option value="">None — compose from the reference images only</option>';+ for (const c of chars) {+ const o = document.createElement('option');+ o.value = c.path;+ const trig = (Array.isArray(c.trigger_words) && c.trigger_words[0]) || '';+ o.dataset.trigger = trig;+ o.textContent = (c.name || c.filename || c.path) + (trig ? ` · "${trig}"` : '');+ sel.appendChild(o);+ }+ if (prev && chars.some(c => c.path === prev)) sel.value = prev;+ sel.style.display = chars.length ? '' : 'none';+ if (empty) empty.style.display = chars.length ? 'none' : '';+ onIngredientCharChange();+}++function onIngredientCharChange() {+ const sel = document.getElementById('ingredient_char_lora');+ const tune = document.getElementById('ingredientCharTune');+ const trigHint = document.getElementById('ingredientCharTrigHint');+ const trigField = document.getElementById('ingredient_char_trigger');+ if (!sel) return;+ const opt = sel.options[sel.selectedIndex];+ const trigger = (opt && opt.dataset.trigger) || '';+ if (trigField) trigField.value = trigger;+ const picked = !!sel.value;+ if (tune) tune.style.display = picked ? '' : 'none';+ if (trigHint) {+ trigHint.innerHTML = picked+ ? (trigger+ ? 'Trigger word <code>' + escapeHtml(trigger) + '</code> is added to your Action automatically so the character fires.'+ : 'No trigger word recorded for this character — it may still fire from the LoRA alone.')+ : '';+ }+}++function onIngredientCharStrength(v) {+ const lab = document.getElementById('ingCharStrLabel');+ const field = document.getElementById('ingredient_char_strength');+ const f = parseFloat(v);+ if (lab) lab.textContent = (isNaN(f) ? 1.8 : f).toFixed(1);+ if (field) field.value = String(v);+}+async function refreshLoras() {// Pull the FULL library (no mode filter) so _knownUserLoras keeps every// entry — that lets refreshLoras() also serve as the "deleted on disk"@@ -30566,6 +32339,10 @@ async function refreshLoras() {knownPaths.has(l.path) || l.path.includes('/')); // keep HF ids (no dir slash)renderLorasList();_serializeLoras();+ // Refill the Ingredients-mode character dropdown from the same library+ // (kind=train_character). Runs here so a newly-trained character appears+ // the moment /loras is re-fetched after training.+ try { populateIngredientCharLoras(); } catch (_) {}}function renderLorasList() {@@ -31385,6 +33162,10 @@ function selectManualCharacter(id) {// based on whether a character is currently selected. Idempotent — safe// to call any time the selection state changes.function _applyCharacterQualityStripVisibility() {+ // Q4 tier keeps the regular quality pills (Quick/Balanced/Standard) —+ // no Q8-only character quality strip. The character LoRA fuses into+ // the Q4 distilled base; identity match is imperfect but it renders.+ if (window.PHOSPHENE_CAP_TIER === 'q4') return;const def = document.getElementById('qualityGroup');const char = document.getElementById('qualityGroupCharacter');const skipWrap = document.getElementById('charSkipstepToggleWrap');@@ -31467,10 +33248,13 @@ function _setCharacterQuality(btn) {if (typeof updateCustomizeSummary === 'function') {try { updateCustomizeSummary(); } catch (_) {}}- // Quality is now 'high'; reveal the HQ-speed row.+ // Quality is now 'high'; reveal the HQ-speed row + STG slider.if (typeof _applyHqSpeedRowVisibility === 'function') {try { _applyHqSpeedRowVisibility(); } catch (_) {}}+ if (typeof _applyStgRowVisibility === 'function') {+ try { _applyStgRowVisibility(); } catch (_) {}+ }}// Skip-step boost toggle handler. Writes 1/0 into the hidden form@@ -31529,6 +33313,20 @@ function _applyHqSpeedRowVisibility() {row.hidden = (q !== 'high');}+// Show the STG "detail guidance" slider only when quality=high (Q8 HQ).+// STG is a no-op on the Q4 distilled paths, so there's nothing to expose+// for Quick/Standard/Balanced. Hiding the row does NOT reset stg_scale —+// the slider's own value persists; the make_job clamp + the helper's+// stg_scale>0 gate mean a stale non-zero value can't engage on a Q4 render+// anyway (the Q4 dispatch never reads stg_scale). Mirror of+// _applyHqSpeedRowVisibility so the two HQ-only rows reveal together.+function _applyStgRowVisibility() {+ const row = document.getElementById('stgRow');+ if (!row) return;+ const q = document.getElementById('quality')?.value || '';+ row.hidden = (q !== 'high');+}+// Wire the char-quality chip clicks once at boot. Idempotent — the// `data-wired` flag prevents double-binding on re-render.function _wireCharacterQualityChips() {@@ -31968,10 +33766,13 @@ document.addEventListener('DOMContentLoaded', () => {if (typeof _applyCharacterQualityStripVisibility === 'function') {try { _applyCharacterQualityStripVisibility(); } catch (e) {}}- // Apply correct HQ-speed-row visibility based on initial quality.+ // Apply correct HQ-speed-row + STG-slider visibility based on initial quality.if (typeof _applyHqSpeedRowVisibility === 'function') {try { _applyHqSpeedRowVisibility(); } catch (e) {}}+ if (typeof _applyStgRowVisibility === 'function') {+ try { _applyStgRowVisibility(); } catch (e) {}+ }});// ====== Models modal ======@@ -32475,12 +34276,7 @@ function workflowSwitch(name) {// chip strip is integrated into Manual (T2V). If we get a stale// 'characters' value from localStorage, snap to 'manual'.if (name === 'characters') name = 'manual';- // Q4 cap-tier doesn't ship the audio workflow. If 'audio' is requested- // anyway (stale localStorage, Load Params on a historical A2V job,- // scripted caller), snap to 'manual' before any pane logic runs.- if (name === 'audio' && document.body.dataset.capTier === 'q4') {- name = 'manual';- }+ // Q4 tier uses the distilled A2V pipeline (no Q8 dev required).document.querySelectorAll('#workflowTabs button[data-workflow]').forEach(b => b.classList.toggle('active', b.dataset.workflow === name));const manual = document.getElementById('genForm');diff --git a/mlx_warm_helper.py b/mlx_warm_helper.pyindex 7427074..93908f2 100644--- a/mlx_warm_helper.py+++ b/mlx_warm_helper.py@@ -102,6 +102,36 @@ MODEL_UPSCALE_ENABLED = os.environ.get("LTX_ENABLE_MODEL_UPSCALE", "").lower() i_USER_VAE_STREAMING_OVERRIDE = os.environ.get("LTX_VAE_STREAMING")+def _log_memory_pressure() -> None:+ """Emit a log line with current memory stats for diagnosing GPU timeouts."""+ try:+ import subprocess, re+ total = int(subprocess.run(["sysctl", "-n", "hw.memsize"],+ capture_output=True, text=True, timeout=1).stdout.strip())+ vm = subprocess.run(["vm_stat"], capture_output=True, text=True, timeout=1).stdout+ m = re.search(r"page size of (\d+)", vm)+ page_size = int(m.group(1)) if m else 16384+ def pages(name: str) -> int:+ mm = re.search(rf"{re.escape(name)}:\s+(\d+)", vm)+ return int(mm.group(1)) if mm else 0+ used_bytes = (pages("Pages active") + pages("Pages wired down")+ + pages("Pages occupied by compressor")) * page_size+ used_gb = used_bytes / 1024**3+ pct = round(used_bytes / total * 100) if total else 0+ emit({"event": "log", "line": f"[mem] used={used_gb:.1f}G/{total/1024**3:.0f}G ({pct}%)"})+ except Exception:+ pass+++def _aggressive_cleanup_before_generate() -> None:+ """Minimize Metal heap fragmentation before pipeline generation."""+ try:+ from ltx_core_mlx.utils.memory import aggressive_cleanup as _ac+ _ac()+ except Exception:+ pass++def _apply_vae_streaming_decision(num_frames: int) -> None:"""Set/unset os.environ['LTX_VAE_STREAMING'] for the upcoming decode.No-op if the user pinned a value at helper start time. Threshold reads@@ -236,6 +266,8 @@ _hq_model_dir = None # remember which model the HQ pipe was built against_a2v_pipe = None # A2VidPipelineTwoStage (Q8 dev + distilled LoRA stage 2)_a2v_model_dir = None # which model the A2V pipe was built against_a2v_lora_key: tuple | None = None # LoRA fingerprint for current A2V cache+_a2v_distilled_pipe = None # A2VidDistilledPipeline (Q4 distilled, no CFG)+_a2v_distilled_model_dir = None_pipe_lock = threading.Lock()@@ -321,6 +353,7 @@ def release_pipelines(keep_kind=None):"""global _t2v_pipe, _i2v_pipe, _extend_pipe, _hq_pipe, _kf_pipe, _hq_model_dir, _kf_model_dirglobal _a2v_pipe, _a2v_model_dir+ global _a2v_distilled_pipe, _a2v_distilled_model_dirglobal _gemma_lmtry:from ltx_core_mlx.utils.memory import aggressive_cleanup@@ -340,6 +373,8 @@ def release_pipelines(keep_kind=None):_kf_pipe = None; _kf_model_dir = None; freed.append("Keyframe")if keep_kind != "a2v" and _a2v_pipe is not None:_a2v_pipe = None; _a2v_model_dir = None; freed.append("A2V")+ if keep_kind != "a2v_distilled" and _a2v_distilled_pipe is not None:+ _a2v_distilled_pipe = None; _a2v_distilled_model_dir = None; freed.append("A2V-distilled")# Always free Gemma LanguageModel when releasing for any pipeline —# ~6 GB persistent that competes with the dev transformer's headroom.# Re-loaded on demand by the next enhance call (one-time ~10s cost).@@ -1081,6 +1116,44 @@ def get_a2v_pipe(model_dir: str, loras: list[dict] | None = None):return _a2v_pipe+def get_a2v_distilled_pipe(model_dir: str):+ """Returns A2VidDistilledPipeline lazily.++ Q4-compatible distilled pipeline — no dev transformer, no CFG, 8+3 steps.+ Cached on model_dir so switching between Q4 and Q8 paths rebuilds.+ """+ global _a2v_distilled_pipe, _a2v_distilled_model_dir+ try:+ from a2vid_distilled import A2VidDistilledPipeline+ except ModuleNotFoundError:+ raise RuntimeError(+ "A2V distilled module not found — run Update to install it."+ ) from None++ _install_a2v_frame_rate_patch()++ try:+ from ltx_core_mlx.utils.memory import aggressive_cleanup as _ac+ except Exception:+ _ac = lambda: None+ with _pipe_lock:+ release_pipelines(keep_kind="a2v_distilled")+ if _a2v_distilled_pipe is None or _a2v_distilled_model_dir != model_dir:+ if _a2v_distilled_pipe is not None:+ emit({"event": "log", "line": "model_dir changed; reloading A2V distilled pipeline."})+ _a2v_distilled_pipe = None+ _ac()+ emit({"event": "log",+ "line": f"Loading A2V distilled pipeline (Q4 — {model_dir})..."})+ _a2v_distilled_pipe = A2VidDistilledPipeline(+ model_dir=model_dir,+ gemma_model_id=GEMMA_PATH,+ low_memory=LOW_MEMORY,+ )+ _a2v_distilled_model_dir = model_dir+ return _a2v_distilled_pipe++# ---- prompt enhancement (Gemma language model) ------------------------------# Separate from the pipeline's TextEncoder wrapper — same weights file, but# the LanguageModel class supports `.enhance_t2v(prompt, seed)` /@@ -1895,6 +1968,7 @@ for line in sys.__stdin__:"line": f"step:get_pipe kind={('i2v' if needs_image else 't2v')}"})pipe = get_pipe("i2v" if needs_image else "t2v", loras=loras)emit({"event": "log", "line": "step:get_pipe done"})+ _log_memory_pressure()accel_mode = configure_acceleration(p.get("accel", "off"))negative_prompt = _clean_text(p.get("negative_prompt"))effective_prompt = _prompt_with_soft_negative(p["prompt"], negative_prompt)@@ -1958,6 +2032,7 @@ for line in sys.__stdin__:elif not upscaler_available():emit({"event": "log", "line": "Sharper upscale requested but model weights missing — falling back to Lanczos."})+ _aggressive_cleanup_before_generate()if use_model_upscale:emit({"event": "log", "line": f"step:generate mode={mode} {kwargs['width']}x{kwargs['height']} {kwargs['num_frames']}f @{kwargs['frame_rate']:.1f}fps steps={kwargs['num_steps']} accel={accel_mode} upscale=model"})# Step 1: generate latents (no save)@@ -1981,7 +2056,8 @@ for line in sys.__stdin__:# panel's wait_done while MLX tears down ~10 GB of Metal# buffers + lazy graph nodes synchronously.emit({"event": "log", "line": "step:decode_and_save done"})- else:+ _aggressive_cleanup_before_generate()+ if not use_model_upscale:emit({"event": "log", "line": f"step:generate mode={mode} {kwargs['width']}x{kwargs['height']} {kwargs['num_frames']}f @{kwargs['frame_rate']:.1f}fps steps={kwargs['num_steps']} accel={accel_mode}"})video_latent, audio_latent = _generate_latents(pipe, needs_image=needs_image, kwargs=kwargs)emit({"event": "log", "line": "step:generate done"})@@ -2180,9 +2256,13 @@ for line in sys.__stdin__:stage1_steps=int(p.get("stage1_steps", 15)),stage2_steps=int(p.get("stage2_steps", 3)),cfg_scale=float(p.get("cfg_scale", 3.0)),- # Default 0.0 — upstream HQ (TwoStageHQPipeline) uses empty- # stg_blocks, so any nonzero stg_scale just runs an extra- # forward pass per step that's then discarded.+ # STG (Spatio-Temporal Guidance) — "detail guidance" slider.+ # Default 0.0 = OFF. The pipeline forces stg_blocks=[] when no+ # explicit guider params are passed, so stg_scale alone is a+ # no-op (an extra forward pass per step that's then discarded).+ # When stg_scale>0 we ALSO pass explicit video/audio guider+ # params with stg_blocks=[28] just below, which is what makes+ # the knob actually do something on the HQ path.stg_scale=float(p.get("stg_scale", 0.0)),enable_teacache=bool(p.get("enable_teacache", True)),teacache_thresh=float(p.get("teacache_thresh", 1.0)),@@ -2207,6 +2287,36 @@ for line in sys.__stdin__:p.get("stage2_image_conditioning", "full")),)+ # STG engage: stg_scale>0 only bites if stg_blocks is non-empty.+ # The HQ pipeline forces stg_blocks=[] in its own default guider+ # params, so we hand it explicit params with stg_blocks=[28] (the+ # block the one/two-stage pipelines perturb). Mirror the pipeline's+ # other defaults verbatim (cfg/rescale/modality) so STG is the only+ # thing that changes. At stg_scale<=0 we pass nothing → the pipeline+ # builds its own [] params → byte-identical to the pre-slider path.+ _stg = float(kwargs.get("stg_scale", 0.0))+ if _stg > 0.0:+ try:+ from ltx_core_mlx.components.guiders import MultiModalGuiderParams+ kwargs["video_guider_params"] = MultiModalGuiderParams(+ cfg_scale=float(kwargs.get("cfg_scale", 3.0)),+ stg_scale=_stg,+ rescale_scale=0.45,+ modality_scale=3.0,+ stg_blocks=[28],+ )+ kwargs["audio_guider_params"] = MultiModalGuiderParams(+ cfg_scale=7.0,+ stg_scale=_stg,+ rescale_scale=1.0,+ modality_scale=3.0,+ stg_blocks=[28],+ )+ emit({"event": "log", "line": f"STG detail guidance ON — stg_scale={_stg:g}, stg_blocks=[28]"})+ except Exception as _stg_exc:+ # Never let STG wiring block a render — fall back to the+ # plain (STG-off) HQ path if the import/shape ever drifts.+ emit({"event": "log", "line": f"STG setup skipped ({_stg_exc}); rendering without STG."})img = p.get("image")if img:if not os.path.exists(img):@@ -2474,6 +2584,79 @@ for line in sys.__stdin__:_is_busy = Falsecontinue+ if action == "generate_a2v_distilled":+ # Audio-to-Video via the Q4 distilled pipeline (no dev transformer,+ # no CFG, 8+3 steps). Fits 24 GB systems where Q8 dev doesn't.+ job_id = msg.get("id", "?")+ p = msg.get("params", {}) or {}+ model_dir = p.get("model_dir") or MODEL_ID+ seed = int(p.get("seed", -1))+ if seed == -1:+ seed = random.randint(0, 2**31 - 1)+ _is_busy = True+ try:+ t0 = time.time()+ configure_acceleration("off")+ audio_path = p.get("audio_path") or ""+ if not audio_path:+ raise RuntimeError("audio_path is required for A2V")+ if not os.path.exists(audio_path):+ raise RuntimeError(f"audio file not found: {audio_path}")+ num_frames = int(p["frames"])+ pipe = get_a2v_distilled_pipe(model_dir)+ _apply_vae_streaming_decision(num_frames)+ kwargs = dict(+ prompt=p["prompt"],+ output_path=p["output_path"],+ audio_path=audio_path,+ height=int(p["height"]),+ width=int(p["width"]),+ num_frames=num_frames,+ frame_rate=float(p.get("frame_rate", 24.0)),+ seed=seed,+ stage1_steps=int(p.get("stage1_steps", 8)),+ stage2_steps=int(p.get("stage2_steps", 3)),+ audio_start_time=float(p.get("audio_start_time", 0.0)),+ audio_conditioning_scale=float(p.get("audio_conditioning_scale", 1.0)),+ )+ ref_image = p.get("image") or None+ if ref_image:+ if not os.path.exists(ref_image):+ raise RuntimeError(f"reference image not found: {ref_image}")+ kwargs["image"] = ref_image+ amd = p.get("audio_max_duration")+ if amd is not None:+ try:+ kwargs["audio_max_duration"] = float(amd)+ except (TypeError, ValueError):+ pass+ emit({+ "event": "log",+ "line": (+ f"step:generate_a2v_distilled {kwargs['width']}x{kwargs['height']} "+ f"{kwargs['num_frames']}f @{kwargs['frame_rate']:.1f}fps "+ f"stage1={kwargs['stage1_steps']} stage2={kwargs['stage2_steps']} "+ f"audio={os.path.basename(audio_path)}"+ f" a2v_scale={kwargs.get('audio_conditioning_scale', 1.0)}"+ f"{' image=' + os.path.basename(ref_image) if ref_image else ''}"+ ),+ })+ kwargs = _filter_unsupported_kwargs(pipe.generate_and_save, kwargs)+ out_path = pipe.generate_and_save(**kwargs)+ elapsed = round(time.time() - t0, 2)+ _last_activity = time.time()+ emit({+ "event": "done", "id": job_id,+ "output": str(out_path), "elapsed_sec": elapsed,+ "seed_used": seed,+ })+ except Exception as exc:+ _last_activity = time.time()+ emit({"event": "error", "id": job_id, "error": str(exc), "trace": traceback.format_exc()})+ finally:+ _is_busy = False+ continue+if action == "generate_hdr":# HDR via IC-LoRA. Phase 1 of IC-LoRA support in Phosphene.# Uses HDRICLoraPipeline from ltx_pipelines_mlx.hdr_ic_lora —@@ -2569,6 +2752,147 @@ for line in sys.__stdin__:_is_busy = Falsecontinue+ if action == "generate_restore":+ # IC-LoRA reference-conditioned render. Serves TWO panel modes through+ # one code path (both fuse an IC-LoRA + ride a source clip on the IC+ # reference channel via ICLoraPipeline):+ # - Colorize (mode=restore): the source is a B&W clip; LoRA strength+ # 1.0; two-stage (skip_stage_2 unset). The first real IC-LoRA+ # feature on un-gated weights (DoctorDiffusion Colorizer).+ # - Ingredients (mode=ingredients): the "source" is the reference+ # SHEET looped to N frames (the panel composes + writes it); LoRA+ # strength 1.4; single-stage (skip_stage_2=True). Flagship+ # multi-reference composition.+ # Mechanically this mirrors generate_hdr but with TWO deliberate+ # differences:+ # (a) ICLoraPipeline (ltx_pipelines_mlx.ic_lora), NOT+ # HDRICLoraPipeline. The community Colorize LoRA carries no+ # hdr_transform metadata — only reference_downscale_factor=1 —+ # so the LogC3 inverse + HDR .npz companion the HDR class adds+ # would be wrong here. ICLoraPipeline fuses the LoRA, runs the+ # two-stage walk, and writes a plain SDR mp4.+ # (b) A non-empty SOURCE video is REQUIRED. It rides the IC+ # reference channel as video_conditioning=[(src, strength)] —+ # the B&W clip the user wants colorized. (HDR Phase 1 ran+ # text-driven with video_conditioning=[].) Verified on MLX by+ # the de-risk render (scratchpad/ic_colorize_smoke.py).+ #+ # Routing: like HDR, the LoRA was trained against the Q4 distilled+ # checkpoint, so the panel forces model_dir onto the Q4 distilled+ # folder. ffprobe (probe_video_info, called inside generate_and_save+ # for the reference video) needs FFMPEG_BIN on PATH — the helper+ # inherits it from the panel (mlx_ltx_panel.py:5008).+ job_id = msg.get("id", "?")+ p = msg.get("params", {}) or {}+ model_dir = p.get("model_dir") or MODEL_ID+ seed = int(p.get("seed", -1))+ if seed == -1:+ seed = random.randint(0, 2**31 - 1)+ _is_busy = True+ try:+ t0 = time.time()+ configure_acceleration("off")+ from ltx_pipelines_mlx.ic_lora import ICLoraPipeline+ loras = p.get("loras") or []+ if not loras:+ raise RuntimeError(+ "Restore job requires the Colorize IC-LoRA in `loras`. The "+ "panel should have injected the curated colorize LoRA."+ )+ # A source video is mandatory — it IS the IC reference channel.+ video_conditioning = p.get("video_conditioning") or []+ if not video_conditioning:+ raise RuntimeError(+ "Restore (Colorize) requires a source video. The panel "+ "should have set video_conditioning=[(src, strength)] from "+ "restore_video_path."+ )+ # Resolve each LoRA path (HF repo id → local safetensors via+ # snapshot_download + largest-file pick; absolute path → pass-through).+ resolved = [+ (_resolve_lora_path(str(l["path"])), float(l.get("strength", 1.0)))+ for l in loras+ ]+ num_frames = int(p["frames"])+ _apply_vae_streaming_decision(num_frames)+ # Tear down any existing cached pipeline before instantiating+ # ICLoraPipeline — it loads its own DiT + VAE at init, so holding+ # the t2v / i2v caches just doubles the memory footprint.+ release_pipelines("restore render incoming")+ pipe = ICLoraPipeline(+ model_dir=Path(model_dir),+ lora_paths=resolved,+ low_memory=LOW_MEMORY,+ )+ emit({"event": "log",+ "line": f"step:generate_restore {p['width']}x{p['height']} "+ f"{num_frames}f @{float(p.get('frame_rate', 24.0)):.1f}fps "+ f"stage1={int(p.get('stage1_steps', 8))} "+ f"stage2={int(p.get('stage2_steps', 3))} "+ f"loras={len(resolved)} "+ f"ref_videos={len(video_conditioning)} "+ f"ref_strengths={[round(float(s), 3) for _, s in video_conditioning]} "+ f"ref_downscale={getattr(pipe, 'reference_downscale_factor', '?')}"})+ kwargs = dict(+ prompt=p["prompt"],+ output_path=p["output_path"],+ video_conditioning=video_conditioning,+ height=int(p["height"]),+ width=int(p["width"]),+ num_frames=num_frames,+ frame_rate=float(p.get("frame_rate", 24.0)),+ seed=seed,+ stage1_steps=int(p.get("stage1_steps", 8)),+ stage2_steps=int(p.get("stage2_steps", 3)),+ )+ # Ingredients (multi-reference) reuses this same action but runs the+ # public Space's single-stage recipe — skip_stage_2=True, generated+ # at 2x the sheet resolution. Colorize leaves this False (two-stage),+ # so restore stays byte-identical. Only set the kwarg when the panel+ # asked for it, so the pipeline default still wins otherwise.+ if p.get("skip_stage_2"):+ kwargs["skip_stage_2"] = True+ kwargs = _filter_unsupported_kwargs(pipe.generate_and_save, kwargs)+ # Ingredients is single-stage ONLY (the public Space's recipe). If the+ # imported pipeline package is an older/pinned build whose+ # generate_and_save lacks `skip_stage_2`, _filter_unsupported_kwargs+ # would have SILENTLY dropped it → a two-stage run whose clean,+ # no-LoRA Stage 2 refines against the raw reference and collapses the+ # output back to a faithful copy of the sheet (static, ~no motion).+ # Fail loudly here instead of shipping that broken render. Colorize+ # never sets skip_stage_2, so this guard is inert for it (byte-identical).+ if p.get("skip_stage_2") and "skip_stage_2" not in kwargs:+ raise RuntimeError(+ "Ingredients requires single-stage generation (skip_stage_2), "+ "but the imported ltx-pipelines-mlx build's generate_and_save "+ "does not accept it — it would silently run two-stage and "+ "produce a static copy of the reference sheet. Upgrade/repair "+ "the ltx-2-mlx pipeline (need a build with skip_stage_2; "+ "v0.14.8+ has it)."+ )+ out_path = pipe.generate_and_save(**kwargs)+ # Drop the pipeline aggressively — restore jobs are rare and the+ # DiT+VAE cost is substantial; don't cache it like t2v/i2v.+ try:+ pipe = None+ from ltx_core_mlx.utils.memory import aggressive_cleanup as _ac+ _ac()+ except Exception:+ pass+ elapsed = round(time.time() - t0, 2)+ _last_activity = time.time()+ emit({+ "event": "done", "id": job_id,+ "output": str(out_path), "elapsed_sec": elapsed,+ "seed_used": seed,+ })+ except Exception as exc:+ _last_activity = time.time()+ emit({"event": "error", "id": job_id, "error": str(exc), "trace": traceback.format_exc()})+ finally:+ _is_busy = False+ continue+if action == "enhance_prompt":# Gemma-driven prompt rewriting. Same model file as the pipeline's# text encoder, but loaded as a `GemmaLanguageModel` (the wrapperdiff --git a/panel_assets/stats.html b/panel_assets/stats.htmlindex 6f8b5e3..bde4caf 100644--- a/panel_assets/stats.html+++ b/panel_assets/stats.html@@ -550,6 +550,131 @@padding: 1px 6px; border-radius: 4px;}+ /* ============================================================+ Open items board — the live "what needs attention" list.+ Two columns (issues | PRs), each a stack of rows. Newest first.+ ============================================================ */+ .board {+ display: grid; grid-template-columns: 1fr 1fr; gap: 14px;+ }+ @media (max-width: 760px) { .board { grid-template-columns: 1fr; } }+ .board-col { min-width: 0; }+ .board-col > h3 {+ display: flex; align-items: center; gap: 8px;+ }+ .board-col .count-pill {+ display: inline-flex; align-items: center; justify-content: center;+ min-width: 20px; height: 18px; padding: 0 6px;+ border-radius: var(--r-pill);+ background: var(--bg-2); border: 1px solid var(--border);+ color: var(--muted); font-size: 10.5px; font-weight: 700;+ font-family: var(--ph-font-mono); font-variant-numeric: tabular-nums;+ letter-spacing: 0;+ }+ .board-list {+ display: flex; flex-direction: column; gap: 7px;+ list-style: none; margin: 0; padding: 0;+ }+ .item {+ position: relative;+ display: block;+ background: var(--bg-2);+ border: 1px solid var(--border);+ border-left-width: 3px;+ border-radius: var(--r-md);+ padding: 11px 13px 11px 12px;+ text-decoration: none;+ color: var(--text);+ transition: border-color var(--t-base), background var(--t-base), transform var(--t-fast);+ }+ .item:hover {+ background: var(--panel-2);+ border-color: var(--border-strong);+ text-decoration: none;+ transform: translateY(-1px);+ }+ .item.is-issue { border-left-color: var(--success); }+ .item.is-pr { border-left-color: var(--purple, #B14AFF); }+ .item.is-draft { border-left-color: var(--faint); }+ .item-top {+ display: flex; align-items: baseline; gap: 8px;+ }+ .item-badge {+ flex-shrink: 0;+ display: inline-flex; align-items: center; gap: 4px;+ padding: 2px 7px; border-radius: var(--r-pill);+ font-size: 9.5px; font-weight: 700; text-transform: uppercase;+ letter-spacing: 0.06em;+ font-family: var(--ph-font-mono);+ border: 1px solid transparent;+ }+ .item-badge.issue {+ color: var(--success);+ background: rgba(63, 185, 80, 0.10);+ border-color: rgba(63, 185, 80, 0.30);+ }+ .item-badge.pr {+ color: #c99bff;+ background: rgba(177, 74, 255, 0.12);+ border-color: rgba(177, 74, 255, 0.32);+ }+ .item-badge.draft {+ color: var(--muted);+ background: rgba(140, 160, 220, 0.08);+ border-color: var(--border);+ }+ .item-num {+ flex-shrink: 0;+ color: var(--faint);+ font-family: var(--ph-font-mono); font-size: 11.5px; font-weight: 600;+ font-variant-numeric: tabular-nums;+ }+ .item-title {+ flex: 1 1 auto; min-width: 0;+ color: var(--text);+ font-size: 12.5px; font-weight: 500; line-height: 1.4;+ /* Clamp to 2 lines so a very long title can't blow up a row. */+ display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;+ overflow: hidden;+ }+ .item:hover .item-title { color: var(--accent-bright); }+ .item-meta {+ display: flex; align-items: center; gap: 8px; flex-wrap: wrap;+ margin-top: 7px;+ color: var(--faint);+ font-size: 10.5px;+ font-family: var(--ph-font-mono);+ }+ .item-meta .who { color: var(--muted); }+ .item-meta .dot { color: var(--faint); opacity: 0.6; }+ .item-meta .comments { display: inline-flex; align-items: center; gap: 3px; }+ .item-labels {+ display: inline-flex; align-items: center; gap: 5px; flex-wrap: wrap;+ }+ .item-label {+ display: inline-flex; align-items: center;+ padding: 1px 7px; border-radius: var(--r-pill);+ font-size: 9.5px; font-weight: 600; line-height: 1.5;+ border: 1px solid var(--lc, var(--border));+ color: var(--lc, var(--muted));+ background: color-mix(in srgb, var(--lc, var(--border)) 12%, transparent);+ white-space: nowrap;+ }+ .board-more {+ margin-top: 8px;+ color: var(--faint); font-size: 10.5px; font-style: italic;+ font-family: var(--ph-font-mono);+ }+ .board-empty {+ display: flex; align-items: center; gap: 8px;+ padding: 18px 14px;+ background: var(--bg-2);+ border: 1px dashed var(--border);+ border-radius: var(--r-md);+ color: var(--muted); font-size: 12px;+ }+ .board-empty .ok { color: var(--success); font-size: 14px; }+/* ============================================================Skeleton loading state.============================================================ */@@ -705,6 +830,36 @@</div></section>+ <!-- ============================================================+ NEEDS ATTENTION — live board of the actual open issues + PRs.+ Populated from the latest snapshot's `open_items` array (added+ by scripts/fetch_repo_stats.py). Hidden entirely if the fetcher+ predates the field (older snapshot) so old data degrades cleanly.+ ============================================================ -->+ <section class="card" id="sec-attention" hidden>+ <div class="section-head">+ <h2>Needs attention <span class="h2-sub">open issues & pull requests · newest first</span></h2>+ <a class="icon-btn" id="attention-repo-link"+ href="https://github.com/mrbizarro/phosphene/issues"+ target="_blank" rel="noopener"+ title="Open the issues + PRs on GitHub">+ <span class="ico">↗</span> on GitHub+ </a>+ </div>+ <div class="board">+ <div class="board-col">+ <h3>Open issues <span class="count-pill" id="attn-issues-count">0</span></h3>+ <ul class="board-list" id="attn-issues-list"></ul>+ <div class="board-more" id="attn-issues-more" hidden></div>+ </div>+ <div class="board-col">+ <h3>Open PRs <span class="count-pill" id="attn-prs-count">0</span></h3>+ <ul class="board-list" id="attn-prs-list"></ul>+ <div class="board-more" id="attn-prs-more" hidden></div>+ </div>+ </div>+ </section>+<!-- ============================================================FUNNEL — Views → Clones → Stars → Forks.============================================================ -->@@ -712,6 +867,21 @@<div class="section-head"><h2>Discovery funnel <span class="h2-sub">how the repo converts pageviews to commitment</span></h2></div>+ <!-- All-time install/user headline — the number GitHub can't show+ (it only keeps 14 days). Computed from the stitched clone archive+ in renderFunnel(). This is what "how many actual users" means. -->+ <div id="alltime-hero" style="display:grid;grid-template-columns:1fr 1fr;gap:14px;margin:0 0 16px">+ <div style="background:rgba(63,185,80,0.06);border:1px solid rgba(63,185,80,0.28);border-radius:12px;padding:16px 18px">+ <div style="font-size:11px;letter-spacing:.08em;text-transform:uppercase;color:var(--muted)">Estimated users <span style="color:#3fb950;opacity:.85">· all-time</span></div>+ <div id="ath-users" style="font-size:34px;font-weight:680;color:var(--text);line-height:1.05;margin-top:5px">—</div>+ <div id="ath-users-sub" style="font-size:11.5px;color:var(--muted);margin-top:4px">distinct installs · since first archive</div>+ </div>+ <div style="background:rgba(63,185,80,0.06);border:1px solid rgba(63,185,80,0.28);border-radius:12px;padding:16px 18px">+ <div style="font-size:11px;letter-spacing:.08em;text-transform:uppercase;color:var(--muted)">Total clones <span style="color:#3fb950;opacity:.85">· all-time</span></div>+ <div id="ath-clones" style="font-size:34px;font-weight:680;color:var(--text);line-height:1.05;margin-top:5px">—</div>+ <div id="ath-clones-sub" style="font-size:11.5px;color:var(--muted);margin-top:4px">vs GitHub's 14-day window</div>+ </div>+ </div><div class="funnel" id="funnel"aria-label="Funnel from views to clones to stars to forks"><!-- populated by JS -->@@ -1523,6 +1693,23 @@${!last ? `<div class="funnel-arrow" aria-hidden="true">›</div>` : ''}</div>`;}).join('');++ // All-time install / user headline — the number GitHub can't show.+ // clonesSeriesAllTime() unions EVERY snapshot's 14-day window into one+ // continuous history, so we recover the full record beyond GitHub's+ // 14-day cutoff. est users = sum of daily unique IPs ÷ 1.7 (reinstall+ // pattern); the true count sits between this and the raw unique sum.+ const _at = clonesSeriesAllTime(rows);+ const _atClones = _at.reduce((a, p) => a + (p.count || 0), 0);+ const _atUniq = _at.reduce((a, p) => a + (p.uniques || 0), 0);+ const _atUsers = _atUniq > 0 ? Math.round(_atUniq / 1.7) : 0;+ const _setTxt = (id, v) => { const e = document.getElementById(id); if (e) e.textContent = v; };+ _setTxt('ath-users', fmt(_atUsers));+ _setTxt('ath-clones', fmt(_atClones));+ if (_at.length) {+ _setTxt('ath-users-sub', `≈ distinct installs · ${_atUniq.toLocaleString()} unique IPs since ${_at[0].date}`);+ _setTxt('ath-clones-sub', `${_at.length} days archived · GitHub only keeps 14`);+ }}// ===================================================================@@ -2079,6 +2266,123 @@return `<span class="trend down" title="${diff.toLocaleString()} vs prior snapshot">↓</span>`;}+ // ===================================================================+ // NEEDS ATTENTION — live board of the actual open issues + PRs.+ // Reads last.open_items (added by the fetcher). Degrades to hidden+ // when the field is absent (older snapshot / fetcher).+ // ===================================================================++ /** Terse age like "3d" / "2w" / "5mo" / "1y" for the board rows. */+ function ageShort(iso) {+ const t = new Date(iso).getTime();+ if (!Number.isFinite(t)) return '';+ const s = Math.max(0, (Date.now() - t) / 1000);+ if (s < 3600) return Math.max(1, Math.floor(s / 60)) + 'm';+ if (s < 86400) return Math.floor(s / 3600) + 'h';+ const d = Math.floor(s / 86400);+ if (d < 14) return d + 'd';+ if (d < 60) return Math.floor(d / 7) + 'w';+ if (d < 365) return Math.floor(d / 30) + 'mo';+ return (d / 365).toFixed(d % 365 === 0 ? 0 : 1).replace(/\.0$/, '') + 'y';+ }++ /** One board row for an open issue / PR. */+ function openItemRow(it) {+ const isPr = !!it.is_pr;+ const draft = isPr && !!it.draft;+ const kls = draft ? 'is-draft' : (isPr ? 'is-pr' : 'is-issue');+ const badge = draft+ ? '<span class="item-badge draft">draft</span>'+ : (isPr ? '<span class="item-badge pr">PR</span>'+ : '<span class="item-badge issue">issue</span>');+ const href = it.html_url+ ? escapeAttr(it.html_url)+ : `https://github.com/mrbizarro/phosphene/issues/${encodeURIComponent(it.number)}`;+ const created = it.created_at || '';+ const age = ageShort(created);+ const ageHtml = age+ ? `<span class="dot" aria-hidden="true">·</span><span title="opened ${escapeAttr(created)}">${escapeHtml(age)}</span>`+ : '';+ const commentsHtml = (it.comments > 0)+ ? `<span class="dot" aria-hidden="true">·</span><span class="comments" title="${fmt(it.comments)} comment${it.comments === 1 ? '' : 's'}">💬 ${escapeHtml(String(it.comments))}</span>`+ : '';+ const labels = Array.isArray(it.labels) ? it.labels.slice(0, 4) : [];+ const labelsHtml = labels.length+ ? `<span class="item-labels">` + labels.map(l => {+ const raw = (l && l.color) ? String(l.color).replace(/[^0-9a-fA-F]/g, '') : '';+ const col = /^[0-9a-fA-F]{6}$/.test(raw) ? '#' + raw : 'var(--faint)';+ return `<span class="item-label" style="--lc:${col}">${escapeHtml(l.name || '')}</span>`;+ }).join('') + `</span>`+ : '';+ return `<li>+ <a class="item ${kls}" href="${href}" target="_blank" rel="noopener">+ <div class="item-top">+ ${badge}+ <span class="item-num">#${escapeHtml(String(it.number))}</span>+ <span class="item-title">${escapeHtml(it.title || '(untitled)')}</span>+ </div>+ <div class="item-meta">+ <span class="who">@${escapeHtml(it.author || 'ghost')}</span>+ ${ageHtml}+ ${commentsHtml}+ ${labelsHtml}+ </div>+ </a>+ </li>`;+ }++ function renderOpenItems(rows) {+ const sec = $('#sec-attention');+ if (!sec) return;+ const last = rows[rows.length - 1] || {};+ const items = Array.isArray(last.open_items) ? last.open_items : null;++ // Feature-detect: hide the whole section on a snapshot that predates+ // the fetcher field, so old archives don't show an empty board.+ if (items == null) { sec.hidden = true; return; }+ sec.hidden = false;++ const issues = items.filter(it => !it.is_pr);+ const prs = items.filter(it => it.is_pr);++ // Prefer the authoritative counts (open_issues / open_prs) for the+ // pills — they're the true totals even if the list itself was capped.+ const issuesTotal = (last.open_issues != null) ? last.open_issues : issues.length;+ const prsTotal = (last.open_prs != null) ? last.open_prs : prs.length;+ $('#attn-issues-count').textContent = fmt(issuesTotal);+ $('#attn-prs-count').textContent = fmt(prsTotal);++ // Cap what we actually paint per column so a big backlog stays glanceable.+ const SHOWN = 12;++ const paint = (list, listSel, moreSel, total, noun) => {+ const body = $(listSel);+ const more = $(moreSel);+ if (!list.length) {+ body.innerHTML = `<li><div class="board-empty">+ <span class="ok" aria-hidden="true">✓</span>+ <span>No open ${noun} — inbox zero.</span>+ </div></li>`;+ if (more) more.hidden = true;+ return;+ }+ body.innerHTML = list.slice(0, SHOWN).map(openItemRow).join('');+ const hiddenCount = Math.max(0, total - Math.min(list.length, SHOWN));+ const capped = !!last.open_items_truncated;+ if (more && (hiddenCount > 0 || capped)) {+ more.hidden = false;+ more.textContent = capped+ ? `+ more (list capped at fetch time) — see all on GitHub ↗`+ : `+ ${hiddenCount} more ${noun} — see all on GitHub ↗`;+ } else if (more) {+ more.hidden = true;+ }+ };++ paint(issues, '#attn-issues-list', '#attn-issues-more', issuesTotal, 'issues');+ paint(prs, '#attn-prs-list', '#attn-prs-more', prsTotal, 'PRs');+ }+function renderTables(rows) {const last = rows[rows.length - 1] || {};const refs = Array.isArray(last.referrers) ? last.referrers : [];@@ -2269,7 +2573,7 @@// ===================================================================function showError(err) {- ['sec-now', 'sec-funnel', 'sec-over-time', 'sec-traffic', 'sec-releases']+ ['sec-now', 'sec-attention', 'sec-funnel', 'sec-over-time', 'sec-traffic', 'sec-releases'].forEach(id => { const e = document.getElementById(id); if (e) e.hidden = true; });const meta = $('#meta');if (meta) meta.innerHTML = `<span style="color:var(--danger)">could not load stats</span>`;@@ -2354,6 +2658,7 @@return;}renderKpiStrip(allRows);+ renderOpenItems(allRows);renderFunnel(allRows);renderTables(allRows);renderReleases(allRows);diff --git a/required_files.json b/required_files.jsonindex 24787da..36b7c0c 100644--- a/required_files.json+++ b/required_files.json@@ -18,7 +18,8 @@"vae_decoder.safetensors","vae_encoder.safetensors","audio_vae.safetensors",- "vocoder.safetensors"+ "vocoder.safetensors",+ "spatial_upscaler_x2_v1_1.safetensors"],"download_include": ["*.json",@@ -27,7 +28,8 @@"vae_decoder.safetensors","vae_encoder.safetensors","audio_vae.safetensors",- "vocoder.safetensors"+ "vocoder.safetensors",+ "spatial_upscaler_x2_v1_1.safetensors"]},{@@ -74,6 +76,62 @@"vocoder.safetensors","spatial_upscaler_x2_v1_1.safetensors"]+ },+ {+ "key": "ic_colorize",+ "kind": "optional",+ "name": "Colorize IC-LoRA (community)",+ "blurb": "Optional. Powers the Colorize restore mode — adds natural color to a B&W source clip. Un-gated community weights (no HF token).",+ "repo_id": "DoctorDiffusion/LTX-2.3-IC-LoRA-Colorizer",+ "local_dir": "mlx_models/loras/ic",+ "size_gb": 1,+ "files": [+ "LTX-2.3-22b-IC-LoRA-Colorizer-0.9.safetensors"+ ],+ "file_sizes": {+ "LTX-2.3-22b-IC-LoRA-Colorizer-0.9.safetensors": 327287384+ },+ "download_include": [+ "LTX-2.3-22b-IC-LoRA-Colorizer-0.9.safetensors"+ ]+ },+ {+ "_comment": "Ingredients (flagship multi-reference) IC-LoRA. BYTE-IDENTICAL to the gated official Lightricks/LTX-2.3-22b-IC-LoRA-Ingredients (same 1308778338-byte size, sha256 515e4e139001ac6282357a5b35372e42e98b3affd5fcc886a52242abeed19559), mirrored un-gated. WARNING: DeepBeepMeep/LTX-2 is a ~708 GB mega-repo (71 safetensors) — the download_include here pulls ONLY the one ingredients file (1.3 GB), and the worker fallback uses hf_hub_download for the exact filename, NEVER a bare snapshot_download of the whole repo.",+ "key": "ic_ingredients",+ "kind": "optional",+ "name": "Ingredients IC-LoRA",+ "blurb": "Optional. Powers the Ingredients mode — composes 2-8 reference images (face + prop + location) into one new video. Un-gated mirror of the official weight (no HF token).",+ "repo_id": "DeepBeepMeep/LTX-2",+ "local_dir": "mlx_models/loras/ic",+ "size_gb": 2,+ "files": [+ "ltx-2.3-22b-ic-lora-ingredients-0.9.safetensors"+ ],+ "file_sizes": {+ "ltx-2.3-22b-ic-lora-ingredients-0.9.safetensors": 1308778338+ },+ "download_include": [+ "ltx-2.3-22b-ic-lora-ingredients-0.9.safetensors"+ ]+ },+ {+ "_comment": "Control (Union) IC-LoRA — drives a render's motion/structure/composition from a control video. This is the OFFICIAL Lightricks weight and it is UN-GATED + public (gated:false, single 654465352-byte safetensors), so it downloads token-less exactly like the community Colorizer — NO mrbizarro mirror, NO HF token, NO mega-repo workaround. reference_downscale_factor=2 (the IC encoder halves the control clip; handled in iclora_utils).",+ "key": "ic_union_control",+ "kind": "optional",+ "name": "Control IC-LoRA (Union, official)",+ "blurb": "Optional. Powers the Control mode — drives motion/structure/composition from a control video. Official un-gated Lightricks weight (no HF token).",+ "repo_id": "Lightricks/LTX-2.3-22b-IC-LoRA-Union-Control",+ "local_dir": "mlx_models/loras/ic",+ "size_gb": 1,+ "files": [+ "ltx-2.3-22b-ic-lora-union-control-ref0.5.safetensors"+ ],+ "file_sizes": {+ "ltx-2.3-22b-ic-lora-union-control-ref0.5.safetensors": 654465352+ },+ "download_include": [+ "ltx-2.3-22b-ic-lora-union-control-ref0.5.safetensors"+ ]}],diff --git a/scripts/fetch_repo_stats.py b/scripts/fetch_repo_stats.pyindex 8f7ce3a..0aca420 100644--- a/scripts/fetch_repo_stats.py+++ b/scripts/fetch_repo_stats.py@@ -45,6 +45,17 @@ OUTPUT SCHEMA (one JSON object per UTC day, newline-delimited)"watchers": N, # alias for stars (GH legacy)"subscribers": N, # actual GitHub "watch""open_prs": N,+ # The live "what needs attention" board: the ACTUAL open issues ++ # PRs (not just counts), newest-first, capped at OPEN_ITEMS_CAP.+ # Non-sensitive fields only — this stays local-only (gitignored).+ "open_items": [+ {"number": N, "title": "...", "author": "login",+ "created_at": "...Z", "html_url": "...", "is_pr": false,+ "labels": [{"name": "bug", "color": "d73a4a"}],+ "comments": N, "draft": false},+ ...+ ],+ "open_items_truncated": false, # true if list hit OPEN_ITEMS_CAP# Back-compat: most-recent-day slice. Same numbers as the last# element of clones_window/views_window. Kept so older dashboards# don't break.@@ -125,6 +136,10 @@ STARS_CAP = 5000FORKS_CAP = 2000ISSUES_CAP = 5000 # combined issues + PRs in one streamCOMMITS_CAP = 3000 # trailing 365-day window+# The live "open items" board only needs the current backlog head, not the+# whole history. 200 open issues+PRs is already an unusable wall on a+# glance-board; beyond that we truncate and flag it.+OPEN_ITEMS_CAP = 200# Retry policy for transient failures.RETRY_BACKOFFS = (2, 8, 30)@@ -298,6 +313,58 @@ def fetch_open_prs(repo: str) -> int:return int(r.get("total_count", 0))+def fetch_open_items(repo: str) -> list[dict]:+ """The actual list of currently-open issues AND pull requests, so the+ dashboard can render a live "what needs attention" board instead of a+ bare count.++ GitHub's /issues endpoint returns PRs too (a PR is a subclass of+ Issue), discriminated by the presence of a `pull_request` key. We keep+ only the small, non-sensitive fields the board renders — number, title,+ author login, created_at, is_pr, labels (name only), and comment count.+ We deliberately DROP body text, reactions, assignees, etc.: the board+ is a glanceable attention list, and this file is local-only anyway+ (Mr Bizarro 2026-07-10).++ Newest-first (GitHub's default sort=created&direction=desc), capped at+ OPEN_ITEMS_CAP so a viral repo's backlog can't bloat the row. The count+ fields (open_issues / open_prs) remain the source of truth for totals;+ a `truncated` flag tells the dashboard when the list is a head slice."""+ entries = _get_paginated(+ f"/repos/{repo}/issues?state=open&sort=created&direction=desc",+ max_items=OPEN_ITEMS_CAP,+ )+ out: list[dict] = []+ for e in entries:+ if not isinstance(e, dict):+ continue+ is_pr = "pull_request" in e and bool(e.get("pull_request"))+ user = e.get("user") or {}+ labels = []+ for lb in e.get("labels") or []:+ if isinstance(lb, dict):+ name = lb.get("name")+ if name:+ labels.append({+ "name": str(name)[:60],+ "color": str(lb.get("color") or "")[:6],+ })+ elif isinstance(lb, str):+ labels.append({"name": lb[:60], "color": ""})+ out.append({+ "number": int(e.get("number", 0)),+ "title": (e.get("title") or "")[:280],+ "author": str(user.get("login") or "") or "ghost",+ "created_at": e.get("created_at") or "",+ "html_url": e.get("html_url") or "",+ "is_pr": is_pr,+ "labels": labels[:6],+ "comments": int(e.get("comments", 0)),+ "draft": bool(e.get("draft", False)) if is_pr else False,+ })+ return out++def _normalize_traffic_day(entry: dict) -> dict:"""Map a Traffic-API entry to our schema. `timestamp` arrives as anISO-8601 datetime (e.g. '2026-05-08T00:00:00Z'); we keep only the@@ -642,6 +709,15 @@ def main(argv: list[str] | None = None) -> int:print(f" prs: {open_prs} (open_issues adjusted to {repo_obj['open_issues']})",flush=True)+ # The actual open issues + PRs, so the dashboard renders a live+ # attention board (not just the count). Cheap on a normal repo; capped.+ open_items = fetch_open_items(repo)+ open_items_truncated = len(open_items) >= OPEN_ITEMS_CAP+ _n_pr = sum(1 for it in open_items if it.get("is_pr"))+ print(f" open items: {len(open_items)} listed "+ f"({len(open_items) - _n_pr} issues · {_n_pr} prs)"+ + (" (TRUNCATED)" if open_items_truncated else ""), flush=True)+clones_window = fetch_clones_window(repo)views_window = fetch_views_window(repo)# Back-compat: most-recent-day slice as a dict.@@ -721,6 +797,8 @@ def main(argv: list[str] | None = None) -> int:"issues_closed": issue_pr["issues_closed"],"prs_opened": issue_pr["prs_opened"],"prs_closed": issue_pr["prs_closed"],+ "open_items": open_items,+ "open_items_truncated": open_items_truncated,"commits_timeline": commits_timeline,"release_timeline": release_timeline,"referrers": referrers,diff --git a/update.js b/update.jsindex 3caf1a1..d241096 100644--- a/update.js+++ b/update.js@@ -282,6 +282,68 @@ module.exports = {].join("\n")}},++ // ---- Colorize IC-LoRA (restore mode, ~0.3 GB, un-gated) --------------+ // Self-heal existing installs onto the Colorize restore feature. UN-GATED+ // community weights (no HF token). BEST-EFFORT — a network hiccup must not+ // fail the update; the worker falls back to the repo id, and the panel+ // surfaces Repair. hf skips it when already present (fast verify).+ {+ method: "shell.run",+ params: {+ venv: "env",+ path: "ltx-2-mlx",+ env: { HF_HUB_ENABLE_HF_TRANSFER: "1" },+ message: [+ "echo 'Ensuring the Colorize IC-LoRA is present (restore mode, optional)…' && \\",+ "hf download DoctorDiffusion/LTX-2.3-IC-LoRA-Colorizer --local-dir ../mlx_models/loras/ic --include 'LTX-2.3-22b-IC-LoRA-Colorizer-0.9.safetensors' \\",+ "|| echo 'WARN: Colorize IC-LoRA fetch failed — the Colorize mode will fetch it on first use, or click Repair.'"+ ].join("\n")+ }+ },++ // ---- Ingredients IC-LoRA (multi-reference mode, ~1.3 GB, un-gated) ----+ // Self-heal existing installs onto the flagship Ingredients feature. The+ // official weight is GATED; DeepBeepMeep/LTX-2 mirrors the BYTE-IDENTICAL+ // file un-gated (no HF token). BEST-EFFORT — must not fail the update; the+ // worker self-heals via a targeted single-file fetch, and the panel+ // surfaces Repair. CRITICAL: --include pulls ONLY the one ingredients file+ // (DeepBeepMeep/LTX-2 is a ~708 GB mega-repo). hf skips it when already+ // present (fast verify).+ {+ method: "shell.run",+ params: {+ venv: "env",+ path: "ltx-2-mlx",+ env: { HF_HUB_ENABLE_HF_TRANSFER: "1" },+ message: [+ "echo 'Ensuring the Ingredients IC-LoRA is present (multi-reference mode, optional)…' && \\",+ "hf download DeepBeepMeep/LTX-2 --local-dir ../mlx_models/loras/ic --include 'ltx-2.3-22b-ic-lora-ingredients-0.9.safetensors' \\",+ "|| echo 'WARN: Ingredients IC-LoRA fetch failed — the Ingredients mode will fetch it on first use, or click Repair.'"+ ].join("\n")+ }+ },++ // ---- Control (Union) IC-LoRA (control mode, ~0.65 GB, OFFICIAL un-gated)+ // Self-heal existing installs onto the Control feature. This is the+ // OFFICIAL Lightricks weight and it is UN-GATED + public (no HF token, no+ // mirror, no mega-repo workaround) — a plain single-file fetch like the+ // Colorize one above. BEST-EFFORT — must not fail the update; the worker+ // falls back to the repo id, and the panel surfaces Repair. hf skips it+ // when already present (fast verify).+ {+ method: "shell.run",+ params: {+ venv: "env",+ path: "ltx-2-mlx",+ env: { HF_HUB_ENABLE_HF_TRANSFER: "1" },+ message: [+ "echo 'Ensuring the Control IC-LoRA is present (Union, control mode, optional)…' && \\",+ "hf download Lightricks/LTX-2.3-22b-IC-LoRA-Union-Control --local-dir ../mlx_models/loras/ic --include 'ltx-2.3-22b-ic-lora-union-control-ref0.5.safetensors' \\",+ "|| echo 'WARN: Control IC-LoRA fetch failed — the Control mode will fetch it on first use, or click Repair.'"+ ].join("\n")+ }+ },{method: "shell.run",params: {