umer-wasim commited on
Commit
4822334
·
verified ·
1 Parent(s): 4e82195

0.1.2: calmer design, models (Pro, Sound, Long, images), online GPU (Kaggle/Colab), worker

Browse files
NOTICE CHANGED
@@ -24,5 +24,21 @@ TAEHV tiny decoders taew2_1 / taew2_2 (downloaded on first run, used for Preview
24
  umT5-XXL text encoder (downloaded on first run)
25
  https://huggingface.co/google/umt5-xxl — Apache License 2.0; GGUF conversion city96/umt5-xxl-encoder-gguf
26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  You are responsible for the videos you make and how you use them. Do not use Ora to make content that is unlawful,
28
  deceptive, or that infringes other people's rights.
 
24
  umT5-XXL text encoder (downloaded on first run)
25
  https://huggingface.co/google/umt5-xxl — Apache License 2.0; GGUF conversion city96/umt5-xxl-encoder-gguf
26
 
27
+ Optional models (downloaded only if you choose them in Models, or fetched on your own online GPU)
28
+ Wan2.2 T2V A14B — Apache-2.0 (Alibaba Wan); GGUF: QuantStack/Wan2.2-T2V-A14B-GGUF
29
+ Z-Image-Turbo 6B — Apache-2.0 (Tongyi-MAI); GGUF: leejet/Z-Image-Turbo-GGUF; prompt reader Qwen3-4B-Instruct-2507 (Apache-2.0)
30
+ FLUX.1-schnell 12B — Apache-2.0 (Black Forest Labs); GGUF: leejet/FLUX.1-schnell-gguf; CLIP-L and T5-XXL encoders (Apache-2.0)
31
+ Qwen-Image-2512 20B — Apache-2.0 (Alibaba Qwen); GGUF: unsloth/Qwen-Image-2512-GGUF; prompt reader Qwen2.5-VL-7B-Instruct (Apache-2.0)
32
+ LTX-2.3 22B (distilled) — LTX-2 Community License Agreement (Lightricks): free for entities under US$10M annual revenue;
33
+ https://github.com/Lightricks/LTX-2 ; GGUF: unsloth/LTX-2.3-GGUF
34
+ Prompt reader: Gemma 3 12B (Google) — Gemma Terms of Use, https://ai.google.dev/gemma/terms ; GGUF: unsloth/gemma-3-12b-it-qat-GGUF
35
+ MiniMax H3 (pruned) — MiniMax H3 Community License Agreement: products with more than US$20M yearly revenue need written
36
+ permission from MiniMax; products using it show "MiniMax H3" (Ora does, wherever it is chosen or used).
37
+ https://huggingface.co/MiniMaxAI/MiniMax-H3 ; GGUF: leejet/MiniMax-H3-GGUF; VAEs: Comfy-Org/MiniMax-H3
38
+
39
+ Online GPU (optional, your own accounts)
40
+ The Ora GPU worker (space/worker/ora_worker.py, Apache-2.0) runs in Kaggle or Google Colab notebooks you start.
41
+ Colab connections use a Cloudflare quick tunnel (cloudflared, Apache-2.0, downloaded inside the notebook).
42
+
43
  You are responsible for the videos you make and how you use them. Do not use Ora to make content that is unlawful,
44
  deceptive, or that infringes other people's rights.
README.md CHANGED
@@ -19,10 +19,15 @@ Ora is a desktop app that makes short videos from text prompts **on your own com
19
  | Wan2.2 TI2V 5B (Quality) | 1280×704, 24 fps, 2–5 s (480p on CPU-only computers) | 3.8 GB (Q5_K_M GGUF) + 1.4 GB VAE |
20
  | umT5-XXL prompt reader (shared) | — | 4.7 GB (Q6_K GGUF) |
21
 
22
- In the app you choose where it runs (Automatic, Graphics or Processor only), see the expected time for your computer before you start, stop a run at any time, and clear the prompt history.
23
-
24
  Nothing is uploaded and no account is needed. The app downloads the models once (pinned revisions, SHA-256 checked) and then works offline.
25
 
 
 
 
 
 
 
 
26
  ## Install
27
 
28
  | System | Command |
 
19
  | Wan2.2 TI2V 5B (Quality) | 1280×704, 24 fps, 2–5 s (480p on CPU-only computers) | 3.8 GB (Q5_K_M GGUF) + 1.4 GB VAE |
20
  | umT5-XXL prompt reader (shared) | — | 4.7 GB (Q6_K GGUF) |
21
 
 
 
22
  Nothing is uploaded and no account is needed. The app downloads the models once (pinned revisions, SHA-256 checked) and then works offline.
23
 
24
+ ## Models and online GPU (0.1.2)
25
+
26
+ - **Video:** Wan2.1 1.3B (Fast/Preview), Wan2.2 5B (Quality, also animates images), Wan2.2 A14B (Pro), LTX-2.3 22B (video with sound, beta), MiniMax H3 (up to 15 s with sound, beta).
27
+ - **Images:** Z-Image-Turbo 6B, FLUX.1-schnell 12B, Qwen-Image-2512 20B.
28
+ - The app checks the computer and locks models it cannot run, with the reason.
29
+ - **Online GPU (beta):** connect your own Kaggle (API token) or Google Colab (one notebook line + connection code) and choose Run on › Online. The worker is [`worker/ora_worker.py`](worker/ora_worker.py); the CUDA engine is in the releases repo.
30
+
31
  ## Install
32
 
33
  | System | Command |
app/core.cjs CHANGED
@@ -5,10 +5,13 @@ const LENGTHS = [2, 3, 5]; // seconds offered in the app
5
  const SHAPES = ['landscape', 'portrait', 'square'];
6
  const QUALITIES = ['preview', 'draft', 'standard', 'best'];
7
 
8
- // Wan needs 4n+1 frames (the VAE packs 4 frames into one latent frame, plus the first frame).
9
- function frameCount(fps, seconds) {
10
- const n = Math.max(1, Math.round((fps * seconds - 1) / 4));
11
- return 4 * n + 1;
 
 
 
12
  }
13
 
14
  // GPU vendor ids from Chromium's app.getGPUInfo('complete').
@@ -71,33 +74,46 @@ function buildArgs(manifest, job, paths, engine) {
71
  // Preview: a quick look at composition and motion (1 s, small, 8 steps) whatever length was picked
72
  const preview = job.quality === 'preview';
73
  const [w, h] = sizeFor(model, job.shape, engine.gpu, job.quality);
74
- const frames = frameCount(model.fps, preview ? model.preview.seconds : job.seconds);
75
  const steps = preview ? model.preview.steps : (model.steps[job.quality] || model.steps.standard);
76
- const decoder = decoderFor(job, engine, paths);
 
 
 
 
77
  const args = [
78
  '-M', 'vid_gen',
79
  '--diffusion-model', paths.diffusion,
80
  // Preview decodes with the tiny TAEHV decoder (much faster, a little softer); everything else with the full VAE
81
  ...(decoder === 'tae' ? ['--tae', paths.tae] : ['--vae', paths.vae]),
82
- '--t5xxl', paths.t5,
 
83
  '-p', job.prompt,
84
- '-n', job.negative || manifest.negative,
85
  '--cfg-scale', String(model.cfg),
86
  '--sampling-method', 'euler',
87
  '--steps', String(steps),
88
- '--flow-shift', String(model.flowShift),
89
  '-W', String(w), '-H', String(h),
90
  '--video-frames', String(frames),
91
  '--fps', String(model.fps),
92
  '--seed', String(job.seed),
93
  '--vae-tiling',
94
- '-o', paths.outPattern,
 
95
  '-v',
96
  ];
 
 
 
 
 
 
 
97
  if (engine.args && engine.args.length) args.push(...engine.args);
98
  // flash attention and weight placement (GPU, RAM) are automatic in sd-cli (--flash-attn auto, --auto-fit on)
99
  if (job.threads) args.push('-t', String(job.threads));
100
- return { args, decoder, width: w, height: h, frames, fps: model.fps, steps, seconds: preview ? model.preview.seconds : job.seconds };
101
  }
102
 
103
  // sd-cli progress bar: " |=====> | 3/20 - 41.23s/it" (or it/s). Returns { done, total, secPerStep } or null.
@@ -111,7 +127,7 @@ function parseProgress(line) {
111
  // sd-cli prints the same progress bar for sampling steps and for VAE decode tiles; these lines mark the switch.
112
  function phaseChange(line) {
113
  if (/sampling completed|generating latent video completed|decode_video_outputs|VAE decode tile/i.test(line)) return 'decoding';
114
- if (/generate_video \d+x\d+x\d+/i.test(line)) return 'frames'; // printed after the prompt is read
115
  return null;
116
  }
117
 
@@ -132,9 +148,14 @@ function validateJob(job, manifest) {
132
  if (job && job.prompt && job.prompt.length > 2000) errors.push('The prompt is too long (2000 characters at most).');
133
  if (!job || !manifest.models[job.model]) errors.push('Pick a model.');
134
  if (!job || !SHAPES.includes(job.shape)) errors.push('Pick a shape.');
135
- if (!job || !LENGTHS.includes(job.seconds)) errors.push('Pick a length.');
136
  if (!job || !QUALITIES.includes(job.quality)) errors.push('Pick a quality.');
137
  if (!job || !Number.isInteger(job.seed) || job.seed < 0 || job.seed > 2 ** 31 - 1) errors.push('The seed must be a whole number.');
 
 
 
 
 
138
  return errors;
139
  }
140
 
@@ -161,4 +182,75 @@ function validateProject(p) {
161
  return errors;
162
  }
163
 
164
- module.exports = { cleanGpuName, decoderFor, phaseChange, MAX_SHOTS, folderName, validateProject, LENGTHS, SHAPES, QUALITIES, frameCount, describeGpus, pickEngine, sizeFor, buildArgs, parseProgress, parseStage, validateJob, slug };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  const SHAPES = ['landscape', 'portrait', 'square'];
6
  const QUALITIES = ['preview', 'draft', 'standard', 'best'];
7
 
8
+ // Frame counts each model family accepts: Wan 4n+1 (the VAE packs 4 frames per latent frame, plus the first),
9
+ // LTX 8n+1, MiniMax-H3 17k+5 (rounded up, at least 5).
10
+ function frameCount(fps, seconds, rule = 'wan') {
11
+ const want = fps * seconds;
12
+ if (rule === 'ltx') return 8 * Math.max(1, Math.round((want - 1) / 8)) + 1;
13
+ if (rule === 'h3') return 17 * Math.max(0, Math.ceil((want - 5) / 17)) + 5;
14
+ return 4 * Math.max(1, Math.round((want - 1) / 4)) + 1;
15
  }
16
 
17
  // GPU vendor ids from Chromium's app.getGPUInfo('complete').
 
74
  // Preview: a quick look at composition and motion (1 s, small, 8 steps) whatever length was picked
75
  const preview = job.quality === 'preview';
76
  const [w, h] = sizeFor(model, job.shape, engine.gpu, job.quality);
77
+ const frames = frameCount(model.fps, preview ? model.preview.seconds : job.seconds, model.frameRule);
78
  const steps = preview ? model.preview.steps : (model.steps[job.quality] || model.steps.standard);
79
+ const wan = !model.family || model.family === 'wan-moe';
80
+ const decoder = wan ? decoderFor(job, engine, paths) : 'vae';
81
+ // text encoders: Wan uses umT5; LTX a Gemma 3 LLM plus its embeddings connectors; MiniMax-H3 a Qwen3-VL LLM
82
+ const enc = model.family === 'ltx' ? ['--llm', paths.llm, '--embeddings-connectors', paths.connectors]
83
+ : model.family === 'h3' ? ['--llm', paths.llm, '--rng', 'cpu'] : ['--t5xxl', paths.t5];
84
  const args = [
85
  '-M', 'vid_gen',
86
  '--diffusion-model', paths.diffusion,
87
  // Preview decodes with the tiny TAEHV decoder (much faster, a little softer); everything else with the full VAE
88
  ...(decoder === 'tae' ? ['--tae', paths.tae] : ['--vae', paths.vae]),
89
+ ...enc,
90
+ ...(model.sound ? ['--audio-vae', paths.audioVae] : []),
91
  '-p', job.prompt,
92
+ ...(model.family === 'h3' ? [] : ['-n', job.negative || manifest.negative]),
93
  '--cfg-scale', String(model.cfg),
94
  '--sampling-method', 'euler',
95
  '--steps', String(steps),
96
+ ...(model.flowShift ? ['--flow-shift', String(model.flowShift)] : []),
97
  '-W', String(w), '-H', String(h),
98
  '--video-frames', String(frames),
99
  '--fps', String(model.fps),
100
  '--seed', String(job.seed),
101
  '--vae-tiling',
102
+ // models with sound write one WebM with picture and audio; the others write PNG frames for Ora to encode
103
+ '-o', model.sound ? paths.outVideo : paths.outPattern,
104
  '-v',
105
  ];
106
+ if (model.family === 'wan-moe') {
107
+ // Wan2.2 A14B: a high-noise expert lays out the scene, the low-noise expert (--diffusion-model) adds detail
108
+ const hi = preview ? Math.max(2, Math.round(steps * .7)) : (model.highSteps[job.quality] || model.highSteps.standard);
109
+ args.push('--high-noise-diffusion-model', paths.high, '--high-noise-cfg-scale', String(model.cfg),
110
+ '--high-noise-sampling-method', 'euler', '--high-noise-steps', String(hi), '--offload-to-cpu');
111
+ }
112
+ if (paths.init) args.push('-i', paths.init); // image-to-video: the engine centre-crops and resizes it to W x H
113
  if (engine.args && engine.args.length) args.push(...engine.args);
114
  // flash attention and weight placement (GPU, RAM) are automatic in sd-cli (--flash-attn auto, --auto-fit on)
115
  if (job.threads) args.push('-t', String(job.threads));
116
+ return { args, decoder, sound: !!model.sound, width: w, height: h, frames, fps: model.fps, steps, seconds: preview ? model.preview.seconds : job.seconds };
117
  }
118
 
119
  // sd-cli progress bar: " |=====> | 3/20 - 41.23s/it" (or it/s). Returns { done, total, secPerStep } or null.
 
127
  // sd-cli prints the same progress bar for sampling steps and for VAE decode tiles; these lines mark the switch.
128
  function phaseChange(line) {
129
  if (/sampling completed|generating latent video completed|decode_video_outputs|VAE decode tile/i.test(line)) return 'decoding';
130
+ if (/generate_video \d+x\d+x\d+|generate_image \d+x\d+/i.test(line)) return 'frames'; // printed after the prompt is read
131
  return null;
132
  }
133
 
 
148
  if (job && job.prompt && job.prompt.length > 2000) errors.push('The prompt is too long (2000 characters at most).');
149
  if (!job || !manifest.models[job.model]) errors.push('Pick a model.');
150
  if (!job || !SHAPES.includes(job.shape)) errors.push('Pick a shape.');
151
+ if (!job || !((manifest.models[job.model] && manifest.models[job.model].lengths) || LENGTHS).includes(job.seconds)) errors.push('Pick a length.');
152
  if (!job || !QUALITIES.includes(job.quality)) errors.push('Pick a quality.');
153
  if (!job || !Number.isInteger(job.seed) || job.seed < 0 || job.seed > 2 ** 31 - 1) errors.push('The seed must be a whole number.');
154
+ if (job && job.initImage !== undefined) {
155
+ const ii = job.initImage;
156
+ if (!ii || typeof ii.id !== 'string' || typeof ii.file !== 'string' || !/^[\w.-]+\.png$/.test(ii.file)) errors.push('Bad start image.');
157
+ if (job.model !== 'quality') errors.push('Animating an image needs the Quality (5B) model.');
158
+ }
159
  return errors;
160
  }
161
 
 
182
  return errors;
183
  }
184
 
185
+ // --- images (Z-Image-Turbo) -------------------------------------------------------------------------------------
186
+
187
+ const IMAGE_SHAPES = ['square', 'landscape', 'portrait', 'insta'];
188
+ const IMAGE_SIZES = ['small', 'large'];
189
+
190
+ function validateImageJob(job, manifest) {
191
+ const errors = [];
192
+ if (!job || typeof job.prompt !== 'string' || job.prompt.trim().length < 3) errors.push('Describe the image first.');
193
+ if (job && job.prompt && job.prompt.length > 2000) errors.push('The prompt is too long (2000 characters at most).');
194
+ if (!job || !IMAGE_SHAPES.includes(job.shape)) errors.push('Pick a shape.');
195
+ if (!job || !IMAGE_SIZES.includes(job.size)) errors.push('Pick a size.');
196
+ if (!job || !Number.isInteger(job.count) || job.count < 1 || job.count > 4) errors.push('Make 1 to 4 images.');
197
+ if (!job || !Number.isInteger(job.seed) || job.seed < 0 || job.seed > 2 ** 31 - 1) errors.push('The seed must be a whole number.');
198
+ if (!manifest.image) errors.push('No image model in this version.');
199
+ if (job && job.imageModel !== undefined && !(manifest.images && manifest.images[job.imageModel])) errors.push('Pick an image model.');
200
+ return errors;
201
+ }
202
+
203
+ // Arguments for one sd-cli image run (txt2img). job.imageModel picks the model (zimage | flux1s | qwenimg);
204
+ // paths = { diffusion, vae, llm | clip_l + t5, outPattern }.
205
+ function imageModelOf(manifest, job) { return (manifest.images && manifest.images[job.imageModel || 'zimage']) || manifest.image; }
206
+ function buildImageArgs(manifest, job, paths, engine) {
207
+ const m = imageModelOf(manifest, job);
208
+ const [w, h] = m.sizes[job.shape][job.size];
209
+ const enc = m.family === 'flux' ? ['--clip_l', paths.clip_l, '--t5xxl', paths.t5] : ['--llm', paths.llm];
210
+ const args = [
211
+ '--diffusion-model', paths.diffusion,
212
+ '--vae', paths.vae,
213
+ ...enc,
214
+ '-p', job.prompt,
215
+ '--cfg-scale', String(m.cfg),
216
+ '--steps', String(m.steps),
217
+ '--sampling-method', 'euler',
218
+ '-W', String(w), '-H', String(h),
219
+ '-b', String(job.count),
220
+ '--seed', String(job.seed),
221
+ '-o', paths.outPattern,
222
+ '-v',
223
+ ];
224
+ if (m.flowShift) args.push('--flow-shift', String(m.flowShift));
225
+ if (engine.args && engine.args.length) args.push(...engine.args);
226
+ return { args, width: w, height: h, steps: m.steps, count: job.count };
227
+ }
228
+
229
+ // Can this computer run a catalog model? hw = { platform, arch, ram, freeDisk, engine, gpus, vram (GB or null) }.
230
+ // Returns { ok, reason, warn }. Locked models stay visible with the reason.
231
+ function checkRequirements(entry, hw, downloadBytes = 0) {
232
+ const req = entry.requires || {};
233
+ const GBn = b => Math.round(b / 2 ** 30);
234
+ const ramGB = GBn(hw.ram || 0);
235
+ const apple = hw.platform === 'darwin' && hw.arch === 'arm64';
236
+ const where = apple ? `this Mac has ${ramGB} GB` : `this computer has ${ramGB} GB of memory`;
237
+ if (req.gpu) {
238
+ if (apple) {
239
+ if (req.apple && ramGB < req.apple) return { ok: false, reason: `Needs a Mac with Apple silicon and ${req.apple} GB of memory or more; ${where}.` };
240
+ } else if (hw.engine && hw.engine.gpuUnavailable) {
241
+ return { ok: false, reason: `Needs a graphics card with ${req.vram} GB of memory or more. ${hw.engine.gpuUnavailable}` };
242
+ } else {
243
+ const strong = (hw.gpus || []).filter(g => g.vendor === 'NVIDIA' || g.vendor === 'AMD');
244
+ if (!strong.length) return { ok: false, reason: `Needs an NVIDIA or AMD graphics card with ${req.vram} GB of memory or more; none was found on this computer, so Ora runs on its processor.` };
245
+ if (hw.vram != null && hw.vram < req.vram) return { ok: false, reason: `Needs ${req.vram} GB of graphics memory; your ${strong[0].name || strong[0].vendor} has ${hw.vram} GB.` };
246
+ if (hw.vram == null) var warn = `Needs ${req.vram} GB of graphics memory. Ora could not read how much your graphics card has.`;
247
+ }
248
+ }
249
+ if (req.ram && ramGB + 1 < req.ram) return { ok: false, reason: `Needs ${req.ram} GB of memory; ${where}.` };
250
+ if (downloadBytes && hw.freeDisk != null && hw.freeDisk < downloadBytes + 2e9) {
251
+ return { ok: false, reason: `Needs ${(downloadBytes / 1e9).toFixed(1)} GB of free disk space (plus 2 GB to work); ${(hw.freeDisk / 1e9).toFixed(1)} GB is free.` };
252
+ }
253
+ return { ok: true, warn };
254
+ }
255
+
256
+ module.exports = { imageModelOf, checkRequirements, IMAGE_SHAPES, IMAGE_SIZES, validateImageJob, buildImageArgs, cleanGpuName, decoderFor, phaseChange, MAX_SHOTS, folderName, validateProject, LENGTHS, SHAPES, QUALITIES, frameCount, describeGpus, pickEngine, sizeFor, buildArgs, parseProgress, parseStage, validateJob, slug };
app/main.cjs CHANGED
@@ -13,6 +13,7 @@ const crypto = require('node:crypto');
13
  const { spawn } = require('node:child_process');
14
  const { pathToFileURL } = require('node:url');
15
  const core = require('./core.cjs');
 
16
 
17
  // ORA_USER_DATA (development only): a separate app folder, so a test copy can run beside an installed Ora
18
  if (!app.isPackaged && process.env.ORA_USER_DATA) app.setPath('userData', process.env.ORA_USER_DATA);
@@ -23,7 +24,9 @@ const VIDEOS = path.join(DATA, 'videos');
23
  const SETTINGS = path.join(DATA, 'settings.json');
24
  // ORA_SAVE_DIR (development only): where test runs save their MP4s instead of the user's Videos folder
25
  const SAVE_DIR = (!app.isPackaged && process.env.ORA_SAVE_DIR) || path.join(app.getPath('videos'), 'Ora');
 
26
 
 
27
  let win = null;
28
  let download = null; // { abort() } while models download
29
  let job = null; // { id, child, cancelled } while a video renders
