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
feat(enhance): protect LoRA triggers + tame Gemma's invention reflex
mrbizarro794881cb970d
diff --git a/mlx_ltx_panel.py b/mlx_ltx_panel.pyindex f9565de..c4dd8e2 100644--- a/mlx_ltx_panel.py+++ b/mlx_ltx_panel.py@@ -10828,12 +10828,49 @@ class Handler(BaseHTTPRequestHandler):mode = "t2v"if not user_prompt:self._json({"error": "no prompt provided"}, 400); return- push(f"[enhance] {mode}: {user_prompt[:80]}…")+ # 2026-05-20 — collect trigger tokens that Gemma MUST preserve+ # case-exact. Three sources, unioned:+ # 1. The panel-supplied `preserve_tokens` form field (the+ # Enhance button sends active-LoRA triggers + character+ # trigger).+ # 2. Known character names from list_characters() — covers+ # the case where the user typed a character name without+ # having loaded the LoRA yet (e.g. typing "bizarrotrn" in+ # a fresh session before the avatar picker fired).+ # 3. Tokens in the user's prompt that look like trigger words+ # (lowercase, no spaces, ends in `trn` or matches a known+ # character id) — defense in depth against (1) being+ # empty.+ preserve_raw = (form.get("preserve_tokens", [""])[0] or "").strip()+ preserve_set: set[str] = set()+ if preserve_raw:+ try:+ preserve_set.update(+ str(t).strip() for t in json.loads(preserve_raw)+ if str(t).strip()+ )+ except (TypeError, ValueError, json.JSONDecodeError):+ # Allow plain comma-separated fallback for API users+ preserve_set.update(+ t.strip() for t in preserve_raw.split(",")+ if t.strip()+ )+ try:+ for char in list_characters():+ trig = (char.get("trigger") or "").strip()+ if trig and trig in user_prompt:+ preserve_set.add(trig)+ except Exception:+ pass+ preserve_tokens = sorted(preserve_set)+ push(f"[enhance] {mode}: {user_prompt[:80]}…"+ + (f" preserve={preserve_tokens}" if preserve_tokens else ""))try:result = HELPER.run({"action": "enhance_prompt","id": f"enh-{int(time.time()*1000)}",- "params": {"prompt": user_prompt, "mode": mode, "seed": 10},+ "params": {"prompt": user_prompt, "mode": mode, "seed": 10,+ "preserve_tokens": preserve_tokens},})except Exception as exc:push(f"[enhance] failed: {exc}")@@ -22558,7 +22595,24 @@ async function enhancePrompt() {btn.innerHTML = '<svg class="ph" aria-hidden="true" style="margin-right:6px;vertical-align:-2px"><use href="#ph-sparkle-fill"/></svg>Loading Gemma… (~15s on cold start)';let res;try {+ // Collect trigger tokens to preserve case-exact through enhance.+ // Source: every active LoRA's trigger_words + the active character+ // trigger (if Character mode). Server unions these with any+ // matching character ids found in the raw prompt as a defense in+ // depth — see /prompt/enhance handler for the merge.+ const preserveTokens = [];+ if (typeof _activeLoras !== 'undefined' && Array.isArray(_activeLoras)) {+ for (const l of _activeLoras) {+ for (const t of (l.trigger_words || [])) {+ const s = String(t || '').trim();+ if (s) preserveTokens.push(s);+ }+ }+ }+ const charIdEl = document.getElementById('character_id');+ if (charIdEl && charIdEl.value) preserveTokens.push(charIdEl.value);const fd = new URLSearchParams({ prompt: original, mode });+ if (preserveTokens.length) fd.set('preserve_tokens', JSON.stringify(preserveTokens));const r = await fetch('/prompt/enhance', { method: 'POST', body: fd });res = await r.json();} catch (e) {diff --git a/mlx_warm_helper.py b/mlx_warm_helper.pyindex 2911028..4265047 100644--- a/mlx_warm_helper.py+++ b/mlx_warm_helper.py@@ -2182,6 +2182,28 @@ for line in sys.__stdin__:# that knows how to do `enhance_t2v` / `enhance_i2v`). First call# eats a ~10-15s Gemma load; cached afterwards. release_pipelines# frees Gemma when a real render comes in, so memory doesn't pile up.+ #+ # 2026-05-20 — augmented system prompt + trigger-word preservation.+ # The upstream Lightricks system prompt is good but two problems+ # showed up in practice (Mr Bizarro report):+ #+ # 1. Trigger words like `bizarrotrn` survived but got CAPITALIZED+ # ("Bizarrotrn"). The LoRA was trained against the exact+ # lowercase token — re-casing breaks tokenization and the+ # LoRA may not fire as cleanly.+ #+ # 2. The official prompt says "if input is vague, invent concrete+ # details" → Gemma invented "futuristic motorcycle" / "neon-+ # lit avenue" / "polished chrome" when the user just said+ # "cool bike". That over-decorates renders away from the+ # character LoRA's training distribution.+ #+ # Fix: pass a system_prompt= override that extends the official+ # one with PRESERVE-EXACTLY rules for the panel-supplied+ # preserve_tokens list, plus a "restrained invention" addendum.+ # Then do a post-hoc safety pass: if any preserve token isn't+ # in the output case-exact, splice it back in by replacing the+ # case-shifted variant.job_id = msg.get("id", "?")p = msg.get("params", {}) or {}user_prompt = (p.get("prompt") or "").strip()@@ -2189,6 +2211,10 @@ for line in sys.__stdin__:if mode not in ("t2v", "i2v"):mode = "t2v"seed = int(p.get("seed", 10))+ preserve_tokens = p.get("preserve_tokens") or []+ if not isinstance(preserve_tokens, list):+ preserve_tokens = []+ preserve_tokens = [str(t).strip() for t in preserve_tokens if str(t).strip()]if not user_prompt:emit({"event": "error", "id": job_id, "error": "empty prompt"})continue@@ -2196,10 +2222,65 @@ for line in sys.__stdin__:try:t0 = time.time()lm = get_gemma_lm()+ # Build augmented system prompt: official + Phosphene addendum.+ base_sys = (lm.default_gemma_t2v_system_prompt if mode == "t2v"+ else lm.default_gemma_i2v_system_prompt)+ addendum_lines = [+ "",+ "#### Phosphene addendum (overrides any conflict above):",+ "- Preserve every camera-move and shot description the user",+ " wrote verbatim. Do not add invented camera motion.",+ "- If the user said 'cool bike' / 'a guy' / vague nouns,",+ " keep them generic. DO NOT invent specific brands, model",+ " numbers, or location styles (no 'futuristic', 'neon-lit',",+ " 'polished chrome' unless the user said so).",+ "- Color and lighting: prefer one or two concrete words",+ " ('warm afternoon sun', 'overcast sky') over flowery",+ " cascades ('shimmering golden hour bathed in...').",+ "- Audio sentence stays as one trailing line that begins",+ " with 'Audio:'.",+ ]+ if preserve_tokens:+ addendum_lines += [+ "",+ "#### LoRA trigger tokens — PRESERVE CASE-EXACT:",+ ("The user's prompt contains LoRA trigger tokens that "+ "MUST appear in the output exactly as written, "+ "lowercase, no spelling changes, no capitalization "+ "changes, no substitutions:"),+ " " + ", ".join(preserve_tokens),+ ("These tokens identify trained character / style LoRAs. "+ "Re-casing or rewording them breaks tokenization and "+ "the LoRA will not fire. If you would normally rephrase "+ "(e.g. 'Bizarrotrn the man' → 'a man named Bizarro'), "+ "DO NOT — emit the token verbatim, in lowercase."),+ ]+ augmented_sys = base_sys + "\n" + "\n".join(addendum_lines)if mode == "t2v":- enhanced = lm.enhance_t2v(user_prompt, seed=seed)+ enhanced = lm.enhance_t2v(user_prompt, seed=seed,+ system_prompt=augmented_sys)else:- enhanced = lm.enhance_i2v(user_prompt, seed=seed)+ enhanced = lm.enhance_i2v(user_prompt, seed=seed,+ system_prompt=augmented_sys)+ # Post-hoc safety: case-exact restore for any preserve token+ # that Gemma still managed to mutate. Catches "Bizarrotrn" →+ # restore "bizarrotrn".+ restored: list[str] = []+ for tok in preserve_tokens:+ if not tok:+ continue+ if tok in enhanced:+ continue # already case-exact, no work+ # Case-insensitive locate + replace with case-exact token.+ import re+ pat = re.compile(re.escape(tok), re.IGNORECASE)+ new_enhanced, n = pat.subn(tok, enhanced)+ if n > 0:+ enhanced = new_enhanced+ restored.append(tok)+ if restored:+ emit({"event": "log",+ "line": f" [enhance] restored case-exact trigger(s): {', '.join(restored)}"})elapsed = round(time.time() - t0, 2)_last_activity = time.time()emit({@@ -2208,6 +2289,8 @@ for line in sys.__stdin__:"original": user_prompt,"mode": mode,"elapsed_sec": elapsed,+ "preserve_tokens": preserve_tokens,+ "restored_tokens": restored,})except Exception as exc:_last_activity = time.time()