@@ -48,10 +51,30 @@ function writeSettings(patch) {
48
  // --- hardware and engine ---------------------------------------------------------------------------------------
49
 
50
  let gpus = [];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  async function hardware() {
52
  if (!gpus.length) {
53
  try { gpus = core.describeGpus(await app.getGPUInfo('complete')); } catch { gpus = []; }
54
  }
 
55
  const cpus = os.cpus();
56
  const engine = core.pickEngine(process.platform, process.arch, gpus, readSettings().engine);
57
  let freeDisk = null;
@@ -59,7 +82,7 @@ async function hardware() {
59
  return {
60
  platform: process.platform, arch: process.arch, osVersion: os.release(),
61
  cpu: cpus[0] ? cpus[0].model.trim() : 'unknown', cores: cpus.length,
62
- ram: os.totalmem(), gpus, engine, freeDisk,
63
  };
64
  }
65
 
@@ -86,6 +109,31 @@ function fileStatus() {
86
  return out;
87
  }
88
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  function modelsReady(modelKey) {
90
  const st = fileStatus();
91
  return manifest.models[modelKey].files.every(k => st[k].ready);
@@ -141,28 +189,31 @@ async function downloadFile(f, signal, onBytes) {
141
  fs.renameSync(part, final);
142
  }
143
 
144
- async function downloadModels() {
 
145
  if (download) return;
146
  fs.mkdirSync(MODELS, { recursive: true });
147
  const ctrl = new AbortController();
148
  download = { abort: () => ctrl.abort() };
149
  const st = fileStatus();
150
- const keys = Object.keys(manifest.files).filter(k => !st[k].ready);
 
 
151
  const need = keys.reduce((a, k) => a + manifest.files[k].size - st[k].have, 0);
152
  try {
153
  const s = await fsp.statfs(MODELS);
154
  if (s.bavail * s.bsize < need + 2e9) throw new Error(`Not enough free disk space: ${(need / 1e9).toFixed(1)} GB more is needed, plus 2 GB for videos.`);
155
  for (const k of keys) {
156
- send('download:progress', { key: k, status: fileStatus() });
157
  let last = 0;
158
  await downloadFile(manifest.files[k], ctrl.signal, have => {
159
  const now = Date.now();
160
- if (now - last > 400) { last = now; const s2 = fileStatus(); s2[k].have = have; send('download:progress', { key: k, status: s2 }); }
161
  });
162
  }
163
- send('download:done', { status: fileStatus() });
164
  } catch (e) {
165
- send('download:error', { message: ctrl.signal.aborted ? 'Paused. Press Download to continue where it stopped.' : e.message, status: fileStatus() });
166
  } finally { download = null; }
167
  }
168
 
@@ -183,90 +234,323 @@ async function listVideos() {
183
 
184
  async function writeMeta(dir, meta) { await fsp.writeFile(path.join(dir, 'meta.json'), JSON.stringify(meta, null, 2)); }
185
 
186
- async function generate(input) {
187
- if (job) throw new Error('A video is already being made.');
188
- const req = { ...input, seed: Number.isInteger(input.seed) ? input.seed : crypto.randomInt(0, 2 ** 31 - 1) };
189
- const errors = [...core.validateJob(req, manifest), ...core.validateProject(req.project)];
190
- if (errors.length) throw new Error(errors.join(' '));
191
- if (!modelsReady(req.model)) throw new Error('The models for this option are not downloaded yet.');
192
- const hw = await hardware();
193
- const files = manifest.models[req.model].files.map(k => path.join(MODELS, manifest.files[k].name));
194
- const title = req.project ? req.project.title : req.prompt;
195
- const id = `${new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19)}-${req.project ? `${req.project.index}-` : ''}${core.slug(title, 24)}`;
196
- const dir = path.join(VIDEOS, id);
197
- const framesDir = path.join(dir, 'frames');
198
- await fsp.mkdir(framesDir, { recursive: true });
199
- const run = core.buildArgs(manifest, req, { diffusion: files[0], vae: files[1], t5: files[2], tae: files[3], outPattern: path.join(framesDir, 'frame_%03d.png') }, hw.engine);
200
- const meta = {
201
- id, created: new Date().toISOString(), status: 'running', prompt: req.prompt, model: req.model, shape: req.shape,
202
- seconds: run.seconds, quality: req.quality, seed: req.seed, width: run.width, height: run.height,
203
- frames: run.frames, fps: run.fps, steps: run.steps, engine: hw.engine.id, decoder: run.decoder,
204
- project: req.project ? { folder: req.project.folder, index: req.project.index, total: req.project.total, title: req.project.title } : undefined,
205
  };
206
- await writeMeta(dir, meta);
207
- await fsp.writeFile(path.join(dir, 'command.txt'), [engineBinary(hw.engine.id), ...run.args].map(a => JSON.stringify(a)).join(' '));
208
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
209
  // ORA_FAKE_ENGINE (development only): a script that replays a recorded sd-cli run, for testing the app quickly
210
  const fake = !app.isPackaged && process.env.ORA_FAKE_ENGINE;
211
  const bin = fake ? process.execPath : engineBinary(hw.engine.id);
212
- if (fake) { run.args.unshift(fake); }
213
- if (!fs.existsSync(bin)) throw new Error(`The video engine is missing (${hw.engine.id}). Reinstall Ora.`);
214
  const started = Date.now();
215
  const log = fs.createWriteStream(path.join(dir, 'engine.log'));
216
  const env = { ...process.env };
217
  if (process.platform === 'linux') env.LD_LIBRARY_PATH = [engineDir(hw.engine.id), env.LD_LIBRARY_PATH].filter(Boolean).join(':');
218
  if (fake) env.ELECTRON_RUN_AS_NODE = '1';
219
- const child = spawn(bin, run.args, { cwd: dir, env, windowsHide: true });
220
  job = { id, child, cancelled: false };
221
- send('job:update', { id, stage: 'loading', meta, hardware: { cpu: hw.cpu, cores: hw.cores, ram: hw.ram, gpus: hw.gpus, engine: hw.engine, threads: req.threads || null } });
222
 
223
  let buf = '';
224
- let phase = 'loading'; // loading -> frames (sampling steps) -> decoding (VAE tiles)
225
  const onData = chunk => {
226
  log.write(chunk);
227
  buf += chunk.toString();
228
  const lines = buf.split(/\r|\n/);
229
  buf = lines.pop();
230
- for (const line of lines) {
231
- const ph = core.phaseChange(line);
232
- if (ph && ph !== phase) { phase = ph; send('job:update', { id, stage: ph, elapsed: Date.now() - started }); }
233
- const p = core.parseProgress(line);
234
- if (p && (phase === 'frames' || phase === 'decoding')) { send('job:update', { id, stage: phase, progress: p, elapsed: Date.now() - started }); continue; }
235
- if (phase === 'loading') { const s = core.parseStage(line); if (s) send('job:update', { id, stage: s, elapsed: Date.now() - started }); }
236
- }
237
  };
238
  child.stdout.on('data', onData);
239
  child.stderr.on('data', onData);
240
-
241
  const code = await new Promise(resolve => { child.on('close', resolve); child.on('error', e => { log.write(String(e)); resolve(-1); }); });
242
  log.end();
243
- const cancelled = job && job.cancelled;
244
  job = null;
245
- const frames = (await fsp.readdir(framesDir)).filter(f => f.endsWith('.png')).sort();
246
- meta.seconds_taken = Math.round((Date.now() - started) / 1000);
247
- if (cancelled) {
248
- await fsp.rm(dir, { recursive: true, force: true });
249
- send('job:end', { id, cancelled: true });
250
- return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
251
  }
252
- if (code !== 0 || frames.length === 0) {
253
- meta.status = 'failed';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
254
  await writeMeta(dir, meta);
255
- const tail = (await fsp.readFile(path.join(dir, 'engine.log'), 'utf8').catch(() => '')).split('\n').filter(Boolean).slice(-6).join('\n');
256
- send('job:end', { id, error: `The engine stopped (code ${code}).`, log: tail });
257
  return;
258
  }
 
259
  meta.status = 'encoding';
260
  meta.frameFiles = frames;
261
  await writeMeta(dir, meta);
262
  send('job:end', { id, meta }); // renderer now encodes the MP4 and calls video:save
263
  }
264
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
265
  function cancelJob() {
266
  if (!job) return;
267
  job.cancelled = true;
268
- try { job.child.kill(process.platform === 'win32' ? undefined : 'SIGTERM'); } catch { }
269
  const c = job.child;
 
 
270
  setTimeout(() => { try { c.kill('SIGKILL'); } catch { } }, 4000);
271
  }
272
 
@@ -293,7 +577,7 @@ async function saveEncoded(id, bytes, ext) {
293
  await fsp.copyFile(path.join(dir, file), target);
294
  // keep the first frame as a poster, drop the rest
295
  const frames = meta.frameFiles || [];
296
- if (frames[0]) await fsp.copyFile(path.join(dir, 'frames', frames[0]), path.join(dir, 'poster.png'));
297
  await fsp.rm(path.join(dir, 'frames'), { recursive: true, force: true });
298
  delete meta.frameFiles;
299
  Object.assign(meta, { status: 'done', file, savedTo: target });
@@ -357,19 +641,55 @@ app.whenReady().then(() => {
357
 
358
  ipcMain.handle('state', async () => ({
359
  version: app.getVersion(), manifest, files: fileStatus(), hardware: await hardware(), settings: readSettings(),
360
- videos: await listVideos(), saveDir: SAVE_DIR, downloading: !!download, running: job ? job.id : null,
361
  }));
362
- ipcMain.handle('download:start', () => { downloadModels(); return true; });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
363
  ipcMain.handle('download:pause', () => { if (download) download.abort(); return true; });
364
  ipcMain.handle('project:create', async (_e, name) => {
365
  const base = `${new Date().toISOString().slice(0, 10)} ${core.folderName(name, 50)}`;
366
  let folder = base, n = 2;
367
- while (fs.existsSync(path.join(SAVE_DIR, folder))) folder = `${base} ${n++}`;
368
- await fsp.mkdir(path.join(SAVE_DIR, folder), { recursive: true });
369
- return folder;
370
  });
371
  ipcMain.handle('job:start', (_e, input) => { generate(input).catch(e => send('job:end', { error: e.message })); return true; });
 
372
  ipcMain.handle('job:cancel', () => { cancelJob(); return true; });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
373
  ipcMain.handle('video:save', (_e, id, bytes, ext) => saveEncoded(id, bytes, ext));
374
  ipcMain.handle('video:fail', async (_e, id, message) => {
375
  const dir = insideVideos(id);
@@ -388,7 +708,8 @@ app.whenReady().then(() => {
388
  });
389
  ipcMain.handle('video:reveal', (_e, p) => {
390
  const real = path.resolve(String(p));
391
- if (real.startsWith(path.resolve(SAVE_DIR) + path.sep) && fs.existsSync(real)) {
 
392
  if (fs.statSync(real).isDirectory()) shell.openPath(real); else shell.showItemInFolder(real);
393
  }
394
  else shell.openPath(SAVE_DIR);
 
13
  const { spawn } = require('node:child_process');
14
  const { pathToFileURL } = require('node:url');
15
  const core = require('./core.cjs');
16
+ const { createRemote } = require('./remote.cjs');
17
 
18
  // ORA_USER_DATA (development only): a separate app folder, so a test copy can run beside an installed Ora
19
  if (!app.isPackaged && process.env.ORA_USER_DATA) app.setPath('userData', process.env.ORA_USER_DATA);
 
24
  const SETTINGS = path.join(DATA, 'settings.json');
25
  // ORA_SAVE_DIR (development only): where test runs save their MP4s instead of the user's Videos folder
26
  const SAVE_DIR = (!app.isPackaged && process.env.ORA_SAVE_DIR) || path.join(app.getPath('videos'), 'Ora');
27
+ const IMAGE_DIR = (!app.isPackaged && process.env.ORA_SAVE_DIR) ? path.join(process.env.ORA_SAVE_DIR, 'images') : path.join(app.getPath('pictures'), 'Ora');
28
 
29
+ const remote = createRemote(DATA);
30
  let win = null;
31
  let download = null; // { abort() } while models download
32
  let job = null; // { id, child, cancelled } while a video renders
 
51
  // --- hardware and engine ---------------------------------------------------------------------------------------
52
 
53
  let gpus = [];
54
+ let vram; // GB of the strongest graphics card, null when it cannot be read (undefined = not checked yet)
55
+ // Graphics memory is not in Chromium's GPU info: ask nvidia-smi (NVIDIA, Windows/Linux) or the amdgpu driver (Linux).
56
+ // Apple Silicon shares memory with the CPU, so its "graphics memory" is the RAM. Anything else: unknown.
57
+ function readVram() {
58
+ try {
59
+ const out = require('node:child_process').execFileSync('nvidia-smi', ['--query-gpu=memory.total', '--format=csv,noheader,nounits'], { timeout: 4000, windowsHide: true }).toString();
60
+ const mb = Math.max(...out.split(/\r?\n/).map(Number).filter(n => n > 0));
61
+ if (Number.isFinite(mb)) return Math.round(mb / 1024);
62
+ } catch { }
63
+ if (process.platform === 'linux') {
64
+ try {
65
+ const sizes = fs.readdirSync('/sys/class/drm').filter(d => /^card\d+$/.test(d))
66
+ .map(d => { try { return Number(fs.readFileSync(`/sys/class/drm/${d}/device/mem_info_vram_total`, 'utf8')); } catch { return 0; } });
67
+ const b = Math.max(0, ...sizes);
68
+ if (b > 0) return Math.round(b / 2 ** 30);
69
+ } catch { }
70
+ }
71
+ return null;
72
+ }
73
  async function hardware() {
74
  if (!gpus.length) {
75
  try { gpus = core.describeGpus(await app.getGPUInfo('complete')); } catch { gpus = []; }
76
  }
77
+ if (vram === undefined) vram = process.platform === 'darwin' ? null : readVram();
78
  const cpus = os.cpus();
79
  const engine = core.pickEngine(process.platform, process.arch, gpus, readSettings().engine);
80
  let freeDisk = null;
 
82
  return {
83
  platform: process.platform, arch: process.arch, osVersion: os.release(),
84
  cpu: cpus[0] ? cpus[0].model.trim() : 'unknown', cores: cpus.length,
85
+ ram: os.totalmem(), gpus, vram, engine, freeDisk,
86
  };
87
  }
88
 
 
109
  return out;
110
  }
111
 
112
+ // { diffusion: 'wan21', vae: 'vae21', … } -> the same roles with full file paths
113
+ function rolePaths(roles) {
114
+ return Object.fromEntries(Object.entries(roles || {}).map(([role, key]) => [role, path.join(MODELS, manifest.files[key].name)]));
115
+ }
116
+
117
+ // Files a catalog entry needs (video models in "models", image models in "images").
118
+ function catalogFiles(id) {
119
+ const m = manifest.models[id] || (manifest.images && manifest.images[id]);
120
+ return m ? m.files : [];
121
+ }
122
+
123
+ // The Models screen: for each entry, installed or not, bytes still to download, and whether this computer can run it.
124
+ async function catalogStatus() {
125
+ const hw = await hardware();
126
+ const st = fileStatus();
127
+ return (manifest.catalog || []).map(e => {
128
+ const files = catalogFiles(e.id);
129
+ const total = files.length ? files.reduce((a, k) => a + st[k].size, 0) : (e.size || 0);
130
+ const have = files.reduce((a, k) => a + (st[k].ready ? st[k].size : st[k].have), 0);
131
+ const toGet = files.length ? total - have : total;
132
+ const installed = files.length > 0 && files.every(k => st[k].ready);
133
+ return { ...e, installed, total, have, check: core.checkRequirements(e, hw, installed ? 0 : toGet) };
134
+ });
135
+ }
136
+
137
  function modelsReady(modelKey) {
138
  const st = fileStatus();
139
  return manifest.models[modelKey].files.every(k => st[k].ready);
 
189
  fs.renameSync(part, final);
190
  }
191
 
192
+ // set: 'required' (the video models, first run) or 'image' (the optional image model)
193
+ async function downloadModels(set = 'required') {
194
  if (download) return;
195
  fs.mkdirSync(MODELS, { recursive: true });
196
  const ctrl = new AbortController();
197
  download = { abort: () => ctrl.abort() };
198
  const st = fileStatus();
199
+ const wanted = set === 'required' ? Object.keys(manifest.files).filter(k => !manifest.files[k].optional)
200
+ : set === 'image' ? manifest.image.files : catalogFiles(set);
201
+ const keys = wanted.filter(k => !st[k].ready);
202
  const need = keys.reduce((a, k) => a + manifest.files[k].size - st[k].have, 0);
203
  try {
204
  const s = await fsp.statfs(MODELS);
205
  if (s.bavail * s.bsize < need + 2e9) throw new Error(`Not enough free disk space: ${(need / 1e9).toFixed(1)} GB more is needed, plus 2 GB for videos.`);
206
  for (const k of keys) {
207
+ send('download:progress', { set, key: k, status: fileStatus() });
208
  let last = 0;
209
  await downloadFile(manifest.files[k], ctrl.signal, have => {
210
  const now = Date.now();
211
+ if (now - last > 400) { last = now; const s2 = fileStatus(); s2[k].have = have; send('download:progress', { set, key: k, status: s2 }); }
212
  });
213
  }
214
+ send('download:done', { set, status: fileStatus() });
215
  } catch (e) {
216
+ send('download:error', { set, message: ctrl.signal.aborted ? 'Paused. Press Download to continue where it stopped.' : e.message, status: fileStatus() });
217
  } finally { download = null; }
218
  }
219
 
 
234
 
235
  async function writeMeta(dir, meta) { await fsp.writeFile(path.join(dir, 'meta.json'), JSON.stringify(meta, null, 2)); }
236
 
237
+ // Turns engine log lines (from a local sd-cli or an online worker) into job:update messages for the progress screen.
238
+ function progressFor(id, steps, started) {
239
+ let phase = 'loading'; // loading -> frames (sampling steps) -> decoding (VAE tiles)
240
+ let item = 0; // images finished sampling, for a batch
241
+ return line => {
242
+ const ph = core.phaseChange(line);
243
+ if (ph === 'decoding' && phase === 'frames') item++;
244
+ if (ph && ph !== phase) { phase = ph; send('job:update', { id, stage: ph, item, elapsed: Date.now() - started }); }
245
+ const p = core.parseProgress(line);
246
+ if (p && phase === 'decoding' && p.total === steps && p.done < p.total) { phase = 'frames'; send('job:update', { id, stage: 'frames', item, elapsed: Date.now() - started }); }
247
+ if (p && (phase === 'frames' || phase === 'decoding')) { send('job:update', { id, stage: phase, item, progress: p, elapsed: Date.now() - started }); return; }
248
+ if (phase === 'loading') { const st = core.parseStage(line); if (st) send('job:update', { id, stage: st, elapsed: Date.now() - started }); }
249
+ if (/^\[ora\] model ready/.test(line)) send('job:update', { id, stage: 'remote', note: line.replace('[ora] ', ''), elapsed: Date.now() - started });
 
 
 
 
 
 
250
  };
251
+ }
 
252
 
253
+ // GPU time Ora has used online, per platform (Kaggle and Colab do not report the remaining quota through an API).
254
+ const USAGE = path.join(DATA, 'online-usage.json');
255
+ function readUsage() { try { return JSON.parse(fs.readFileSync(USAGE, 'utf8')); } catch { return { runs: [], quota: {} }; } }
256
+ function recordUsage(where, seconds, what) {
257
+ const u = readUsage();
258
+ u.runs.push({ where, at: new Date().toISOString(), seconds: Math.max(0, Math.round(seconds)), what });
259
+ const cutoff = Date.now() - 60 * 864e5;
260
+ u.runs = u.runs.filter(x => Date.parse(x.at) > cutoff);
261
+ fs.writeFileSync(USAGE, JSON.stringify(u, null, 2));
262
+ }
263
+ function usageSummary() {
264
+ const u = readUsage(), week = Date.now() - 7 * 864e5;
265
+ const out = {};
266
+ for (const where of ['kaggle', 'colab']) {
267
+ const runs = u.runs.filter(x => x.where === where);
268
+ const last7 = runs.filter(x => Date.parse(x.at) > week).reduce((a, x) => a + x.seconds, 0);
269
+ const q = u.quota[where];
270
+ // "left": the hours the user read on the platform, minus what Ora has used since then
271
+ const since = q ? runs.filter(x => Date.parse(x.at) > Date.parse(q.at)).reduce((a, x) => a + x.seconds, 0) : 0;
272
+ out[where] = { last7, quota: q || null, left: q ? Math.max(0, q.hours * 3600 - since) : null };
273
+ }
274
+ return out;
275
+ }
276
+
277
+ // Online runs: the engine arguments use placeholders that the worker fills in on its machine.
278
+ const REMOTE_ENGINE = { id: 'remote', gpu: true, args: [] };
279
+ function placeholderPaths(roles) { return Object.fromEntries(Object.keys(roles || {}).map(role => [role, `{model:${roles[role]}}`])); }
280
+ function fileEntries(roles) {
281
+ return Object.fromEntries(Object.values(roles || {}).map(k => { const f = manifest.files[k]; return [k, { name: f.name, repo: f.repo, rev: f.rev, path: f.path, url: f.url, size: f.size }]; }));
282
+ }
283
+ async function remoteHardware(where) {
284
+ const st = remote.status()[where];
285
+ // nvidia-smi reports e.g. "Tesla T4, 15360 MiB" -> "Tesla T4 · 15 GB"
286
+ const raw = (st && st.gpu) || '';
287
+ const m = /^(.*?),\s*(\d+)\s*MiB/.exec(raw);
288
+ const name = m ? `${m[1]} · ${Math.round(+m[2] / 1024)} GB` : (raw && !/no NVIDIA/.test(raw) ? raw : 'GPU (shown after the first run)');
289
+ return { cpu: where === 'kaggle' ? 'Your Kaggle notebook' : 'Your Colab notebook', cores: 0, ram: 0, gpus: [{ vendor: '', name }], engine: { id: `online-${where}`, gpu: true, args: [] } };
290
+ }
291
+
292
+ // Runs sd-cli for one job and streams progress to the renderer. Resolves with { code, cancelled, started }.
293
+ // The same progress bar is printed for sampling steps and for decode tiles; a bar with the job's step count is
294
+ // sampling, anything else after sampling is decoding (for an image batch this alternates once per image).
295
+ async function runEngine({ id, dir, args, hw, meta, steps }) {
296
+ await fsp.writeFile(path.join(dir, 'command.txt'), [engineBinary(hw.engine.id), ...args].map(a => JSON.stringify(a)).join(' '));
297
  // ORA_FAKE_ENGINE (development only): a script that replays a recorded sd-cli run, for testing the app quickly
298
  const fake = !app.isPackaged && process.env.ORA_FAKE_ENGINE;
299
  const bin = fake ? process.execPath : engineBinary(hw.engine.id);
300
+ const argv = fake ? [fake, ...args] : args;
301
+ if (!fs.existsSync(bin)) throw new Error(`The engine is missing (${hw.engine.id}). Reinstall Ora.`);
302
  const started = Date.now();
303
  const log = fs.createWriteStream(path.join(dir, 'engine.log'));
304
  const env = { ...process.env };
305
  if (process.platform === 'linux') env.LD_LIBRARY_PATH = [engineDir(hw.engine.id), env.LD_LIBRARY_PATH].filter(Boolean).join(':');
306
  if (fake) env.ELECTRON_RUN_AS_NODE = '1';
307
+ const child = spawn(bin, argv, { cwd: dir, env, windowsHide: true });
308
  job = { id, child, cancelled: false };
309
+ send('job:update', { id, stage: 'loading', meta, hardware: { cpu: hw.cpu, cores: hw.cores, ram: hw.ram, gpus: hw.gpus, engine: hw.engine } });
310
 
311
  let buf = '';
312
+ const onLine = progressFor(id, steps, started);
313
  const onData = chunk => {
314
  log.write(chunk);
315
  buf += chunk.toString();
316
  const lines = buf.split(/\r|\n/);
317
  buf = lines.pop();
318
+ for (const line of lines) onLine(line);
 
 
 
 
 
 
319
  };
320
  child.stdout.on('data', onData);
321
  child.stderr.on('data', onData);
 
322
  const code = await new Promise(resolve => { child.on('close', resolve); child.on('error', e => { log.write(String(e)); resolve(-1); }); });
323
  log.end();
324
+ const cancelled = !!(job && job.cancelled);
325
  job = null;
326
+ return { code, cancelled, started };
327
+ }
328
+
329
+ async function engineFailed(id, dir, meta, code) {
330
+ meta.status = 'failed';
331
+ await writeMeta(dir, meta);
332
+ const tail = (await fsp.readFile(path.join(dir, 'engine.log'), 'utf8').catch(() => '')).split('\n').filter(Boolean).slice(-6).join('\n');
333
+ send('job:end', { id, error: `The engine stopped (code ${code}).`, log: tail });
334
+ }
335
+
336
+ function newId(title, project) {
337
+ return `${new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19)}-${project ? `${project.index}-` : ''}${core.slug(title, 24)}`;
338
+ }
339
+
340
+ // Sets up a video job (folder, arguments, history record). where: 'local' | 'colab' | 'kaggle'.
341
+ async function prepareVideo(input, where) {
342
+ const req = { ...input, seed: Number.isInteger(input.seed) ? input.seed : crypto.randomInt(0, 2 ** 31 - 1) };
343
+ const errors = [...core.validateJob(req, manifest), ...core.validateProject(req.project)];
344
+ if (errors.length) throw new Error(errors.join(' '));
345
+ if (where === 'local' && !modelsReady(req.model)) throw new Error('The models for this option are not downloaded yet.');
346
+ let init;
347
+ if (req.initImage) {
348
+ init = path.join(insideVideos(req.initImage.id), req.initImage.file);
349
+ if (!fs.existsSync(init)) throw new Error('The start image was not found. It may have been deleted from the history.');
350
  }
351
+ const hw = where === 'local' ? await hardware() : await remoteHardware(where);
352
+ const roles = manifest.models[req.model].roles;
353
+ const title = req.project ? req.project.title : req.prompt;
354
+ const id = newId(title, req.project);
355
+ const dir = path.join(VIDEOS, id);
356
+ const framesDir = path.join(dir, 'frames');
357
+ await fsp.mkdir(framesDir, { recursive: true });
358
+ if (init) await fsp.copyFile(init, path.join(dir, 'start.png')); // keep it with the video, as its source
359
+ const paths = where === 'local'
360
+ ? { ...rolePaths(roles), init: init ? path.join(dir, 'start.png') : undefined, outPattern: path.join(framesDir, 'frame_%03d.png'), outVideo: path.join(dir, 'video.webm') }
361
+ : { ...placeholderPaths(roles), init: init ? '{init}' : undefined, outPattern: '{out}/frame_%03d.png', outVideo: '{out}/video.webm' };
362
+ // online: how to place a big model on the platform's GPUs (Kaggle has two T4s) comes from models.json
363
+ const mo = manifest.models[req.model].online || {};
364
+ const remoteEngine = { ...REMOTE_ENGINE, args: (where === 'kaggle' ? mo.kaggleArgs : mo.colabArgs) || ['--offload-to-cpu'] };
365
+ const run = core.buildArgs(manifest, req, paths, where === 'local' ? hw.engine : remoteEngine);
366
+ const meta = {
367
+ id, kind: 'video', created: new Date().toISOString(), status: 'running', prompt: req.prompt, model: req.model, shape: req.shape,
368
+ seconds: run.seconds, quality: req.quality, seed: req.seed, width: run.width, height: run.height,
369
+ frames: run.frames, fps: run.fps, steps: run.steps, engine: hw.engine.id, decoder: run.decoder, fromImage: !!init, where, sound: run.sound,
370
+ project: req.project ? { folder: req.project.folder, index: req.project.index, total: req.project.total, title: req.project.title } : undefined,
371
+ };
372
+ await writeMeta(dir, meta);
373
+ const remoteJob = where === 'local' ? null : {
374
+ id, kind: 'video', fps: run.fps, args: run.args, files: fileEntries(roles),
375
+ initPng: init ? (await fsp.readFile(path.join(dir, 'start.png'))).toString('base64') : undefined,
376
+ };
377
+ return { id, dir, framesDir, run, meta, hw, remoteJob };
378
+ }
379
+
380
+ // After the engine (local or online): an MP4 from the worker is saved directly; PNG frames go to the renderer to encode.
381
+ async function finishVideo(p, code, started) {
382
+ const { id, dir, framesDir, meta } = p;
383
+ const frames = (await fsp.readdir(framesDir).catch(() => [])).filter(f => f.endsWith('.png')).sort();
384
+ meta.seconds_taken = Math.round((Date.now() - started) / 1000);
385
+ const mp4 = path.join(dir, 'video.mp4');
386
+ const webm = path.join(dir, 'video.webm'); // models with sound, run locally (no ffmpeg here): kept as WebM
387
+ const made = fs.existsSync(mp4) ? mp4 : fs.existsSync(webm) ? webm : null;
388
+ if (code === 0 && made) {
389
+ meta.status = 'encoding';
390
  await writeMeta(dir, meta);
391
+ const saved = await saveEncoded(id, await fsp.readFile(made), made === webm ? 'webm' : 'mp4');
392
+ send('job:end', { id, meta: saved, done: true });
393
  return;
394
  }
395
+ if (code !== 0 || frames.length === 0) return engineFailed(id, dir, meta, code);
396
  meta.status = 'encoding';
397
  meta.frameFiles = frames;
398
  await writeMeta(dir, meta);
399
  send('job:end', { id, meta }); // renderer now encodes the MP4 and calls video:save
400
  }
401
 
402
+ async function generate(input) {
403
+ if (job) throw new Error('Something is already being made.');
404
+ const where = input.runOn === 'colab' ? 'colab' : 'local';
405
+ const p = await prepareVideo(input, where);
406
+ if (where === 'colab') return runOnColab(p, p.run.steps, () => finishVideo(p, 0, p.started));
407
+ const { code, cancelled, started } = await runEngine({ id: p.id, dir: p.dir, args: p.run.args, hw: p.hw, meta: p.meta, steps: p.run.steps });
408
+ if (cancelled) {
409
+ await fsp.rm(p.dir, { recursive: true, force: true });
410
+ send('job:end', { id: p.id, cancelled: true });
411
+ return;
412
+ }
413
+ return finishVideo(p, code, started);
414
+ }
415
+
416
+ // Colab: send the job, stream its log through the same progress parser, download the results into the job folder.
417
+ async function runOnColab(p, steps, finish) {
418
+ const started = Date.now();
419
+ p.started = started;
420
+ job = { id: p.id, cancelled: false, child: null };
421
+ send('job:update', { id: p.id, stage: 'loading', meta: p.meta, hardware: p.hw });
422
+ send('job:update', { id: p.id, stage: 'remote', note: 'Sent to your Colab notebook', elapsed: 0 });
423
+ const onLine = progressFor(p.id, steps, started);
424
+ const log = fs.createWriteStream(path.join(p.dir, 'engine.log'));
425
+ let res;
426
+ try {
427
+ res = await remote.runColab(p.remoteJob, p.dir, line => { log.write(line + '\n'); onLine(line); }, () => job && job.cancelled);
428
+ } catch (e) {
429
+ log.end(); job = null;
430
+ p.meta.status = 'failed'; p.meta.error = e.message; await writeMeta(p.dir, p.meta);
431
+ send('job:end', { id: p.id, error: e.message });
432
+ return;
433
+ }
434
+ log.end();
435
+ job = null;
436
+ recordUsage('colab', (Date.now() - started) / 1000, p.meta.kind);
437
+ if (res.cancelled) { await fsp.rm(p.dir, { recursive: true, force: true }); send('job:end', { id: p.id, cancelled: true }); return; }
438
+ if (res.code !== 0) return engineFailed(p.id, p.dir, p.meta, res.code);
439
+ return finish();
440
+ }
441
+
442
+ // Images: Z-Image-Turbo (or a catalog model), 1-4 per prompt. Saved as PNGs in Pictures/Ora/<project>/.
443
+ async function prepareImages(input, where) {
444
+ const req = { ...input, seed: Number.isInteger(input.seed) ? input.seed : crypto.randomInt(0, 2 ** 31 - 1) };
445
+ const errors = [...core.validateImageJob(req, manifest), ...core.validateProject(req.project)];
446
+ if (errors.length) throw new Error(errors.join(' '));
447
+ const im = core.imageModelOf(manifest, req);
448
+ if (where === 'local' && !im.files.every(k => fileStatus()[k].ready)) throw new Error('This image model is not downloaded yet.');
449
+ const hw = where === 'local' ? await hardware() : await remoteHardware(where);
450
+ const title = req.project ? req.project.title : req.prompt;
451
+ const id = newId(title, req.project);
452
+ const dir = path.join(VIDEOS, id);
453
+ await fsp.mkdir(dir, { recursive: true });
454
+ const paths = where === 'local' ? { ...rolePaths(im.roles), outPattern: path.join(dir, 'img_%02d.png') } : { ...placeholderPaths(im.roles), outPattern: '{out}/img_%02d.png' };
455
+ const run = core.buildImageArgs(manifest, req, paths, where === 'local' ? hw.engine : REMOTE_ENGINE);
456
+ const meta = {
457
+ id, kind: 'image', created: new Date().toISOString(), status: 'running', prompt: req.prompt, model: req.imageModel || 'zimage', modelLabel: im.label, shape: req.shape,
458
+ size: req.size, count: run.count, seed: req.seed, width: run.width, height: run.height, steps: run.steps, engine: hw.engine.id, where,
459
+ project: req.project ? { folder: req.project.folder, index: req.project.index, total: req.project.total, title: req.project.title } : undefined,
460
+ };
461
+ await writeMeta(dir, meta);
462
+ const remoteJob = where === 'local' ? null : { id, kind: 'image', args: run.args, files: fileEntries(im.roles) };
463
+ return { id, dir, run, meta, hw, req, remoteJob };
464
+ }
465
+
466
+ async function finishImages(p, code, started) {
467
+ const { id, dir, meta, req } = p;
468
+ const images = (await fsp.readdir(dir)).filter(f => /^img_\d+\.png$/.test(f)).sort();
469
+ meta.seconds_taken = Math.round((Date.now() - started) / 1000);
470
+ if (code !== 0 || images.length === 0) return engineFailed(id, dir, meta, code);
471
+ // copy to Pictures/Ora/<project>/ as "01 title.png", "01 title 2.png" … (shot number first, like videos)
472
+ const dirOut = path.join(IMAGE_DIR, req.project ? req.project.folder : '');
473
+ await fsp.mkdir(dirOut, { recursive: true });
474
+ const base = req.project ? `${String(req.project.index).padStart(2, '0')} ${core.folderName(req.project.title, 40)}` : `Ora ${meta.created.slice(0, 10)} ${core.slug(req.prompt, 40)}`;
475
+ meta.savedFiles = [];
476
+ for (const [i, f] of images.entries()) {
477
+ let target = path.join(dirOut, `${base}${i ? ` ${i + 1}` : ''}.png`), n = 2;
478
+ while (fs.existsSync(target)) target = path.join(dirOut, `${base}${i ? ` ${i + 1}` : ''} (${n++}).png`);
479
+ await fsp.copyFile(path.join(dir, f), target);
480
+ meta.savedFiles.push(target);
481
+ }
482
+ await fsp.copyFile(path.join(dir, images[0]), path.join(dir, 'poster.png'));
483
+ Object.assign(meta, { status: 'done', images, savedTo: meta.savedFiles[0] });
484
+ await writeMeta(dir, meta);
485
+ send('job:end', { id, meta, done: true });
486
+ }
487
+
488
+ async function generateImages(input) {
489
+ if (job) throw new Error('Something is already being made.');
490
+ const where = input.runOn === 'colab' ? 'colab' : 'local';
491
+ const p = await prepareImages(input, where);
492
+ if (where === 'colab') return runOnColab(p, p.run.steps, () => finishImages(p, 0, p.started));
493
+ const { code, cancelled, started } = await runEngine({ id: p.id, dir: p.dir, args: p.run.args, hw: p.hw, meta: p.meta, steps: p.run.steps });
494
+ if (cancelled) {
495
+ await fsp.rm(p.dir, { recursive: true, force: true });
496
+ send('job:end', { id: p.id, cancelled: true });
497
+ return;
498
+ }
499
+ return finishImages(p, code, started);
500
+ }
501
+
502
+ // Kaggle: a whole project in one notebook run (the GPU machine starts once), then each shot is finished in order.
503
+ async function runOnKaggle(inputs) {
504
+ if (job) throw new Error('Something is already being made.');
505
+ const preps = [];
506
+ for (const input of inputs) preps.push(input.kind === 'image' ? await prepareImages(input, 'kaggle') : await prepareVideo(input, 'kaggle'));
507
+ const started = Date.now();
508
+ job = { id: preps[0].id, cancelled: false, child: null, kaggle: true };
509
+ send('job:update', { id: preps[0].id, stage: 'loading', meta: preps[0].meta, hardware: preps[0].hw });
510
+ const note = (st, url) => send('job:update', { id: preps[0].id, stage: 'remote', note: { queued: 'Waiting for a Kaggle GPU…', running: 'Running on your Kaggle notebook (results arrive when it finishes)…', complete: 'Kaggle finished. Downloading the results…' }[st] || `Kaggle: ${st}`, url, elapsed: Date.now() - started });
511
+ let out;
512
+ try {
513
+ out = await remote.runKaggle(preps.map(p => p.remoteJob), note, () => job && job.cancelled);
514
+ recordUsage('kaggle', (Date.now() - started) / 1000, `${preps.length} job${preps.length > 1 ? 's' : ''}`);
515
+ } catch (e) {
516
+ recordUsage('kaggle', (Date.now() - started) / 1000, 'failed');
517
+ job = null;
518
+ for (const p of preps) { p.meta.status = 'failed'; p.meta.error = e.message; await writeMeta(p.dir, p.meta); }
519
+ send('job:end', { id: preps[0].id, error: e.message, batchEnd: true });
520
+ return;
521
+ }
522
+ job = null;
523
+ if (out.cancelled) {
524
+ for (const p of preps) await fsp.rm(p.dir, { recursive: true, force: true });
525
+ send('job:end', { id: preps[0].id, cancelled: true, batchEnd: true, note: `Stopped waiting. The run may still finish on Kaggle: ${out.url}` });
526
+ return;
527
+ }
528
+ // output files are "out/<job id>/<file>"; results.json says which jobs worked
529
+ const byPath = Object.fromEntries(out.files.map(f => [f.fileName, f.url]));
530
+ let results = [];
531
+ try { results = JSON.parse((await remote.download(byPath['out/results.json'])).toString('utf8')).results; } catch { }
532
+ for (const p of preps) {
533
+ const r = results.find(x => x.id === p.id);
534
+ if (!r || r.code !== 0) { await engineFailed(p.id, p.dir, p.meta, r ? r.code : -1); continue; }
535
+ await fsp.writeFile(path.join(p.dir, 'engine.log'), out.log || '');
536
+ for (const f of r.files) {
537
+ const url = byPath[`out/${p.id}/${f}`];
538
+ if (!url) continue;
539
+ const sub = /^frame_/.test(f) ? path.join(p.dir, 'frames') : p.dir;
540
+ await fsp.mkdir(sub, { recursive: true });
541
+ await fsp.writeFile(path.join(sub, f), await remote.download(url));
542
+ }
543
+ if (p.meta.kind === 'image') await finishImages(p, 0, started); else await finishVideo(p, 0, started);
544
+ }
545
+ send('job:end', { id: preps[0].id, batchEnd: true });
546
+ }
547
+
548
  function cancelJob() {
549
  if (!job) return;
550
  job.cancelled = true;
 
551
  const c = job.child;
552
+ if (!c) return; // online run: the runner sees job.cancelled and stops
553
+ try { c.kill(process.platform === 'win32' ? undefined : 'SIGTERM'); } catch { }
554
  setTimeout(() => { try { c.kill('SIGKILL'); } catch { } }, 4000);
555
  }
556
 
 
577
  await fsp.copyFile(path.join(dir, file), target);
578
  // keep the first frame as a poster, drop the rest
579
  const frames = meta.frameFiles || [];
580
+ if (frames[0] && fs.existsSync(path.join(dir, 'frames', frames[0]))) await fsp.copyFile(path.join(dir, 'frames', frames[0]), path.join(dir, 'poster.png'));
581
  await fsp.rm(path.join(dir, 'frames'), { recursive: true, force: true });
582
  delete meta.frameFiles;
583
  Object.assign(meta, { status: 'done', file, savedTo: target });
 
641
 
642
  ipcMain.handle('state', async () => ({
643
  version: app.getVersion(), manifest, files: fileStatus(), hardware: await hardware(), settings: readSettings(),
644
+ videos: await listVideos(), saveDir: SAVE_DIR, imageDir: IMAGE_DIR, downloading: !!download, running: job ? job.id : null,
645
  }));
646
+ ipcMain.handle('download:start', async (_e, set) => {
647
+ if (set && set !== 'required' && set !== 'image') {
648
+ const e = (await catalogStatus()).find(c => c.id === set);
649
+ if (!e || e.soon || e.builtin) throw new Error('This model cannot be downloaded.');
650
+ if (!e.check.ok) throw new Error(e.check.reason);
651
+ }
652
+ downloadModels(set === 'image' || (manifest.catalog || []).some(c => c.id === set) ? set : 'required');
653
+ return true;
654
+ });
655
+ ipcMain.handle('catalog', () => catalogStatus());
656
+ ipcMain.handle('model:remove', async (_e, id) => {
657
+ const e = (manifest.catalog || []).find(c => c.id === id);
658
+ if (!e || e.builtin || id === 'zimage') throw new Error('Built-in models cannot be removed here.');
659
+ if (job) throw new Error('Wait until the current video or image is finished.');
660
+ // only remove files no other installed model uses (A14B shares umT5 and the Wan 2.1 VAE with Fast)
661
+ const others = new Set((manifest.catalog || []).filter(c => c.id !== id).flatMap(c => catalogFiles(c.id)));
662
+ for (const k of catalogFiles(id)) if (!others.has(k)) await fsp.rm(path.join(MODELS, manifest.files[k].name), { force: true });
663
+ return catalogStatus();
664
+ });
665
  ipcMain.handle('download:pause', () => { if (download) download.abort(); return true; });
666
  ipcMain.handle('project:create', async (_e, name) => {
667
  const base = `${new Date().toISOString().slice(0, 10)} ${core.folderName(name, 50)}`;
668
  let folder = base, n = 2;
669
+ while (fs.existsSync(path.join(SAVE_DIR, folder)) || fs.existsSync(path.join(IMAGE_DIR, folder))) folder = `${base} ${n++}`;
670
+ return folder; // created when the first file is saved (Videos/Ora for videos, Pictures/Ora for images)
 
671
  });
672
  ipcMain.handle('job:start', (_e, input) => { generate(input).catch(e => send('job:end', { error: e.message })); return true; });
673
+ ipcMain.handle('image:start', (_e, input) => { generateImages(input).catch(e => send('job:end', { error: e.message })); return true; });
674
  ipcMain.handle('job:cancel', () => { cancelJob(); return true; });
675
+ ipcMain.handle('kaggle:run', (_e, inputs) => { runOnKaggle(Array.isArray(inputs) ? inputs.slice(0, 5) : []).catch(e => send('job:end', { error: e.message, batchEnd: true })); return true; });
676
+ ipcMain.handle('online:status', () => ({ ...remote.status(), usage: usageSummary() }));
677
+ ipcMain.handle('online:setQuota', (_e, where, hours) => {
678
+ const u = readUsage();
679
+ if (hours == null || hours === '') delete u.quota[where];
680
+ else if (Number.isFinite(+hours) && +hours >= 0 && +hours <= 200) u.quota[where] = { hours: +hours, at: new Date().toISOString() };
681
+ fs.writeFileSync(USAGE, JSON.stringify(u, null, 2));
682
+ return usageSummary();
683
+ });
684
+ ipcMain.handle('online:colab', (_e, code) => remote.connectColab(code));
685
+ ipcMain.handle('online:kaggleFile', async () => {
686
+ const r = await dialog.showOpenDialog(win, { title: 'Choose your kaggle.json', properties: ['openFile'], filters: [{ name: 'Kaggle token', extensions: ['json'] }] });
687
+ if (r.canceled || !r.filePaths[0]) return remote.status();
688
+ return remote.connectKaggle(await fsp.readFile(r.filePaths[0], 'utf8'));
689
+ });
690
+ ipcMain.handle('online:disconnect', (_e, which) => remote.disconnect(which === 'kaggle' ? 'kaggle' : 'colab'));
691
+ ipcMain.handle('online:open', (_e, which) => shell.openExternal(which === 'kaggle' ? 'https://www.kaggle.com/settings/account' : 'https://colab.research.google.com/#create=true'));
692
+ ipcMain.handle('online:workerLine', () => `!curl -fsSL ${remote.workerUrl} -o ora_worker.py && python3 ora_worker.py --serve`);
693
  ipcMain.handle('video:save', (_e, id, bytes, ext) => saveEncoded(id, bytes, ext));
694
  ipcMain.handle('video:fail', async (_e, id, message) => {
695
  const dir = insideVideos(id);
 
708
  });
709
  ipcMain.handle('video:reveal', (_e, p) => {
710
  const real = path.resolve(String(p));
711
+ const inside = [SAVE_DIR, IMAGE_DIR].some(d => real.startsWith(path.resolve(d) + path.sep));
712
+ if (inside && fs.existsSync(real)) {
713
  if (fs.statSync(real).isDirectory()) shell.openPath(real); else shell.showItemInFolder(real);
714
  }
715
  else shell.openPath(SAVE_DIR);
app/models.json CHANGED
@@ -51,6 +51,186 @@
51
  "url": "https://raw.githubusercontent.com/madebyollin/taehv/011dfc2112197741c540e0bdd5b7b67bcc930771/safetensors/taew2_2.safetensors",
52
  "size": 22848048,
53
  "sha256": "b84609b2a133d48434bd9636bfcb44bf05168dc436e2d3cecf26256faa1f5325"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  }
55
  },
56
  "models": {
@@ -103,7 +283,19 @@
103
  ]
104
  },
105
  "decoder": "tae"
106
- }
 
 
 
 
 
 
 
 
 
 
 
 
107
  },
108
  "quality": {
109
  "label": "Quality — Wan2.2 5B",
@@ -168,8 +360,632 @@
168
  ]
169
  },
170
  "decoder": "tae"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
  }
172
  }
173
  },
174
- "negative": "色调艳丽,过曝,静态,细节模糊不清,字幕,风格,作品,画作,画面,静止,整体发灰,最差质量,低质量,JPEG压缩残留,丑陋的,残缺的,多余的手指,画得不好的手部,画得不好的脸部,畸形的,毁容的,形态畸形的肢体,手指融合,静止不动的画面,杂乱的背景,三条腿,背景人很多,倒着走"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
  }
 
51
  "url": "https://raw.githubusercontent.com/madebyollin/taehv/011dfc2112197741c540e0bdd5b7b67bcc930771/safetensors/taew2_2.safetensors",
52
  "size": 22848048,
53
  "sha256": "b84609b2a133d48434bd9636bfcb44bf05168dc436e2d3cecf26256faa1f5325"
54
+ },
55
+ "zimg": {
56
+ "name": "z_image_turbo-Q4_K.gguf",
57
+ "repo": "leejet/Z-Image-Turbo-GGUF",
58
+ "rev": "c61c0e422dc8b541b7548cf33a4ef8302b0f8085",
59
+ "path": "z_image_turbo-Q4_K.gguf",
60
+ "size": 3864250304,
61
+ "sha256": "14b375ab4f226bc5378f68f37e899ef3c2242b8541e61e2bc1aff40976086fbd",
62
+ "optional": true
63
+ },
64
+ "qwen3": {
65
+ "name": "Qwen3-4B-Instruct-2507-Q4_K_M.gguf",
66
+ "repo": "unsloth/Qwen3-4B-Instruct-2507-GGUF",
67
+ "rev": "a06e946bb6b655725eafa393f4a9745d460374c9",
68
+ "path": "Qwen3-4B-Instruct-2507-Q4_K_M.gguf",
69
+ "size": 2497281120,
70
+ "sha256": "3605803b982cb64aead44f6c1b2ae36e3acdb41d8e46c8a94c6533bc4c67e597",
71
+ "optional": true
72
+ },
73
+ "aezi": {
74
+ "name": "z_image_ae.safetensors",
75
+ "repo": "Comfy-Org/Z-Image-Turbo",
76
+ "rev": "6fc90a3b1b653e935a0d175e260736de25b84df5",
77
+ "path": "split_files/vae/ae.safetensors",
78
+ "size": 335304388,
79
+ "sha256": "afc8e28272cd15db3919bacdb6918ce9c1ed22e96cb12c4d5ed0fba823529e38",
80
+ "optional": true
81
+ },
82
+ "w14hi": {
83
+ "name": "Wan2.2-T2V-A14B-HighNoise-Q4_K_M.gguf",
84
+ "repo": "QuantStack/Wan2.2-T2V-A14B-GGUF",
85
+ "rev": "73eafba53a1a8f29254e4c77f92e74ea27d7cd6f",
86
+ "path": "HighNoise/Wan2.2-T2V-A14B-HighNoise-Q4_K_M.gguf",
87
+ "size": 9650090496,
88
+ "sha256": "e0c490c6e316fd91ff52034e4ca66b825717e33ff11624585c0ccfcb5d410c59",
89
+ "optional": true
90
+ },
91
+ "w14lo": {
92
+ "name": "Wan2.2-T2V-A14B-LowNoise-Q4_K_M.gguf",
93
+ "repo": "QuantStack/Wan2.2-T2V-A14B-GGUF",
94
+ "rev": "73eafba53a1a8f29254e4c77f92e74ea27d7cd6f",
95
+ "path": "LowNoise/Wan2.2-T2V-A14B-LowNoise-Q4_K_M.gguf",
96
+ "size": 9650090496,
97
+ "sha256": "091a5bae02e14aa016bc9b10a7892efda4c629346b81c5dcebbe30ea2ac8923a",
98
+ "optional": true
99
+ },
100
+ "flux1s": {
101
+ "name": "flux1-schnell-q4_k.gguf",
102
+ "repo": "leejet/FLUX.1-schnell-gguf",
103
+ "rev": "c7f665ddaf9f197ff493f41fc211f5480f5f19ac",
104
+ "path": "flux1-schnell-q4_k.gguf",
105
+ "size": 6884606880,
106
+ "sha256": "619697cc4c2bf587416aa1afa98d474a44c80eb4e3a3f64ea8f99ab0ed9adb7a",
107
+ "optional": true
108
+ },
109
+ "clipl": {
110
+ "name": "clip_l.safetensors",
111
+ "repo": "comfyanonymous/flux_text_encoders",
112
+ "rev": "6af2a98e3f615bdfa612fbd85da93d1ed5f69ef5",
113
+ "path": "clip_l.safetensors",
114
+ "size": 246144152,
115
+ "sha256": "660c6f5b1abae9dc498ac2d21e1347d2abdb0cf6c0c0c8576cd796491d9a6cdd",
116
+ "optional": true
117
+ },
118
+ "t5q5": {
119
+ "name": "t5-v1_1-xxl-encoder-Q5_K_M.gguf",
120
+ "repo": "city96/t5-v1_1-xxl-encoder-gguf",
121
+ "rev": "005a6ea51a7d0b84d677b3e633bb52a8c85a83d9",
122
+ "path": "t5-v1_1-xxl-encoder-Q5_K_M.gguf",
123
+ "size": 3386856640,
124
+ "sha256": "b51cbb10b1a7aac6dd1c3b62f0ed908bfd06e0b42d2f3577d43e061361f51dae",
125
+ "optional": true
126
+ },
127
+ "qwimg": {
128
+ "name": "qwen-image-2512-Q4_K_M.gguf",
129
+ "repo": "unsloth/Qwen-Image-2512-GGUF",
130
+ "rev": "1626d7531f84b4d2ea1cd6d2e69f41ec027dd354",
131
+ "path": "qwen-image-2512-Q4_K_M.gguf",
132
+ "size": 13244758560,
133
+ "sha256": "b2a5f6249eb58ee10c9e2ce8cb1114b89897db23de2fdf7dc49140800aa928fc",
134
+ "optional": true
135
+ },
136
+ "qwvae": {
137
+ "name": "qwen_image_vae.safetensors",
138
+ "repo": "Comfy-Org/Qwen-Image_ComfyUI",
139
+ "rev": "1f12b17be14c89b026c51a91d67c32f84bb047bc",
140
+ "path": "split_files/vae/qwen_image_vae.safetensors",
141
+ "size": 253806246,
142
+ "sha256": "a70580f0213e67967ee9c95f05bb400e8fb08307e017a924bf3441223e023d1f",
143
+ "optional": true
144
+ },
145
+ "qwvl": {
146
+ "name": "Qwen2.5-VL-7B-Instruct.Q4_K_M.gguf",
147
+ "repo": "mradermacher/Qwen2.5-VL-7B-Instruct-GGUF",
148
+ "rev": "cfa2baa09946b211c107e6e104948987a64dd2c1",
149
+ "path": "Qwen2.5-VL-7B-Instruct.Q4_K_M.gguf",
150
+ "size": 4683072512,
151
+ "sha256": "0f00a930ba3108b6861ddadf74d8ebbd82e257c63eba728e62c3e8970f5eed94",
152
+ "optional": true
153
+ },
154
+ "ltxd": {
155
+ "name": "ltx-2.3-22b-distilled-1.1-Q4_K_M.gguf",
156
+ "repo": "unsloth/LTX-2.3-GGUF",
157
+ "rev": "96e8ed4925ead3db9ff4d0084f165ef6a74f28d0",
158
+ "path": "distilled-1.1/ltx-2.3-22b-distilled-1.1-Q4_K_M.gguf",
159
+ "size": 14194441248,
160
+ "sha256": "5d09efdc0b8ec2054c44a05366cd7c6634ffa333b379b1f8baf018a78974b73d",
161
+ "optional": true
162
+ },
163
+ "ltxconn": {
164
+ "name": "ltx-2.3-22b-distilled_embeddings_connectors.safetensors",
165
+ "repo": "unsloth/LTX-2.3-GGUF",
166
+ "rev": "96e8ed4925ead3db9ff4d0084f165ef6a74f28d0",
167
+ "path": "text_encoders/ltx-2.3-22b-distilled_embeddings_connectors.safetensors",
168
+ "size": 2312144712,
169
+ "sha256": "c61cbb396e2a8175d8b2da51f0fdac885a4ccd22c9f64dafa5aa2c455dc8a507",
170
+ "optional": true
171
+ },
172
+ "ltxavae": {
173
+ "name": "ltx-2.3-22b-distilled_audio_vae.safetensors",
174
+ "repo": "unsloth/LTX-2.3-GGUF",
175
+ "rev": "96e8ed4925ead3db9ff4d0084f165ef6a74f28d0",
176
+ "path": "vae/ltx-2.3-22b-distilled_audio_vae.safetensors",
177
+ "size": 364853140,
178
+ "sha256": "3cd6a6eb8cb28f5ecc12f1f3126952b2a3d2b0b42ad3270e63cefafafe0d9b57",
179
+ "optional": true
180
+ },
181
+ "ltxvvae": {
182
+ "name": "ltx-2.3-22b-distilled_video_vae.safetensors",
183
+ "repo": "unsloth/LTX-2.3-GGUF",
184
+ "rev": "96e8ed4925ead3db9ff4d0084f165ef6a74f28d0",
185
+ "path": "vae/ltx-2.3-22b-distilled_video_vae.safetensors",
186
+ "size": 1452256522,
187
+ "sha256": "e68d6d8f8a42942ac9b862cc315beb3bc30805a8876c7ad63ba5bf7a2b8e168a",
188
+ "optional": true
189
+ },
190
+ "gemma3": {
191
+ "name": "gemma-3-12b-it-qat-UD-Q4_K_XL.gguf",
192
+ "repo": "unsloth/gemma-3-12b-it-qat-GGUF",
193
+ "rev": "858acec7ec0541a46c39985c95d3b52d8f3ab183",
194
+ "path": "gemma-3-12b-it-qat-UD-Q4_K_XL.gguf",
195
+ "size": 7432229248,
196
+ "sha256": "da98f81c86916ed1c76b3eeda56b25cb7b8352b01093e2edb8028110fe2cb53b",
197
+ "optional": true
198
+ },
199
+ "h3d": {
200
+ "name": "minimax_h3_fl2va_pruned-Q4_K_M.gguf",
201
+ "repo": "leejet/MiniMax-H3-GGUF",
202
+ "rev": "d9c4c6312b4728a68a15a35626d84775a6523783",
203
+ "path": "minimax_h3_fl2va_pruned-Q4_K_M.gguf",
204
+ "size": 11420663904,
205
+ "sha256": "dd948e08ad0ba3c71bd42f368e283dd82e790f5122a63b276e22a3e0283d0c10",
206
+ "optional": true
207
+ },
208
+ "h3te": {
209
+ "name": "qwen3vl_32b_minimax_h3-Q4_K_M.gguf",
210
+ "repo": "leejet/MiniMax-H3-GGUF",
211
+ "rev": "d9c4c6312b4728a68a15a35626d84775a6523783",
212
+ "path": "qwen3vl_32b_minimax_h3-Q4_K_M.gguf",
213
+ "size": 18218065024,
214
+ "sha256": "11e6efe70a57ce7f4838c47bdbd1a1c4b8ce10e2b7747f1b065990b70f4b05fc",
215
+ "optional": true
216
+ },
217
+ "h3vvae": {
218
+ "name": "minimax_h3_video_vae_fp16.safetensors",
219
+ "repo": "Comfy-Org/MiniMax-H3",
220
+ "rev": "e5eb578a89295337b8ff433a035929ce0279e0b6",
221
+ "path": "vae/minimax_h3_video_vae_fp16.safetensors",
222
+ "size": 5207808496,
223
+ "sha256": "7c1f131492e7eddacaac9069a61b81bdd39de5cc96561e677c5eab1cdce5e522",
224
+ "optional": true
225
+ },
226
+ "h3avae": {
227
+ "name": "minimax_h3_audio_vae_fp32.safetensors",
228
+ "repo": "Comfy-Org/MiniMax-H3",
229
+ "rev": "e5eb578a89295337b8ff433a035929ce0279e0b6",
230
+ "path": "vae/minimax_h3_audio_vae_fp32.safetensors",
231
+ "size": 605254808,
232
+ "sha256": "8e505d95dd1561d47abd43d4238fd40d9bb1ae9e147ed0a4cba778d76ae4db48",
233
+ "optional": true
234
  }
235
  },
236
  "models": {
 
283
  ]
284
  },
285
  "decoder": "tae"
286
+ },
287
+ "roles": {
288
+ "diffusion": "wan21",
289
+ "vae": "vae21",
290
+ "t5": "umt5",
291
+ "tae": "tae21"
292
+ },
293
+ "lengths": [
294
+ 2,
295
+ 3,
296
+ 5
297
+ ],
298
+ "frameRule": "wan"
299
  },
300
  "quality": {
301
  "label": "Quality — Wan2.2 5B",
 
360
  ]
361
  },
362
  "decoder": "tae"
363
+ },
364
+ "roles": {
365
+ "diffusion": "wan22",
366
+ "vae": "vae22",
367
+ "t5": "umt5",
368
+ "tae": "tae22"
369
+ },
370
+ "lengths": [
371
+ 2,
372
+ 3,
373
+ 5
374
+ ],
375
+ "frameRule": "wan"
376
+ },
377
+ "pro": {
378
+ "label": "Pro — Wan2.2 A14B",
379
+ "detail": "Best Wan quality, 720p; needs a strong graphics card",
380
+ "family": "wan-moe",
381
+ "files": [
382
+ "w14lo",
383
+ "w14hi",
384
+ "vae21",
385
+ "umt5"
386
+ ],
387
+ "fps": 16,
388
+ "sizes": {
389
+ "landscape": [
390
+ 1280,
391
+ 720
392
+ ],
393
+ "portrait": [
394
+ 720,
395
+ 1280
396
+ ],
397
+ "square": [
398
+ 960,
399
+ 960
400
+ ]
401
+ },
402
+ "lowSizes": {
403
+ "landscape": [
404
+ 832,
405
+ 480
406
+ ],
407
+ "portrait": [
408
+ 480,
409
+ 832
410
+ ],
411
+ "square": [
412
+ 624,
413
+ 624
414
+ ]
415
+ },
416
+ "cfg": 3.5,
417
+ "flowShift": 3.0,
418
+ "steps": {
419
+ "draft": 6,
420
+ "standard": 10,
421
+ "best": 16
422
+ },
423
+ "highSteps": {
424
+ "draft": 4,
425
+ "standard": 8,
426
+ "best": 12
427
+ },
428
+ "preview": {
429
+ "seconds": 1,
430
+ "steps": 6,
431
+ "sizes": {
432
+ "landscape": [
433
+ 512,
434
+ 288
435
+ ],
436
+ "portrait": [
437
+ 288,
438
+ 512
439
+ ],
440
+ "square": [
441
+ 384,
442
+ 384
443
+ ]
444
+ }
445
+ },
446
+ "roles": {
447
+ "diffusion": "w14lo",
448
+ "high": "w14hi",
449
+ "vae": "vae21",
450
+ "t5": "umt5"
451
+ },
452
+ "lengths": [
453
+ 2,
454
+ 3,
455
+ 5
456
+ ],
457
+ "frameRule": "wan",
458
+ "online": {
459
+ "kaggleArgs": [
460
+ "--offload-to-cpu"
461
+ ],
462
+ "colabArgs": [
463
+ "--offload-to-cpu"
464
+ ]
465
+ }
466
+ },
467
+ "ltx23": {
468
+ "label": "Sound — LTX-2.3 22B",
469
+ "detail": "Video with matching sound, 720p",
470
+ "family": "ltx",
471
+ "sound": true,
472
+ "frameRule": "ltx",
473
+ "files": [
474
+ "ltxd",
475
+ "ltxvvae",
476
+ "ltxavae",
477
+ "gemma3",
478
+ "ltxconn"
479
+ ],
480
+ "roles": {
481
+ "diffusion": "ltxd",
482
+ "vae": "ltxvvae",
483
+ "audioVae": "ltxavae",
484
+ "llm": "gemma3",
485
+ "connectors": "ltxconn"
486
+ },
487
+ "fps": 24,
488
+ "lengths": [
489
+ 2,
490
+ 3,
491
+ 5,
492
+ 10
493
+ ],
494
+ "sizes": {
495
+ "landscape": [
496
+ 1280,
497
+ 704
498
+ ],
499
+ "portrait": [
500
+ 704,
501
+ 1280
502
+ ],
503
+ "square": [
504
+ 960,
505
+ 960
506
+ ]
507
+ },
508
+ "lowSizes": {
509
+ "landscape": [
510
+ 768,
511
+ 448
512
+ ],
513
+ "portrait": [
514
+ 448,
515
+ 768
516
+ ],
517
+ "square": [
518
+ 576,
519
+ 576
520
+ ]
521
+ },
522
+ "cfg": 1.0,
523
+ "steps": {
524
+ "draft": 6,
525
+ "standard": 8,
526
+ "best": 12
527
+ },
528
+ "online": {
529
+ "kaggleArgs": [
530
+ "--backend",
531
+ "diffusion=cuda0,te=cuda1,vae=cuda1",
532
+ "--offload-to-cpu",
533
+ "--vae-tiling"
534
+ ],
535
+ "colabArgs": [
536
+ "--offload-to-cpu",
537
+ "--vae-tiling"
538
+ ]
539
+ }
540
+ },
541
+ "h3": {
542
+ "label": "Long — MiniMax-H3",
543
+ "detail": "Up to 15 s with stereo sound",
544
+ "family": "h3",
545
+ "sound": true,
546
+ "frameRule": "h3",
547
+ "files": [
548
+ "h3d",
549
+ "h3vvae",
550
+ "h3avae",
551
+ "h3te"
552
+ ],
553
+ "roles": {
554
+ "diffusion": "h3d",
555
+ "vae": "h3vvae",
556
+ "audioVae": "h3avae",
557
+ "llm": "h3te"
558
+ },
559
+ "fps": 24,
560
+ "lengths": [
561
+ 5,
562
+ 10,
563
+ 15
564
+ ],
565
+ "sizes": {
566
+ "landscape": [
567
+ 864,
568
+ 480
569
+ ],
570
+ "portrait": [
571
+ 480,
572
+ 864
573
+ ],
574
+ "square": [
575
+ 672,
576
+ 672
577
+ ]
578
+ },
579
+ "cfg": 1.0,
580
+ "flowShift": 12.0,
581
+ "steps": {
582
+ "draft": 12,
583
+ "standard": 20,
584
+ "best": 30
585
+ },
586
+ "online": {
587
+ "kaggleArgs": [
588
+ "--backend",
589
+ "diffusion=cuda0,te=cuda0&cuda1,vae=cuda1",
590
+ "--offload-to-cpu",
591
+ "--vae-tiling"
592
+ ]
593
+ }
594
+ }
595
+ },
596
+ "negative": "色调艳丽,过曝,静态,细节模糊不清,字幕,风格,作品,画作,画面,静止,整体发灰,最差质量,低质量,JPEG压缩残留,丑陋的,残缺的,多余的手指,画得不好的手部,画得不好的脸部,畸形的,毁容的,形态畸形的肢体,手指融合,静止不动的画面,杂乱的背景,三条腿,背景人很多,倒着走",
597
+ "image": {
598
+ "label": "Z-Image-Turbo 6B",
599
+ "files": [
600
+ "zimg",
601
+ "aezi",
602
+ "qwen3"
603
+ ],
604
+ "steps": 8,
605
+ "cfg": 1.0,
606
+ "sizes": {
607
+ "square": {
608
+ "small": [
609
+ 512,
610
+ 512
611
+ ],
612
+ "large": [
613
+ 1024,
614
+ 1024
615
+ ]
616
+ },
617
+ "landscape": {
618
+ "small": [
619
+ 640,
620
+ 368
621
+ ],
622
+ "large": [
623
+ 1280,
624
+ 720
625
+ ]
626
+ },
627
+ "portrait": {
628
+ "small": [
629
+ 368,
630
+ 640
631
+ ],
632
+ "large": [
633
+ 720,
634
+ 1280
635
+ ]
636
+ },
637
+ "insta": {
638
+ "small": [
639
+ 512,
640
+ 640
641
+ ],
642
+ "large": [
643
+ 768,
644
+ 960
645
+ ]
646
+ }
647
+ },
648
+ "family": "zimage",
649
+ "roles": {
650
+ "diffusion": "zimg",
651
+ "vae": "aezi",
652
+ "llm": "qwen3"
653
+ }
654
+ },
655
+ "images": {
656
+ "zimage": {
657
+ "label": "Z-Image-Turbo 6B",
658
+ "files": [
659
+ "zimg",
660
+ "aezi",
661
+ "qwen3"
662
+ ],
663
+ "steps": 8,
664
+ "cfg": 1.0,
665
+ "sizes": {
666
+ "square": {
667
+ "small": [
668
+ 512,
669
+ 512
670
+ ],
671
+ "large": [
672
+ 1024,
673
+ 1024
674
+ ]
675
+ },
676
+ "landscape": {
677
+ "small": [
678
+ 640,
679
+ 368
680
+ ],
681
+ "large": [
682
+ 1280,
683
+ 720
684
+ ]
685
+ },
686
+ "portrait": {
687
+ "small": [
688
+ 368,
689
+ 640
690
+ ],
691
+ "large": [
692
+ 720,
693
+ 1280
694
+ ]
695
+ },
696
+ "insta": {
697
+ "small": [
698
+ 512,
699
+ 640
700
+ ],
701
+ "large": [
702
+ 768,
703
+ 960
704
+ ]
705
+ }
706
+ },
707
+ "family": "zimage",
708
+ "roles": {
709
+ "diffusion": "zimg",
710
+ "vae": "aezi",
711
+ "llm": "qwen3"
712
+ }
713
+ },
714
+ "flux1s": {
715
+ "label": "FLUX.1-schnell 12B",
716
+ "family": "flux",
717
+ "files": [
718
+ "flux1s",
719
+ "aezi",
720
+ "clipl",
721
+ "t5q5"
722
+ ],
723
+ "steps": 4,
724
+ "cfg": 1.0,
725
+ "sizes": {
726
+ "square": {
727
+ "small": [
728
+ 512,
729
+ 512
730
+ ],
731
+ "large": [
732
+ 1024,
733
+ 1024
734
+ ]
735
+ },
736
+ "landscape": {
737
+ "small": [
738
+ 640,
739
+ 368
740
+ ],
741
+ "large": [
742
+ 1280,
743
+ 720
744
+ ]
745
+ },
746
+ "portrait": {
747
+ "small": [
748
+ 368,
749
+ 640
750
+ ],
751
+ "large": [
752
+ 720,
753
+ 1280
754
+ ]
755
+ },
756
+ "insta": {
757
+ "small": [
758
+ 512,
759
+ 640
760
+ ],
761
+ "large": [
762
+ 768,
763
+ 960
764
+ ]
765
+ }
766
+ },
767
+ "roles": {
768
+ "diffusion": "flux1s",
769
+ "vae": "aezi",
770
+ "clip_l": "clipl",
771
+ "t5": "t5q5"
772
+ }
773
+ },
774
+ "qwenimg": {
775
+ "label": "Qwen-Image-2512 20B",
776
+ "family": "qwen",
777
+ "files": [
778
+ "qwimg",
779
+ "qwvae",
780
+ "qwvl"
781
+ ],
782
+ "steps": 20,
783
+ "cfg": 2.5,
784
+ "flowShift": 3.0,
785
+ "sizes": {
786
+ "square": {
787
+ "small": [
788
+ 512,
789
+ 512
790
+ ],
791
+ "large": [
792
+ 1024,
793
+ 1024
794
+ ]
795
+ },
796
+ "landscape": {
797
+ "small": [
798
+ 640,
799
+ 368
800
+ ],
801
+ "large": [
802
+ 1280,
803
+ 720
804
+ ]
805
+ },
806
+ "portrait": {
807
+ "small": [
808
+ 368,
809
+ 640
810
+ ],
811
+ "large": [
812
+ 720,
813
+ 1280
814
+ ]
815
+ },
816
+ "insta": {
817
+ "small": [
818
+ 512,
819
+ 640
820
+ ],
821
+ "large": [
822
+ 768,
823
+ 960
824
+ ]
825
+ }
826
+ },
827
+ "roles": {
828
+ "diffusion": "qwimg",
829
+ "vae": "qwvae",
830
+ "llm": "qwvl"
831
  }
832
  }
833
  },
834
+ "catalog": [
835
+ {
836
+ "id": "fast",
837
+ "kind": "video",
838
+ "title": "Wan2.1 T2V 1.3B",
839
+ "tag": "Fast · Preview",
840
+ "made": "480p, 2–5 s",
841
+ "license": "Apache-2.0",
842
+ "by": "Alibaba Wan",
843
+ "requires": {
844
+ "ram": 16
845
+ },
846
+ "builtin": true,
847
+ "text": "Quick drafts and social clips. Runs on any computer, including the processor alone.",
848
+ "online": {
849
+ "kaggle": true,
850
+ "colab": true
851
+ }
852
+ },
853
+ {
854
+ "id": "quality",
855
+ "kind": "video",
856
+ "title": "Wan2.2 TI2V 5B",
857
+ "tag": "Quality",
858
+ "made": "720p, 2–5 s, animates images",
859
+ "license": "Apache-2.0",
860
+ "by": "Alibaba Wan",
861
+ "requires": {
862
+ "ram": 16
863
+ },
864
+ "builtin": true,
865
+ "text": "Sharper detail and smoother motion. Also turns your images into video.",
866
+ "online": {
867
+ "kaggle": true,
868
+ "colab": true
869
+ }
870
+ },
871
+ {
872
+ "id": "pro",
873
+ "kind": "video",
874
+ "title": "Wan2.2 T2V A14B",
875
+ "tag": "Pro",
876
+ "made": "720p, 2–5 s, best Wan quality",
877
+ "license": "Apache-2.0",
878
+ "by": "Alibaba Wan",
879
+ "requires": {
880
+ "gpu": true,
881
+ "vram": 16,
882
+ "apple": 32,
883
+ "ram": 32
884
+ },
885
+ "text": "Two 14B experts (one for the overall scene, one for detail). The strongest Wan model; slow without a big graphics card.",
886
+ "online": {
887
+ "kaggle": true,
888
+ "colab": true
889
+ }
890
+ },
891
+ {
892
+ "id": "ltx23",
893
+ "kind": "video",
894
+ "title": "LTX-2.3 22B",
895
+ "tag": "With sound",
896
+ "made": "Video with matching sound, 720p, 2–10 s",
897
+ "license": "LTX-2 Community (free under $10M revenue a year)",
898
+ "by": "Lightricks",
899
+ "requires": {
900
+ "gpu": true,
901
+ "vram": 24,
902
+ "apple": 48,
903
+ "ram": 32
904
+ },
905
+ "beta": true,
906
+ "text": "Makes the picture and the sound together: footsteps, rain, music, voices. The distilled version needs only 8 steps. Prompt reader: Google Gemma 3 12B (Gemma terms).",
907
+ "online": {
908
+ "kaggle": true,
909
+ "colab": false
910
+ }
911
+ },
912
+ {
913
+ "id": "h3",
914
+ "kind": "video",
915
+ "title": "MiniMax-H3",
916
+ "tag": "Up to 15 s",
917
+ "made": "Up to 15 s in one clip, stereo sound",
918
+ "license": "MiniMax H3 Community (free under $20M revenue a year; shows \"MiniMax H3\" in the app)",
919
+ "by": "MiniMax",
920
+ "requires": {
921
+ "gpu": true,
922
+ "vram": 24,
923
+ "apple": 64,
924
+ "ram": 64
925
+ },
926
+ "text": "The longest open model today: up to 15 seconds in one clip, with sound. Uses the pruned 33B model and a 32B prompt reader, so it needs a very large graphics card, or Kaggle online.",
927
+ "beta": true,
928
+ "online": {
929
+ "kaggle": true,
930
+ "colab": false
931
+ }
932
+ },
933
+ {
934
+ "id": "zimage",
935
+ "kind": "image",
936
+ "title": "Z-Image-Turbo 6B",
937
+ "tag": "Default",
938
+ "made": "Images up to 1280×720",
939
+ "license": "Apache-2.0",
940
+ "by": "Tongyi-MAI",
941
+ "requires": {
942
+ "ram": 16
943
+ },
944
+ "text": "Photo-real product shots and posters in 8 steps. Runs on any computer.",
945
+ "online": {
946
+ "kaggle": true,
947
+ "colab": true
948
+ }
949
+ },
950
+ {
951
+ "id": "flux1s",
952
+ "kind": "image",
953
+ "title": "FLUX.1-schnell 12B",
954
+ "tag": "Sharp",
955
+ "made": "Images up to 1280×720, 4 steps",
956
+ "license": "Apache-2.0",
957
+ "by": "Black Forest Labs",
958
+ "requires": {
959
+ "gpu": true,
960
+ "vram": 8,
961
+ "apple": 16,
962
+ "ram": 16
963
+ },
964
+ "text": "Very sharp, detailed images in only 4 steps on a graphics card.",
965
+ "online": {
966
+ "kaggle": true,
967
+ "colab": true
968
+ }
969
+ },
970
+ {
971
+ "id": "qwenimg",
972
+ "kind": "image",
973
+ "title": "Qwen-Image-2512 20B",
974
+ "tag": "Best text",
975
+ "made": "Images with readable text",
976
+ "license": "Apache-2.0",
977
+ "by": "Alibaba Qwen",
978
+ "requires": {
979
+ "gpu": true,
980
+ "vram": 16,
981
+ "apple": 32,
982
+ "ram": 32
983
+ },
984
+ "text": "The newest Qwen-Image (December 2025 release): the best open model for words in images, such as posters, labels and signs, in English and Chinese.",
985
+ "online": {
986
+ "kaggle": true,
987
+ "colab": true
988
+ }
989
+ }
990
+ ]
991
  }
app/package.json CHANGED
@@ -1,7 +1,7 @@
1
  {
2
  "name": "devseis-ora",
3
  "productName": "Ora",
4
- "version": "0.1.1",
5
  "description": "Make videos from a prompt on your own computer with Wan2.1 1.3B and Wan2.2 5B.",
6
  "author": {
7
  "name": "Devseis",
@@ -38,7 +38,8 @@
38
  "core.cjs",
39
  "models.json",
40
  "renderer/**",
41
- "package.json"
 
42
  ],
43
  "asar": true,
44
  "afterPack": "scripts/after-pack.cjs",
 
1
  {
2
  "name": "devseis-ora",
3
  "productName": "Ora",
4
+ "version": "0.1.2",
5
  "description": "Make videos from a prompt on your own computer with Wan2.1 1.3B and Wan2.2 5B.",
6
  "author": {
7
  "name": "Devseis",
 
38
  "core.cjs",
39
  "models.json",
40
  "renderer/**",
41
+ "package.json",
42
+ "remote.cjs"
43
  ],
44
  "asar": true,
45
  "afterPack": "scripts/after-pack.cjs",
app/preload.cjs CHANGED
@@ -5,14 +5,25 @@ const on = channel => fn => { const h = (_e, p) => fn(p); ipcRenderer.on(channel
5
 
6
  contextBridge.exposeInMainWorld('ora', {
7
  state: () => ipcRenderer.invoke('state'),
8
- downloadStart: () => ipcRenderer.invoke('download:start'),
9
  downloadPause: () => ipcRenderer.invoke('download:pause'),
 
 
10
  onDownloadProgress: on('download:progress'),
11
  onDownloadDone: on('download:done'),
12
  onDownloadError: on('download:error'),
13
  createProject: name => ipcRenderer.invoke('project:create', name),
14
  start: job => ipcRenderer.invoke('job:start', job),
 
15
  cancel: () => ipcRenderer.invoke('job:cancel'),
 
 
 
 
 
 
 
 
16
  onJobUpdate: on('job:update'),
17
  onJobEnd: on('job:end'),
18
  save: (id, bytes, ext) => ipcRenderer.invoke('video:save', id, bytes, ext),
 
5
 
6
  contextBridge.exposeInMainWorld('ora', {
7
  state: () => ipcRenderer.invoke('state'),
8
+ downloadStart: set => ipcRenderer.invoke('download:start', set),
9
  downloadPause: () => ipcRenderer.invoke('download:pause'),
10
+ catalog: () => ipcRenderer.invoke('catalog'),
11
+ removeModel: id => ipcRenderer.invoke('model:remove', id),
12
  onDownloadProgress: on('download:progress'),
13
  onDownloadDone: on('download:done'),
14
  onDownloadError: on('download:error'),
15
  createProject: name => ipcRenderer.invoke('project:create', name),
16
  start: job => ipcRenderer.invoke('job:start', job),
17
+ startImages: job => ipcRenderer.invoke('image:start', job),
18
  cancel: () => ipcRenderer.invoke('job:cancel'),
19
+ runKaggle: jobs => ipcRenderer.invoke('kaggle:run', jobs),
20
+ onlineStatus: () => ipcRenderer.invoke('online:status'),
21
+ setQuota: (where, hours) => ipcRenderer.invoke('online:setQuota', where, hours),
22
+ connectColab: code => ipcRenderer.invoke('online:colab', code),
23
+ connectKaggle: () => ipcRenderer.invoke('online:kaggleFile'),
24
+ disconnectOnline: which => ipcRenderer.invoke('online:disconnect', which),
25
+ openOnline: which => ipcRenderer.invoke('online:open', which),
26
+ workerLine: () => ipcRenderer.invoke('online:workerLine'),
27
  onJobUpdate: on('job:update'),
28
  onJobEnd: on('job:end'),
29
  save: (id, bytes, ext) => ipcRenderer.invoke('video:save', id, bytes, ext),
app/remote.cjs ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict';
2
+ // Online GPUs for Ora, on the user's own accounts:
3
+ // Colab - the user runs ora_worker.py --serve in a notebook and pastes its connection code (tunnel URL + secret);
4
+ // Ora sends one job at a time and polls live progress.
5
+ // Kaggle - Ora pushes a private script notebook (GPU + internet on) to the user's account through the Kaggle API,
6
+ // waits for it, and downloads the results from its output.
7
+ // Credentials are encrypted with Electron's safeStorage (the OS keychain) and only ever sent to their platform.
8
+
9
+ const { safeStorage, net } = require('electron');
10
+ const fs = require('node:fs');
11
+ const fsp = require('node:fs/promises');
12
+ const path = require('node:path');
13
+
14
+ const WORKER_URL = 'https://devseis-ora.static.hf.space/worker/ora_worker.py';
15
+ const KAGGLE = 'https://www.kaggle.com/api/v1';
16
+ const KERNEL_SLUG = 'ora-gpu';
17
+
18
+ function createRemote(dataDir) {
19
+ const FILE = path.join(dataDir, 'connections.json');
20
+ const read = () => { try { return JSON.parse(fs.readFileSync(FILE, 'utf8')); } catch { return {}; } };
21
+ const write = v => { fs.mkdirSync(dataDir, { recursive: true }); fs.writeFileSync(FILE, JSON.stringify(v, null, 2), { mode: 0o600 }); };
22
+ const seal = text => safeStorage.isEncryptionAvailable() ? { enc: safeStorage.encryptString(text).toString('base64') } : { plain: text };
23
+ const open = box => box && (box.enc ? safeStorage.decryptString(Buffer.from(box.enc, 'base64')) : box.plain);
24
+
25
+ // ---- what the renderer may see (never the secrets) ----
26
+ function status() {
27
+ const c = read();
28
+ return {
29
+ kaggle: c.kaggle ? { connected: true, username: c.kaggle.username, gpu: c.kaggle.gpu || null } : { connected: false },
30
+ colab: c.colab ? { connected: true, gpu: c.colab.gpu || null, since: c.colab.since } : { connected: false },
31
+ };
32
+ }
33
+
34
+ // ---- Colab -------------------------------------------------------------------------------------------------
35
+ function decodeCode(code) {
36
+ const m = /^ora1\.([A-Za-z0-9_-]+)$/.exec(String(code).trim());
37
+ if (!m) throw new Error('That is not an Ora connection code. Copy the whole line that starts with "ora1." from the notebook.');
38
+ const j = JSON.parse(Buffer.from(m[1], 'base64url').toString('utf8'));
39
+ if (!/^https:\/\/[a-z0-9-]+\.trycloudflare\.com$/.test(j.url) && !/^http:\/\/127\.0\.0\.1:\d+$/.test(j.url)) throw new Error('The connection code has an unexpected address.');
40
+ return j;
41
+ }
42
+ async function colabCall(pathname, { method = 'GET', body, raw = false, timeout = 30000 } = {}) {
43
+ const c = read().colab;
44
+ if (!c) throw new Error('Colab is not connected.');
45
+ const ctrl = new AbortController();
46
+ const t = setTimeout(() => ctrl.abort(), timeout);
47
+ try {
48
+ const res = await net.fetch(c.url + pathname, {
49
+ method, signal: ctrl.signal,
50
+ headers: { 'X-Ora-Secret': open(c.secret), 'Content-Type': 'application/json' },
51
+ body: body ? JSON.stringify(body) : undefined,
52
+ });
53
+ if (res.status === 403) throw new Error('Colab refused the connection code. Copy a new code from the notebook.');
54
+ if (!res.ok) throw new Error(`Colab answered ${res.status}.`);
55
+ return raw ? Buffer.from(await res.arrayBuffer()) : res.json();
56
+ } catch (e) {
57
+ if (e.name === 'AbortError' || /fetch failed|ENOTFOUND|ECONNREFUSED|ERR_/.test(String(e.message))) {
58
+ throw new Error('Cannot reach the Colab notebook. Its session may have ended: run the cell again and paste the new code.');
59
+ }
60
+ throw e;
61
+ } finally { clearTimeout(t); }
62
+ }
63
+ async function connectColab(code) {
64
+ const j = decodeCode(code);
65
+ const c = read();
66
+ c.colab = { url: j.url, secret: seal(j.secret), since: new Date().toISOString() };
67
+ write(c);
68
+ try {
69
+ const hello = await colabCall('/hello', { timeout: 20000 });
70
+ c.colab.gpu = hello.gpu;
71
+ write(c);
72
+ return status();
73
+ } catch (e) { delete c.colab; write(c); throw e; }
74
+ }
75
+
76
+ // Run one job on Colab. onLine gets each engine log line (for progress). Files are saved into dir.
77
+ async function runColab(job, dir, onLine, isCancelled) {
78
+ await colabCall('/job', { method: 'POST', body: job, timeout: 60000 });
79
+ let since = 0, st;
80
+ for (;;) {
81
+ if (isCancelled()) { await colabCall(`/cancel/${job.id}`, { method: 'POST' }).catch(() => { }); return { cancelled: true }; }
82
+ st = await colabCall(`/status/${job.id}?since=${since}`);
83
+ since = st.next;
84
+ for (const l of st.lines) onLine(l);
85
+ if (st.state === 'done' || st.state === 'failed' || st.state === 'cancelled') break;
86
+ await new Promise(r => setTimeout(r, 1500));
87
+ }
88
+ if (st.state !== 'done') return { code: (st.result && st.result.code) || 1, files: [] };
89
+ const files = [];
90
+ for (const f of st.result.files) {
91
+ const sub = /^frame_/.test(f) ? path.join(dir, 'frames') : dir;
92
+ await fsp.mkdir(sub, { recursive: true });
93
+ await fsp.writeFile(path.join(sub, f), await colabCall(`/file/${job.id}/${f}`, { raw: true, timeout: 600000 }));
94
+ files.push(f);
95
+ }
96
+ return { code: 0, files, seconds: st.result.seconds };
97
+ }
98
+
99
+ // ---- Kaggle ------------------------------------------------------------------------------------------------
100
+ function kaggleAuth() {
101
+ const k = read().kaggle;
102
+ if (!k) throw new Error('Kaggle is not connected.');
103
+ return { username: k.username, header: 'Basic ' + Buffer.from(`${k.username}:${open(k.key)}`).toString('base64') };
104
+ }
105
+ async function kaggleCall(pathname, { method = 'GET', body } = {}) {
106
+ const { header } = kaggleAuth();
107
+ const res = await net.fetch(KAGGLE + pathname, { method, headers: { Authorization: header, 'Content-Type': 'application/json' }, body: body ? JSON.stringify(body) : undefined });
108
+ const text = await res.text();
109
+ let j; try { j = JSON.parse(text); } catch { j = { message: text.slice(0, 200) }; }
110
+ if (res.status === 401 || res.status === 403) throw new Error('Kaggle did not accept this API token. Create a new token in Kaggle (Settings › API) and choose the new kaggle.json.');
111
+ if (!res.ok) throw new Error(`Kaggle: ${j.message || j.error || res.status}`);
112
+ return j;
113
+ }
114
+ async function connectKaggle(jsonText) {
115
+ let k;
116
+ try { k = JSON.parse(jsonText); } catch { throw new Error('That file is not a kaggle.json.'); }
117
+ if (!k.username || !k.key) throw new Error('kaggle.json must contain "username" and "key".');
118
+ const c = read();
119
+ c.kaggle = { username: String(k.username), key: seal(String(k.key)) };
120
+ write(c);
121
+ try {
122
+ await kaggleCall(`/kernels/list?user=${encodeURIComponent(k.username)}&pageSize=1`);
123
+ return status();
124
+ } catch (e) { delete c.kaggle; write(c); throw e; }
125
+ }
126
+
127
+ // The notebook Ora pushes: fetch the worker, write the jobs, run them all, leave results in /kaggle/working/out.
128
+ function kaggleScript(jobs) {
129
+ return [
130
+ '# Made by Ora (https://huggingface.co/spaces/Devseis/Ora). Runs Ora video/image jobs on this GPU.',
131
+ 'import json, subprocess, urllib.request',
132
+ `urllib.request.urlretrieve(${JSON.stringify(WORKER_URL)}, "/kaggle/working/ora_worker.py")`,
133
+ `json.dump(json.loads(${JSON.stringify(JSON.stringify({ jobs }))}), open("/kaggle/working/job.json", "w"))`,
134
+ 'subprocess.run(["python3", "/kaggle/working/ora_worker.py", "--batch", "/kaggle/working/job.json", "--out", "/kaggle/working/out"], check=True)',
135
+ '',
136
+ ].join('\n');
137
+ }
138
+
139
+ // Run a batch of jobs on Kaggle (one notebook run for a whole project: the GPU machine starts once).
140
+ async function runKaggle(jobs, onState, isCancelled) {
141
+ const { username } = kaggleAuth();
142
+ const push = await kaggleCall('/kernels/push', {
143
+ method: 'POST',
144
+ body: {
145
+ slug: `${username}/${KERNEL_SLUG}`, newTitle: KERNEL_SLUG, text: kaggleScript(jobs), language: 'python', kernelType: 'script',
146
+ isPrivate: true, enableGpu: true, enableTpu: false, enableInternet: true,
147
+ datasetDataSources: [], competitionDataSources: [], kernelDataSources: [], modelDataSources: [], categoryIds: [],
148
+ },
149
+ });
150
+ if (push.error) throw new Error(`Kaggle: ${push.error}`);
151
+ onState('queued', push.url);
152
+ for (;;) {
153
+ await new Promise(r => setTimeout(r, 15000));
154
+ if (isCancelled()) return { cancelled: true, url: push.url };
155
+ const st = await kaggleCall(`/kernels/status?userName=${encodeURIComponent(username)}&kernelSlug=${KERNEL_SLUG}`);
156
+ onState(st.status, push.url);
157
+ if (st.status === 'complete') break;
158
+ if (st.status === 'error' || st.status === 'cancelAcknowledged') {
159
+ throw new Error(`The Kaggle run stopped: ${st.failureMessage || st.status}. Open it on Kaggle to see the log: ${push.url}`);
160
+ }
161
+ }
162
+ const out = await kaggleCall(`/kernels/output?userName=${encodeURIComponent(username)}&kernelSlug=${KERNEL_SLUG}`);
163
+ return { files: out.files || [], log: out.log || '', url: push.url };
164
+ }
165
+ async function download(url) {
166
+ const res = await net.fetch(url);
167
+ if (!res.ok) throw new Error(`Download failed (${res.status}).`);
168
+ return Buffer.from(await res.arrayBuffer());
169
+ }
170
+
171
+ function disconnect(which) { const c = read(); delete c[which]; write(c); return status(); }
172
+
173
+ return { status, connectColab, connectKaggle, runColab, runKaggle, download, disconnect, workerUrl: WORKER_URL };
174
+ }
175
+
176
+ module.exports = { createRemote };
app/renderer/app.js CHANGED
@@ -1,6 +1,6 @@
1
  'use strict';
2
  /* global Mp4Muxer, WebMMuxer */
3
- // Ora renderer: model download screen, prompt form, progress, MP4 encoding (WebCodecs) and the video history.
4
 
5
  const $ = id => document.getElementById(id);
6
  const GB = n => `${(n / 1e9).toFixed(1)} GB`;
@@ -26,6 +26,8 @@ const jobQuality = f => isPreview(f) ? 'preview' : f.quality;
26
  const STAGE_TEXT = { loading: 'Loading the models', prompt: 'Reading your prompt' };
27
 
28
  const MAX_SHOTS = 5;
 
 
29
 
30
  let S = null; // state from main
31
  const form = { model: 'fast', shape: 'landscape', seconds: 3, quality: 'standard' };
@@ -33,13 +35,30 @@ let shots = ['']; // one prompt per shot; each becomes its own video
33
  let styles = []; // labels from STYLES, added to every shot
34
  let current = null; // meta of the video on the stage
35
  let runStart = 0;
36
- let queue = null; // { folder, jobs, index, done: [], cancelled } while shots are being made
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
 
38
  function store(k, v) { try { if (v === undefined) return JSON.parse(localStorage.getItem(k)); localStorage.setItem(k, JSON.stringify(v)); } catch { return undefined; } }
39
 
40
  // --- segmented controls ----------------------------------------------------------------------------------------
41
 
42
- function seg(el, options, key, render) {
 
43
  el.setAttribute('role', 'radiogroup');
44
  el.innerHTML = '';
45
  for (const [value, label, sub] of options) {
@@ -49,22 +68,32 @@ function seg(el, options, key, render) {
49
  b.dataset.value = value;
50
  b.innerHTML = sub ? `<b></b><span></span>` : '';
51
  if (sub) { b.querySelector('b').textContent = label; b.querySelector('span').textContent = sub; } else b.textContent = label;
52
- b.addEventListener('click', () => { form[key] = value; sync(); store('ora.form', form); if (render) render(); });
 
 
 
 
53
  el.appendChild(b);
54
  }
55
  }
56
  function sync() {
57
  if (S) for (const b of $('modelSeg').children) {
58
- const ok = modelReady(b.dataset.value === 'preview' ? 'fast' : b.dataset.value);
59
  b.disabled = !ok;
60
  b.title = ok ? '' : 'Still downloading';
61
  }
62
  if (S && !allReady(S.files)) {
63
- const have = Object.values(S.files).reduce((a, f) => a + (f.ready ? f.size : f.have), 0);
64
- const total = Object.values(S.files).reduce((a, f) => a + f.size, 0);
 
65
  $('dlNote').hidden = false;
66
  $('dlNote').textContent = `The Quality model is still downloading (${GB(have)} of ${GB(total)}). It becomes available here when it is ready.`;
67
  } else $('dlNote').hidden = true;
 
 
 
 
 
68
  const pv = isPreview(form);
69
  for (const id of ['lengthSeg', 'qualitySeg']) for (const b of $(id).children) b.disabled = pv;
70
  $('previewNote').hidden = !pv;
@@ -76,7 +105,12 @@ function sync() {
76
 
77
  // --- estimate --------------------------------------------------------------------------------------------------
78
 
79
- function frames(fps, seconds) { const n = Math.max(1, Math.round((fps * seconds - 1) / 4)); return 4 * n + 1; }
 
 
 
 
 
80
  function workFor(f) {
81
  const m = S.manifest.models[jobModel(f)];
82
  if (isPreview(f)) {
@@ -85,7 +119,7 @@ function workFor(f) {
85
  }
86
  const table = (!S.hardware.engine.gpu && m.lowSizes) ? m.lowSizes : m.sizes;
87
  const [w, h] = table[f.shape];
88
- return { w, h, frames: frames(m.fps, f.seconds), steps: m.steps[f.quality], fps: m.fps, model: jobModel(f), tae: f.quality === 'draft' && !S.hardware.engine.gpu };
89
  }
90
  // seconds per step measured on this computer, per model and engine, scaled by pixels x frames
91
  function speedKey(f) {
@@ -120,13 +154,81 @@ function shotSeconds(f) {
120
  if (!S.hardware.engine.gpu) return { sec: roughCpu(w), basis: 'rough' };
121
  return { sec: null, basis: 'unknown' };
122
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  function estimate() {
124
  if (!S) return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
  const w = workFor(form);
126
  const n = shots.length;
127
  const label = `${w.preview ? 'Preview: 1 s, ' : ''}${w.w}×${w.h}, ${w.frames} frames at ${w.fps} fps, ${w.steps} steps`;
128
- const { sec, basis } = shotSeconds(form);
129
  const box = $('estimateBox');
 
 
130
  if (sec == null) {
131
  $('estTime').textContent = 'Time: measured on the first video';
132
  $('estimate').textContent = `${label}. On a graphics card a shot usually takes minutes; Ora times the first one and estimates from then on.`;
@@ -183,7 +285,10 @@ function renderSetup(status, message) {
183
  if (message !== undefined) $('setupStatus').textContent = message;
184
  }
185
 
186
- function allReady(status) { return Object.values(status).every(f => f.ready); }
 
 
 
187
  function modelReady(key) { return S.manifest.models[key].files.every(k => S.files[k].ready); }
188
 
189
  function showSetup(downloading) {
@@ -197,8 +302,11 @@ function setDownloading(on) {
197
  }
198
 
199
  let speed = { t: 0, bytes: 0, rate: 0 };
 
200
  function onProgress(p) {
201
  S.files = p.status;
 
 
202
  if (!$('studio').hidden) { sync(); return; }
203
  const have = Object.values(p.status).reduce((a, f) => a + (f.ready ? f.size : f.have), 0);
204
  const total = Object.values(p.status).reduce((a, f) => a + f.size, 0);
@@ -209,23 +317,170 @@ function onProgress(p) {
209
  renderSetup(p.status, `Downloading ${p.status[p.key].name}${speed.rate > 0 ? ` at ${(speed.rate / 1e6).toFixed(1)} MB/s` : ''}${left}. You can pause and continue later.`);
210
  }
211
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
212
  // --- studio ----------------------------------------------------------------------------------------------------
213
 
214
  function showStudio() {
215
  $('setup').hidden = true; $('studio').hidden = false;
216
  const m = S.manifest.models;
217
- seg($('modelSeg'), [
218
- ['preview', 'Preview · 1.3B', 'Quick 1 s look, small size. Good for phone screens and checking a prompt'],
219
- ['fast', 'Fast · 1.3B', m.fast.detail], ['quality', 'Quality · 5B', m.quality.detail]], 'model');
220
  seg($('shapeSeg'), SHAPES.map(([v, l]) => [v, l]), 'shape');
221
- seg($('lengthSeg'), LENGTHS.map(([v, l]) => [v, l]), 'seconds');
222
  seg($('qualitySeg'), QUALITY, 'quality');
223
  if (!modelReady(jobModel(form))) form.model = modelReady('fast') ? 'fast' : 'quality';
 
 
 
224
  renderRunOn();
 
225
  sync();
226
  renderGrid();
227
  }
228
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
229
  function renderStyles() {
230
  const box = $('styleChips');
231
  box.innerHTML = '';
@@ -251,7 +506,7 @@ function composePrompt(shot) {
251
  }
252
 
253
  function saveDraft() {
254
- store('ora.draft', { shots, styles, scene: $('scene').value, project: $('projectName').value });
255
  }
256
 
257
  function renderShots(states) {
@@ -290,6 +545,52 @@ function showStage(which) {
290
  $('stageEmpty').hidden = which !== 'empty';
291
  $('stageRun').hidden = which !== 'run';
292
  $('stageVideo').hidden = which !== 'video';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
293
  }
294
  function setRing(pct) {
295
  const p = Math.max(0, Math.min(100, pct));
@@ -304,7 +605,7 @@ function playVideo(meta) {
304
  v.src = `ora://video/${encodeURIComponent(meta.id)}/${meta.file}`;
305
  v.play().catch(() => { });
306
  const mins = meta.seconds_taken ? ` · made in ${MIN(meta.seconds_taken)}` : '';
307
- $('videoInfo').textContent = `${meta.width}×${meta.height} · ${meta.seconds} s · ${meta.quality === 'preview' ? 'Preview, ' : ''}${meta.model === 'fast' ? 'Wan2.1 1.3B' : 'Wan2.2 5B'} · seed ${meta.seed}${mins}`;
308
  }
309
 
310
  function renderGrid() {
@@ -318,13 +619,18 @@ function renderGrid() {
318
  c.innerHTML = '<img alt=""><div class="meta"><div class="p"></div><div class="s"></div></div><button class="ghost del" type="button">Delete</button>';
319
  c.querySelector('img').src = `ora://video/${encodeURIComponent(meta.id)}/poster.png`;
320
  c.querySelector('img').style.aspectRatio = `${meta.width} / ${meta.height}`;
321
- c.querySelector('.p').textContent = meta.project ? `${meta.project.index}. ${meta.project.title}` : meta.prompt;
322
- c.querySelector('.s').textContent = `${meta.project && meta.project.total > 1 ? `${meta.project.folder.slice(11)} · ` : ''}${meta.quality === 'preview' ? 'Preview · ' : ''}${meta.seconds} s · ${meta.model === 'fast' ? '1.3B' : '5B'} · ${new Date(meta.created).toLocaleString()}`;
323
- const open = () => playVideo(meta);
 
 
 
 
 
324
  c.addEventListener('click', e => { if (!e.target.closest('.del')) open(); });
325
  c.addEventListener('keydown', e => { if (e.key === 'Enter' && e.target === c) open(); });
326
  c.querySelector('.del').addEventListener('click', async () => {
327
- if (!confirm('Delete this video from Ora? The copy in your Videos folder stays.')) return;
328
  await window.ora.remove(meta.id);
329
  S.videos = S.videos.filter(v => v.id !== meta.id);
330
  if (current && current.id === meta.id) { current = null; showStage('empty'); }
@@ -334,13 +640,58 @@ function renderGrid() {
334
  }
335
  }
336
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
337
  function formError(msg) { $('formError').hidden = !msg; $('formError').textContent = msg || ''; if (msg) $('formError').scrollIntoView({ block: 'center', behavior: 'smooth' }); }
338
 
339
  function setRunning(on) {
340
  const n = shots.length;
341
  $('goBtn').hidden = on;
342
  $('stopBtn').hidden = !on;
343
- $('goBtn').textContent = n > 1 ? `Make ${n} videos` : 'Make video';
344
  $('clearHistoryBtn').disabled = on;
345
  $('clearPromptsBtn').disabled = on;
346
  }
@@ -353,22 +704,46 @@ function stopRun() {
353
  window.ora.cancel();
354
  }
355
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
356
  async function submit(e) {
357
  e.preventDefault();
358
  formError('');
359
  if (queue) return;
 
360
  const empty = shots.findIndex(t => t.trim().length < 3);
361
  if (empty >= 0) return formError(shots.length > 1 ? `Shot ${empty + 1} is empty. Describe it or remove it.` : 'Describe the video first.');
362
  const seedText = $('seed').value.trim();
363
  if (seedText && !/^\d{1,10}$/.test(seedText)) return formError('The seed must be a whole number.');
364
  const n = shots.length;
365
- const est = shotSeconds(form);
366
  if (est.sec != null && est.sec * n > 2 * 3600 && !confirm(`This will take about ${MIN(est.sec * n)} on this computer${n > 1 ? ` (${n} shots)` : ''}. You can stop it at any time. Start anyway?`)) return;
367
  const name = $('projectName').value.trim() || shots[0].trim().split(/\s+/).slice(0, 6).join(' ');
368
  const folder = await window.ora.createProject(name);
369
  const base = { ...form, model: jobModel(form), quality: jobQuality(form), negative: $('negative').value.trim() || undefined, seed: seedText ? Math.min(+seedText, 2 ** 31 - 1) : undefined };
370
- const jobs = shots.map((t, i) => ({ ...base, prompt: composePrompt(t), project: { folder, index: i + 1, total: n, title: t.trim().slice(0, 300) } }));
371
- queue = { folder, jobs, index: 0, done: [], states: shots.map(() => 'waiting'), cancelled: false };
 
 
372
  renderShots(queue.states);
373
  $('projectDone').hidden = true;
374
  setRunning(true);
@@ -390,11 +765,17 @@ function nextShot() {
390
  showStage('run');
391
  setRing(0);
392
  renderRun();
393
- $('runQueue').textContent = q.jobs.length > 1 ? `Shot ${q.index + 1} of ${q.jobs.length}` : '';
394
  $('runStage').textContent = 'Starting…';
395
  $('runDetail').textContent = '';
396
  $('runPrompt').textContent = job.project.title;
397
- window.ora.start(job);
 
 
 
 
 
 
398
  }
399
 
400
  function finishQueue() {
@@ -404,7 +785,8 @@ function finishQueue() {
404
  setRunning(false);
405
  renderShots();
406
  if (!q) return;
407
- if (q.done.length) {
 
408
  playVideo(q.done[0]);
409
  if (q.jobs.length > 1) {
410
  $('projectDone').hidden = false;
@@ -428,6 +810,7 @@ function newRun() { return { phase: 'prep', t0: Date.now(), starts: { prep: Date
428
  function setPhase(ph) {
429
  if (!run || run.phase === ph) return;
430
  const now = Date.now();
 
431
  run.ends[run.phase] = now;
432
  run.phase = ph;
433
  run.starts[ph] = now;
@@ -438,11 +821,19 @@ function renderConfig() {
438
  if (!meta || !hw) return;
439
  const gpu = hw.engine.gpu;
440
  const gpuName = (hw.gpus || []).map(g => `${g.vendor} ${g.name}`.trim()).join(', ');
 
441
  const preview = meta.quality === 'preview';
442
- const rows = [
443
- ['Computer', `${hw.cpu} · ${hw.cores} threads · ${Math.round(hw.ram / 2 ** 30)} GB memory`],
444
- ['Runs on', gpu ? `${engineLabel(hw.engine)}${gpuName ? ` · ${gpuName}` : ''}` : `Processor only${gpuName ? ` (graphics not used: ${gpuName})` : ''}`],
445
- ['Model', `${preview ? 'Preview · ' : ''}${meta.model === 'fast' ? 'Wan2.1 1.3B' : 'Wan2.2 5B'}`],
 
 
 
 
 
 
 
446
  ['Video', `${meta.width}×${meta.height} · ${meta.frames} frames · ${meta.seconds} s at ${meta.fps} fps`],
447
  ['Work', `${meta.steps} frame steps, then decoding with the ${meta.decoder === 'tae' ? 'fast decoder' : 'full decoder (best detail)'}`],
448
  ['Seed', String(meta.seed)],
@@ -480,6 +871,13 @@ function timeLeft() {
480
  }
481
  }
482
 
 
 
 
 
 
 
 
483
  function renderPhases() {
484
  const list = $('runPhases');
485
  list.innerHTML = '';
@@ -497,7 +895,8 @@ function renderPhases() {
497
  detail = key === 'frames' ? ` · step ${bar.done} of ${bar.total}` : ` · part ${bar.done} of ${bar.total}`;
498
  if (i === at) pct = 100 * bar.done / bar.total;
499
  }
500
- li.querySelector('.name').textContent = name + detail;
 
501
  const t0 = run.starts[key], t1 = run.ends[key];
502
  li.querySelector('.t').textContent = t0 ? MIN(((t1 || Date.now()) - t0) / 1000) + (bar && bar.sps && i === at ? ` · ${Math.round(bar.sps)} s each` : '') : '';
503
  li.querySelector('.pbar div').style.width = `${pct.toFixed(1)}%`;
@@ -511,8 +910,8 @@ function renderRun() {
511
  if (!run) return;
512
  const elapsed = (Date.now() - run.t0) / 1000;
513
  const left = timeLeft();
514
- $('runStage').textContent = run.phase === 'prep' && run.sub ? run.sub : (PHASES.find(p => p[0] === run.phase) || [0, 'Working'])[1];
515
- $('runDetail').textContent = `${MIN(elapsed)} so far${left != null ? ` · about ${MIN(left)} left` : ''}`;
516
  // ring: share of the time, when it can be estimated; otherwise fixed shares per phase
517
  let pct;
518
  if (left != null) pct = 100 * elapsed / (elapsed + left);
@@ -537,10 +936,17 @@ function onJobUpdate(u) {
537
  if (!run) return;
538
  if (u.meta) {
539
  run.meta = u.meta; run.hw = u.hardware;
540
- run.rec = store(`ora.speed.${u.meta.engine}.${u.meta.model}.${u.meta.decoder || 'vae'}`);
541
  renderConfig();
542
  }
 
 
 
 
 
 
543
  if (u.stage === 'frames' || u.stage === 'decoding') setPhase(u.stage);
 
544
  else if (STAGE_TEXT[u.stage] && run.phase === 'prep') run.sub = STAGE_TEXT[u.stage];
545
  if (u.progress && (u.stage === 'frames' || u.stage === 'decoding')) {
546
  run[u.stage] = { done: u.progress.done, total: u.progress.total, sps: u.progress.secPerStep, at: Date.now() };
@@ -550,6 +956,7 @@ function onJobUpdate(u) {
550
 
551
  async function onJobEnd(r) {
552
  const q = queue;
 
553
  if (r.cancelled) { if (q) q.cancelled = true; return finishQueue(); }
554
  if (r.error) {
555
  if (q) { q.states[q.index] = 'failed'; q.cancelled = true; }
@@ -557,6 +964,18 @@ async function onJobEnd(r) {
557
  return finishQueue();
558
  }
559
  const meta = r.meta;
 
 
 
 
 
 
 
 
 
 
 
 
560
  if (run) { setPhase('saving'); renderRun(); }
561
  try {
562
  const { bytes, ext } = await encode(meta);
@@ -565,6 +984,9 @@ async function onJobEnd(r) {
565
  const sec = (a, b) => run.starts[a] && run.ends[a] ? (run.ends[a] - run.starts[a]) / 1000 : (b ?? null);
566
  remember(saved, { secPerStep: run.frames.sps, prepSec: sec('prep', 0), decodeSec: sec('decoding') });
567
  }
 
 
 
568
  S.videos.unshift(saved);
569
  renderGrid();
570
  setRing(100);
@@ -578,6 +1000,26 @@ async function onJobEnd(r) {
578
  nextShot();
579
  }
580
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
581
  // PNG frames -> H.264 MP4 with WebCodecs; VP9 WebM if this system has no H.264 encoder.
582
  async function encode(meta) {
583
  const { width, height, fps } = meta;
@@ -629,7 +1071,8 @@ function engineLabel(e) {
629
  }
630
  function renderDevice() {
631
  const h = S.hardware;
632
- $('deviceChip').textContent = `${engineLabel(h.engine)} · ${Math.round(h.ram / 2 ** 30)} GB RAM`;
 
633
  const os = { darwin: 'macOS', win32: 'Windows', linux: 'Linux' }[h.platform] || h.platform;
634
  const rows = [
635
  ['System', `${os} (${h.arch})`], ['Processor', `${h.cpu} · ${h.cores} threads`], ['Memory', `${Math.round(h.ram / 2 ** 30)} GB`],
@@ -651,18 +1094,27 @@ function renderDevice() {
651
  async function init() {
652
  S = await window.ora.state();
653
  $('version').textContent = S.version;
654
- $('saveDirText').textContent = `Saved to ${S.saveDir}`;
 
655
  renderDevice();
 
 
656
  Object.assign(form, store('ora.form') || {});
657
  if (!S.manifest.models[form.model] && !isPreview(form)) form.model = 'fast';
 
 
658
  if (form.quality === 'preview') form.quality = 'standard';
659
  const draft = store('ora.draft') || {};
660
  shots = Array.isArray(draft.shots) && draft.shots.length ? draft.shots.slice(0, MAX_SHOTS).map(String) : [store('ora.prompt') || ''];
661
  styles = Array.isArray(draft.styles) ? draft.styles.filter(l => STYLES.some(([x]) => x === l)) : [];
662
  $('scene').value = draft.scene || '';
663
  $('projectName').value = draft.project || '';
 
 
 
664
  renderStyles();
665
  renderShots();
 
666
  $('stageHint').textContent = S.hardware.engine.gpu ? 'Tip: use Preview to check a prompt quickly, then make the full video with Fast or Quality.' : 'Tip: on the processor, use Preview to check a prompt first. Full videos take much longer.';
667
  if (allReady(S.files) || (modelReady('fast') && store('ora.startedFast'))) { showStudio(); if (!allReady(S.files) && !S.downloading) window.ora.downloadStart(); }
668
  else showSetup(S.downloading);
@@ -679,11 +1131,15 @@ $('downloadBtn').addEventListener('click', async () => {
679
  });
680
  window.ora.onDownloadProgress(onProgress);
681
  window.ora.onDownloadDone(p => {
 
 
682
  S.files = p.status; setDownloading(false); renderSetup(p.status, 'All models are ready.');
683
  if ($('studio').hidden) setTimeout(showStudio, 700); else sync();
684
  });
685
  $('startFastBtn').addEventListener('click', () => { store('ora.startedFast', true); if (!$('downloadBtn').dataset.on) window.ora.downloadStart(); showStudio(); });
686
  window.ora.onDownloadError(p => {
 
 
687
  S.files = p.status; setDownloading(false); renderSetup(p.status, p.message);
688
  if (!$('studio').hidden) { $('dlNote').hidden = false; $('dlNote').textContent = `Download stopped: ${p.message} Restart Ora to try again.`; }
689
  });
@@ -705,7 +1161,7 @@ document.addEventListener('keydown', e => { if (e.key === 'Escape' && queue && !
705
  // ---- clear prompts / clear history ----
706
  function clearPrompts() {
707
  shots = [''];
708
- $('scene').value = ''; $('projectName').value = ''; $('seed').value = ''; $('negative').value = '';
709
  styles = [];
710
  try { localStorage.removeItem('ora.draft'); localStorage.removeItem('ora.prompt'); } catch { }
711
  renderShots(); renderStyles(); setRunning(false); estimate();
@@ -724,23 +1180,39 @@ $('clearConfirm').addEventListener('click', async () => {
724
  // ---- run on: automatic / graphics / processor ----
725
  function renderRunOn() {
726
  const h = S.hardware, e = h.engine;
727
- const opts = [['auto', 'Automatic'], ['gpu', 'Graphics'], ['cpu', 'Processor']];
728
  const el = $('runOnSeg');
729
  el.innerHTML = ''; el.setAttribute('role', 'radiogroup');
730
- const choice = S.settings.engine || 'auto';
731
  for (const [v, l] of opts) {
732
  const b = document.createElement('button');
733
  b.type = 'button'; b.setAttribute('role', 'radio'); b.dataset.value = v; b.textContent = l;
734
  b.setAttribute('aria-checked', String(choice === v));
735
  if (v === 'gpu' && e.gpuUnavailable) { b.disabled = true; b.title = e.gpuUnavailable; }
 
736
  b.addEventListener('click', async () => {
 
 
 
 
 
737
  S.settings = await window.ora.setSettings({ engine: v });
 
738
  S = { ...S, ...(await window.ora.state()) };
739
  renderDevice(); renderRunOn(); estimate();
740
  });
741
  el.appendChild(b);
742
  }
743
  const gpuName = (h.gpus || []).filter(g => g.vendor !== 'Apple' || h.platform === 'darwin').map(g => `${g.vendor} ${g.name}`.trim()).join(', ');
 
 
 
 
 
 
 
 
 
744
  $('runOnNote').textContent = e.gpuUnavailable
745
  ? `Now: processor. ${e.gpuUnavailable}`
746
  : `Now: ${e.gpu ? `graphics${gpuName ? ` (${gpuName})` : ''}` : 'processor only'}.${choice === 'auto' && !e.gpu && h.platform !== 'darwin' ? ' No NVIDIA or AMD graphics card was found; choose Graphics to try your graphics anyway.' : ''}`;
@@ -757,6 +1229,50 @@ $('reuseBtn').addEventListener('click', () => {
757
  store('ora.form', form); saveDraft(); renderShots(); setRunning(false); sync();
758
  });
759
  $('openSaveDir').addEventListener('click', () => window.ora.openSaveDir());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
760
  $('deviceChip').addEventListener('click', () => $('deviceDlg').showModal());
761
  $('closeDevice').addEventListener('click', () => $('deviceDlg').close());
762
  $('openModels').addEventListener('click', () => window.ora.openModels());
 
1
  'use strict';
2
  /* global Mp4Muxer, WebMMuxer */
3
+ // Ora renderer: model download screen, video and image forms, progress, MP4 encoding (WebCodecs) and the history.
4
 
5
  const $ = id => document.getElementById(id);
6
  const GB = n => `${(n / 1e9).toFixed(1)} GB`;
 
26
  const STAGE_TEXT = { loading: 'Loading the models', prompt: 'Reading your prompt' };
27
 
28
  const MAX_SHOTS = 5;
29
+ // MiniMax's licence asks products to show "MiniMax H3" wherever it is used
30
+ const MODEL_NAMES = { fast: 'Wan2.1 1.3B', quality: 'Wan2.2 5B', pro: 'Wan2.2 A14B', ltx23: 'LTX-2.3 22B (with sound)', h3: 'MiniMax H3 (with sound)' };
31
 
32
  let S = null; // state from main
33
  const form = { model: 'fast', shape: 'landscape', seconds: 3, quality: 'standard' };
 
35
  let styles = []; // labels from STYLES, added to every shot
36
  let current = null; // meta of the video on the stage
37
  let runStart = 0;
38
+ let queue = null; // { folder, jobs, index, done: [], cancelled } while shots or images are being made
39
+ let mode = 'video'; // 'video' | 'image'
40
+ const imgForm = { model: 'zimage', shape: 'square', size: 'small', count: 1 };
41
+ let catalog = []; // the Models screen: entries from main with install state and the requirement check
42
+ let online = { kaggle: { connected: false }, colab: { connected: false } };
43
+ // "Run on" in the form: auto | gpu | cpu (this computer, kept in settings) or online (Kaggle/Colab, kept here)
44
+ const runWhere = () => store('ora.runOnline') && onlineChoice() ? onlineChoice() : 'local';
45
+ function onlineChoice() {
46
+ const pref = store('ora.onlineService');
47
+ if (pref && online[pref] && online[pref].connected) return pref;
48
+ return online.colab.connected ? 'colab' : online.kaggle.connected ? 'kaggle' : null;
49
+ }
50
+ const T4 = { platform: 'linux', arch: 'x64', ram: 13 * 2 ** 30, freeDisk: null, engine: { id: 'online', gpu: true, args: [] }, gpus: [{ vendor: 'NVIDIA', name: 'T4' }], vram: 16 };
51
+ let startImage = null; // { id, file } of an Ora image to animate (image-to-video with the 5B model)
52
+ const IMG_SHAPES = [['square', '1:1'], ['landscape', '16:9'], ['portrait', '9:16'], ['insta', '4:5']];
53
+ const IMG_SIZES = [['small', 'Small · fast'], ['large', 'Large · best']];
54
+ const IMG_COUNTS = [[1, '1'], [2, '2'], [3, '3'], [4, '4']];
55
 
56
  function store(k, v) { try { if (v === undefined) return JSON.parse(localStorage.getItem(k)); localStorage.setItem(k, JSON.stringify(v)); } catch { return undefined; } }
57
 
58
  // --- segmented controls ----------------------------------------------------------------------------------------
59
 
60
+ // target: the settings object the buttons change (the video form, or imgForm for images)
61
+ function seg(el, options, key, render, target = form) {
62
  el.setAttribute('role', 'radiogroup');
63
  el.innerHTML = '';
64
  for (const [value, label, sub] of options) {
 
68
  b.dataset.value = value;
69
  b.innerHTML = sub ? `<b></b><span></span>` : '';
70
  if (sub) { b.querySelector('b').textContent = label; b.querySelector('span').textContent = sub; } else b.textContent = label;
71
+ b.addEventListener('click', () => {
72
+ target[key] = value; sync(); store(target === form ? 'ora.form' : 'ora.imgForm', target);
73
+ if (target === imgForm) setRunning(!!queue);
74
+ if (render) render();
75
+ });
76
  el.appendChild(b);
77
  }
78
  }
79
  function sync() {
80
  if (S) for (const b of $('modelSeg').children) {
81
+ const ok = runWhere() !== 'local' || modelReady(b.dataset.value === 'preview' ? 'fast' : b.dataset.value);
82
  b.disabled = !ok;
83
  b.title = ok ? '' : 'Still downloading';
84
  }
85
  if (S && !allReady(S.files)) {
86
+ const req = requiredKeys().map(k => S.files[k]);
87
+ const have = req.reduce((a, f) => a + (f.ready ? f.size : f.have), 0);
88
+ const total = req.reduce((a, f) => a + f.size, 0);
89
  $('dlNote').hidden = false;
90
  $('dlNote').textContent = `The Quality model is still downloading (${GB(have)} of ${GB(total)}). It becomes available here when it is ready.`;
91
  } else $('dlNote').hidden = true;
92
+ if (startImage) for (const b of $('modelSeg').children) if (b.dataset.value !== 'quality') { b.disabled = true; b.title = 'Animating an image needs the Quality (5B) model'; }
93
+ for (const [id, key] of [['imgShapeSeg', 'shape'], ['imgSizeSeg', 'size'], ['imgCountSeg', 'count']]) {
94
+ for (const b of $(id).children) b.setAttribute('aria-checked', String(String(imgForm[key]) === b.dataset.value));
95
+ }
96
+ if (S) renderImageDownload();
97
  const pv = isPreview(form);
98
  for (const id of ['lengthSeg', 'qualitySeg']) for (const b of $(id).children) b.disabled = pv;
99
  $('previewNote').hidden = !pv;
 
105
 
106
  // --- estimate --------------------------------------------------------------------------------------------------
107
 
108
+ function frames(fps, seconds, rule = 'wan') {
109
+ const want = fps * seconds;
110
+ if (rule === 'ltx') return 8 * Math.max(1, Math.round((want - 1) / 8)) + 1;
111
+ if (rule === 'h3') return 17 * Math.max(0, Math.ceil((want - 5) / 17)) + 5;
112
+ return 4 * Math.max(1, Math.round((want - 1) / 4)) + 1;
113
+ }
114
  function workFor(f) {
115
  const m = S.manifest.models[jobModel(f)];
116
  if (isPreview(f)) {
 
119
  }
120
  const table = (!S.hardware.engine.gpu && m.lowSizes) ? m.lowSizes : m.sizes;
121
  const [w, h] = table[f.shape];
122
+ return { w, h, frames: frames(m.fps, f.seconds, m.frameRule), steps: m.steps[f.quality], fps: m.fps, model: jobModel(f), tae: f.quality === 'draft' && !S.hardware.engine.gpu };
123
  }
124
  // seconds per step measured on this computer, per model and engine, scaled by pixels x frames
125
  function speedKey(f) {
 
154
  if (!S.hardware.engine.gpu) return { sec: roughCpu(w), basis: 'rough' };
155
  return { sec: null, basis: 'unknown' };
156
  }
157
+ function imageWork() {
158
+ const [w, h] = S.manifest.image.sizes[imgForm.shape][imgForm.size];
159
+ return { w, h, steps: S.manifest.image.steps, count: imgForm.count };
160
+ }
161
+ // Z-Image-Turbo (6B, 8 steps). Rough processor time until measured here, from a run on a 4-core Intel i7 (8 threads):
162
+ // 512x512 = 1024 tokens took 70 s per step, 48 s to decode, ~15 s for the prompt (9.2 min in all).
163
+ function imageSeconds() {
164
+ const w = imageWork();
165
+ const rec = store(`ora.speed.${S.hardware.engine.id}.${imgForm.model}`);
166
+ if (rec && rec.perImage) return { sec: (rec.prepSec || 0) + rec.perImage * (w.w * w.h) / rec.work * w.count, basis: 'measured' };
167
+ if (S.hardware.engine.gpu) return { sec: null, basis: 'unknown' };
168
+ const x = (w.w / 16) * (w.h / 16) / 1024;
169
+ const cores = Math.max(2, Math.min(32, S.hardware.cores || 8));
170
+ const perStep = 70 * x * (0.85 + 0.15 * x) * (8 / cores);
171
+ return { sec: 15 + w.count * (perStep * w.steps + w.w * w.h * 1.8e-4), basis: 'rough' };
172
+ }
173
+ // --- online GPU time and quota -----------------------------------------------------------------------------------
174
+ // Rough T4 seconds for one video shot until Ora has timed one: ~1/20 of this Intel CPU's time for the same work,
175
+ // plus downloading the model files into the notebook on its first use there (~150 MB/s).
176
+ function onlineSeconds(w) {
177
+ const rec = store(`ora.speed.online-${runWhere()}.${w.model}`);
178
+ if (rec && rec.secPerStep) return (rec.prepSec || 0) + rec.secPerStep * (w.w * w.h * w.frames) / rec.work * w.steps + (rec.decodeSec || 0) * (w.w * w.h * w.frames) / rec.work;
179
+ const big = { fast: 1, quality: 2.5, pro: 7, ltx23: 6, h3: 12 }[w.model] || 1;
180
+ const lat = (w.frames - 1) / 4 + 1, x = (w.w / 16) * (w.h / 16) * lat / 2880;
181
+ return 158 * (0.76 * x + 0.24 * x * x) * w.steps / 20 * big + modelFetchSeconds(S.manifest.models[w.model].files);
182
+ }
183
+ function modelFetchSeconds(keys) { return keys.reduce((a, k) => a + S.manifest.files[k].size, 0) / 150e6; }
184
+ function imgModelFiles() { return ((S.manifest.images || {})[imgForm.model] || S.manifest.image).files; }
185
+ const H = s => s < 3600 ? `${Math.round(s / 60)} min` : `${(s / 3600).toFixed(1)} h`;
186
+ function onlineEstimate(label, gpuSeconds, n) {
187
+ const where = runWhere(), u = (online.usage || {})[where] || {};
188
+ const startup = where === 'kaggle' ? 240 : 0; // Kaggle starts a fresh machine for each project
189
+ const total = gpuSeconds + startup;
190
+ $('estTime').textContent = `About ${H(total)} of ${where === 'kaggle' ? 'Kaggle' : 'Colab'} GPU time`;
191
+ const parts = [`${label}${n > 1 ? `, ${n} shots` : ''}.`];
192
+ if (where === 'kaggle') parts.push('Includes ~4 min for Kaggle to start a machine and, on first use, downloading the model there.');
193
+ parts.push(store(`ora.speed.online-${where}.${mode === 'image' ? imgForm.model : jobModel(form)}`) ? 'Based on your last online run.' : 'Rough until your first online run; Ora times it.');
194
+ parts.push(`Ora has used ${H(u.last7 || 0)} on ${where === 'kaggle' ? 'Kaggle' : 'Colab'} in the last 7 days.`);
195
+ let warn = false;
196
+ if (u.left != null) {
197
+ parts.push(`About ${H(u.left)} of your quota left, ${H(Math.max(0, u.left - total))} after this.`);
198
+ warn = total > u.left;
199
+ if (warn) parts.push('This is more than you have left.');
200
+ } else if (where === 'kaggle') parts.push('Set your Kaggle quota in Online GPU to see what is left.');
201
+ else parts.push('Google does not publish free Colab limits.');
202
+ $('estimate').textContent = parts.join(' ');
203
+ $('estimateBox').classList.toggle('warn', warn);
204
+ }
205
+
206
  function estimate() {
207
  if (!S) return;
208
+ if (mode === 'image' && runWhere() !== 'local') {
209
+ const w = imageWork();
210
+ // a T4 does an 8-step 1024x1024 Z-Image in well under a minute; bigger models scale with their size
211
+ const big = { zimage: 1, flux1s: 1.2, qwenimg: 4 }[imgForm.model] || 1;
212
+ return onlineEstimate(`${w.count} image${w.count > 1 ? 's' : ''} at ${w.w}×${w.h}`, w.count * 40 * big * (w.w * w.h) / (1024 * 1024) + modelFetchSeconds(imgModelFiles()), 1);
213
+ }
214
+ if (mode === 'image') {
215
+ const w = imageWork();
216
+ const { sec, basis } = imageSeconds();
217
+ const label = `${w.count} image${w.count > 1 ? 's' : ''} at ${w.w}×${w.h}, ${w.steps} steps`;
218
+ const box = $('estimateBox');
219
+ if (sec == null) { $('estTime').textContent = 'Time: measured on the first image'; $('estimate').textContent = `${label}. On a graphics card an image usually takes seconds.`; box.classList.remove('warn'); return; }
220
+ $('estTime').textContent = `About ${MIN(sec)}${w.count > 1 ? ` for ${w.count}` : ''}`;
221
+ const slow = sec > 2 * 3600;
222
+ $('estimate').textContent = `${label}. ${basis === 'measured' ? 'Based on your last image on this computer.' : 'Rough estimate for this processor; the first image measures the real time.'}${slow ? ' This is a long run: try Small or fewer images first.' : ''}`;
223
+ box.classList.toggle('warn', slow);
224
+ return;
225
+ }
226
  const w = workFor(form);
227
  const n = shots.length;
228
  const label = `${w.preview ? 'Preview: 1 s, ' : ''}${w.w}×${w.h}, ${w.frames} frames at ${w.fps} fps, ${w.steps} steps`;
 
229
  const box = $('estimateBox');
230
+ if (runWhere() !== 'local') return onlineEstimate(label, onlineSeconds(w) * shots.length, shots.length);
231
+ const { sec, basis } = shotSeconds(form);
232
  if (sec == null) {
233
  $('estTime').textContent = 'Time: measured on the first video';
234
  $('estimate').textContent = `${label}. On a graphics card a shot usually takes minutes; Ora times the first one and estimates from then on.`;
 
285
  if (message !== undefined) $('setupStatus').textContent = message;
286
  }
287
 
288
+ // the image model is optional: only the video files count for "ready"
289
+ function requiredKeys() { return Object.keys(S.manifest.files).filter(k => !S.manifest.files[k].optional); }
290
+ function allReady(status) { return requiredKeys().every(k => status[k] && status[k].ready); }
291
+ function imageReady() { return S.manifest.image && S.manifest.image.files.every(k => S.files[k] && S.files[k].ready); }
292
  function modelReady(key) { return S.manifest.models[key].files.every(k => S.files[k].ready); }
293
 
294
  function showSetup(downloading) {
 
302
  }
303
 
304
  let speed = { t: 0, bytes: 0, rate: 0 };
305
+ let catTick = 0;
306
  function onProgress(p) {
307
  S.files = p.status;
308
+ if (p.set === 'image') { imgDownloading = true; renderImageDownload(); return; }
309
+ if (p.set && p.set !== 'required') { mdlDownloading = p.set; if (Date.now() - catTick > 1500) { catTick = Date.now(); refreshCatalog(); } return; }
310
  if (!$('studio').hidden) { sync(); return; }
311
  const have = Object.values(p.status).reduce((a, f) => a + (f.ready ? f.size : f.have), 0);
312
  const total = Object.values(p.status).reduce((a, f) => a + f.size, 0);
 
317
  renderSetup(p.status, `Downloading ${p.status[p.key].name}${speed.rate > 0 ? ` at ${(speed.rate / 1e6).toFixed(1)} MB/s` : ''}${left}. You can pause and continue later.`);
318
  }
319
 
320
+ // --- image model download (optional, from the Image tab) -------------------------------------------------------
321
+
322
+ let imgDownloading = false;
323
+ function renderImageDownload() {
324
+ const keys = S.manifest.image.files;
325
+ const total = keys.reduce((a, k) => a + S.files[k].size, 0);
326
+ const have = keys.reduce((a, k) => a + (S.files[k].ready ? S.files[k].size : S.files[k].have), 0);
327
+ $('imgDl').hidden = imageReady() || runWhere() !== 'local';
328
+ $('imgDlSize').textContent = GB(total);
329
+ $('imgDlBar').style.width = `${(100 * have / total).toFixed(1)}%`;
330
+ $('imgDlBtn').textContent = imgDownloading ? 'Pause' : have > 0 ? 'Continue download' : 'Download image model';
331
+ if (have > 0 && !imageReady()) $('imgDlStatus').textContent = `${GB(have)} of ${GB(total)}`;
332
+ }
333
+
334
  // --- studio ----------------------------------------------------------------------------------------------------
335
 
336
  function showStudio() {
337
  $('setup').hidden = true; $('studio').hidden = false;
338
  const m = S.manifest.models;
339
+ renderModelChoices();
 
 
340
  seg($('shapeSeg'), SHAPES.map(([v, l]) => [v, l]), 'shape');
341
+ renderLengths();
342
  seg($('qualitySeg'), QUALITY, 'quality');
343
  if (!modelReady(jobModel(form))) form.model = modelReady('fast') ? 'fast' : 'quality';
344
+ seg($('imgShapeSeg'), IMG_SHAPES, 'shape', null, imgForm);
345
+ seg($('imgSizeSeg'), IMG_SIZES, 'size', null, imgForm);
346
+ seg($('imgCountSeg'), IMG_COUNTS, 'count', null, imgForm);
347
  renderRunOn();
348
+ setMode(mode);
349
  sync();
350
  renderGrid();
351
  }
352
 
353
+ // Model choices in the forms: the built-in ones, plus catalog models that are installed and can run here.
354
+ function catalogOk(id) {
355
+ const c = catalog.find(e => e.id === id);
356
+ if (!c) return false;
357
+ if (runWhere() !== 'local') return !c.soon && !!(c.online && c.online[runWhere()]); // files are fetched on the online GPU
358
+ return !!(c.installed && c.check.ok);
359
+ }
360
+ function renderModelChoices() {
361
+ const m = S.manifest.models;
362
+ const vids = [
363
+ ['preview', 'Preview · 1.3B', 'Quick 1 s look, small size. Good for phone screens and checking a prompt'],
364
+ ['fast', 'Fast · 1.3B', m.fast.detail], ['quality', 'Quality · 5B', m.quality.detail]];
365
+ if (m.pro && catalogOk('pro')) vids.push(['pro', 'Pro · Wan2.2 A14B', m.pro.detail]);
366
+ if (m.ltx23 && catalogOk('ltx23')) vids.push(['ltx23', 'Sound · LTX-2.3 22B', `${m.ltx23.detail} · Beta`]);
367
+ if (m.h3 && catalogOk('h3')) vids.push(['h3', 'Long · MiniMax-H3', `${m.h3.detail} · Beta · shows "MiniMax H3"`]);
368
+ seg($('modelSeg'), vids, 'model', renderLengths);
369
+ if (!vids.some(v => v[0] === form.model)) form.model = 'fast';
370
+ const imgs = [['zimage', 'Z-Image-Turbo 6B', 'Default · photo-real, any computer']];
371
+ if (catalogOk('flux1s')) imgs.push(['flux1s', 'FLUX.1-schnell 12B', 'Very sharp, 4 steps']);
372
+ if (catalogOk('qwenimg')) imgs.push(['qwenimg', 'Qwen-Image 20B', 'Best for text in images']);
373
+ seg($('imgModelSeg'), imgs, 'model', null, imgForm);
374
+ if (!imgs.some(v => v[0] === imgForm.model)) imgForm.model = 'zimage';
375
+ $('imgModelSeg').closest('.field').querySelector('.seg').hidden = imgs.length < 2;
376
+ }
377
+
378
+ // --- online GPU (Kaggle, Colab) ----------------------------------------------------------------------------------
379
+
380
+ const cleanErr = e => String(e && e.message || e).replace(/^Error invoking remote method '[^']+': (Error: )?/, '');
381
+ async function refreshOnline() { try { online = await window.ora.onlineStatus(); } catch { } renderOnline(); }
382
+ function renderOnline() {
383
+ const k = online.kaggle, c = online.colab;
384
+ $('kaggleStatus').innerHTML = k.connected ? '<span class="ok">✓ Connected</span>' : '<span class="muted">Not connected</span>';
385
+ if (k.connected) $('kaggleStatus').append(` as ${k.username}`);
386
+ $('kaggleRemove').hidden = !k.connected;
387
+ $('kaggleConnect').textContent = k.connected ? 'Choose a new kaggle.json…' : 'Choose kaggle.json…';
388
+ $('colabStatus').innerHTML = c.connected ? '<span class="ok">✓ Connected</span>' : '<span class="muted">Not connected</span>';
389
+ if (c.connected && c.gpu) $('colabStatus').append(` · ${c.gpu}`);
390
+ $('colabRemove').hidden = !c.connected;
391
+ const u = online.usage || {};
392
+ for (const where of ['kaggle', 'colab']) {
393
+ const x = u[where] || {};
394
+ $(`${where}Usage`).textContent = `Ora has used ${H(x.last7 || 0)} of ${where === 'kaggle' ? 'Kaggle' : 'Colab'} GPU time in the last 7 days.${x.left != null ? ` About ${H(x.left)} of your quota left (you entered ${x.quota.hours} h on ${new Date(x.quota.at).toLocaleDateString()}).` : ''}`;
395
+ }
396
+ if (S && !$('studio').hidden) { renderRunOn(); renderModelChoices(); sync(); }
397
+ }
398
+ async function openOnline() {
399
+ $('colabLine').textContent = await window.ora.workerLine();
400
+ await refreshOnline();
401
+ $('onlineDlg').showModal();
402
+ }
403
+
404
+ // --- models screen ---------------------------------------------------------------------------------------------
405
+
406
+ let mdlDownloading = null; // catalog id being downloaded
407
+ async function refreshCatalog() {
408
+ try { catalog = await window.ora.catalog(); } catch { catalog = []; }
409
+ renderCatalog();
410
+ if (!$('studio').hidden) { renderModelChoices(); sync(); }
411
+ }
412
+ function renderCatalog() {
413
+ const h = S.hardware;
414
+ const apple = h.platform === 'darwin' && h.arch === 'arm64';
415
+ const gpuTxt = apple ? 'Apple graphics (shares memory)' : h.engine.gpu ? `${(h.gpus.find(g => g.vendor === 'NVIDIA' || g.vendor === 'AMD') || h.gpus[0] || {}).name || 'graphics card'}${h.vram ? `, ${h.vram} GB` : ''}` : 'no graphics card in use (processor only)';
416
+ $('mdlDevice').textContent = `This computer: ${h.cpu} · ${Math.round(h.ram / 2 ** 30)} GB memory · ${gpuTxt} · ${h.freeDisk != null ? GB(h.freeDisk) : '?'} free disk`;
417
+ for (const [kind, box] of [['video', $('mdlVideo')], ['image', $('mdlImage')]]) {
418
+ box.innerHTML = '';
419
+ for (const e of catalog.filter(c => c.kind === kind)) {
420
+ const d = document.createElement('div');
421
+ const locked = !e.installed && !e.check.ok;
422
+ d.className = `mdl${e.installed ? ' installed' : ''}${locked || e.soon ? ' locked' : ''}`;
423
+ d.innerHTML = '<div class="mdl-top"><span class="mdl-title"></span><span class="mdl-tag"></span></div><div class="mdl-made"></div><div class="mdl-text"></div><div class="mdl-meta"></div><div class="mdl-status"></div>';
424
+ d.querySelector('.mdl-title').textContent = e.title;
425
+ d.querySelector('.mdl-tag').textContent = e.tag;
426
+ d.querySelector('.mdl-made').textContent = e.made;
427
+ d.querySelector('.mdl-text').textContent = e.text;
428
+ const sizeTxt = e.builtin ? 'included' : e.installed ? `${GB(e.total)} on disk` : `${GB(e.total - e.have)} to download${e.have > 0 ? ' (shares files you already have)' : ''}`;
429
+ d.querySelector('.mdl-meta').textContent = `${e.by} · ${e.license} · ${sizeTxt}`;
430
+ const st = d.querySelector('.mdl-status');
431
+ if (e.installed) {
432
+ st.innerHTML = '<span class="ok">✓ Installed</span>';
433
+ if (!e.check.ok) { const w = document.createElement('span'); w.className = 'lock'; w.textContent = e.check.reason; st.appendChild(w); }
434
+ if (!e.builtin && e.id !== 'zimage') {
435
+ const rm = document.createElement('button'); rm.className = 'link'; rm.type = 'button'; rm.textContent = `Remove (${GB(e.total)})`;
436
+ rm.addEventListener('click', async () => {
437
+ if (!confirm(`Remove ${e.title} from this computer? You can download it again later.`)) return;
438
+ try { catalog = await window.ora.removeModel(e.id); S.files = (await window.ora.state()).files; renderCatalog(); renderModelChoices(); sync(); } catch (err) { alert(String(err.message || err).replace(/^Error invoking remote method '[^']+': (Error: )?/, '')); }
439
+ });
440
+ st.appendChild(rm);
441
+ }
442
+ } else if (e.soon) {
443
+ st.innerHTML = '<span class="lock">Coming next</span>';
444
+ if (!e.check.ok) { const w = document.createElement('span'); w.className = 'muted'; w.textContent = e.check.reason; st.appendChild(w); }
445
+ } else if (locked) {
446
+ st.innerHTML = '<span class="lock">🔒 Can’t run on this computer.</span>';
447
+ const w = document.createElement('span'); w.className = 'muted'; w.textContent = e.check.reason; st.appendChild(w);
448
+ const b = document.createElement('button'); b.className = 'ghost'; b.type = 'button'; b.disabled = true; b.textContent = `Download ${GB(e.total - e.have)}`; st.appendChild(b);
449
+ } else {
450
+ if (e.have > 0) { const pr = document.createElement('div'); pr.className = 'progress'; pr.style.width = '100%'; pr.innerHTML = `<div style="width:${(100 * e.have / e.total).toFixed(1)}%"></div>`; st.appendChild(pr); }
451
+ const b = document.createElement('button'); b.className = 'primary'; b.type = 'button';
452
+ b.textContent = mdlDownloading === e.id ? 'Pause' : e.have > 0 ? `Continue (${GB(e.total - e.have)} left)` : `Download ${GB(e.total)}`;
453
+ b.disabled = !!mdlDownloading && mdlDownloading !== e.id;
454
+ b.addEventListener('click', async () => {
455
+ if (mdlDownloading === e.id) { await window.ora.downloadPause(); return; }
456
+ try { mdlDownloading = e.id; renderCatalog(); await window.ora.downloadStart(e.id); }
457
+ catch (err) { mdlDownloading = null; renderCatalog(); alert(String(err.message || err).replace(/^Error invoking remote method '[^']+': (Error: )?/, '')); }
458
+ });
459
+ st.appendChild(b);
460
+ if (e.check.warn) { const w = document.createElement('span'); w.className = 'warn'; w.textContent = e.check.warn; st.appendChild(w); }
461
+ }
462
+ // where it can also run online (files are fetched on the online GPU, nothing to download here)
463
+ if (e.online && (e.online.kaggle || e.online.colab)) {
464
+ const on = document.createElement('div'); on.className = 'mdl-online';
465
+ const where = ['kaggle', 'colab'].filter(w => e.online[w]).map(w => w === 'kaggle' ? 'Kaggle (2 × T4)' : 'Colab (T4)');
466
+ on.textContent = `✓ Runs online on ${where.join(' and ')}${e.beta ? ' · Beta' : ''}`;
467
+ if (!onlineChoice()) { const b = document.createElement('button'); b.type = 'button'; b.className = 'link'; b.textContent = 'Connect'; b.addEventListener('click', () => { $('modelsDlg').close(); openOnline(); }); on.append(' · ', b); }
468
+ d.appendChild(on);
469
+ }
470
+ box.appendChild(d);
471
+ }
472
+ }
473
+ }
474
+
475
+ // Lengths depend on the model: Wan 2-5 s, LTX up to 10 s, MiniMax-H3 5/10/15 s
476
+ function renderLengths() {
477
+ const m = S.manifest.models[jobModel(form)];
478
+ const ls = (m && m.lengths) || [2, 3, 5];
479
+ seg($('lengthSeg'), ls.map(v => [v, `${v} s`]), 'seconds');
480
+ if (!ls.includes(form.seconds)) form.seconds = ls.includes(5) ? 5 : ls[0];
481
+ sync();
482
+ }
483
+
484
  function renderStyles() {
485
  const box = $('styleChips');
486
  box.innerHTML = '';
 
506
  }
507
 
508
  function saveDraft() {
509
+ store('ora.draft', { shots, styles, scene: $('scene').value, project: $('projectName').value, image: $('imgPrompt').value });
510
  }
511
 
512
  function renderShots(states) {
 
545
  $('stageEmpty').hidden = which !== 'empty';
546
  $('stageRun').hidden = which !== 'run';
547
  $('stageVideo').hidden = which !== 'video';
548
+ $('stageImages').hidden = which !== 'images';
549
+ }
550
+
551
+ function setMode(m) {
552
+ mode = m === 'image' ? 'image' : 'video';
553
+ store('ora.mode', mode);
554
+ for (const b of $('modeTabs').children) b.setAttribute('aria-selected', String(b.dataset.mode === mode));
555
+ for (const el of document.querySelectorAll('.video-only')) el.hidden = mode !== 'video' || (el.id === 'previewNote' && !isPreview(form));
556
+ for (const el of document.querySelectorAll('.image-only')) el.hidden = mode !== 'image';
557
+ $('startImage').hidden = mode !== 'video' || !startImage;
558
+ $('styleLabel').textContent = mode === 'image' ? 'Style' : 'Style for all shots';
559
+ $('stageTitle').textContent = mode === 'image' ? 'Your images appear here.' : 'Your video appears here.';
560
+ $('projectHint').textContent = mode === 'image' ? '(folder in Pictures/Ora)' : '(folder in Videos/Ora)';
561
+ setRunning(!!queue);
562
+ if (S) { sync(); }
563
+ }
564
+
565
+ function setStartImage(si) {
566
+ startImage = si;
567
+ if (si) {
568
+ $('startImageImg').src = `ora://video/${encodeURIComponent(si.id)}/${si.file}`;
569
+ if (modelReady('quality')) form.model = 'quality';
570
+ }
571
+ setMode('video');
572
+ }
573
+
574
+ function showImages(meta) {
575
+ current = meta;
576
+ showStage('images');
577
+ const g = $('imgGrid');
578
+ g.innerHTML = '';
579
+ (meta.images || []).forEach((file, i) => {
580
+ const t = document.createElement('div');
581
+ t.className = 'img-tile';
582
+ t.innerHTML = '<img alt=""><div class="tile-bar"><button class="primary" type="button">Animate this image</button><button class="ghost" type="button">Show in folder</button></div>';
583
+ t.querySelector('img').src = `ora://video/${encodeURIComponent(meta.id)}/${file}`;
584
+ t.querySelector('img').alt = `Image ${i + 1}: ${meta.prompt}`;
585
+ const [anim, show] = t.querySelectorAll('button');
586
+ anim.disabled = !modelReady('quality');
587
+ anim.title = anim.disabled ? 'Needs the Quality (5B) model' : 'Make a video that starts from this image';
588
+ anim.addEventListener('click', () => { setStartImage({ id: meta.id, file }); $('shots').querySelector('textarea').focus(); });
589
+ show.addEventListener('click', () => window.ora.reveal((meta.savedFiles || [])[i] || meta.savedTo));
590
+ g.appendChild(t);
591
+ });
592
+ const mins = meta.seconds_taken ? ` · made in ${MIN(meta.seconds_taken)}` : '';
593
+ $('imagesInfo').textContent = `${meta.images.length} image${meta.images.length > 1 ? 's' : ''} · ${meta.width}×${meta.height} · ${meta.modelLabel || 'Z-Image-Turbo'} · seed ${meta.seed}${mins}`;
594
  }
595
  function setRing(pct) {
596
  const p = Math.max(0, Math.min(100, pct));
 
605
  v.src = `ora://video/${encodeURIComponent(meta.id)}/${meta.file}`;
606
  v.play().catch(() => { });
607
  const mins = meta.seconds_taken ? ` · made in ${MIN(meta.seconds_taken)}` : '';
608
+ $('videoInfo').textContent = `${meta.fromImage ? 'From an image · ' : ''}${meta.width}×${meta.height} · ${meta.seconds} s · ${meta.quality === 'preview' ? 'Preview, ' : ''}${MODEL_NAMES[meta.model] || meta.model} · seed ${meta.seed}${mins}`;
609
  }
610
 
611
  function renderGrid() {
 
619
  c.innerHTML = '<img alt=""><div class="meta"><div class="p"></div><div class="s"></div></div><button class="ghost del" type="button">Delete</button>';
620
  c.querySelector('img').src = `ora://video/${encodeURIComponent(meta.id)}/poster.png`;
621
  c.querySelector('img').style.aspectRatio = `${meta.width} / ${meta.height}`;
622
+ c.querySelector('.p').textContent = meta.kind === 'image' ? meta.prompt : meta.project ? `${meta.project.index}. ${meta.project.title}` : meta.prompt;
623
+ if (meta.kind === 'image') {
624
+ const k = document.createElement('span'); k.className = 'kind'; k.textContent = meta.count > 1 ? `Image ×${meta.count}` : 'Image';
625
+ c.prepend(k);
626
+ }
627
+ if (meta.kind === 'image') c.querySelector('.s').textContent = `${meta.width}×${meta.height} · ${meta.modelLabel || 'Z-Image'} · ${new Date(meta.created).toLocaleString()}`;
628
+ else c.querySelector('.s').textContent = `${meta.project && meta.project.total > 1 ? `${meta.project.folder.slice(11)} · ` : ''}${meta.quality === 'preview' ? 'Preview · ' : ''}${meta.seconds} s · ${({ fast: '1.3B', quality: '5B', pro: 'A14B', ltx23: 'LTX-2.3', h3: 'MiniMax H3' })[meta.model] || meta.model} · ${new Date(meta.created).toLocaleString()}`;
629
+ const open = () => meta.kind === 'image' ? showImages(meta) : playVideo(meta);
630
  c.addEventListener('click', e => { if (!e.target.closest('.del')) open(); });
631
  c.addEventListener('keydown', e => { if (e.key === 'Enter' && e.target === c) open(); });
632
  c.querySelector('.del').addEventListener('click', async () => {
633
+ if (!confirm(meta.kind === 'image' ? 'Delete these images from Ora? The copies in your Pictures folder stay.' : 'Delete this video from Ora? The copy in your Videos folder stays.')) return;
634
  await window.ora.remove(meta.id);
635
  S.videos = S.videos.filter(v => v.id !== meta.id);
636
  if (current && current.id === meta.id) { current = null; showStage('empty'); }
 
640
  }
641
  }
642
 
643
+ // Example projects shown while the history is empty; clicking one fills the form.
644
+ const IDEAS = [
645
+ { title: 'Juice product ad', mode: 'video', tag: 'Video · 2 shots', styles: ['Product ad', 'Golden hour'], scene: 'a glass bottle of orange juice with a plain white label, on dark wet stone', shots: ['Close-up of the bottle, droplets running down the glass, slow push-in', 'Juice pours into a glass in slow motion'] },
646
+ { title: 'Sneaker reel', mode: 'video', tag: 'Video · 9:16', shape: 'portrait', styles: ['Studio light', 'Close-up'], scene: 'a white running sneaker with orange details', shots: ['The sneaker slowly rotates on a turntable, soft shadow below'] },
647
+ { title: 'Coffee mood film', mode: 'video', tag: 'Video · B-roll', styles: ['Cinematic', 'Handheld'], scene: 'a small café in the morning', shots: ['Steam rises from a cup of coffee on a wooden table by the window', 'A barista pours milk into a cup, making latte art'] },
648
+ { title: 'Skincare hero shot', mode: 'image', tag: 'Image · 4:5', shape: 'insta', styles: ['Product ad', 'Studio light'], image: 'A frosted glass serum bottle with a gold cap on a pale pink stone pedestal, soft shadows, water droplets, clean beige background, premium product photography' },
649
+ { title: 'Travel poster', mode: 'image', tag: 'Image · 16:9', shape: 'landscape', styles: ['Golden hour'], image: 'A quiet harbour town at sunset, colourful houses on the hillside, small fishing boats, warm light reflecting on calm water, wide shot' },
650
+ { title: 'Food close-up', mode: 'image', tag: 'Image · 1:1', shape: 'square', styles: ['Close-up'], image: 'A stack of fluffy pancakes with blueberries and maple syrup dripping down, on a white plate, morning light, shallow depth of field' },
651
+ ];
652
+ function renderIdeas() {
653
+ const g = $('ideaGrid');
654
+ g.innerHTML = '';
655
+ for (const idea of IDEAS) {
656
+ const b = document.createElement('button');
657
+ b.type = 'button'; b.className = 'idea';
658
+ b.innerHTML = '<span class="idea-tag"></span><b></b><span class="idea-text"></span>';
659
+ b.querySelector('.idea-tag').textContent = idea.tag;
660
+ b.querySelector('b').textContent = idea.title;
661
+ b.querySelector('.idea-text').textContent = idea.mode === 'image' ? idea.image : idea.shots.join(' → ');
662
+ b.addEventListener('click', () => useIdea(idea));
663
+ g.appendChild(b);
664
+ }
665
+ }
666
+ function useIdea(idea) {
667
+ if (queue) return;
668
+ styles = idea.styles.slice();
669
+ $('projectName').value = idea.title;
670
+ if (idea.mode === 'image') {
671
+ $('imgPrompt').value = idea.image;
672
+ if (idea.shape) imgForm.shape = idea.shape;
673
+ store('ora.imgForm', imgForm);
674
+ setMode('image');
675
+ } else {
676
+ setStartImage(null);
677
+ shots = idea.shots.slice();
678
+ $('scene').value = idea.scene || '';
679
+ if (idea.shape) form.shape = idea.shape;
680
+ store('ora.form', form);
681
+ renderShots();
682
+ setMode('video');
683
+ }
684
+ renderStyles(); saveDraft(); sync();
685
+ $('form').scrollTop = 0;
686
+ }
687
+
688
  function formError(msg) { $('formError').hidden = !msg; $('formError').textContent = msg || ''; if (msg) $('formError').scrollIntoView({ block: 'center', behavior: 'smooth' }); }
689
 
690
  function setRunning(on) {
691
  const n = shots.length;
692
  $('goBtn').hidden = on;
693
  $('stopBtn').hidden = !on;
694
+ $('goBtn').textContent = mode === 'image' ? (imgForm.count > 1 ? `Make ${imgForm.count} images` : 'Make image') : startImage ? 'Animate image' : n > 1 ? `Make ${n} videos` : 'Make video';
695
  $('clearHistoryBtn').disabled = on;
696
  $('clearPromptsBtn').disabled = on;
697
  }
 
704
  window.ora.cancel();
705
  }
706
 
707
+ async function submitImages() {
708
+ const prompt = $('imgPrompt').value.trim();
709
+ if (prompt.length < 3) return formError('Describe the image first.');
710
+ if (runWhere() === 'local' && !imageReady()) return formError('Download the image model first (button above).');
711
+ if (imgForm.model !== 'zimage' && !catalogOk(imgForm.model)) return formError('That image model is not installed. Open Models to download it.');
712
+ const seedText = $('seed').value.trim();
713
+ if (seedText && !/^\d{1,10}$/.test(seedText)) return formError('The seed must be a whole number.');
714
+ const est = runWhere() === 'local' ? imageSeconds() : { sec: null };
715
+ if (est.sec != null && est.sec > 2 * 3600 && !confirm(`This will take about ${MIN(est.sec)} on this computer. You can stop it at any time. Start anyway?`)) return;
716
+ const name = $('projectName').value.trim() || prompt.split(/\s+/).slice(0, 6).join(' ');
717
+ const folder = await window.ora.createProject(name);
718
+ const parts = [prompt.replace(/[.,;]+$/, '')];
719
+ for (const [label, text] of STYLES) if (styles.includes(label)) parts.push(text);
720
+ const { model: imageModel, ...imgOpts } = imgForm;
721
+ const job = { kind: 'image', ...imgOpts, imageModel, prompt: parts.join(', '), seed: seedText ? Math.min(+seedText, 2 ** 31 - 1) : undefined, project: { folder, index: 1, total: 1, title: prompt.slice(0, 300) } };
722
+ job.runOn = runWhere();
723
+ queue = { folder, jobs: [job], index: 0, done: [], states: ['running'], cancelled: false, kind: 'image', kaggle: job.runOn === 'kaggle' };
724
+ setRunning(true);
725
+ nextShot();
726
+ }
727
+
728
  async function submit(e) {
729
  e.preventDefault();
730
  formError('');
731
  if (queue) return;
732
+ if (mode === 'image') return submitImages();
733
  const empty = shots.findIndex(t => t.trim().length < 3);
734
  if (empty >= 0) return formError(shots.length > 1 ? `Shot ${empty + 1} is empty. Describe it or remove it.` : 'Describe the video first.');
735
  const seedText = $('seed').value.trim();
736
  if (seedText && !/^\d{1,10}$/.test(seedText)) return formError('The seed must be a whole number.');
737
  const n = shots.length;
738
+ const est = runWhere() === 'local' ? shotSeconds(form) : { sec: null };
739
  if (est.sec != null && est.sec * n > 2 * 3600 && !confirm(`This will take about ${MIN(est.sec * n)} on this computer${n > 1 ? ` (${n} shots)` : ''}. You can stop it at any time. Start anyway?`)) return;
740
  const name = $('projectName').value.trim() || shots[0].trim().split(/\s+/).slice(0, 6).join(' ');
741
  const folder = await window.ora.createProject(name);
742
  const base = { ...form, model: jobModel(form), quality: jobQuality(form), negative: $('negative').value.trim() || undefined, seed: seedText ? Math.min(+seedText, 2 ** 31 - 1) : undefined };
743
+ if (startImage && base.model !== 'quality') return formError('Animating an image needs the Quality (5B) model.');
744
+ const jobs = shots.map((t, i) => ({ ...base, ...(startImage ? { initImage: { id: startImage.id, file: startImage.file } } : {}), prompt: composePrompt(t), project: { folder, index: i + 1, total: n, title: t.trim().slice(0, 300) } }));
745
+ for (const j of jobs) j.runOn = runWhere();
746
+ queue = { folder, jobs, index: 0, done: [], states: shots.map(() => 'waiting'), cancelled: false, kaggle: runWhere() === 'kaggle' };
747
  renderShots(queue.states);
748
  $('projectDone').hidden = true;
749
  setRunning(true);
 
765
  showStage('run');
766
  setRing(0);
767
  renderRun();
768
+ $('runQueue').textContent = job.kind === 'image' ? (job.count > 1 ? `${job.count} images` : 'Image') : q.jobs.length > 1 ? `Shot ${q.index + 1} of ${q.jobs.length}` : '';
769
  $('runStage').textContent = 'Starting…';
770
  $('runDetail').textContent = '';
771
  $('runPrompt').textContent = job.project.title;
772
+ if (q.kaggle) {
773
+ // Kaggle runs the whole project at once; the progress screen shows the notebook's state until results come back
774
+ q.states = q.states.map(() => 'running'); renderShots(q.states);
775
+ window.ora.runKaggle(q.jobs);
776
+ return;
777
+ }
778
+ if (job.kind === 'image') window.ora.startImages(job); else window.ora.start(job);
779
  }
780
 
781
  function finishQueue() {
 
785
  setRunning(false);
786
  renderShots();
787
  if (!q) return;
788
+ if (q.done.length && q.done[0].kind === 'image') showImages(q.done[0]);
789
+ else if (q.done.length) {
790
  playVideo(q.done[0]);
791
  if (q.jobs.length > 1) {
792
  $('projectDone').hidden = false;
 
810
  function setPhase(ph) {
811
  if (!run || run.phase === ph) return;
812
  const now = Date.now();
813
+ if (ph === 'frames' && !run.starts.frames0) run.starts.frames0 = now;
814
  run.ends[run.phase] = now;
815
  run.phase = ph;
816
  run.starts[ph] = now;
 
821
  if (!meta || !hw) return;
822
  const gpu = hw.engine.gpu;
823
  const gpuName = (hw.gpus || []).map(g => `${g.vendor} ${g.name}`.trim()).join(', ');
824
+ if (/^online-/.test(hw.engine.id)) hw.cpu = hw.cpu || 'Online notebook';
825
  const preview = meta.quality === 'preview';
826
+ const rows = meta.kind === 'image' ? [
827
+ ['Computer', hw.cores ? `${hw.cpu} · ${hw.cores} threads · ${Math.round(hw.ram / 2 ** 30)} GB memory` : hw.cpu],
828
+ ['Runs on', /^online-/.test(hw.engine.id) ? `Online GPU · ${gpuName}` : gpu ? `${engineLabel(hw.engine)}${gpuName ? ` · ${gpuName}` : ''}` : 'Processor only'],
829
+ ['Model', meta.modelLabel || 'Z-Image-Turbo 6B'],
830
+ ['Image', `${meta.width}×${meta.height} · ${meta.count} image${meta.count > 1 ? 's' : ''}`],
831
+ ['Work', `${meta.steps} steps per image, then decoding`],
832
+ ['Seed', String(meta.seed)],
833
+ ] : [
834
+ ['Computer', hw.cores ? `${hw.cpu} · ${hw.cores} threads · ${Math.round(hw.ram / 2 ** 30)} GB memory` : hw.cpu],
835
+ ['Runs on', /^online-/.test(hw.engine.id) ? `Online GPU · ${gpuName}` : gpu ? `${engineLabel(hw.engine)}${gpuName ? ` · ${gpuName}` : ''}` : `Processor only${gpuName ? ` (graphics not used: ${gpuName})` : ''}`],
836
+ ['Model', `${preview ? 'Preview · ' : ''}${MODEL_NAMES[meta.model] || meta.model}`],
837
  ['Video', `${meta.width}×${meta.height} · ${meta.frames} frames · ${meta.seconds} s at ${meta.fps} fps`],
838
  ['Work', `${meta.steps} frame steps, then decoding with the ${meta.decoder === 'tae' ? 'fast decoder' : 'full decoder (best detail)'}`],
839
  ['Seed', String(meta.seed)],
 
871
  }
872
  }
873
 
874
+ function phaseNames() {
875
+ if (run && run.meta && run.meta.kind === 'image') {
876
+ const n = run.meta.count || 1;
877
+ return { prep: 'Load models and read the prompt', frames: n > 1 ? 'Make the images' : 'Make the image', decoding: 'Turn into pictures', saving: 'Save the PNGs' };
878
+ }
879
+ return Object.fromEntries(PHASES);
880
+ }
881
  function renderPhases() {
882
  const list = $('runPhases');
883
  list.innerHTML = '';
 
895
  detail = key === 'frames' ? ` · step ${bar.done} of ${bar.total}` : ` · part ${bar.done} of ${bar.total}`;
896
  if (i === at) pct = 100 * bar.done / bar.total;
897
  }
898
+ const imgN = run.meta && run.meta.kind === 'image' && run.meta.count > 1 && (key === 'frames' || key === 'decoding') ? ` · image ${Math.min((run.item || 0) + (key === 'frames' ? 1 : 0), run.meta.count)} of ${run.meta.count}` : '';
899
+ li.querySelector('.name').textContent = (phaseNames()[key] || name) + imgN + detail;
900
  const t0 = run.starts[key], t1 = run.ends[key];
901
  li.querySelector('.t').textContent = t0 ? MIN(((t1 || Date.now()) - t0) / 1000) + (bar && bar.sps && i === at ? ` · ${Math.round(bar.sps)} s each` : '') : '';
902
  li.querySelector('.pbar div').style.width = `${pct.toFixed(1)}%`;
 
910
  if (!run) return;
911
  const elapsed = (Date.now() - run.t0) / 1000;
912
  const left = timeLeft();
913
+ $('runStage').textContent = run.phase === 'prep' && run.sub ? run.sub : (phaseNames()[run.phase] || 'Working');
914
+ $('runDetail').textContent = `${MIN(elapsed)} so far${left != null ? ` · about ${MIN(left)} left` : ''}${run.note ? ` · ${run.note}` : ''}`;
915
  // ring: share of the time, when it can be estimated; otherwise fixed shares per phase
916
  let pct;
917
  if (left != null) pct = 100 * elapsed / (elapsed + left);
 
936
  if (!run) return;
937
  if (u.meta) {
938
  run.meta = u.meta; run.hw = u.hardware;
939
+ run.rec = u.meta.kind === 'image' ? null : store(`ora.speed.${u.meta.engine}.${u.meta.model}.${u.meta.decoder || 'vae'}`);
940
  renderConfig();
941
  }
942
+ if (u.stage === 'remote') { run.note = u.note; if (u.url) run.url = u.url; renderRun(); return; }
943
+ if (u.item != null) run.item = u.item;
944
+ if (u.stage === 'frames' && run.phase === 'decoding' && run.meta && run.meta.kind === 'image') run.starts.frames = Date.now();
945
+ if (u.stage === 'decoding' && run.phase === 'frames' && run.meta && run.meta.kind === 'image' && !run.prepSec) {
946
+ run.prepSec = (run.starts.frames - run.t0) / 1000;
947
+ }
948
  if (u.stage === 'frames' || u.stage === 'decoding') setPhase(u.stage);
949
+ if (run.meta && run.meta.kind === 'image' && run.item > 0) run.perImage = ((Date.now() - (run.starts.frames0 || run.t0)) / 1000 - (run.prepSec || 0)) / run.item;
950
  else if (STAGE_TEXT[u.stage] && run.phase === 'prep') run.sub = STAGE_TEXT[u.stage];
951
  if (u.progress && (u.stage === 'frames' || u.stage === 'decoding')) {
952
  run[u.stage] = { done: u.progress.done, total: u.progress.total, sps: u.progress.secPerStep, at: Date.now() };
 
956
 
957
  async function onJobEnd(r) {
958
  const q = queue;
959
+ if (q && q.kaggle) return onKaggleEnd(r, q);
960
  if (r.cancelled) { if (q) q.cancelled = true; return finishQueue(); }
961
  if (r.error) {
962
  if (q) { q.states[q.index] = 'failed'; q.cancelled = true; }
 
964
  return finishQueue();
965
  }
966
  const meta = r.meta;
967
+ if (r.done && meta.kind === 'video') {
968
+ S.videos.unshift(meta); renderGrid(); estimate();
969
+ if (q) { q.done.push(meta); q.states[q.index] = 'done'; q.index++; }
970
+ return nextShot();
971
+ }
972
+ if (r.done && meta.kind === 'image') {
973
+ if (run && run.perImage) store(`ora.speed.${meta.engine}.${meta.model || 'zimage'}`, { work: meta.width * meta.height, perImage: run.perImage, prepSec: run.prepSec });
974
+ S.videos.unshift(meta);
975
+ renderGrid();
976
+ if (q) { q.done.push(meta); q.states[q.index] = 'done'; q.index++; }
977
+ return nextShot();
978
+ }
979
  if (run) { setPhase('saving'); renderRun(); }
980
  try {
981
  const { bytes, ext } = await encode(meta);
 
984
  const sec = (a, b) => run.starts[a] && run.ends[a] ? (run.ends[a] - run.starts[a]) / 1000 : (b ?? null);
985
  remember(saved, { secPerStep: run.frames.sps, prepSec: sec('prep', 0), decodeSec: sec('decoding') });
986
  }
987
+ if (saved.where && saved.where !== 'local' && run && run.frames && run.frames.sps) {
988
+ store(`ora.speed.online-${saved.where}.${saved.model}`, { work: saved.width * saved.height * saved.frames, secPerStep: run.frames.sps, prepSec: 0, decodeSec: 0 });
989
+ }
990
  S.videos.unshift(saved);
991
  renderGrid();
992
  setRing(100);
 
1000
  nextShot();
1001
  }
1002
 
1003
+ async function onKaggleEnd(r, q) {
1004
+ if (r.cancelled || r.error) {
1005
+ q.cancelled = true;
1006
+ if (r.error) formError(r.error);
1007
+ else if (r.note) formError(r.note);
1008
+ return finishQueue();
1009
+ }
1010
+ if (r.meta) {
1011
+ const i = r.meta.project ? r.meta.project.index - 1 : 0;
1012
+ let saved = r.meta;
1013
+ if (!r.done) { // frames came back (no ffmpeg on the notebook): encode here
1014
+ try { const { bytes, ext } = await encode(r.meta); saved = await window.ora.save(r.meta.id, bytes, ext); }
1015
+ catch (e) { await window.ora.fail(r.meta.id, String(e.message || e)); q.states[i] = 'failed'; renderShots(q.states); return; }
1016
+ }
1017
+ S.videos.unshift(saved); renderGrid();
1018
+ q.done.push(saved); q.states[i] = 'done'; renderShots(q.states);
1019
+ }
1020
+ if (r.batchEnd) { q.index = q.jobs.length; finishQueue(); }
1021
+ }
1022
+
1023
  // PNG frames -> H.264 MP4 with WebCodecs; VP9 WebM if this system has no H.264 encoder.
1024
  async function encode(meta) {
1025
  const { width, height, fps } = meta;
 
1071
  }
1072
  function renderDevice() {
1073
  const h = S.hardware;
1074
+ const w = typeof runWhere === 'function' ? runWhere() : 'local';
1075
+ $('deviceChip').textContent = w !== 'local' ? `Online · ${w === 'colab' ? 'Colab' : 'Kaggle'}` : `${engineLabel(h.engine)} · ${Math.round(h.ram / 2 ** 30)} GB RAM`;
1076
  const os = { darwin: 'macOS', win32: 'Windows', linux: 'Linux' }[h.platform] || h.platform;
1077
  const rows = [
1078
  ['System', `${os} (${h.arch})`], ['Processor', `${h.cpu} · ${h.cores} threads`], ['Memory', `${Math.round(h.ram / 2 ** 30)} GB`],
 
1094
  async function init() {
1095
  S = await window.ora.state();
1096
  $('version').textContent = S.version;
1097
+ $('saveDirText').textContent = `Videos: ${S.saveDir} · Images: ${S.imageDir}`;
1098
+ $('saveDirText').title = `Videos are saved in ${S.saveDir}, images in ${S.imageDir}`;
1099
  renderDevice();
1100
+ try { catalog = await window.ora.catalog(); } catch { catalog = []; }
1101
+ try { online = await window.ora.onlineStatus(); } catch { }
1102
  Object.assign(form, store('ora.form') || {});
1103
  if (!S.manifest.models[form.model] && !isPreview(form)) form.model = 'fast';
1104
+ if (form.model === 'pro' && !catalogOk('pro')) form.model = 'fast';
1105
+ if (store('ora.runOnline') && !onlineChoice()) store('ora.runOnline', false);
1106
  if (form.quality === 'preview') form.quality = 'standard';
1107
  const draft = store('ora.draft') || {};
1108
  shots = Array.isArray(draft.shots) && draft.shots.length ? draft.shots.slice(0, MAX_SHOTS).map(String) : [store('ora.prompt') || ''];
1109
  styles = Array.isArray(draft.styles) ? draft.styles.filter(l => STYLES.some(([x]) => x === l)) : [];
1110
  $('scene').value = draft.scene || '';
1111
  $('projectName').value = draft.project || '';
1112
+ $('imgPrompt').value = draft.image || '';
1113
+ Object.assign(imgForm, store('ora.imgForm') || {});
1114
+ mode = store('ora.mode') === 'image' ? 'image' : 'video';
1115
  renderStyles();
1116
  renderShots();
1117
+ renderIdeas();
1118
  $('stageHint').textContent = S.hardware.engine.gpu ? 'Tip: use Preview to check a prompt quickly, then make the full video with Fast or Quality.' : 'Tip: on the processor, use Preview to check a prompt first. Full videos take much longer.';
1119
  if (allReady(S.files) || (modelReady('fast') && store('ora.startedFast'))) { showStudio(); if (!allReady(S.files) && !S.downloading) window.ora.downloadStart(); }
1120
  else showSetup(S.downloading);
 
1131
  });
1132
  window.ora.onDownloadProgress(onProgress);
1133
  window.ora.onDownloadDone(p => {
1134
+ if (p.set && p.set !== 'required' && p.set !== 'image') { S.files = p.status; mdlDownloading = null; refreshCatalog(); return; }
1135
+ if (p.set === 'image') { S.files = p.status; imgDownloading = false; $('imgDlStatus').textContent = 'Image model ready.'; sync(); if (current && current.kind === 'image') showImages(current); return; }
1136
  S.files = p.status; setDownloading(false); renderSetup(p.status, 'All models are ready.');
1137
  if ($('studio').hidden) setTimeout(showStudio, 700); else sync();
1138
  });
1139
  $('startFastBtn').addEventListener('click', () => { store('ora.startedFast', true); if (!$('downloadBtn').dataset.on) window.ora.downloadStart(); showStudio(); });
1140
  window.ora.onDownloadError(p => {
1141
+ if (p.set && p.set !== 'required' && p.set !== 'image') { S.files = p.status; mdlDownloading = null; refreshCatalog(); if (!/Paused/.test(p.message)) alert(p.message); return; }
1142
+ if (p.set === 'image') { S.files = p.status; imgDownloading = false; renderImageDownload(); $('imgDlStatus').textContent = p.message; return; }
1143
  S.files = p.status; setDownloading(false); renderSetup(p.status, p.message);
1144
  if (!$('studio').hidden) { $('dlNote').hidden = false; $('dlNote').textContent = `Download stopped: ${p.message} Restart Ora to try again.`; }
1145
  });
 
1161
  // ---- clear prompts / clear history ----
1162
  function clearPrompts() {
1163
  shots = [''];
1164
+ $('scene').value = ''; $('projectName').value = ''; $('seed').value = ''; $('negative').value = ''; $('imgPrompt').value = '';
1165
  styles = [];
1166
  try { localStorage.removeItem('ora.draft'); localStorage.removeItem('ora.prompt'); } catch { }
1167
  renderShots(); renderStyles(); setRunning(false); estimate();
 
1180
  // ---- run on: automatic / graphics / processor ----
1181
  function renderRunOn() {
1182
  const h = S.hardware, e = h.engine;
1183
+ const opts = [['auto', 'Automatic'], ['gpu', 'Graphics'], ['cpu', 'Processor'], ['online', 'Online']];
1184
  const el = $('runOnSeg');
1185
  el.innerHTML = ''; el.setAttribute('role', 'radiogroup');
1186
+ const choice = runWhere() !== 'local' ? 'online' : (S.settings.engine || 'auto');
1187
  for (const [v, l] of opts) {
1188
  const b = document.createElement('button');
1189
  b.type = 'button'; b.setAttribute('role', 'radio'); b.dataset.value = v; b.textContent = l;
1190
  b.setAttribute('aria-checked', String(choice === v));
1191
  if (v === 'gpu' && e.gpuUnavailable) { b.disabled = true; b.title = e.gpuUnavailable; }
1192
+ if (v === 'online' && !onlineChoice()) b.title = 'Connect Kaggle or Colab first';
1193
  b.addEventListener('click', async () => {
1194
+ if (v === 'online') {
1195
+ if (!onlineChoice()) { await openOnline(); return; }
1196
+ store('ora.runOnline', true); renderRunOn(); renderModelChoices(); renderDevice(); sync(); return;
1197
+ }
1198
+ store('ora.runOnline', false);
1199
  S.settings = await window.ora.setSettings({ engine: v });
1200
+ renderDevice();
1201
  S = { ...S, ...(await window.ora.state()) };
1202
  renderDevice(); renderRunOn(); estimate();
1203
  });
1204
  el.appendChild(b);
1205
  }
1206
  const gpuName = (h.gpus || []).filter(g => g.vendor !== 'Apple' || h.platform === 'darwin').map(g => `${g.vendor} ${g.name}`.trim()).join(', ');
1207
+ const where = runWhere();
1208
+ if (where !== 'local') {
1209
+ const st = online[where];
1210
+ const other = where === 'colab' ? (online.kaggle.connected ? 'kaggle' : null) : (online.colab.connected ? 'colab' : null);
1211
+ $('runOnNote').innerHTML = '';
1212
+ $('runOnNote').append(`Now: online on your ${where === 'colab' ? 'Colab notebook' : 'Kaggle account'}${st.gpu ? ` (${st.gpu})` : ''}. ${where === 'kaggle' ? 'Each run starts a GPU machine first (2–5 min).' : 'Progress is live.'} `);
1213
+ if (other) { const sw = document.createElement('button'); sw.type = 'button'; sw.className = 'link'; sw.textContent = `Use ${other === 'colab' ? 'Colab' : 'Kaggle'} instead`; sw.addEventListener('click', () => { store('ora.onlineService', other); renderRunOn(); sync(); }); $('runOnNote').append(sw); }
1214
+ return;
1215
+ }
1216
  $('runOnNote').textContent = e.gpuUnavailable
1217
  ? `Now: processor. ${e.gpuUnavailable}`
1218
  : `Now: ${e.gpu ? `graphics${gpuName ? ` (${gpuName})` : ''}` : 'processor only'}.${choice === 'auto' && !e.gpu && h.platform !== 'darwin' ? ' No NVIDIA or AMD graphics card was found; choose Graphics to try your graphics anyway.' : ''}`;
 
1229
  store('ora.form', form); saveDraft(); renderShots(); setRunning(false); sync();
1230
  });
1231
  $('openSaveDir').addEventListener('click', () => window.ora.openSaveDir());
1232
+ $('modelsBtn').addEventListener('click', async () => { await refreshCatalog(); $('modelsDlg').showModal(); });
1233
+ document.addEventListener('click', async e => { if (e.target.closest('[data-open-models]')) { await refreshCatalog(); $('modelsDlg').showModal(); } });
1234
+ $('closeModels').addEventListener('click', () => $('modelsDlg').close());
1235
+ $('onlineBtn').addEventListener('click', openOnline);
1236
+ $('closeOnline').addEventListener('click', () => $('onlineDlg').close());
1237
+ $('kaggleOpen').addEventListener('click', () => window.ora.openOnline('kaggle'));
1238
+ $('colabOpen').addEventListener('click', () => window.ora.openOnline('colab'));
1239
+ $('colabCopy').addEventListener('click', async () => { try { await navigator.clipboard.writeText($('colabLine').textContent); $('colabCopy').textContent = 'Copied'; setTimeout(() => { $('colabCopy').textContent = 'Copy'; }, 1500); } catch { } });
1240
+ $('kaggleConnect').addEventListener('click', async () => {
1241
+ $('kaggleStatus').textContent = 'Checking the token with Kaggle…';
1242
+ try { online = await window.ora.connectKaggle(); store('ora.onlineService', 'kaggle'); } catch (e) { await refreshOnline(); $('kaggleStatus').textContent = cleanErr(e); return; }
1243
+ renderOnline();
1244
+ });
1245
+ $('colabConnect').addEventListener('click', async () => {
1246
+ const code = $('colabCode').value.trim();
1247
+ if (!code) return;
1248
+ $('colabStatus').textContent = 'Connecting to your notebook…';
1249
+ try { online = await window.ora.connectColab(code); $('colabCode').value = ''; store('ora.onlineService', 'colab'); } catch (e) { await refreshOnline(); $('colabStatus').textContent = cleanErr(e); return; }
1250
+ renderOnline();
1251
+ });
1252
+ $('kaggleRemove').addEventListener('click', async () => { online = await window.ora.disconnectOnline('kaggle'); renderOnline(); });
1253
+ $('kaggleQuotaSave').addEventListener('click', async () => {
1254
+ const v = $('kaggleQuota').value.trim();
1255
+ online.usage = await window.ora.setQuota('kaggle', v === '' ? null : Number(v));
1256
+ renderOnline(); sync();
1257
+ });
1258
+ $('colabRemove').addEventListener('click', async () => { online = await window.ora.disconnectOnline('colab'); renderOnline(); });
1259
+ $('modeTabs').addEventListener('click', e => { const b = e.target.closest('button[data-mode]'); if (b && !queue) setMode(b.dataset.mode); });
1260
+ $('startImageRemove').addEventListener('click', () => setStartImage(null));
1261
+ $('imgPrompt').addEventListener('input', saveDraft);
1262
+ $('imgRevealBtn').addEventListener('click', () => current && window.ora.reveal(current.savedTo));
1263
+ $('imgReuseBtn').addEventListener('click', () => {
1264
+ if (!current || current.kind !== 'image') return;
1265
+ Object.assign(imgForm, { shape: current.shape, size: current.size, count: current.count });
1266
+ $('imgPrompt').value = current.project ? current.project.title : current.prompt;
1267
+ $('seed').value = String(current.seed);
1268
+ store('ora.imgForm', imgForm); saveDraft(); sync();
1269
+ });
1270
+ $('imgDlBtn').addEventListener('click', async () => {
1271
+ if (imgDownloading) { await window.ora.downloadPause(); return; }
1272
+ imgDownloading = true; renderImageDownload();
1273
+ $('imgDlStatus').textContent = 'Starting the download…';
1274
+ await window.ora.downloadStart('image');
1275
+ });
1276
  $('deviceChip').addEventListener('click', () => $('deviceDlg').showModal());
1277
  $('closeDevice').addEventListener('click', () => $('deviceDlg').close());
1278
  $('openModels').addEventListener('click', () => window.ora.openModels());
app/renderer/index.html CHANGED
@@ -11,6 +11,8 @@
11
  <div class="brand"><span class="mark" aria-hidden="true"></span><span>Ora</span><small id="version"></small></div>
12
  <button class="chip" id="deviceChip" type="button" aria-haspopup="dialog"></button>
13
  <div class="spacer"></div>
 
 
14
  <button class="ghost" id="openSaveDir" type="button">Videos folder</button>
15
  </header>
16
 
@@ -40,29 +42,46 @@
40
  <h2>New project</h2>
41
  <button class="link" id="clearPromptsBtn" type="button">Clear prompts</button>
42
  </div>
43
- <div class="field">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  <span class="label">Shots <small class="muted">(1 to 5, one video each)</small></span>
45
  <ol class="shots" id="shots"></ol>
46
  <button class="ghost add-shot" id="addShot" type="button">+ Add shot</button>
47
  </div>
48
- <label class="field">
49
  <span class="label">Same scene for all shots <small class="muted">(optional)</small></span>
50
  <textarea id="scene" rows="2" maxlength="600" placeholder="a glass bottle of orange juice with a plain white label, on dark wet stone"></textarea>
51
  </label>
52
  <div class="field">
53
- <span class="label">Style for all shots</span>
54
  <div class="styles" id="styleChips" aria-label="Styles"></div>
55
  </div>
56
  <label class="field">
57
- <span class="label">Project name <small class="muted">(folder in Videos/Ora)</small></span>
58
  <input id="projectName" maxlength="60" placeholder="Orange juice ad">
59
  </label>
60
 
61
- <div class="field">
62
  <span class="label">Model</span>
63
  <div class="seg seg-models" id="modelSeg"></div>
 
64
  </div>
65
- <div class="row">
66
  <div class="field">
67
  <span class="label">Shape</span>
68
  <div class="seg" id="shapeSeg"></div>
@@ -72,22 +91,51 @@
72
  <div class="seg" id="lengthSeg"></div>
73
  </div>
74
  </div>
75
- <div class="field">
76
  <span class="label">Quality</span>
77
  <div class="seg" id="qualitySeg"></div>
78
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  <div class="field">
80
  <span class="label">Run on</span>
81
  <div class="seg" id="runOnSeg"></div>
82
  <p class="muted small" id="runOnNote"></p>
83
  </div>
84
- <p class="muted small" id="previewNote" hidden>Preview always makes 1 second at a small size, so length and quality are fixed. When you like the idea, make it with Fast or Quality. The full video is made at a larger size, so it will not match the preview frame for frame.</p>
85
 
86
  <details class="advanced">
87
  <summary>Advanced</summary>
88
  <label class="field"><span class="label">Seed <small class="muted">(empty = random; same seed, prompt and settings = same video)</small></span>
89
  <input id="seed" inputmode="numeric" pattern="[0-9]*" placeholder="random"></label>
90
- <label class="field"><span class="label">Avoid <small class="muted">(negative prompt; empty = Wan's default list)</small></span>
91
  <textarea id="negative" rows="2" maxlength="1000" placeholder="blurry, text, watermark, distorted hands"></textarea></label>
92
  </details>
93
 
@@ -105,7 +153,7 @@
105
  <div class="stage panel" id="stage">
106
  <div class="stage-empty" id="stageEmpty">
107
  <span class="mark big-mark" aria-hidden="true"></span>
108
- <p>Your video appears here.</p>
109
  <p class="muted small" id="stageHint"></p>
110
  </div>
111
  <div class="stage-run" id="stageRun" hidden>
@@ -131,6 +179,15 @@
131
  </section>
132
  </div>
133
  </div>
 
 
 
 
 
 
 
 
 
134
  <div class="stage-video" id="stageVideo" hidden>
135
  <video id="player" controls loop playsinline></video>
136
  <div class="video-bar">
@@ -145,9 +202,12 @@
145
  </div>
146
 
147
  <div class="history">
148
- <div class="history-head"><h2>Your videos</h2><span class="muted small" id="saveDirText"></span><span class="spacer"></span><button class="link" id="clearHistoryBtn" type="button" hidden>Clear history</button></div>
149
  <div class="grid" id="grid"></div>
150
- <p class="muted small" id="gridEmpty">Videos you make are listed here and saved to your Videos folder.</p>
 
 
 
151
  </div>
152
  </div>
153
  </section>
@@ -160,6 +220,57 @@
160
  <div class="dlg-actions"><button class="ghost" id="openModels" type="button">Open models folder</button><button class="primary" id="closeDevice" type="button">Close</button></div>
161
  </dialog>
162
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
163
  <dialog id="clearDlg">
164
  <h2>Clear history</h2>
165
  <p>This removes Ora's list of past videos and the prompts saved with them.</p>
 
11
  <div class="brand"><span class="mark" aria-hidden="true"></span><span>Ora</span><small id="version"></small></div>
12
  <button class="chip" id="deviceChip" type="button" aria-haspopup="dialog"></button>
13
  <div class="spacer"></div>
14
+ <button class="ghost" id="onlineBtn" type="button">Online GPU</button>
15
+ <button class="ghost" id="modelsBtn" type="button">Models</button>
16
  <button class="ghost" id="openSaveDir" type="button">Videos folder</button>
17
  </header>
18
 
 
42
  <h2>New project</h2>
43
  <button class="link" id="clearPromptsBtn" type="button">Clear prompts</button>
44
  </div>
45
+ <div class="mode-tabs" id="modeTabs" role="tablist" aria-label="What to make">
46
+ <button type="button" role="tab" data-mode="video" aria-selected="true"><span class="mi" aria-hidden="true">▶</span>Video</button>
47
+ <button type="button" role="tab" data-mode="image" aria-selected="false"><span class="mi" aria-hidden="true">◼</span>Image</button>
48
+ </div>
49
+
50
+ <div class="start-image" id="startImage" hidden>
51
+ <img id="startImageImg" alt="">
52
+ <div><b>Animating this image</b><span class="muted small">Quality (5B) model. Describe the motion: camera move, what changes.</span></div>
53
+ <button class="link" id="startImageRemove" type="button">Remove</button>
54
+ </div>
55
+
56
+ <div class="field image-only" hidden>
57
+ <span class="label">Describe the image</span>
58
+ <textarea id="imgPrompt" rows="5" maxlength="1500" placeholder="A glass bottle of orange juice with a plain white label on dark wet stone, morning light from the left, droplets on the glass, product photography"></textarea>
59
+ </div>
60
+
61
+ <div class="field video-only">
62
  <span class="label">Shots <small class="muted">(1 to 5, one video each)</small></span>
63
  <ol class="shots" id="shots"></ol>
64
  <button class="ghost add-shot" id="addShot" type="button">+ Add shot</button>
65
  </div>
66
+ <label class="field video-only">
67
  <span class="label">Same scene for all shots <small class="muted">(optional)</small></span>
68
  <textarea id="scene" rows="2" maxlength="600" placeholder="a glass bottle of orange juice with a plain white label, on dark wet stone"></textarea>
69
  </label>
70
  <div class="field">
71
+ <span class="label" id="styleLabel">Style for all shots</span>
72
  <div class="styles" id="styleChips" aria-label="Styles"></div>
73
  </div>
74
  <label class="field">
75
+ <span class="label">Project name <small class="muted" id="projectHint">(folder in Videos/Ora)</small></span>
76
  <input id="projectName" maxlength="60" placeholder="Orange juice ad">
77
  </label>
78
 
79
+ <div class="field video-only">
80
  <span class="label">Model</span>
81
  <div class="seg seg-models" id="modelSeg"></div>
82
+ <button class="link more-models" type="button" data-open-models>More video models…</button>
83
  </div>
84
+ <div class="row video-only">
85
  <div class="field">
86
  <span class="label">Shape</span>
87
  <div class="seg" id="shapeSeg"></div>
 
91
  <div class="seg" id="lengthSeg"></div>
92
  </div>
93
  </div>
94
+ <div class="field video-only">
95
  <span class="label">Quality</span>
96
  <div class="seg" id="qualitySeg"></div>
97
  </div>
98
+
99
+ <div class="image-only" hidden>
100
+ <div class="img-dl" id="imgDl" hidden>
101
+ <b>Download the image model (one time)</b>
102
+ <span class="muted small">Z-Image-Turbo 6B by Tongyi-MAI, Apache-2.0: commercial use allowed. About <span id="imgDlSize">6.7 GB</span>.</span>
103
+ <div class="progress"><div id="imgDlBar"></div></div>
104
+ <span class="muted small" id="imgDlStatus"></span>
105
+ <button class="primary" id="imgDlBtn" type="button">Download image model</button>
106
+ </div>
107
+ <div class="field">
108
+ <span class="label">Model</span>
109
+ <div class="seg seg-models" id="imgModelSeg"></div>
110
+ <button class="link more-models" type="button" data-open-models>More image models…</button>
111
+ </div>
112
+ <div class="field">
113
+ <span class="label">Shape</span>
114
+ <div class="seg" id="imgShapeSeg"></div>
115
+ </div>
116
+ <div class="row">
117
+ <div class="field">
118
+ <span class="label">Size</span>
119
+ <div class="seg" id="imgSizeSeg"></div>
120
+ </div>
121
+ <div class="field">
122
+ <span class="label">Images</span>
123
+ <div class="seg" id="imgCountSeg"></div>
124
+ </div>
125
+ </div>
126
+ </div>
127
  <div class="field">
128
  <span class="label">Run on</span>
129
  <div class="seg" id="runOnSeg"></div>
130
  <p class="muted small" id="runOnNote"></p>
131
  </div>
132
+ <p class="muted small video-only" id="previewNote" hidden>Preview always makes 1 second at a small size, so length and quality are fixed. When you like the idea, make it with Fast or Quality. The full video is made at a larger size, so it will not match the preview frame for frame.</p>
133
 
134
  <details class="advanced">
135
  <summary>Advanced</summary>
136
  <label class="field"><span class="label">Seed <small class="muted">(empty = random; same seed, prompt and settings = same video)</small></span>
137
  <input id="seed" inputmode="numeric" pattern="[0-9]*" placeholder="random"></label>
138
+ <label class="field video-only"><span class="label">Avoid <small class="muted">(negative prompt; empty = Wan's default list)</small></span>
139
  <textarea id="negative" rows="2" maxlength="1000" placeholder="blurry, text, watermark, distorted hands"></textarea></label>
140
  </details>
141
 
 
153
  <div class="stage panel" id="stage">
154
  <div class="stage-empty" id="stageEmpty">
155
  <span class="mark big-mark" aria-hidden="true"></span>
156
+ <p id="stageTitle">Your video appears here.</p>
157
  <p class="muted small" id="stageHint"></p>
158
  </div>
159
  <div class="stage-run" id="stageRun" hidden>
 
179
  </section>
180
  </div>
181
  </div>
182
+ <div class="stage-images" id="stageImages" hidden>
183
+ <div class="img-grid" id="imgGrid"></div>
184
+ <div class="video-bar">
185
+ <div class="muted small" id="imagesInfo"></div>
186
+ <div class="spacer"></div>
187
+ <button class="ghost" id="imgRevealBtn" type="button">Show in folder</button>
188
+ <button class="ghost" id="imgReuseBtn" type="button">Use these settings</button>
189
+ </div>
190
+ </div>
191
  <div class="stage-video" id="stageVideo" hidden>
192
  <video id="player" controls loop playsinline></video>
193
  <div class="video-bar">
 
202
  </div>
203
 
204
  <div class="history">
205
+ <div class="history-head"><h2>Your work</h2><span class="muted small save-dir" id="saveDirText"></span><span class="spacer"></span><button class="link" id="clearHistoryBtn" type="button" hidden>Clear history</button></div>
206
  <div class="grid" id="grid"></div>
207
+ <div class="ideas" id="gridEmpty">
208
+ <p class="muted small">Videos and images you make are listed here. Not sure where to start? Pick an idea: it fills in the form.</p>
209
+ <div class="idea-grid" id="ideaGrid"></div>
210
+ </div>
211
  </div>
212
  </div>
213
  </section>
 
220
  <div class="dlg-actions"><button class="ghost" id="openModels" type="button">Open models folder</button><button class="primary" id="closeDevice" type="button">Close</button></div>
221
  </dialog>
222
 
223
+ <dialog id="modelsDlg" class="models-dlg">
224
+ <div class="mdl-head">
225
+ <div><h2>Models</h2><p class="muted small" id="mdlDevice"></p></div>
226
+ <button class="ghost" id="closeModels" type="button">Close</button>
227
+ </div>
228
+ <p class="muted small">Ora picks models to suit this computer. Models it cannot run here stay listed, locked, with the reason. Every model runs on your computer; nothing is uploaded.</p>
229
+ <h3 class="mdl-sec">Video</h3>
230
+ <div class="mdl-grid" id="mdlVideo"></div>
231
+ <h3 class="mdl-sec">Image</h3>
232
+ <div class="mdl-grid" id="mdlImage"></div>
233
+ <p class="muted small mdl-foot">Longest open model today: 15 seconds in one clip (MiniMax-H3). For longer videos, make up to 5 shots in a project and join them in your video editor.</p>
234
+ </dialog>
235
+
236
+ <dialog id="onlineDlg" class="models-dlg">
237
+ <div class="mdl-head">
238
+ <div><h2>Online GPU</h2><p class="muted small">Use a free graphics card from your own Kaggle or Google account. Ora sends your prompts there and brings the videos and images back to this computer.</p></div>
239
+ <button class="ghost" id="closeOnline" type="button">Close</button>
240
+ </div>
241
+ <div class="mdl-grid online-grid">
242
+ <div class="mdl" id="kaggleCard">
243
+ <div class="mdl-top"><span class="mdl-title">Kaggle</span><span class="mdl-tag">Automatic</span></div>
244
+ <div class="mdl-made">Free NVIDIA T4 or P100 (16 GB), about 30 hours a week</div>
245
+ <ol class="steps-list">
246
+ <li>Make a free account at kaggle.com and verify your phone number (Kaggle needs it for GPU and internet).</li>
247
+ <li>Kaggle › Settings › API › <b>Create New Token</b>. This downloads <code>kaggle.json</code>.</li>
248
+ <li>Choose that file here. Ora starts the GPU for you each time.</li>
249
+ </ol>
250
+ <div class="mdl-status" id="kaggleStatus"></div>
251
+ <div class="row-btns"><button class="ghost" id="kaggleOpen" type="button">Open Kaggle settings</button><button class="primary" id="kaggleConnect" type="button">Choose kaggle.json…</button><button class="link" id="kaggleRemove" type="button" hidden>Disconnect</button></div>
252
+ <p class="muted small">Each run starts a fresh machine: allow 2–5 minutes before the first frame. A whole project runs in one go.</p>
253
+ <div class="quota-row"><label for="kaggleQuota">GPU hours left on Kaggle now <small class="muted">(Kaggle › Settings › Quota)</small></label><input id="kaggleQuota" inputmode="decimal" placeholder="e.g. 30"><button class="ghost" id="kaggleQuotaSave" type="button">Save</button></div>
254
+ <p class="muted small" id="kaggleUsage"></p>
255
+ </div>
256
+ <div class="mdl" id="colabCard">
257
+ <div class="mdl-top"><span class="mdl-title">Google Colab</span><span class="mdl-tag">Live progress</span></div>
258
+ <div class="mdl-made">Free NVIDIA T4 (16 GB) when available, sessions up to about 12 hours</div>
259
+ <ol class="steps-list">
260
+ <li>Open a new Colab notebook, then Runtime › Change runtime type › <b>T4 GPU</b>.</li>
261
+ <li>Paste this line into a cell and press Run:</li>
262
+ </ol>
263
+ <div class="cmd-line"><code id="colabLine"></code><button class="ghost" id="colabCopy" type="button">Copy</button></div>
264
+ <ol class="steps-list" start="3"><li>Copy the connection code it prints (starts with <code>ora1.</code>) and paste it here.</li></ol>
265
+ <div class="paste-row"><input id="colabCode" placeholder="ora1.…" autocomplete="off" spellcheck="false"><button class="primary" id="colabConnect" type="button">Connect</button></div>
266
+ <div class="mdl-status" id="colabStatus"></div>
267
+ <div class="row-btns"><button class="ghost" id="colabOpen" type="button">Open Colab</button><button class="link" id="colabRemove" type="button" hidden>Disconnect</button></div>
268
+ <p class="muted small" id="colabUsage"></p>
269
+ </div>
270
+ </div>
271
+ <p class="muted small mdl-foot">Your Kaggle token and Colab code are stored encrypted on this computer and sent only to Kaggle or your own notebook. Ora never sees your passwords. Kaggle and Colab are meant for data science and AI work; check their terms of use. Free GPU time is limited by each platform.</p>
272
+ </dialog>
273
+
274
  <dialog id="clearDlg">
275
  <h2>Clear history</h2>
276
  <p>This removes Ora's list of past videos and the prompts saved with them.</p>
app/renderer/styles.css CHANGED
@@ -65,7 +65,8 @@ h2 { font-size: 17px; margin: 0; }
65
  .link:hover { color: var(--text); }
66
  button:focus-visible, textarea:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
67
 
68
- main { flex: 1; overflow: auto; }
 
69
  .panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
70
 
71
  /* setup */
@@ -84,8 +85,10 @@ main { flex: 1; overflow: auto; }
84
  .progress div { height: 100%; width: 0; background: var(--grad); transition: width .3s; }
85
 
86
  /* studio */
87
- .studio { display: grid; grid-template-columns: minmax(340px, 410px) 1fr; gap: 20px; padding: 20px 22px 30px; align-items: start; }
88
- #form { padding: 20px; display: flex; flex-direction: column; gap: 15px; position: sticky; top: 0; }
 
 
89
  .form-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: -2px; }
90
  .form-head h2 { font-size: 19px; }
91
  .field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
@@ -120,7 +123,7 @@ textarea:focus, input:focus, select:focus { border-color: var(--line-2); backgro
120
  .error { margin: 0; color: var(--err); font-size: 13px; white-space: pre-wrap; }
121
 
122
  .right { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
123
- .stage { min-height: 400px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
124
  .stage-empty { text-align: center; padding: 44px; }
125
  .stage-empty p:first-of-type { font: 600 17px var(--head); margin: 16px 0 6px; }
126
  .stage-run { display: flex; flex-direction: column; gap: 20px; padding: 28px; width: 100%; max-width: 900px; }
@@ -150,7 +153,8 @@ textarea:focus, input:focus, select:focus { border-color: var(--line-2); backgro
150
  .video-bar { display: flex; align-items: center; gap: 8px; padding: 12px 14px; flex-wrap: wrap; }
151
 
152
  .history-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; }
153
- .history-head h2 { font-size: 19px; }
 
154
  .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
155
  .card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; cursor: pointer; text-align: left; padding: 0; display: flex; flex-direction: column; box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s; }
156
  .card:hover { transform: translateY(-2px); box-shadow: 0 18px 36px -22px rgba(60, 30, 80, .45); }
@@ -191,3 +195,98 @@ dd { margin: 0; }
191
  .add-shot { align-self: flex-start; font-size: 13px; }
192
  .run-queue { color: var(--accent-2); font-weight: 700; letter-spacing: .02em; margin-bottom: 2px; }
193
  .project-done { width: 100%; margin: 0; color: var(--ok); font-weight: 600; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  .link:hover { color: var(--text); }
66
  button:focus-visible, textarea:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
67
 
68
+ main { flex: 1; overflow: auto; min-height: 0; }
69
+ main:has(> .studio:not([hidden])) { overflow: hidden; }
70
  .panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
71
 
72
  /* setup */
 
85
  .progress div { height: 100%; width: 0; background: var(--grad); transition: width .3s; }
86
 
87
  /* studio */
88
+ .studio { display: grid; grid-template-columns: minmax(340px, 410px) 1fr; gap: 20px; padding: 20px 22px 0; align-items: stretch; height: 100%; min-height: 0; }
89
+ /* the form and the right side scroll on their own, so neither leaves the other with an empty band */
90
+ #form { padding: 20px; display: flex; flex-direction: column; gap: 15px; overflow-y: auto; max-height: 100%; margin-bottom: 20px; overscroll-behavior: contain; }
91
+ .right { overflow-y: auto; padding-bottom: 20px; min-height: 0; }
92
  .form-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: -2px; }
93
  .form-head h2 { font-size: 19px; }
94
  .field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
 
123
  .error { margin: 0; color: var(--err); font-size: 13px; white-space: pre-wrap; }
124
 
125
  .right { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
126
+ .stage { min-height: 340px; display: flex; align-items: center; justify-content: center; overflow: hidden; flex: none; }
127
  .stage-empty { text-align: center; padding: 44px; }
128
  .stage-empty p:first-of-type { font: 600 17px var(--head); margin: 16px 0 6px; }
129
  .stage-run { display: flex; flex-direction: column; gap: 20px; padding: 28px; width: 100%; max-width: 900px; }
 
153
  .video-bar { display: flex; align-items: center; gap: 8px; padding: 12px 14px; flex-wrap: wrap; }
154
 
155
  .history-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; }
156
+ .history-head h2 { font-size: 19px; white-space: nowrap; }
157
+ .save-dir { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
158
  .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
159
  .card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; cursor: pointer; text-align: left; padding: 0; display: flex; flex-direction: column; box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s; }
160
  .card:hover { transform: translateY(-2px); box-shadow: 0 18px 36px -22px rgba(60, 30, 80, .45); }
 
195
  .add-shot { align-self: flex-start; font-size: 13px; }
196
  .run-queue { color: var(--accent-2); font-weight: 700; letter-spacing: .02em; margin-bottom: 2px; }
197
  .project-done { width: 100%; margin: 0; color: var(--ok); font-weight: 600; }
198
+
199
+ /* video / image mode */
200
+ .mode-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--panel-2); padding: 5px; border-radius: 14px; }
201
+ .mode-tabs button { border: 0; background: transparent; border-radius: 10px; padding: 10px; font: 600 14px var(--head); color: var(--muted); cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; }
202
+ .mode-tabs button[aria-selected="true"] { background: #fff; color: var(--text); box-shadow: 0 3px 12px -5px rgba(60, 30, 80, .35); }
203
+ .mode-tabs .mi { font-size: 11px; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
204
+ .image-only { display: flex; flex-direction: column; gap: 15px; }
205
+ .start-image { display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; align-items: center; background: linear-gradient(115deg, rgba(245,165,36,.12), rgba(139,92,246,.12)); border-radius: 14px; padding: 10px; }
206
+ .start-image img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; display: block; }
207
+ .start-image div { display: flex; flex-direction: column; gap: 2px; font-size: 13.5px; }
208
+ .img-dl { display: flex; flex-direction: column; gap: 8px; background: var(--panel-2); border-radius: 14px; padding: 14px; }
209
+ .img-dl .primary { align-self: flex-start; }
210
+ .stage-images { width: 100%; display: flex; flex-direction: column; }
211
+ .img-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; padding: 14px; }
212
+ .img-tile { position: relative; border-radius: 12px; overflow: hidden; background: #120d1c; }
213
+ .img-tile img { width: 100%; display: block; }
214
+ .img-tile .tile-bar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; gap: 6px; padding: 10px; background: linear-gradient(transparent, rgba(18, 13, 28, .75)); opacity: 0; transition: opacity .15s; }
215
+ .img-tile:hover .tile-bar, .img-tile:focus-within .tile-bar { opacity: 1; }
216
+ .img-tile .tile-bar button { font-size: 12px; padding: 6px 10px; }
217
+ .card .kind { position: absolute; top: 8px; left: 8px; font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; background: rgba(255,255,255,.9); color: var(--text); padding: 2px 8px; border-radius: 999px; }
218
+ .card { position: relative; }
219
+
220
+ /* ideas while the history is empty */
221
+ .ideas { display: flex; flex-direction: column; gap: 12px; }
222
+ .ideas > p { margin: 0; }
223
+ .idea-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
224
+ .idea { text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; cursor: pointer; display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s, border-color .15s; font: inherit; color: inherit; }
225
+ .idea:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent-2) 40%, var(--line)); box-shadow: 0 18px 36px -22px rgba(60, 30, 80, .45); }
226
+ .idea b { font: 600 15px var(--head); }
227
+ .idea-tag { align-self: flex-start; font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--accent-2); background: rgba(255, 94, 98, .1); padding: 2px 8px; border-radius: 999px; }
228
+ .idea-text { font-size: 12.5px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
229
+ @media (max-width: 980px) {
230
+ .studio { height: auto; padding-bottom: 20px; }
231
+ #form, .right { overflow: visible; max-height: none; }
232
+ main:has(> .studio:not([hidden])) { overflow: auto; }
233
+ }
234
+
235
+ /* models catalog */
236
+ .more-models { align-self: flex-start; margin-top: 2px; }
237
+ .models-dlg { max-width: 980px; width: calc(100% - 48px); max-height: calc(100vh - 60px); overflow-y: auto; }
238
+ .mdl-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
239
+ .mdl-head p { margin: 4px 0 0; }
240
+ .mdl-sec { margin: 20px 0 10px; font-size: 15px; }
241
+ .mdl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
242
+ .mdl { border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; background: #fff; }
243
+ .mdl.installed { border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); }
244
+ .mdl.locked { background: var(--panel-2); }
245
+ .mdl.locked .mdl-title, .mdl.locked .mdl-text { opacity: .7; }
246
+ .mdl-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
247
+ .mdl-title { font: 600 15px var(--head); }
248
+ .mdl-tag { font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--accent-2); background: rgba(255, 94, 98, .1); padding: 2px 8px; border-radius: 999px; }
249
+ .mdl-made { font-size: 13px; font-weight: 600; }
250
+ .mdl-text { font-size: 12.5px; color: var(--muted); }
251
+ .mdl-meta { font-size: 11.5px; color: var(--muted); }
252
+ .mdl-status { font-size: 12.5px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
253
+ .mdl-status .ok { color: var(--ok); font-weight: 600; }
254
+ .mdl-status .lock { color: var(--warn); }
255
+ .mdl-status .warn { color: var(--warn); font-size: 12px; }
256
+ .mdl .progress { height: 5px; }
257
+ .mdl button { font-size: 12.5px; padding: 6px 12px; }
258
+
259
+ /* online GPU */
260
+ .online-grid { grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); margin-top: 12px; }
261
+ .steps-list { margin: 4px 0 0; padding-left: 20px; font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
262
+ .steps-list b { color: var(--text); }
263
+ .steps-list code, .cmd-line code { font-size: 12px; }
264
+ .cmd-line { display: flex; gap: 6px; align-items: center; background: #1c1530; color: #f1f1f6; border-radius: 10px; padding: 6px 6px 6px 12px; }
265
+ .cmd-line code { flex: 1; overflow-x: auto; white-space: nowrap; }
266
+ .cmd-line .ghost { background: #fff; padding: 4px 10px; font-size: 12px; }
267
+ .paste-row { display: flex; gap: 8px; }
268
+ .paste-row input { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
269
+ .row-btns { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
270
+ .remote-note { color: var(--accent-2); font-weight: 600; }
271
+
272
+ .quota-row { display: grid; grid-template-columns: 1fr 90px auto; gap: 8px; align-items: center; font-size: 12.5px; margin-top: 6px; }
273
+ .quota-row input { padding: 6px 10px; }
274
+
275
+ .mdl-online { font-size: 12px; color: var(--ok); font-weight: 600; border-top: 1px dashed var(--line); padding-top: 6px; margin-top: 2px; }
276
+
277
+ /* calmer colours: solid ink buttons, neutral chips; the gradient stays in the logo and the progress bars */
278
+ .primary { background: #1c1530; color: #fff; box-shadow: 0 8px 18px -12px rgba(28, 21, 48, .55); }
279
+ .primary:hover { background: #2e2447; filter: none; }
280
+ .stop { background: #fff; color: #c62f35; border: 1.5px solid #c62f35; }
281
+ .stop:hover { background: #fff5f5; }
282
+ .styles button[aria-pressed="true"] { background: #1c1530; color: #fff; border-color: #1c1530; }
283
+ .seg-models button[aria-checked="true"] { box-shadow: 0 0 0 1.5px #1c1530, 0 4px 14px -8px rgba(28, 21, 48, .4); }
284
+ .mode-tabs .mi { background: none; -webkit-background-clip: initial; background-clip: initial; color: var(--muted); }
285
+ .mode-tabs button[aria-selected="true"] .mi { color: var(--text); }
286
+ .idea-tag, .mdl-tag, .card .kind { background: rgba(28, 21, 48, .07); color: #3b3352; }
287
+ .run-queue { color: var(--muted); }
288
+ .shot.state-running .num { background: #1c1530; color: #fff; }
289
+ .start-image { background: #f4eee7; }
290
+ .ring { background: conic-gradient(#1c1530 calc(var(--p) * 1%), var(--panel-2) 0); }
291
+ .phase.active .dot { border-color: #1c1530; background: rgba(28, 21, 48, .25); }
292
+ body { background-image: none; }
app/test/core.test.cjs CHANGED
@@ -105,3 +105,63 @@ assert.equal(core.cleanGpuName('ANGLE (Intel, ANGLE Metal Renderer: Intel(R) Iri
105
  assert.equal(core.cleanGpuName('ANGLE (NVIDIA, NVIDIA GeForce RTX 4070 (0x00002786) Direct3D11 vs_5_0 ps_5_0, D3D11)'), 'NVIDIA GeForce RTX 4070');
106
  assert.equal(core.cleanGpuName('Apple M2'), 'Apple M2');
107
  console.log('gpu name tests passed');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  assert.equal(core.cleanGpuName('ANGLE (NVIDIA, NVIDIA GeForce RTX 4070 (0x00002786) Direct3D11 vs_5_0 ps_5_0, D3D11)'), 'NVIDIA GeForce RTX 4070');
106
  assert.equal(core.cleanGpuName('Apple M2'), 'Apple M2');
107
  console.log('gpu name tests passed');
108
+
109
+ // images
110
+ const ij = { prompt: 'a red sneaker on white', shape: 'insta', size: 'small', count: 2, seed: 5 };
111
+ assert.deepEqual(core.validateImageJob(ij, manifest), []);
112
+ assert.ok(core.validateImageJob({ ...ij, count: 5 }, manifest).length);
113
+ assert.ok(core.validateImageJob({ ...ij, shape: 'wide' }, manifest).length);
114
+ const ia = core.buildImageArgs(manifest, ij, { diffusion: 'z.gguf', vae: 'ae.st', llm: 'q.gguf', outPattern: 'o/img_%02d.png' }, { gpu: false, args: [] });
115
+ const iat = f => ia.args[ia.args.indexOf(f) + 1];
116
+ assert.equal(ia.width, 512); assert.equal(ia.height, 640); assert.equal(iat('-b'), '2'); assert.equal(iat('--llm'), 'q.gguf'); assert.equal(iat('--steps'), '8');
117
+ for (const sh of Object.values(manifest.image.sizes)) for (const [w, h] of Object.values(sh)) { assert.equal(w % 16, 0); assert.equal(h % 16, 0); }
118
+ assert.equal(core.phaseChange('[I] generate_image 512x640 --- image.cpp:822'), 'frames');
119
+ // image-to-video
120
+ const iv = { prompt: 'slow push-in', model: 'quality', shape: 'landscape', seconds: 2, quality: 'draft', seed: 3, initImage: { id: 'x', file: 'img_00.png' } };
121
+ assert.deepEqual(core.validateJob(iv, manifest), []);
122
+ assert.ok(core.validateJob({ ...iv, model: 'fast' }, manifest).length);
123
+ assert.ok(core.validateJob({ ...iv, initImage: { id: 'x', file: '../../etc/passwd' } }, manifest).length);
124
+ const iva = core.buildArgs(manifest, iv, { ...paths, init: '/tmp/a.png' }, { gpu: true, args: [] }).args;
125
+ assert.equal(iva[iva.indexOf('-i') + 1], '/tmp/a.png');
126
+ console.log('image tests passed');
127
+
128
+ // catalog: Pro (Wan2.2 A14B, two experts)
129
+ const pr = core.buildArgs(manifest, { ...job, model: 'pro', quality: 'standard' }, { diffusion: 'lo.gguf', high: 'hi.gguf', vae: 'v', t5: 't', outPattern: 'o' }, { gpu: true, args: [] });
130
+ const pat = f => pr.args[pr.args.indexOf(f) + 1];
131
+ assert.equal(pat('--diffusion-model'), 'lo.gguf'); assert.equal(pat('--high-noise-diffusion-model'), 'hi.gguf'); assert.equal(pat('--high-noise-steps'), '8'); assert.equal(pat('--steps'), '10');
132
+ // image families
133
+ const fl = core.buildImageArgs(manifest, { ...ij, imageModel: 'flux1s' }, { diffusion: 'f', vae: 'ae', clip_l: 'c', t5: 't5', outPattern: 'o' }, { args: [] }).args;
134
+ assert.equal(fl[fl.indexOf('--clip_l') + 1], 'c'); assert.equal(fl.indexOf('--llm'), -1); assert.equal(fl[fl.indexOf('--steps') + 1], '4');
135
+ const qw = core.buildImageArgs(manifest, { ...ij, imageModel: 'qwenimg' }, { diffusion: 'q', vae: 'qv', llm: 'vl', outPattern: 'o' }, { args: [] }).args;
136
+ assert.equal(qw[qw.indexOf('--llm') + 1], 'vl'); assert.equal(qw[qw.indexOf('--flow-shift') + 1], '3');
137
+ assert.ok(core.validateImageJob({ ...ij, imageModel: 'nope' }, manifest).length);
138
+ // requirements
139
+ const cat = id => manifest.catalog.find(c => c.id === id);
140
+ const intelMac = { platform: 'darwin', arch: 'x64', ram: 32 * 2 ** 30, freeDisk: 30e9, engine: core.pickEngine('darwin', 'x64', []), gpus: [{ vendor: 'Intel', name: 'Iris Plus' }], vram: null };
141
+ assert.equal(core.checkRequirements(cat('zimage'), intelMac).ok, true);
142
+ const lock = core.checkRequirements(cat('pro'), intelMac);
143
+ assert.equal(lock.ok, false); assert.match(lock.reason, /graphics card with 16 GB/);
144
+ const m1 = { platform: 'darwin', arch: 'arm64', ram: 16 * 2 ** 30, freeDisk: 100e9, engine: core.pickEngine('darwin', 'arm64', []), gpus: [], vram: null };
145
+ assert.equal(core.checkRequirements(cat('flux1s'), m1).ok, true);
146
+ assert.match(core.checkRequirements(cat('qwenimg'), m1).reason, /32 GB/);
147
+ const pc = { platform: 'win32', arch: 'x64', ram: 64 * 2 ** 30, freeDisk: 100e9, engine: core.pickEngine('win32', 'x64', [{ vendor: 'NVIDIA' }]), gpus: [{ vendor: 'NVIDIA', name: 'GeForce RTX 4060' }], vram: 8 };
148
+ assert.equal(core.checkRequirements(cat('flux1s'), pc).ok, true);
149
+ assert.match(core.checkRequirements(cat('pro'), pc).reason, /16 GB of graphics memory; your GeForce RTX 4060 has 8 GB/);
150
+ assert.ok(core.checkRequirements(cat('pro'), { ...pc, vram: null }).warn);
151
+ assert.match(core.checkRequirements(cat('pro'), { ...pc, vram: 24, freeDisk: 5e9 }, 19.3e9).reason, /free disk/);
152
+ console.log('catalog tests passed');
153
+
154
+ // big models: frame rules, encoders, sound output
155
+ assert.equal(core.frameCount(24, 5, 'ltx'), 121); assert.equal(core.frameCount(24, 10, 'ltx'), 241);
156
+ assert.equal(core.frameCount(24, 15, 'h3'), 362); assert.equal(core.frameCount(24, 5, 'h3'), 124);
157
+ const lp = { diffusion: 'l.gguf', vae: 'vv', audioVae: 'av', llm: 'g.gguf', connectors: 'c.st', outPattern: 'o/frame_%03d.png', outVideo: 'o/video.webm' };
158
+ const la = core.buildArgs(manifest, { prompt: 'rain on a window', model: 'ltx23', shape: 'landscape', seconds: 10, quality: 'standard', seed: 1 }, lp, { gpu: true, args: [] }).args;
159
+ const lat = f => la[la.indexOf(f) + 1];
160
+ assert.equal(lat('--llm'), 'g.gguf'); assert.equal(lat('--embeddings-connectors'), 'c.st'); assert.equal(lat('--audio-vae'), 'av'); assert.equal(lat('-o'), 'o/video.webm');
161
+ assert.equal(la.indexOf('--t5xxl'), -1); assert.equal(lat('--video-frames'), '241'); assert.equal(lat('-W'), '1280');
162
+ const ha = core.buildArgs(manifest, { prompt: 'a long take', model: 'h3', shape: 'landscape', seconds: 15, quality: 'standard', seed: 1 }, lp, { gpu: true, args: [] }).args;
163
+ assert.equal(ha[ha.indexOf('--video-frames') + 1], '362'); assert.equal(ha.indexOf('-n'), -1); assert.equal(ha[ha.indexOf('--flow-shift') + 1], '12');
164
+ assert.deepEqual(core.validateJob({ prompt: 'a long take', model: 'h3', shape: 'landscape', seconds: 15, quality: 'standard', seed: 1 }, manifest), []);
165
+ assert.ok(core.validateJob({ prompt: 'x long', model: 'fast', shape: 'landscape', seconds: 15, quality: 'standard', seed: 1 }, manifest).length);
166
+ for (const m of Object.values(manifest.models)) for (const t of [m.sizes, m.lowSizes || {}]) for (const [w, h] of Object.values(t)) assert.equal(w % 16 + h % 16, 0);
167
+ console.log('big model tests passed');
app/test/fake-engine.cjs CHANGED
@@ -29,6 +29,9 @@ const sleep = ms => new Promise(r => setTimeout(r, ms));
29
  if (process.env.ORA_FAKE_FAIL) { process.stderr.write('fake failure\n'); process.exit(3); }
30
  const src = process.env.ORA_FAKE_FRAMES;
31
  const files = fs.readdirSync(src).filter(f => f.endsWith('.png')).sort();
32
- files.forEach((f, i) => fs.copyFileSync(path.join(src, f), out.replace('%03d', String(i).padStart(3, '0'))));
 
 
 
33
  process.stdout.write(`[I] save result video to '${out}'\n`);
34
  })();
 
29
  if (process.env.ORA_FAKE_FAIL) { process.stderr.write('fake failure\n'); process.exit(3); }
30
  const src = process.env.ORA_FAKE_FRAMES;
31
  const files = fs.readdirSync(src).filter(f => f.endsWith('.png')).sort();
32
+ // image runs ask for one file per image (-b N, img_%02d.png); video runs get every frame (frame_%03d.png)
33
+ const count = args.includes('-b') ? Number(args[args.indexOf('-b') + 1]) : null;
34
+ const pick = count ? files.slice(0, count) : files;
35
+ pick.forEach((f, i) => fs.copyFileSync(path.join(src, f), out.replace(/%0(\d)d/, (_m, w) => String(i).padStart(Number(w), '0'))));
36
  process.stdout.write(`[I] save result video to '${out}'\n`);
37
  })();
index.html CHANGED
@@ -24,6 +24,8 @@
24
  <nav>
25
  <a href="#uses">Use cases</a>
26
  <a href="#shots">Shots</a>
 
 
27
  <a href="#models">Models</a>
28
  <a href="#needs">Your computer</a>
29
  <a href="#faq">FAQ</a>
@@ -35,9 +37,9 @@
35
  <!-- hero -->
36
  <section class="hero">
37
  <div class="hero-copy">
38
- <a class="pill" href="#models"><span class="dot"></span>Open models · Wan2.1 1.3B and Wan2.2 5B</a>
39
  <h1>Turn words into <span class="grad">scroll-stopping</span> video.</h1>
40
- <p class="sub">Write up to five shots. Ora turns each one into a video clip for your ad, reel or product film, right on your own computer. No account, no upload, no monthly fee.</p>
41
  <div class="hero-install" id="heroInstall">
42
  <div class="device"><span class="dev-ico" id="devIco" aria-hidden="true"></span><span><span class="dev-label">Your computer</span> <b id="devName">macOS</b></span></div>
43
  <p class="hero-where" id="heroWhere">Open <b>Terminal</b>, paste this line and press Return:</p>
@@ -80,11 +82,11 @@
80
 
81
  <!-- stats -->
82
  <section class="stats" aria-label="Ora in numbers">
83
- <div><b>720p</b><span>with the Quality model</span></div>
84
- <div><b>2–5 s</b><span>per shot</span></div>
 
85
  <div><b>1–5</b><span>shots per project</span></div>
86
- <div><b>9:16</b><span>for reels and stories</span></div>
87
- <div><b>$0</b><span>no credits, no plan</span></div>
88
  </section>
89
 
90
  <!-- use cases -->
@@ -145,31 +147,109 @@
145
  </div>
146
  </section>
147
 
 
 
 
 
 
 
 
 
 
 
 
148
  <!-- models -->
149
  <section class="section" id="models">
150
  <p class="kicker">Models</p>
151
- <h2>Choose the right model for each job</h2>
152
- <div class="plans">
 
 
153
  <article class="plan">
154
- <span class="tag t-prev">Preview</span>
155
- <h3>Check an idea</h3>
156
- <p class="spec">1.3B · 1 s · 512×288</p>
157
- <ul><li>Fastest way to test a prompt</li><li>Fine on a phone screen</li><li>Fast decoder for a quick result</li></ul>
158
- </article>
159
- <article class="plan plan-hl">
160
- <span class="tag t-fast">Fast</span>
161
  <h3>Wan2.1 T2V 1.3B</h3>
162
- <p class="spec">480p · 16 fps · 2, 3 or 5 s</p>
163
- <ul><li>Drafts, social clips, B-roll</li><li>1.5 GB model</li><li>Apache-2.0, commercial use</li></ul>
 
164
  </article>
165
  <article class="plan">
166
  <span class="tag t-qual">Quality</span>
167
  <h3>Wan2.2 TI2V 5B</h3>
168
- <p class="spec">720p · 24 fps · 2, 3 or 5 s</p>
169
- <ul><li>Sharper detail, smoother motion</li><li>Best with a graphics card</li><li>Apache-2.0, commercial use</li></ul>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
170
  </article>
171
  </div>
172
- <p class="note">Runs on Apple graphics (Metal), NVIDIA and AMD graphics cards (Vulkan) or the processor alone, using <a href="https://github.com/leejet/stable-diffusion.cpp" rel="noopener">stable-diffusion.cpp</a>. You choose in the app.</p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
173
  </section>
174
 
175
  <!-- install -->
@@ -196,9 +276,9 @@
196
  <p class="kicker">Your computer</p>
197
  <h2>Faster with a graphics card</h2>
198
  <div class="needs">
199
- <div class="need n-good"><b>Mac with Apple Silicon</b><span>Apple graphics (Metal). Good speed; 16 GB of memory or more for Quality.</span></div>
200
- <div class="need n-best"><b>PC with NVIDIA or AMD graphics</b><span>Vulkan. The fastest option; 8 GB of graphics memory or more is best for Quality.</span></div>
201
- <div class="need n-slow"><b>Intel Mac or PC without graphics</b><span>Processor only. Works, but slowly: measured on a 4-core Intel i7, a 1 s Preview takes about 25 minutes. Use Preview first.</span></div>
202
  </div>
203
  <p class="note">All computers: about <b>16 GB of memory</b> and <b>15 GB of free disk</b>; 64-bit macOS 12+, Windows 10/11 or Linux (x86_64). Ora shows the time for your computer before you start.</p>
204
  </section>
@@ -208,10 +288,10 @@
208
  <p class="kicker">FAQ</p>
209
  <h2>Questions</h2>
210
  <div class="faq">
211
- <details><summary>Is anything uploaded?</summary><p>No. Prompts, frames and videos stay on your computer. Ora only connects to Hugging Face to download itself and the models.</p></details>
212
- <details><summary>Can I use the videos in commercial work?</summary><p>Yes. The Wan models and the umT5 prompt reader are Apache-2.0, which allows commercial use. You are responsible for what you make: do not create content that is unlawful or misleading, or that uses other people's likeness, brands or rights without permission.</p></details>
213
  <details><summary>Will it look like a TV commercial?</summary><p>Each shot is short (up to 5 seconds) and comes from open models of 1.3 and 5 billion parameters. They are great for social posts, concept films, mood films and B-roll. For a finished advert, cut several shots together in your editor and add titles, music and a voice-over.</p></details>
214
- <details><summary>Why only 5 seconds per shot?</summary><p>Both Wan models were trained on clips of about 5 seconds; longer runs repeat or fall apart. Longer videos are built from several shots, which is also how adverts are normally made.</p></details>
215
  <details><summary>Will the product look the same in every shot?</summary><p>Close, not identical. The shared scene and style keep the look alike, but a model working from text alone varies details such as a label or a face between shots.</p></details>
216
  <details><summary>Where are my videos and the models?</summary><p>Videos: <b>Movies/Ora</b> (Mac) or <b>Videos/Ora</b> (Windows, Linux), one folder per project. Models: Mac <code>~/Library/Application Support/Ora</code>, Windows <code>%APPDATA%\Ora</code>, Linux <code>~/.config/Ora</code>.</p></details>
217
  <details><summary>How do I uninstall?</summary><p>macOS and Linux: <code>curl -fsSL https://devseis-ora.static.hf.space/install.sh | bash -s -- --uninstall --purge</code> (leave out <code>--purge</code> to keep the 12 GB of models). Windows: Settings › Apps › Installed apps › Ora › Uninstall, then delete <code>%APPDATA%\Ora</code>.</p></details>
 
24
  <nav>
25
  <a href="#uses">Use cases</a>
26
  <a href="#shots">Shots</a>
27
+ <a href="#images">Images</a>
28
+ <a href="#online">Online GPU</a>
29
  <a href="#models">Models</a>
30
  <a href="#needs">Your computer</a>
31
  <a href="#faq">FAQ</a>
 
37
  <!-- hero -->
38
  <section class="hero">
39
  <div class="hero-copy">
40
+ <a class="pill" href="#models"><span class="dot"></span>New: video with sound, up to 15 s · images · free online GPU</a>
41
  <h1>Turn words into <span class="grad">scroll-stopping</span> video.</h1>
42
+ <p class="sub">Write up to five shots and Ora turns each one into a video clip, or make product images and bring them to life. All on your own computer: no account, no upload, no monthly fee.</p>
43
  <div class="hero-install" id="heroInstall">
44
  <div class="device"><span class="dev-ico" id="devIco" aria-hidden="true"></span><span><span class="dev-label">Your computer</span> <b id="devName">macOS</b></span></div>
45
  <p class="hero-where" id="heroWhere">Open <b>Terminal</b>, paste this line and press Return:</p>
 
82
 
83
  <!-- stats -->
84
  <section class="stats" aria-label="Ora in numbers">
85
+ <div><b>8</b><span>open models, video and image</span></div>
86
+ <div><b>15 s</b><span>longest clip, with sound</span></div>
87
+ <div><b>720p</b><span>video · images up to 1280×720</span></div>
88
  <div><b>1–5</b><span>shots per project</span></div>
89
+ <div><b>$0</b><span>on your computer or a free online GPU</span></div>
 
90
  </section>
91
 
92
  <!-- use cases -->
 
147
  </div>
148
  </section>
149
 
150
+ <!-- image to video -->
151
+ <section class="section" id="images">
152
+ <p class="kicker">Images</p>
153
+ <h2>Make an image, then animate it</h2>
154
+ <div class="i2v">
155
+ <div class="i2v-step"><span class="big-n">1</span><h3>Make product images</h3><p>Switch Ora to <b>Image</b>, describe your product and pick a shape: 1:1, 16:9, 9:16 or 4:5 for Instagram. Make up to four at once with <b>Z-Image-Turbo</b>. PNGs are saved to Pictures/Ora.</p></div>
156
+ <div class="i2v-arrow" aria-hidden="true">→</div>
157
+ <div class="i2v-step"><span class="big-n">2</span><h3>Animate the one you like</h3><p>Press <b>Animate this image</b>. The Quality model (Wan2.2 5B) starts the video from that exact picture, so your product keeps its look in every shot.</p></div>
158
+ </div>
159
+ </section>
160
+
161
  <!-- models -->
162
  <section class="section" id="models">
163
  <p class="kicker">Models</p>
164
+ <h2>The best open models, picked for your computer</h2>
165
+ <p class="lead">Ora checks your computer and shows every model it can run. Models that need a bigger graphics card stay listed with the reason, and most of them also run on a free online GPU from your own Kaggle or Colab account.</p>
166
+ <h3 class="sub-h">Video</h3>
167
+ <div class="plans plans-5">
168
  <article class="plan">
169
+ <span class="tag t-fast">Fast · Preview</span>
 
 
 
 
 
 
170
  <h3>Wan2.1 T2V 1.3B</h3>
171
+ <p class="spec">480p · 2–5 s · 1 s Preview</p>
172
+ <ul><li>Drafts, social clips, B-roll</li><li>Any computer, even without a graphics card</li></ul>
173
+ <p class="runs">Included · online: Kaggle, Colab</p>
174
  </article>
175
  <article class="plan">
176
  <span class="tag t-qual">Quality</span>
177
  <h3>Wan2.2 TI2V 5B</h3>
178
+ <p class="spec">720p · 2–5 s · animates images</p>
179
+ <ul><li>Sharper detail, smoother motion</li><li>Starts from your own image</li></ul>
180
+ <p class="runs">Included · online: Kaggle, Colab</p>
181
+ </article>
182
+ <article class="plan">
183
+ <span class="tag t-pro">Pro</span>
184
+ <h3>Wan2.2 T2V A14B</h3>
185
+ <p class="spec">720p · 2–5 s · two 14B experts</p>
186
+ <ul><li>The strongest Wan model</li><li>19 GB download</li></ul>
187
+ <p class="runs">Graphics card 16 GB+ · online: Kaggle, Colab</p>
188
+ </article>
189
+ <article class="plan plan-hl">
190
+ <span class="tag t-snd">Sound · Beta</span>
191
+ <h3>LTX-2.3 22B</h3>
192
+ <p class="spec">720p · 2–10 s · <b>with sound</b></p>
193
+ <ul><li>Picture and matching audio together: rain, footsteps, music, voices</li><li>Only 8 steps (distilled)</li></ul>
194
+ <p class="runs">Graphics card 24 GB+ · online: Kaggle</p>
195
+ </article>
196
+ <article class="plan plan-hl">
197
+ <span class="tag t-long">Long · Beta</span>
198
+ <h3>MiniMax H3</h3>
199
+ <p class="spec">Up to <b>15 s</b> in one clip · stereo sound</p>
200
+ <ul><li>The longest open video model today</li><li>Pruned 33B model + 32B prompt reader</li></ul>
201
+ <p class="runs">Graphics card 24 GB+ / Mac 64 GB · online: Kaggle</p>
202
+ </article>
203
+ </div>
204
+ <h3 class="sub-h">Image</h3>
205
+ <div class="plans">
206
+ <article class="plan">
207
+ <span class="tag t-img">Default</span>
208
+ <h3>Z-Image-Turbo 6B</h3>
209
+ <p class="spec">Up to 1280×720 · 1–4 per prompt</p>
210
+ <ul><li>Photo-real product shots</li><li>About 9 minutes on a 4-core laptop CPU</li></ul>
211
+ <p class="runs">Any computer (6.7 GB) · online: Kaggle, Colab</p>
212
+ </article>
213
+ <article class="plan">
214
+ <span class="tag t-img">Sharp</span>
215
+ <h3>FLUX.1-schnell 12B</h3>
216
+ <p class="spec">4 steps · very sharp detail</p>
217
+ <ul><li>Crisp, detailed images in seconds on a GPU</li><li>10.5 GB download</li></ul>
218
+ <p class="runs">Graphics card 8 GB+ · online: Kaggle, Colab</p>
219
+ </article>
220
+ <article class="plan">
221
+ <span class="tag t-img">Best text</span>
222
+ <h3>Qwen-Image-2512 20B</h3>
223
+ <p class="spec">Readable words in images</p>
224
+ <ul><li>Posters, labels and signs, English and Chinese</li><li>18 GB download</li></ul>
225
+ <p class="runs">Graphics card 16 GB+ · online: Kaggle, Colab</p>
226
  </article>
227
  </div>
228
+ <p class="note">All of them can be used in commercial work: Wan, Z-Image, FLUX.1-schnell and Qwen-Image are Apache-2.0; LTX-2 is free under US$10M revenue a year; MiniMax H3 is free under US$20M a year, and Ora shows its name wherever it is used. Engine: <a href="https://github.com/leejet/stable-diffusion.cpp" rel="noopener">stable-diffusion.cpp</a>, on Apple graphics, NVIDIA and AMD cards, the processor, or an online NVIDIA GPU.</p>
229
+ </section>
230
+
231
+ <!-- online gpu -->
232
+ <section class="section" id="online">
233
+ <p class="kicker">No graphics card?</p>
234
+ <h2>Use a free online GPU from your own account</h2>
235
+ <p class="lead">Connect <b>Kaggle</b> or <b>Google Colab</b> in Ora and choose <b>Run on › Online</b>. Your prompts go to your own notebook, the video or image is made on its free NVIDIA GPU, and the files come back to your computer. Online runs also unlock bigger models such as Wan2.2 A14B and Qwen-Image.</p>
236
+ <div class="cards">
237
+ <div class="card">
238
+ <div class="tag">Kaggle · automatic</div>
239
+ <h3>About 30 free GPU hours a week</h3>
240
+ <p>Make a Kaggle account, verify your phone, create an API token (<code>kaggle.json</code>) and choose it in Ora. Ora starts the GPU for each project by itself; allow 2–5 minutes for it to start.</p>
241
+ </div>
242
+ <div class="card">
243
+ <div class="tag tag-q">Colab · live progress</div>
244
+ <h3>A free T4 when available</h3>
245
+ <p>Open a Colab notebook with a T4 GPU, paste the one line Ora shows into a cell and run it, then paste the connection code back into Ora. It stays connected until the session ends.</p>
246
+ </div>
247
+ </div>
248
+ <div class="quota-demo">
249
+ <b>Know what it costs before you start.</b>
250
+ <span>Ora shows the GPU time a job will use, for example <i>"About 22 min of Kaggle GPU time"</i>, how much Ora has used in the last 7 days, and, once you enter your Kaggle quota, about how much is left. It warns you before a job that would go over.</span>
251
+ </div>
252
+ <p class="note">Your Kaggle token and Colab code are stored encrypted on your computer and only sent to Kaggle or your own notebook. Free GPU time is set by each platform; check their terms of use. LTX-2.3 and MiniMax H3 need Kaggle (two GPUs); Colab's free tier has one.</p>
253
  </section>
254
 
255
  <!-- install -->
 
276
  <p class="kicker">Your computer</p>
277
  <h2>Faster with a graphics card</h2>
278
  <div class="needs">
279
+ <div class="need n-good"><b>Mac with Apple Silicon</b><span>Apple graphics (Metal). Good speed; 16 GB of memory for Quality, 32 GB for Pro and Qwen-Image, 64 GB for MiniMax H3.</span></div>
280
+ <div class="need n-best"><b>PC with NVIDIA or AMD graphics</b><span>Vulkan. The fastest option: 8 GB of graphics memory for Quality and FLUX, 16 GB for Pro and Qwen-Image, 24 GB for LTX-2.3 and MiniMax H3.</span></div>
281
+ <div class="need n-slow"><b>Intel Mac or PC without graphics</b><span>Processor only. Works, but slowly: measured on a 4-core Intel i7, a 1 s Preview takes about 25 minutes. Use Preview first, or Run on › Online.</span></div>
282
  </div>
283
  <p class="note">All computers: about <b>16 GB of memory</b> and <b>15 GB of free disk</b>; 64-bit macOS 12+, Windows 10/11 or Linux (x86_64). Ora shows the time for your computer before you start.</p>
284
  </section>
 
288
  <p class="kicker">FAQ</p>
289
  <h2>Questions</h2>
290
  <div class="faq">
291
+ <details><summary>Is anything uploaded?</summary><p>Not when you run on your computer: prompts, frames and videos stay there, and Ora only connects to Hugging Face to download itself and the models. If you choose Run on › Online, the prompt goes to your own Kaggle or Colab notebook and the result comes back.</p></details>
292
+ <details><summary>Can I use the videos in commercial work?</summary><p>Yes. Wan, Z-Image, FLUX.1-schnell, Qwen-Image and their prompt readers are Apache-2.0. LTX-2 is free for businesses under US$10M revenue a year and MiniMax H3 under US$20M; above that you need their permission. You are responsible for what you make: do not create content that is unlawful or misleading, or that uses other people's likeness, brands or rights without permission.</p></details>
293
  <details><summary>Will it look like a TV commercial?</summary><p>Each shot is short (up to 5 seconds) and comes from open models of 1.3 and 5 billion parameters. They are great for social posts, concept films, mood films and B-roll. For a finished advert, cut several shots together in your editor and add titles, music and a voice-over.</p></details>
294
+ <details><summary>How long can one clip be?</summary><p>Wan models make 2–5 seconds, LTX-2.3 up to 10 seconds and MiniMax H3 up to 15 seconds, both with sound. No open model makes a full minute in one go yet; longer videos are built from up to five shots in a project, which is also how adverts are normally made.</p></details>
295
  <details><summary>Will the product look the same in every shot?</summary><p>Close, not identical. The shared scene and style keep the look alike, but a model working from text alone varies details such as a label or a face between shots.</p></details>
296
  <details><summary>Where are my videos and the models?</summary><p>Videos: <b>Movies/Ora</b> (Mac) or <b>Videos/Ora</b> (Windows, Linux), one folder per project. Models: Mac <code>~/Library/Application Support/Ora</code>, Windows <code>%APPDATA%\Ora</code>, Linux <code>~/.config/Ora</code>.</p></details>
297
  <details><summary>How do I uninstall?</summary><p>macOS and Linux: <code>curl -fsSL https://devseis-ora.static.hf.space/install.sh | bash -s -- --uninstall --purge</code> (leave out <code>--purge</code> to keep the 12 GB of models). Windows: Settings › Apps › Installed apps › Ora › Uninstall, then delete <code>%APPDATA%\Ora</code>.</p></details>
site/site.css CHANGED
@@ -172,7 +172,8 @@ h3 { font-size: 19px; margin: 0 0 8px; }
172
  .how { margin: 18px 0 12px; font-size: 15px; }
173
  .cmd { display: flex; max-width: 720px; margin: 0 auto; background: var(--cmd); border: 1px solid var(--line-2); border-radius: 14px; overflow: hidden; text-align: left; }
174
  .cmd code { flex: 1; color: #f1f1f6; background: none; padding: 16px 18px; overflow-x: auto; white-space: nowrap; font-size: 14.5px; border-radius: 0; }
175
- .copy { border: 0; background: var(--grad); color: #170b04; font: 700 15px Inter, sans-serif; padding: 0 26px; cursor: pointer; }
 
176
  .fine { color: var(--muted); font-size: 13.5px; margin: 14px auto 0; max-width: 620px; }
177
 
178
  .needs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@@ -221,7 +222,7 @@ footer { max-width: 1180px; margin: 60px auto 0; padding: 26px 24px 40px; border
221
  .stats div { border-left: 0 !important; }
222
  .f1 { left: 12px; bottom: -24px; } .f2 { right: 12px; top: -24px; }
223
  .cmd { flex-direction: column; }
224
- .copy { padding: 13px; }
225
  .install { padding: 34px 18px; }
226
  .final { margin-left: 16px; margin-right: 16px; }
227
  }
@@ -260,3 +261,57 @@ footer { max-width: 1180px; margin: 60px auto 0; padding: 26px 24px 40px; border
260
  @media (max-width: 640px) { .cmd-hero { flex-direction: column; } }
261
 
262
  [hidden] { display: none !important; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
172
  .how { margin: 18px 0 12px; font-size: 15px; }
173
  .cmd { display: flex; max-width: 720px; margin: 0 auto; background: var(--cmd); border: 1px solid var(--line-2); border-radius: 14px; overflow: hidden; text-align: left; }
174
  .cmd code { flex: 1; color: #f1f1f6; background: none; padding: 16px 18px; overflow-x: auto; white-space: nowrap; font-size: 14.5px; border-radius: 0; }
175
+ .copy { border: 0; margin: 6px; border-radius: 9px; background: #fff; color: #1c1530; font: 600 14px Inter, sans-serif; padding: 0 20px; cursor: pointer; transition: background .15s; }
176
+ .copy:hover { background: #f1ece6; }
177
  .fine { color: var(--muted); font-size: 13.5px; margin: 14px auto 0; max-width: 620px; }
178
 
179
  .needs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
 
222
  .stats div { border-left: 0 !important; }
223
  .f1 { left: 12px; bottom: -24px; } .f2 { right: 12px; top: -24px; }
224
  .cmd { flex-direction: column; }
225
+ .copy { padding: 11px; }
226
  .install { padding: 34px 18px; }
227
  .final { margin-left: 16px; margin-right: 16px; }
228
  }
 
261
  @media (max-width: 640px) { .cmd-hero { flex-direction: column; } }
262
 
263
  [hidden] { display: none !important; }
264
+
265
+ /* images section */
266
+ .i2v { display: grid; grid-template-columns: 1fr auto 1fr; gap: 16px; align-items: stretch; }
267
+ .i2v-step { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 26px 24px; box-shadow: 0 10px 30px -20px rgba(60, 30, 80, .25); }
268
+ .i2v-step p { color: var(--muted); margin: 0; font-size: 15px; }
269
+ .i2v-step b { color: var(--text); }
270
+ .i2v-arrow { align-self: center; font: 700 30px var(--head); background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
271
+ .plans-4 { grid-template-columns: repeat(4, 1fr); }
272
+ .t-img { background: rgba(255, 94, 98, .14); color: var(--t-red); }
273
+ @media (max-width: 1020px) { .i2v { grid-template-columns: 1fr; } .i2v-arrow { transform: rotate(90deg); justify-self: center; } .plans-4 { grid-template-columns: 1fr 1fr; } }
274
+ @media (max-width: 640px) { .plans-4 { grid-template-columns: 1fr; } }
275
+
276
+ .sub-h { margin: 26px 0 12px; font-size: 17px; color: var(--muted); }
277
+ .plans-5 { grid-template-columns: repeat(5, 1fr); }
278
+ .plans-5 .plan { padding: 22px 18px; }
279
+ .plan .runs { margin: 14px 0 0; padding-top: 10px; border-top: 1px dashed var(--line); font-size: 12.5px; color: var(--muted); font-weight: 600; }
280
+ .t-pro { background: rgba(28, 21, 48, .1); color: var(--text); }
281
+ .t-snd { background: rgba(255, 94, 98, .16); color: var(--t-red); }
282
+ .t-long { background: rgba(139, 92, 246, .18); color: var(--t-violet); }
283
+ .quota-demo { margin-top: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; }
284
+ .quota-demo span { color: var(--muted); font-size: 15px; }
285
+ @media (max-width: 1180px) { .plans-5 { grid-template-columns: repeat(3, 1fr); } }
286
+ @media (max-width: 760px) { .plans-5 { grid-template-columns: 1fr; } }
287
+ /* two-up info cards (online GPU) */
288
+ .cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
289
+ .card { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 24px 26px; box-shadow: 0 10px 30px -20px rgba(60, 30, 80, .25); }
290
+ .card h3 { margin: 6px 0 8px; }
291
+ .card p { color: var(--muted); margin: 0; font-size: 15px; }
292
+ .card .tag { margin-bottom: 8px; background: rgba(245, 165, 36, .16); color: var(--t-amber); }
293
+ .card .tag.tag-q { background: rgba(139, 92, 246, .18); color: var(--t-violet); }
294
+ @media (max-width: 760px) { .cards { grid-template-columns: 1fr; } }
295
+
296
+ /* calmer colours: solid ink buttons, neutral tags; the gradient stays only in the logo and one headline word */
297
+ .btn { background: #1c1530; color: #fff; box-shadow: 0 8px 20px -12px rgba(28, 21, 48, .55); }
298
+ .btn:hover { background: #2e2447; box-shadow: 0 10px 24px -12px rgba(28, 21, 48, .6); }
299
+ .btn-ghost { background: #fff; color: var(--text); border: 1px solid var(--line-2); box-shadow: none; }
300
+ .btn-ghost:hover { background: #f4eee7; }
301
+ .copy { background: #fff; color: #1c1530; }
302
+ .kicker { background: none; -webkit-background-clip: initial; background-clip: initial; color: var(--muted); }
303
+ .big-n { background: none; -webkit-background-clip: initial; background-clip: initial; color: #1c1530; opacity: .9; }
304
+ .float b { background: none; -webkit-background-clip: initial; background-clip: initial; color: #1c1530; }
305
+ .i2v-arrow { background: none; -webkit-background-clip: initial; background-clip: initial; color: var(--muted); }
306
+ .tag, .t-prev, .t-fast, .t-qual, .t-img, .t-pro, .t-snd, .t-long, .card .tag, .card .tag.tag-q { background: rgba(28, 21, 48, .07); color: #3b3352; }
307
+ .plan-hl { background: #fff; border: 1px solid #1c1530; box-shadow: 0 20px 40px -28px rgba(28, 21, 48, .45); }
308
+ .board li::before { background: #1c1530; opacity: .85; }
309
+ .win-progress div { background: #1c1530; }
310
+ .need::after { background: rgba(28, 21, 48, .07) !important; color: #3b3352 !important; }
311
+ .ico { background: #f4eee7; }
312
+ .ico svg { stroke: #1c1530; }
313
+ .install { background: #fff; }
314
+ :root[data-theme="light"] .install { background: #fff; }
315
+ .final { background: #f4eee7; }
316
+ .glow { opacity: .1 !important; }
317
+ .tick { background: rgba(15, 138, 95, .14); }
tools/build-linux-cuda.sh ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Builds stable-diffusion.cpp's sd-cli for Linux + NVIDIA CUDA (no official build exists), for Ora's online GPU worker
3
+ # on Kaggle (P100 = sm_60, T4 = sm_75) and Colab (T4). Runs in Docker on any machine; no GPU is needed to compile.
4
+ # Output: .build/cuda/ora-engine-linux-cuda.tar.gz (sd-cli + the shared libraries it needs from this build)
5
+ set -euo pipefail
6
+ cd "$(dirname "$0")/.."
7
+ REV=95ff76230889898e1bf40058ba272a3699b50dc6 # same engine revision as the app (release master-1000-95ff762)
8
+ OUT="$PWD/.build/cuda"
9
+ mkdir -p "$OUT"
10
+ docker run --rm --platform linux/amd64 -v "$PWD/.build/sd:/src:ro" -v "$OUT:/out" nvidia/cuda:12.4.1-devel-ubuntu22.04 bash -euc "
11
+ export DEBIAN_FRONTEND=noninteractive
12
+ apt-get update -qq && apt-get install -y -qq git cmake g++ >/dev/null
13
+ cp -a /src /work && cd /work && rm -rf build-mac-x64 && git config --global --add safe.directory /work && test \$(git rev-parse HEAD) = $REV
14
+ cmake -B b -DCMAKE_BUILD_TYPE=Release -DSD_CUDA=ON -DGGML_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES='60;75' \
15
+ -DGGML_NATIVE=OFF -DBUILD_SHARED_LIBS=OFF -DCMAKE_CUDA_RUNTIME_LIBRARY=Static >/out/cmake.log 2>&1
16
+ cmake --build b --config Release -j\$(nproc) --target sd-cli >/out/build.log 2>&1
17
+ mkdir -p /pkg/ora-engine && cp b/bin/sd-cli /pkg/ora-engine/
18
+ ldd b/bin/sd-cli > /pkg/ora-engine/ldd.txt || true
19
+ echo 'stable-diffusion.cpp $REV (MIT), CUDA 12.4, sm_60 sm_75' > /pkg/ora-engine/SOURCE.txt
20
+ tar -C /pkg -czf /out/ora-engine-linux-cuda.tar.gz ora-engine
21
+ cat /pkg/ora-engine/ldd.txt
22
+ "
23
+ ls -la "$OUT"
worker/ora_worker.py ADDED
@@ -0,0 +1,357 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Ora GPU worker: runs Ora's video and image jobs on a free online GPU (Kaggle, Colab) for the person who owns it.
3
+
4
+ Kaggle (Ora starts this itself): python3 ora_worker.py --batch job.json --out /kaggle/working/out
5
+ Colab (paste in one cell): !curl -fsSL https://devseis-ora.static.hf.space/worker/ora_worker.py -o w.py && python3 w.py --serve
6
+
7
+ It downloads Ora's GPU engine (stable-diffusion.cpp built for CUDA) and the model files a job needs, at the pinned
8
+ revisions in Ora's models.json, runs the engine with the arguments Ora built, and returns MP4s (made with ffmpeg) or
9
+ PNGs. In --serve mode it starts a local HTTP server behind a temporary Cloudflare tunnel and prints a connection code;
10
+ only requests carrying that code's secret are accepted. Standard library only.
11
+ """
12
+ import argparse, base64, hashlib, json, os, re, secrets, shutil, subprocess, sys, tarfile, threading, time, urllib.request
13
+ from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
14
+
15
+ VERSION = '0.1.2'
16
+ SITE = 'https://devseis-ora.static.hf.space'
17
+ RELEASES = 'https://huggingface.co/datasets/Devseis/ora-releases/resolve/main'
18
+ ENGINE_FILE = 'ora-engine-linux-cuda.tar.gz'
19
+ HOME = os.path.expanduser(os.environ.get('ORA_HOME', '~/.ora'))
20
+ MODELS = os.path.join(HOME, 'models')
21
+ TOKEN = re.compile(r'\{(model|out|init):?([A-Za-z0-9_]*)\}')
22
+
23
+
24
+ def log(*a):
25
+ print('[ora]', *a, flush=True)
26
+
27
+
28
+ def fetch(url, dest, size=None):
29
+ """Download url to dest (resumes a .part file). Skips the download when dest already has the expected size."""
30
+ if os.path.exists(dest) and (size is None or os.path.getsize(dest) == size):
31
+ return dest
32
+ os.makedirs(os.path.dirname(dest), exist_ok=True)
33
+ part = dest + '.part'
34
+ have = os.path.getsize(part) if os.path.exists(part) else 0
35
+ req = urllib.request.Request(url, headers={'User-Agent': f'ora-worker/{VERSION}', **({'Range': f'bytes={have}-'} if have else {})})
36
+ with urllib.request.urlopen(req, timeout=60) as r, open(part, 'ab' if have and r.status == 206 else 'wb') as f:
37
+ if r.status != 206:
38
+ have = 0
39
+ while True:
40
+ chunk = r.read(8 << 20)
41
+ if not chunk:
42
+ break
43
+ f.write(chunk)
44
+ if size is not None and os.path.getsize(part) != size:
45
+ raise RuntimeError(f'{os.path.basename(dest)}: got {os.path.getsize(part)} bytes, expected {size}')
46
+ os.replace(part, dest)
47
+ return dest
48
+
49
+
50
+ def get_models(files):
51
+ """Download the model files for these keys in parallel (Kaggle and Colab have fast links to Hugging Face)."""
52
+ errors, threads = [], []
53
+
54
+ def one(k):
55
+ f = files[k]
56
+ url = f.get('url') or f"https://huggingface.co/{f['repo']}/resolve/{f['rev']}/{f['path']}"
57
+ try:
58
+ t = time.time()
59
+ fetch(url, os.path.join(MODELS, f['name']), f['size'])
60
+ log(f"model ready: {f['name']} ({f['size'] / 1e9:.1f} GB, {time.time() - t:.0f} s)")
61
+ except Exception as e:
62
+ errors.append(f"{f['name']}: {e}")
63
+
64
+ for k in sorted(files):
65
+ th = threading.Thread(target=one, args=(k,))
66
+ th.start(); threads.append(th)
67
+ for th in threads:
68
+ th.join()
69
+ if errors:
70
+ raise RuntimeError('; '.join(errors))
71
+
72
+
73
+ def get_engine(engine_arg):
74
+ if engine_arg:
75
+ return engine_arg
76
+ exe = os.path.join(HOME, 'engine', 'ora-engine', 'sd-cli')
77
+ if not os.path.exists(exe):
78
+ tgz = fetch(f'{RELEASES}/{ENGINE_FILE}', os.path.join(HOME, ENGINE_FILE))
79
+ with tarfile.open(tgz) as t:
80
+ t.extractall(os.path.join(HOME, 'engine'))
81
+ os.chmod(exe, 0o755)
82
+ return exe
83
+
84
+
85
+ # NVIDIA libraries the CUDA engine links to: cuBLAS and the CUDA runtime (in /usr/local/cuda on Kaggle and Colab)
86
+ # and NCCL. Look in the system CUDA folders and in the nvidia-* pip packages that come with PyTorch; pip-install
87
+ # whatever is still missing. libcuda.so.1 comes with the GPU driver.
88
+ PIP_FOR = {'libcublas.so.12': 'nvidia-cublas-cu12', 'libcublasLt.so.12': 'nvidia-cublas-cu12',
89
+ 'libcudart.so.12': 'nvidia-cuda-runtime-cu12', 'libnccl.so.2': 'nvidia-nccl-cu12'}
90
+
91
+
92
+ def lib_dirs():
93
+ dirs = ['/usr/local/cuda/lib64', '/usr/local/nvidia/lib64', '/usr/lib64-nvidia']
94
+ for sp in sys.path:
95
+ nv = os.path.join(sp, 'nvidia')
96
+ if os.path.isdir(nv):
97
+ dirs += [os.path.join(nv, d, 'lib') for d in os.listdir(nv) if os.path.isdir(os.path.join(nv, d, 'lib'))]
98
+ return [d for d in dirs if os.path.isdir(d)]
99
+
100
+
101
+ def engine_env(exe):
102
+ env = dict(os.environ)
103
+ for attempt in range(2):
104
+ env['LD_LIBRARY_PATH'] = ':'.join(lib_dirs() + [env.get('LD_LIBRARY_PATH', '')]).strip(':')
105
+ try:
106
+ out = subprocess.run(['ldd', exe], capture_output=True, text=True, env=env, timeout=30).stdout
107
+ except Exception:
108
+ return env
109
+ missing = sorted({PIP_FOR[l.split()[0]] for l in out.splitlines() if 'not found' in l and l.split()[0] in PIP_FOR})
110
+ if not missing:
111
+ return env
112
+ if attempt == 0:
113
+ log(f'installing NVIDIA libraries: {", ".join(missing)}')
114
+ subprocess.run([sys.executable, '-m', 'pip', 'install', '-q', *missing])
115
+ log('warning: some NVIDIA libraries are still missing; the engine may not start')
116
+ return env
117
+
118
+
119
+ def gpu_name():
120
+ try:
121
+ return subprocess.run(['nvidia-smi', '--query-gpu=name,memory.total', '--format=csv,noheader'], capture_output=True, text=True, timeout=10).stdout.strip()
122
+ except Exception:
123
+ return 'no NVIDIA GPU found'
124
+
125
+
126
+ def fill(args, out_dir, init_path, man_files):
127
+ """Replace Ora's placeholders: {model:key} -> model file, {out} -> output folder, {init} -> start image."""
128
+
129
+ def rep(m):
130
+ kind, key = m.group(1), m.group(2)
131
+ if kind == 'model':
132
+ return os.path.join(MODELS, man_files[key]['name'])
133
+ if kind == 'out':
134
+ return out_dir
135
+ return init_path or ''
136
+ return [TOKEN.sub(rep, str(a)) for a in args]
137
+
138
+
139
+ def run_job(job, engine, base_out, on_line=None):
140
+ """Run one job. Returns a result dict with the files made."""
141
+ jid = re.sub(r'[^\w-]', '', job['id'])[:80] or 'job'
142
+ out_dir = os.path.join(base_out, jid)
143
+ os.makedirs(out_dir, exist_ok=True)
144
+ init_path = None
145
+ if job.get('initPng'):
146
+ init_path = os.path.join(out_dir, 'start.png')
147
+ with open(init_path, 'wb') as f:
148
+ f.write(base64.b64decode(job['initPng']))
149
+ # Ora sends the exact pinned model files the job needs: {key: {name, repo, rev, path, size}}
150
+ files = {k: v for k, v in job['files'].items() if re.match(r'^[\w.-]+$', v.get('name', ''))}
151
+ get_models(files)
152
+ args = fill(job['args'], out_dir, init_path, files)
153
+ t0 = time.time()
154
+ with open(os.path.join(out_dir, 'engine.log'), 'w') as lf:
155
+ env = STATE.setdefault('env', {}).get(engine) or engine_env(engine)
156
+ STATE['env'][engine] = env
157
+ p = subprocess.Popen([engine, *args], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=out_dir, env=env)
158
+ STATE['proc'] = p
159
+ buf = b''
160
+ while True:
161
+ chunk = p.stdout.read1(4096) if hasattr(p.stdout, 'read1') else p.stdout.read(4096)
162
+ if not chunk:
163
+ break
164
+ lf.write(chunk.decode('utf8', 'replace'))
165
+ buf += chunk
166
+ *lines, buf = re.split(rb'[\r\n]', buf)
167
+ for ln in lines:
168
+ if ln.strip() and on_line:
169
+ on_line(ln.decode('utf8', 'replace'))
170
+ code = p.wait()
171
+ STATE['proc'] = None
172
+ result = {'id': job['id'], 'code': code, 'seconds': round(time.time() - t0), 'files': []}
173
+ if code != 0:
174
+ return result
175
+ if job['kind'] == 'video' and os.path.exists(os.path.join(out_dir, 'video.webm')):
176
+ # models with sound (LTX, MiniMax-H3) write one WebM: make an MP4 with H.264 + AAC, and a poster frame
177
+ webm, mp4 = os.path.join(out_dir, 'video.webm'), os.path.join(out_dir, 'video.mp4')
178
+ subprocess.run(['ffmpeg', '-y', '-loglevel', 'error', '-i', webm, '-frames:v', '1', os.path.join(out_dir, 'poster.png')])
179
+ if shutil.which('ffmpeg') and subprocess.run(['ffmpeg', '-y', '-loglevel', 'error', '-i', webm, '-c:v', 'libx264', '-pix_fmt', 'yuv420p',
180
+ '-crf', '16', '-c:a', 'aac', '-b:a', '192k', '-movflags', '+faststart', mp4]).returncode == 0:
181
+ result['files'] = ['video.mp4'] + (['poster.png'] if os.path.exists(os.path.join(out_dir, 'poster.png')) else [])
182
+ else:
183
+ result['files'] = ['video.webm']
184
+ return result
185
+ if job['kind'] == 'video':
186
+ frames = sorted(f for f in os.listdir(out_dir) if re.match(r'frame_\d+\.png$', f))
187
+ if frames:
188
+ shutil.copy(os.path.join(out_dir, frames[0]), os.path.join(out_dir, 'poster.png'))
189
+ mp4 = os.path.join(out_dir, 'video.mp4')
190
+ if shutil.which('ffmpeg') and subprocess.run(['ffmpeg', '-y', '-loglevel', 'error', '-framerate', str(job.get('fps', 16)),
191
+ '-i', os.path.join(out_dir, 'frame_%03d.png'), '-c:v', 'libx264', '-pix_fmt', 'yuv420p', '-crf', '16',
192
+ '-movflags', '+faststart', mp4]).returncode == 0:
193
+ for f in frames:
194
+ os.remove(os.path.join(out_dir, f))
195
+ result['files'] = ['video.mp4', 'poster.png']
196
+ else:
197
+ result['files'] = frames + ['poster.png'] # Ora encodes the MP4 itself
198
+ else:
199
+ result['files'] = sorted(f for f in os.listdir(out_dir) if re.match(r'img_\d+\.png$', f))
200
+ return result
201
+
202
+
203
+ STATE = {'proc': None}
204
+
205
+
206
+ # --- Kaggle: run a batch of jobs, leave the results in the notebook output ------------------------------------------
207
+
208
+ def batch(job_file, out, engine_arg):
209
+ with open(job_file) as f:
210
+ spec = json.load(f)
211
+ log(f'GPU: {gpu_name()}')
212
+ engine = get_engine(engine_arg)
213
+ results = []
214
+ for job in spec['jobs']:
215
+ log(f"job {job['id']} ({job['kind']})")
216
+ r = run_job(job, engine, out, on_line=lambda ln: print(ln, flush=True))
217
+ results.append(r)
218
+ log(f"job {job['id']} finished with code {r['code']} in {r['seconds']} s")
219
+ with open(os.path.join(out, 'results.json'), 'w') as f:
220
+ json.dump({'version': VERSION, 'gpu': gpu_name(), 'results': results}, f)
221
+
222
+
223
+ # --- Colab: serve jobs over a tunnel, with live progress ------------------------------------------------------------
224
+
225
+ class Jobs:
226
+ def __init__(self):
227
+ self.lock = threading.Lock()
228
+ self.items = {} # id -> {state, lines, result}
229
+
230
+ def add(self, job):
231
+ with self.lock:
232
+ self.items[job['id']] = {'state': 'queued', 'lines': [], 'result': None}
233
+ threading.Thread(target=self._run, args=(job,), daemon=True).start()
234
+
235
+ def _run(self, job):
236
+ it = self.items[job['id']]
237
+ with SERVE['busy']: # one job at a time: one GPU
238
+ if it['state'] == 'cancelled':
239
+ return
240
+ it['state'] = 'running'
241
+ try:
242
+ it['result'] = run_job(job, SERVE['engine'], SERVE['out'], on_line=lambda ln: it['lines'].append(ln[-400:]))
243
+ it['state'] = 'done' if it['result']['code'] == 0 else 'failed'
244
+ except Exception as e:
245
+ it['lines'].append(f'[ora] error: {e}')
246
+ it['state'] = 'failed'
247
+
248
+
249
+ SERVE = {'secret': None, 'jobs': Jobs(), 'busy': threading.Lock(), 'engine': None, 'out': None}
250
+
251
+
252
+ class Handler(BaseHTTPRequestHandler):
253
+ def log_message(self, *a):
254
+ pass
255
+
256
+ def _auth(self):
257
+ if not secrets.compare_digest(self.headers.get('X-Ora-Secret', ''), SERVE['secret']):
258
+ self._send(403, {'error': 'wrong connection code'})
259
+ return False
260
+ return True
261
+
262
+ def _send(self, code, obj=None, body=None, ctype='application/json'):
263
+ data = body if body is not None else json.dumps(obj).encode()
264
+ self.send_response(code)
265
+ self.send_header('Content-Type', ctype)
266
+ self.send_header('Content-Length', str(len(data)))
267
+ self.end_headers()
268
+ self.wfile.write(data)
269
+
270
+ def do_GET(self):
271
+ if not self._auth():
272
+ return
273
+ parts = [p for p in self.path.split('?')[0].split('/') if p]
274
+ if parts == ['hello']:
275
+ return self._send(200, {'ok': True, 'version': VERSION, 'gpu': gpu_name(), 'busy': SERVE['busy'].locked()})
276
+ if len(parts) == 2 and parts[0] == 'status':
277
+ it = SERVE['jobs'].items.get(parts[1])
278
+ if not it:
279
+ return self._send(404, {'error': 'no such job'})
280
+ since = int((re.search(r'since=(\d+)', self.path) or [0, 0])[1])
281
+ return self._send(200, {'state': it['state'], 'lines': it['lines'][since:], 'next': len(it['lines']), 'result': it['result']})
282
+ if len(parts) == 3 and parts[0] == 'file':
283
+ jid, name = re.sub(r'[^\w-]', '', parts[1]), os.path.basename(parts[2])
284
+ p = os.path.join(SERVE['out'], jid, name)
285
+ if not re.match(r'^(video\.mp4|video\.webm|poster\.png|frame_\d+\.png|img_\d+\.png)$', name) or not os.path.exists(p):
286
+ return self._send(404, {'error': 'no such file'})
287
+ with open(p, 'rb') as f:
288
+ return self._send(200, body=f.read(), ctype='video/mp4' if name.endswith('.mp4') else 'image/png')
289
+ self._send(404, {'error': 'not found'})
290
+
291
+ def do_POST(self):
292
+ if not self._auth():
293
+ return
294
+ parts = [p for p in self.path.split('/') if p]
295
+ n = int(self.headers.get('Content-Length', 0))
296
+ if n > 32 << 20:
297
+ return self._send(413, {'error': 'too large'})
298
+ body = json.loads(self.rfile.read(n) or b'{}')
299
+ if parts == ['job']:
300
+ if not isinstance(body.get('args'), list) or body.get('kind') not in ('video', 'image'):
301
+ return self._send(400, {'error': 'bad job'})
302
+ SERVE['jobs'].add(body)
303
+ return self._send(200, {'ok': True})
304
+ if len(parts) == 2 and parts[0] == 'cancel':
305
+ it = SERVE['jobs'].items.get(parts[1])
306
+ if it:
307
+ it['state'] = 'cancelled' if it['state'] == 'queued' else it['state']
308
+ p = STATE['proc']
309
+ if p and it['state'] == 'running':
310
+ p.terminate()
311
+ return self._send(200, {'ok': True})
312
+ self._send(404, {'error': 'not found'})
313
+
314
+
315
+ def start_tunnel(port):
316
+ """A free Cloudflare quick tunnel (no account): prints https://<random>.trycloudflare.com."""
317
+ exe = os.path.join(HOME, 'cloudflared')
318
+ if not os.path.exists(exe):
319
+ fetch('https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64', exe)
320
+ os.chmod(exe, 0o755)
321
+ p = subprocess.Popen([exe, 'tunnel', '--no-autoupdate', '--url', f'http://127.0.0.1:{port}'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
322
+ for line in p.stdout:
323
+ m = re.search(r'https://[a-z0-9-]+\.trycloudflare\.com', line)
324
+ if m:
325
+ threading.Thread(target=lambda: [None for _ in p.stdout], daemon=True).start()
326
+ return m.group(0)
327
+ raise RuntimeError('the tunnel did not start')
328
+
329
+
330
+ def serve(port, tunnel, engine_arg, out):
331
+ SERVE.update(secret=secrets.token_urlsafe(24), engine=get_engine(engine_arg), out=out)
332
+ os.makedirs(out, exist_ok=True)
333
+ httpd = ThreadingHTTPServer(('127.0.0.1', port), Handler)
334
+ threading.Thread(target=httpd.serve_forever, daemon=True).start()
335
+ url = start_tunnel(port) if tunnel else f'http://127.0.0.1:{port}'
336
+ code = 'ora1.' + base64.urlsafe_b64encode(json.dumps({'url': url, 'secret': SERVE['secret']}).encode()).decode().rstrip('=')
337
+ log(f'GPU: {gpu_name()}')
338
+ print('\n' + '=' * 70 + '\nCopy this connection code into Ora (Connections > Colab > Paste code):\n\n' + code + '\n\nKeep this cell running while you use Ora. Stop it to disconnect.\n' + '=' * 70, flush=True)
339
+ while True:
340
+ time.sleep(3600)
341
+
342
+
343
+ if __name__ == '__main__':
344
+ ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
345
+ ap.add_argument('--batch', help='job file from Ora (Kaggle)')
346
+ ap.add_argument('--serve', action='store_true', help='serve jobs from Ora over a tunnel (Colab)')
347
+ ap.add_argument('--out', default=os.path.join(HOME, 'out'))
348
+ ap.add_argument('--port', type=int, default=8765)
349
+ ap.add_argument('--no-tunnel', action='store_true', help='testing: serve on localhost only')
350
+ ap.add_argument('--engine', help='testing: path to an sd-cli to use instead of the CUDA build')
351
+ a = ap.parse_args()
352
+ if a.batch:
353
+ batch(a.batch, a.out, a.engine)
354
+ elif a.serve:
355
+ serve(a.port, not a.no_tunnel, a.engine, a.out)
356
+ else:
357
+ ap.print_help()