Make videos on the computer you already own. FreeVideo runs MiniMax H3 in as little as 8 GB of VRAM and 16 GB of RAM, and adapts its acceleration path to your hardware.
Detailed generation progress with stage words and real percentages
Bowen Xueb4c46ed767ac
diff --git a/freevideo_engine/comfy_bridge.py b/freevideo_engine/comfy_bridge.pyindex dcf2fcf..59eb37c 100644--- a/freevideo_engine/comfy_bridge.py+++ b/freevideo_engine/comfy_bridge.py@@ -429,7 +429,7 @@ class WholeVideoProgress:if self.request['flow'] == 'upscale' or self.retry_reuse_first:return 'pass2'if self.request['flow'] != 'preview' and self.request['two_pass']:- if done > base or (done == base and (name == 'sampling_start' or message.get('stage') in ('layers', 'inputs'))):+ if done > base or (done == base and (name == 'sampling_start' or message.get('stage') in ('layers', 'inputs', 'kernel_prepare'))):return 'pass2'return 'pass1'return {'encoding': 'encode', 'load': 'load', 'decode': 'decode_save'}.get(phase) if isinstance(phase, str) else None@@ -493,9 +493,10 @@ class WholeVideoProgress:self.live_calibration = Trueelif phase == 'load':if event.get('event') == 'loaded':- done, total = 50, 50+ total = self.count[1] if self.count else 50+ done = totalelif event.get('event') == 'prepared_blocks':- done, total = event.get('blocks'), 50+ done, total = message.get('done'), message.get('total')elif event.get('event') == 'model_load_phase':done, total = event.get('done'), event.get('total')# LoRA groups describe a substage, not completion of the whole load.@@ -1031,9 +1032,14 @@ def progress_message(event):return {'label': 'Preparing reference media', 'timing_phase': 'encoding','reference_trimmed': {key: event.get(key) for key in ('kind', 'number', 'seconds', 'used_seconds')}}if name == 'prepared_blocks':- # The cached video model has 50 blocks, as in the former label.- return {'label': 'Loading the video model',- 'timing_phase': 'load', 'done': event.get('blocks'), 'total': 50}+ # Old engine logs omitted the total for the pinned 50-block model.+ # Current workers report the actual model length, including the last+ # block when that length is not a multiple of five.+ result = {'label': 'Loading the video model', 'timing_phase': 'load'}+ done, total = event.get('blocks'), event.get('total', 50)+ if type(done) is int and type(total) is int and total > 0 and 0 <= done <= total:+ result.update(done=done, total=total)+ return resultif name in ('sampling_preset_download', 'reference_assets_download'):reference = name == 'reference_assets_download'return dict(label='Preparing reference media resources' if reference else 'Preparing sampling preset',diff --git a/freevideo_engine/decode.py b/freevideo_engine/decode.pyindex 1827f3c..cedb222 100644--- a/freevideo_engine/decode.py+++ b/freevideo_engine/decode.py@@ -10,21 +10,32 @@ from .offload import LayerOffloader, pin_layer_weightsfrom .vae_tiles import TileDecoder, compile_blocks+DECODE_LABELS = {+ 'vae_load': 'Loading video VAE',+ 'video_decode': 'Decoding the video',+ 'video_postprocess': 'Processing video colors',+ 'rgb_save': 'Saving decoded video',+ 'audio_load_decode': 'Loading and decoding audio',+ 'audio_save': 'Saving decoded audio',+ 'mp4_save': 'Saving MP4 and audio',+}++@torch.no_grad()def decode_to_file(latents, audio_latents, out_path, *, base, offload=False, prefetch=True, tile_group=False,preload=False, pin_weights=False, artifacts_dir=None, phase_callback=None,stream_output=False, stream_weights=False, resident_blocks=0, model_cache=None,linear_compute_cache=False, continuation=None, audio_lead_in_callback=None, output_size=None):+ def phase(name):+ if phase_callback is not None:+ phase_callback(name)+ print(json.dumps({'event': 'decode_phase', 'phase': DECODE_LABELS[name]}), flush=True)+ phase('vae_load')from diffusers import AutoencoderKLMiniMaxH3from diffusers.utils.export_utils import encode_videofrom src.inference.render import PIXEL_MEAN, PIXEL_STD, FPSstarted = time.perf_counter()- def phase(name):- if phase_callback is not None:- phase_callback(name)- phase('vae_load')- print(json.dumps({'event': 'decode_phase', 'phase': 'Loading video VAE'}), flush=True)vae = Noneweight_source = Nonecompute_cache_metrics = None@@ -117,7 +128,6 @@ def decode_to_file(latents, audio_latents, out_path, *, base, offload=False, preload_seconds = time.perf_counter() - starteddecode_started = time.perf_counter()phase('video_decode')- print(json.dumps({'event': 'decode_phase', 'phase': 'Decoding the video'}), flush=True)offload_stats = Nonergb_mapping = Nonestreamed_timings = {}@@ -150,10 +160,10 @@ def decode_to_file(latents, audio_latents, out_path, *, base, offload=False, pregc.collect()torch.cuda.empty_cache()video_decode_seconds = streamed_timings.get('video_decode_seconds', time.perf_counter() - decode_started)- phase('video_postprocess')# Bound postprocessing memory by frame chunks; use the same FP32 operations# and rounding before converting to uint8. Do this on CPU after decoding.if not stream_output:+ phase('video_postprocess')frames = torch.empty((video.shape[2], video.shape[3], video.shape[4], 3), dtype=torch.uint8)pixel_mean = torch.tensor(PIXEL_MEAN).view(1, -1, 1, 1, 1)pixel_std = torch.tensor(PIXEL_STD).view(1, -1, 1, 1, 1)@@ -179,7 +189,6 @@ def decode_to_file(latents, audio_latents, out_path, *, base, offload=False, preartifact_seconds += time.perf_counter() - tickaudio_start = time.perf_counter()phase('audio_load_decode')- print(json.dumps({'event': 'decode_phase', 'phase': 'Loading and decoding audio'}), flush=True)audio_vae = Noneif model_cache is not None:from .resident_models import key, file_identity@@ -195,6 +204,7 @@ def decode_to_file(latents, audio_latents, out_path, *, base, offload=False, preaudio_vae.eval().requires_grad_(False)audio_mean = torch.tensor(audio_vae.config.latents_mean, device='cuda').view(1, -1, 1)audio_std = torch.tensor(audio_vae.config.latents_std, device='cuda').view(1, -1, 1)+ print(json.dumps({'event': 'decode_phase', 'phase': 'Decoding audio'}), flush=True)audio = audio_vae.decode(audio_latents * audio_std + audio_mean, return_dict=False)[0]audio = audio.float().permute(1, 0, 2)[0].cpu()rate = audio_vae.config.sampling_rate@@ -225,7 +235,6 @@ def decode_to_file(latents, audio_latents, out_path, *, base, offload=False, pretemporary = destination.with_name(destination.stem + '.partial' + destination.suffix)encode_started = time.perf_counter()phase('mp4_save')- print(json.dumps({'event': 'decode_phase', 'phase': 'Saving MP4 and audio'}), flush=True)if output_size is not None:# The model rendered a larger size; only the picture is scaled.from .output_fit import fit_framesdiff --git a/freevideo_engine/model_load_progress.py b/freevideo_engine/model_load_progress.pynew file mode 100644index 0000000..9b7e0d0--- /dev/null+++ b/freevideo_engine/model_load_progress.py@@ -0,0 +1,20 @@+"""Real completed video-model blocks; no tensor reads or device imports."""+import json+++class PreparedBlocks:+ def __init__(self, total):+ if type(total) is not int or total < 1:+ raise ValueError('Model block total must be a positive integer')+ self.total, self.done = total, 0++ def report(self, **fields):+ print(json.dumps(dict(fields, event='prepared_blocks', blocks=self.done, total=self.total)), flush=True)++ def complete(self, **fields):+ # Called only after a block's existing preparation and upload submission.+ # A submission count does not claim synchronized GPU upload completion.+ if self.done == self.total:+ raise ValueError('All model blocks have already been prepared')+ self.done += 1+ self.report(**fields)diff --git a/freevideo_engine/progress_timeline.py b/freevideo_engine/progress_timeline.pyindex 7fb3870..5b49243 100644--- a/freevideo_engine/progress_timeline.py+++ b/freevideo_engine/progress_timeline.py@@ -84,6 +84,7 @@ STAGES = frozenset(('gpu','imports','inputs',+ 'kernel_prepare','installation','latent_save','latent_upscale',@@ -123,6 +124,7 @@ LABEL_KEYS = frozenset(('Continuing from the preview','Copy local model','Decoding video and audio',+ 'Decoding audio','Decoding video tiles','Downloading extra model weights (one-time download)','Encoding image/video references',@@ -183,6 +185,8 @@ LABEL_KEYS = frozenset(('Preparing two-pass upscaler','Preparing video','Preparing video decoding',+ 'Preparing GPU programs for the first step',+ 'Processing video colors','Preview saved','Prompt ready','RAM measurement',@@ -214,6 +218,8 @@ LABEL_KEYS = frozenset(('Saving MP# and audio','Saving completed sampling','Saving prompt cache',+ 'Saving decoded video',+ 'Saving decoded audio','Single-pass · # steps','Start ComfyUI','Starting ComfyUI',diff --git a/freevideo_engine/runtime.py b/freevideo_engine/runtime.pyindex 172dae1..64188b4 100644--- a/freevideo_engine/runtime.py+++ b/freevideo_engine/runtime.py@@ -292,6 +292,9 @@ class Engine:block_bind_seconds = 0.upload_submit_seconds = 0.block_order = list(range(len(model.transformer_blocks)))+ from .model_load_progress import PreparedBlocks+ block_progress = PreparedBlocks(len(block_order))+ block_progress.report()if streamed_source is not None and streamed_source.direct_read:# Pins and views are granted in the order blocks are prepared, and# the blocks RAM cannot keep are read from the drive every step.@@ -360,15 +363,9 @@ class Engine:# unpinned bytes are reopened by SafetensorLayers on demand,# rather than accumulating until the first sampling step.prepare_streamed(block, streamed_refiner_count + index - resident_blocks, unread)- # A block whose sampling table is computed here, for a step count- # without stored tables, takes far longer than a cached one; report- # each of those so the load visibly moves.- if prepared % 5 == 0 or (adaln_cache and not cache_hit):- print(json.dumps({'event': 'prepared_blocks', 'blocks': prepared,- 'adaln_cache': adaln_cache, 'adaln_reused_blocks': table_cache_hits,- 'resident_uploaded_blocks': min(prepared, resident_blocks),- 'phase': 'Load cached blocks and upload resident weights',- 'seconds': time.perf_counter() - started}), flush=True)+ block_progress.complete(adaln_cache=adaln_cache, adaln_reused_blocks=table_cache_hits,+ resident_uploaded_blocks=min(prepared, resident_blocks),+ phase='Load cached blocks and upload resident weights', seconds=time.perf_counter() - started)if adaln_cache:del embeddingsself.schedule_hook = model.register_forward_pre_hook(self.cursor.before, with_kwargs=True)diff --git a/freevideo_engine/sampling_progress.py b/freevideo_engine/sampling_progress.pyindex 63558cd..17b1169 100644--- a/freevideo_engine/sampling_progress.py+++ b/freevideo_engine/sampling_progress.py@@ -89,6 +89,9 @@ class SamplingProgress:def start(self):self.event('sampling_start', stage='inputs', step=1)+ # Preparation can encounter a new shape or a cold compiler cache. We+ # cannot tell whether a compile is active, or how far it has progressed.+ self.event('sampling_prepare', stage='kernel_prepare', step=1)def layer(self, index):if len(self.completed) >= self.steps:@@ -160,6 +163,15 @@ def progress_message(event):return dict(label=labels[phase], phase='sample_finalize', stage=phase,done=0, total=0)return None+ if name == 'sampling_prepare':+ done, total = event.get('completed_steps'), event.get('total')+ if type(total) is not int or total < 1 or type(done) is not int or not 0 <= done < total:+ return None+ return dict(label='Preparing GPU programs for the first step', phase='sampling',+ stage='kernel_prepare', done=done, total=total, unit='steps',+ kernel_cache_note=True,+ uniform_remaining_steps=event.get('uniform_remaining_steps', True),+ step_elapsed_seconds=event.get('step_elapsed_seconds', 0.))if name not in ('sampling_start', 'sampling_progress', 'step', 'loaded'):return Nonetotal = event.get('total', 8)diff --git a/scripts/test_freevideo_entry.mjs b/scripts/test_freevideo_entry.mjsindex 53fe143..bc4f4ea 100644--- a/scripts/test_freevideo_entry.mjs+++ b/scripts/test_freevideo_entry.mjs@@ -351,11 +351,12 @@ test('main browser entry registers both views and preserves node hooks', async tconst activity = progress.snapshot().label;removalNode.freevideoShowProgress({compatibility: {level: 2, name_en: 'Compatible', name_zh: '兼容'}});assert.equal(progress.snapshot().label, activity, 'The node must not replace the activity for settings-only events');- assert.match(progress.snapshot().status, /Compatibility setting Compatible|兼容档/);+ assert.match(progress.snapshot().status, /so far|已进行/, 'pause has priority over a settings-only compatibility notice');removalNode.freevideoShowProgress({phase: 'recovery', retry: {kind: 'ram_pressure'}});assert.match(progress.snapshot().status, /Out of RAM|内存不足/);removalNode.freevideoShowProgress({new_request: true, phase: 'load', received_at: 0});- assert.equal(progress.snapshot().status, '', 'A new request clears the old retry and compatibility notice');+ assert.match(progress.snapshot().status, /so far|已进行/, 'An aged new request clears retry and compatibility but shows its own pause');+ assert.doesNotMatch(progress.snapshot().status, /Out of RAM|内存不足|Compatibility setting|兼容档/);assert.equal(progress.stall.hidden, false);assert.equal(timers.size, 1);let layoutCalls = 0, timersDuringLayout;diff --git a/web/editor.css b/web/editor.cssindex b537f53..15e8494 100644--- a/web/editor.css+++ b/web/editor.css@@ -63,7 +63,11 @@.fv-ed-genbar{grid-column:1/-1;grid-row:4;display:flex;align-items:center;gap:12px;padding:0 16px;border-top:1px solid var(--fv-border);border-bottom:1px solid var(--fv-border);background:var(--fv-card);min-width:0}.fv-ed-genbar .fv-ed-description{width:auto}.fv-ed-clip[data-state=running] .fv-block-progress.fv-ed-block-progress{display:grid}-.fv-ed-gen-hint{font-size:13px;color:var(--fv-muted);flex:1;min-width:0}+.fv-ed-gen-hint{display:flex;font-size:13px;color:var(--fv-muted);flex:1;min-width:0;overflow:hidden;white-space:pre}+.fv-ed-gen-part{flex:none}+.fv-ed-gen-stage,.fv-ed-gen-time{min-width:0;overflow:hidden;text-overflow:ellipsis}+.fv-ed-gen-stage{flex:0 1000 auto}+.fv-ed-gen-time{flex:none;max-width:100%}.fv-ed-genbar[data-mode=selected] .fv-ed-gen-hint{flex:none}.fv-ed-gen-note{font-size:13px;color:var(--fv-ink);flex:0 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.fv-ed-gen-note[hidden]{display:none}diff --git a/web/editor.js b/web/editor.jsindex 2efdc99..7f3211b 100644--- a/web/editor.js+++ b/web/editor.js@@ -209,7 +209,8 @@ export function openEditor({api, app, from = null, panel = {}, components: givenfunction barJob(job) {const latest = [...runProgress.values()].filter(message => message.chain.id === job.id).sort((a, b) => (a.received_at || 0) - (b.received_at || 0)).at(-1);- return latest ? {...job, chainProgress: latest.chain} : job;+ const words = panel.progressWords?.() || null;+ return latest ? {...job, chainProgress: latest.chain, words} : words ? {...job, words} : job;}function paintJob(job) {const messages = blockMessages([...runProgress.values()].filter(message => message.chain.id === job.id),@@ -1254,7 +1255,10 @@ export function openEditor({api, app, from = null, panel = {}, components: givenlisteners.push(() => api.removeEventListener('execution_error', executionError));}if (panel.progressElement && typeof MutationObserver !== 'undefined') {- progressObserver = new MutationObserver(() => { for (const job of jobStatuses.values()) paintJob(job); });+ progressObserver = new MutationObserver(() => {+ for (const job of jobStatuses.values()) paintJob(job);+ if (mostRecentJob && jobStatuses.has(mostRecentJob)) genbar?.update(barJob(jobStatuses.get(mostRecentJob)));+ });progressObserver.observe(panel.progressElement, {subtree: true, childList: true, characterData: true, attributes: true, attributeFilter: ['aria-valuenow', 'hidden']});}const bar = tracks.element.querySelector('.fv-ed-track-zoom');diff --git a/web/editor_entry.js b/web/editor_entry.jsindex 3f2feb8..2420faa 100644--- a/web/editor_entry.js+++ b/web/editor_entry.js@@ -29,6 +29,17 @@ export function openEditorView(node, {studio, work = null, extend = false} = {})const number = progressElement.querySelector('.fv-generation-count')?.textContent?.match(/(\d+)%/);return number ? {percent: Number(number[1])} : {percent: 0};};+ // What the creation panel is saying now; the editor covers that panel, so its bar repeats the words.+ panel.progressWords = () => {+ if (progressElement.hidden) return null;+ const words = selector => {+ const element = progressElement.querySelector(selector);+ return element && !element.hidden && element.getClientRects().length ? element.textContent.replace(/\s+/g, ' ').trim() : '';+ };+ // The block already shows the overall percentage; the bar keeps only the stage sentence.+ const stage = words('.fv-generation-label').replace(/(本步 \d+%)$| \(\d+% of this step\)$/, '');+ return {stage, time: words('.fv-generation-status'), stall: words('.fv-generation-stall')};+ };}const handle = openEditor({api, app, panel, from: work ? {work, ...(extend ? {extend: true} : {})} : null, onView(view) {if (view === 'nodes') showNodes(node, studio);diff --git a/web/editor_genbar.js b/web/editor_genbar.jsindex 009c856..137a2cf 100644--- a/web/editor_genbar.js+++ b/web/editor_genbar.js@@ -90,8 +90,17 @@ export function createEditorGenbar(host, {state, t, actions, text = ''}) {const blocks = status?.blocks || [], done = blocks.filter(block => block.state === 'done').length;const number = Math.min(blocks.length || 1, Math.max(done, status?.chainProgress?.index || 0) + 1), count = blocks.length || 1;const remaining = status?.chainProgress?.overall?.remaining_seconds ?? (blocks.every(block => Number.isFinite(block.remaining_seconds)) ? blocks.reduce((sum, block) => sum + block.remaining_seconds, 0) : null);- hint.textContent = t(`Part ${number}/${count}`, `第 ${number}/${count} 段`)- + (remaining != null ? ' · ' + timeEstimate(remaining, t) : '');+ const words = status?.words;+ // The creation panel's own sentences, so a long step says what it is and how long it has taken.+ // At a narrow width only the stage sentence is cut; the part number and the time stay.+ // A single part needs no number; with nothing else to say it reads "Preparing".+ const time = words?.stall || words?.time || (remaining != null ? timeEstimate(remaining, t) : '');+ const stage = words?.stage || (count === 1 && !time ? t('Preparing', '正在准备') : '');+ const spans = [['fv-ed-gen-part', count > 1 ? t(`Part ${number}/${count}`, `第 ${number}/${count} 段`) : ''],+ ['fv-ed-gen-stage', stage], ['fv-ed-gen-time', time]];+ const shown = spans.filter(([, text]) => text).map(([cls, text], index) => [cls, index ? ` · ${text}` : text]);+ hint.replaceChildren(...shown.map(([cls, text]) => el('span', cls, text)));+ hint.title = shown.map(([, text]) => text).join('');}firstFrame.update(busy);references?.update(busy, busy ? undefined : !!actions.references.visible());diff --git a/web/generation_progress.js b/web/generation_progress.jsindex 9c3b5d9..e6314f0 100644--- a/web/generation_progress.js+++ b/web/generation_progress.js@@ -11,6 +11,64 @@ const duration = value => {};const progressFields = ['phase', 'stage', 'timing_phase', 'label', 'done', 'total', 'block'];+// Iris's approved substage sentences. Unknown engine labels never reach the UI.+const SUBACTIVITY = {+ start: ['Starting the generation process', '正在启动生成进程'],+ libraries: ["Loading the text encoder's libraries", '正在载入文本编码器的程序库'],+ weights: ['Reading the text encoder from disk', '正在从硬盘读取文本编码器'],+ gpu: ['Moving the text encoder to the GPU', '正在把文本编码器载入显卡'],+ prompt: ['Encoding the prompt', '正在编码提示词'],+ reference: ['Encoding the reference images and videos', '正在编码参考图片和视频'],+ load: ['Loading the video model', '正在载入视频模型'],+ first: ['Running the first step (it takes longer the first time a size is used or after an update)',+ '正在进行第一步(首次使用这个尺寸或更新后,第一步要多花一些时间)'],+ upscale: ['Upscaling the first pass', '正在放大第一遍的结果'],+ decoder: ['Loading the video decoder', '正在载入视频解码器'],+ decode: ['Decoding the video', '正在解码视频'],+ audio: ['Decoding the audio', '正在解码音频'],+ save: ['Saving the video', '正在保存视频'],+};+// [EN, ZH, EN with a step, ZH with a step]; a request that samples twice adds which pass.+const SAMPLING_NAME = {+ single: ['Sampling', '正在采样', 'Sampling step', '正在采样第 '],+ first: ['Sampling (first pass)', '正在采样(一采)', 'Sampling step', '正在采样第 '],+ pass2: ['Sampling (second pass)', '正在采样(二采)', 'Sampling step', '正在采样第 '],+ preview: ['Sampling (preview)', '正在采样(预览)', 'Sampling step', '正在采样第 '],+};+const SAMPLING_PASS = {first: ['first pass', '一采'], pass2: ['second pass', '二采'], preview: ['preview', '预览']};+const SUBACTIVITY_LABELS = {+ 'Starting generation process': 'start', 'Starting text encoder': 'libraries',+ 'Loading text encoder': 'libraries', 'Preparing text encoder GPU': 'gpu',+ 'Reading text encoder weights': 'weights', 'Preparing text encoder model': 'weights',+ 'Loading text encoder onto GPU': 'gpu', 'Encoding prompt': 'prompt', 'Encoding text and images': 'prompt',+ 'Loading video VAE': 'decoder', 'Loading and decoding audio': 'audio', 'Saving MP4 and audio': 'save',+ 'Decoding the video': 'decode', 'Processing video colors': 'decode', 'Decoding audio': 'audio',+ 'Saving decoded video': 'save', 'Saving decoded audio': 'save',+};+function subactivity(message, activity, t) {+ const phase = message.phase || message.timing_phase || message.stage;+ const label = message.label;+ let key = SUBACTIVITY_LABELS[label];+ const sampling = ['pass1', 'pass2', 'preview'].includes(activity?.key);+ if (sampling) {+ // Engines send kernel_prepare before every pass's first step; its count is the first pass's steps.+ if (message.done === 0 || message.stage === 'kernel_prepare') key = 'first';+ // A paused stage line carries no counts; the normal line keeps the user's steps.+ else return {key: `sampling:${activity.key}`, text: t(...SAMPLING_NAME.single.slice(0, 2)), sampling: true};+ }+ key ||= {prepare: phase === 'starting' ? 'start' : null, encode: LABEL_ACTIVITY.reference.includes(label)+ ? 'reference' : 'prompt', load: 'load', decode: 'decode', save: 'save', upscale: 'upscale'}[activity?.key];+ if (key) return {key, text: t(...SUBACTIVITY[key]), sampling};+ // Only a download name needs the fallback frame; every other activity already reads as a sentence.+ const named = activity && activity.key !== 'prepare' ? activity.text : '';+ return {key: `other:${activity?.key || 'prepare'}`, sampling,+ text: !named ? t(...ACTIVITY.prepare) : activity.key === 'download' ? t(`Still working: ${named}`, `仍在进行:${named}`) : named};+}+const waitDuration = (seconds, t) => {+ const n = Math.floor(Math.max(0, seconds)), minutes = Math.floor(n / 60), rest = n % 60;+ return minutes ? t(`${minutes} min${rest ? ` ${rest} s` : ''}`, rest ? `${minutes} 分 ${rest} 秒` : `${minutes} 分钟`)+ : t(`${rest} s`, `${rest} 秒`);+};// Only our status sentences, scoped to a request; no prompt or engine log.// A reopened Studio/tab must not announce the replayed explanation again.const announcementKey = 'freevideo.progress.announcements';@@ -37,18 +95,17 @@ const STALL_SECONDS_BY_PHASE = Object.freeze({latent_upscale: 180, sample_finalize: 180, decode: 180, save: 180,dependencies: 180, recovery: 180, other: 180,});-// Only these fixed stage sentences reach either progress view, with at most the-// sampling step or a download's size and speed. Engine labels, layer, block and-// frame counts and the original sampling plan remain available in the report.+// Normal stage sentences keep the sampling step or a download's size and speed.+// After 15 s of engine silence SUBACTIVITY names the work without counts.+// Raw engine labels and internal units remain available in the report.// Stage words the product already uses: settings say 一采 / 二采, results say 解码.-// No "正在": the stage line sits beside a moving clock and a small bar.const ACTIVITY = {- prepare: ['Preparing', '准备中'],- prompt: ['Encoding the prompt', '编码提示词'],- combined: ['Encoding the prompt and references', '编码提示词和参考素材'],- load: ['Loading the video model', '载入视频模型'],- decode: ['Decoding the video', '解码视频'],- save: ['Saving the video', '保存视频'],+ prepare: ['Preparing', '正在准备'],+ prompt: ['Encoding the prompt', '正在编码提示词'],+ combined: ['Encoding the prompt and references', '正在编码提示词和参考素材'],+ load: ['Loading the video model', '正在载入视频模型'],+ decode: ['Decoding the video', '正在解码视频'],+ save: ['Saving the video', '正在保存视频'],};const LABEL_ACTIVITY = {prepare: ['Starting generation process', 'Preparing video', 'Checking saved video', 'Resource forecast ready'],@@ -68,9 +125,10 @@ const LABEL_ACTIVITY = {'Low-memory mode for this GPU'],refine: ['Upscaling before the second pass', 'Continuing from the preview', 'Reusing the completed first pass'],decode: ['Loading video VAE', 'Decoding video and audio', 'Decoding the video', 'Decoding video tiles',- 'Loading and decoding audio', 'Reusing completed sampling · retrying video and audio decoding',+ 'Loading and decoding audio', 'Processing video colors', 'Decoding audio',+ 'Reusing completed sampling · retrying video and audio decoding','Checking completed sampling', 'Saving completed sampling', 'Releasing sampling buffers', 'Preparing video decoding'],- save: ['Saving MP4 and audio'],+ save: ['Saving MP4 and audio', 'Saving decoded video', 'Saving decoded audio'],};// Engine steps that run only when the request has reference media.const REFERENCE_WORK = new Set(['Encoding reference media', 'Encoding image/video references', 'Encoding reference audio',@@ -103,13 +161,18 @@ function activityLabel(message, t, plan = {}, secondPass = false, references = f}return {key: 'download', text: t(download[0], download[1]) + detail};}- const steps = (key, en, zh, step, total) => ({key, text: Number.isInteger(step) && Number.isInteger(total) && total > 0- ? t(`${en} · step ${step} of ${total}`, `${zh} · 第 ${step} / ${total} 步`) : t(en, zh)});+ const steps = (key, name, step, total) => {+ const [en, zh, enSteps, zhSteps] = SAMPLING_NAME[name];+ const pass = SAMPLING_PASS[name];+ return {key, text: Number.isInteger(step) && Number.isInteger(total) && total > 0+ ? t(`${enSteps} ${step} of ${total}${pass ? ` (${pass[0]})` : ''}`, `${zhSteps}${step} / ${total} 步${pass ? `(${pass[1]})` : ''}`)+ : t(en, zh)};+ };const base = Number.isInteger(plan.base_steps) && plan.base_steps > 0 ? plan.base_steps : null;const second = plan.second || plan.upscale_target;if (message.prediction || message.sampling_plan) return named('prepare');if (phase === 'recovery') return message.retry?.reuse_sampling === true ? named('decode')- : message.retry?.reuse_first_pass === true ? steps('pass2', 'Second pass', '二采') : named('prepare');+ : message.retry?.reuse_first_pass === true ? steps('pass2', 'pass2') : named('prepare');if (phase === 'sample_finalize') return named('decode');if (message.stage === 'latent_upscale' || phase === 'latent_upscale')return {key: 'upscale', text: Number.isInteger(second?.width) && Number.isInteger(second?.height)@@ -123,12 +186,12 @@ function activityLabel(message, t, plan = {}, secondPass = false, references = fif ((secondPass || phase === 'refinement') && twoPass) {const refine = total !== null && total > base ? total - base : plan.refine_steps;const step = done === null ? null : Math.min(Math.max(1, done - base + 1), refine);- return steps('pass2', 'Second pass', '二采', step, refine);+ return steps('pass2', 'pass2', step, refine);}const count = twoPass ? base : total;const step = done === null || count === null ? null : Math.min(done + 1, count);- if (twoPass && plan.preview) return steps('preview', 'Preview', '预览', step, count);- return twoPass ? steps('pass1', 'First pass', '一采', step, count) : steps('pass1', 'Sampling', '采样', step, count);+ if (twoPass && plan.preview) return steps('preview', 'preview', step, count);+ return steps('pass1', twoPass ? 'first' : 'single', step, count);}const key = labelActivities.get(message.label) || {starting: 'prepare', prepare: 'prepare', prediction: 'prepare', encoding: 'combined',@@ -136,8 +199,11 @@ function activityLabel(message, t, plan = {}, secondPass = false, references = f}[phase] || labelActivities.get(message.stage);if (!key) return null;if (key === 'refine') return {key: 'upscale', text: t('Second pass · upscaling', '二采 · 放大')};- // One sentence for the whole encoding stage. The engine names images in its- // steps either way; only a request with reference media says so.+ // Named encoder and post-sampling events stay distinct, even before a pause.+ const substage = SUBACTIVITY_LABELS[message.label] || (key === 'reference' ? 'reference' : null);+ if (substage) return {key: ['prompt', 'combined', 'reference'].includes(key) ? 'encode' : key,+ text: t(...SUBACTIVITY[substage])};+ // Older or unnamed encoding events keep the safe generic activity.if (key === 'prompt' || key === 'combined' || key === 'reference')return {key: 'encode', text: t(...ACTIVITY[references ? 'combined' : 'prompt'])};// LoRA preparation counts LoRA files, then the model counts its own blocks:@@ -322,6 +388,8 @@ export function createGenerationProgress(t, now = () => Date.now(), {compact = flet pauseAnnounced = false, lastExplanation = '', announcedMessages = new Set();let announcementRecord = null;let remainingSeconds = null;+ let detail = null, localShare = null, decodeMinutes = null, decodeMinutesAt = -Infinity;+ const workShares = new Map();let completedSteps = 0, previousRemaining = null, remainingAt = 0, lastActivity = null;// Once the shown time reaches zero before the video is saved, it stays hidden for this request.// The last minute runs on real time even while an estimate holds the number.@@ -390,7 +458,7 @@ export function createGenerationProgress(t, now = () => Date.now(), {compact = fif (id === reportId) report.textContent = t('Report unavailable · retry', '报告暂不可用 · 重试');} finally { if (id === reportId) report.disabled = false; }};- const counted = value => Number.isInteger(value.total) && value.total > 0 && Number.isInteger(value.done)+ const hasCount = value => Number.isInteger(value.total) && value.total > 0 && Number.isInteger(value.done)&& value.done >= 0 && value.done <= value.total;function drawOverall() {@@ -436,25 +504,23 @@ export function createGenerationProgress(t, now = () => Date.now(), {compact = f// A segment can take several minutes. Extended silence gets a notice once;// leave the run going, and// offer the report, whose engine log shows the step it stopped at.- let stallHasReport = null, stallLoading = null;+ let stallHasReport = null;+ const segmentTypical = () => detail?.sampling && valid(state.estimated_step_seconds)+ ? state.estimated_step_seconds : overall.typical_seconds;function drawStall(age, ended) {const floor = STALL_SECONDS_BY_PHASE[state.phase || state.timing_phase] ?? STALL_SECONDS_BY_PHASE.other;- const threshold = Math.max(floor, valid(overall.typical_seconds) ? 2 * overall.typical_seconds : 0);+ const typical = segmentTypical();+ const threshold = Math.max(floor, valid(typical) ? 2 * typical : 0);const shown = !ended && age >= threshold;const wasShown = !stall.hidden;const hasReport = reportId !== null;- // Shown after 3 minutes, without saying so: the card shows two times only.- const loading = (state.phase || state.timing_phase) === 'load';- if (shown && (stall.hidden || hasReport !== stallHasReport || loading !== stallLoading)) {- const first = loading- ? t('No loading progress for a while. Generation is still running, so you can keep waiting.',- '已经有一段时间没有新的加载进度,生成仍在进行,可以继续等待。')- : t('No progress for a while. Generation is still running, so you can keep waiting.',+ // The separate notice never adds another clock or blocks the run.+ if (shown && (stall.hidden || hasReport !== stallHasReport)) {+ const first = t('No progress for a while. Generation is still running, so you can keep waiting.','已经有一段时间没有新的进度,生成仍在进行,可以继续等待。');const sentence = hasReport ? first + t(' You can also use Download report below and submit the report in a GitHub issue; we will look into it and work on a fix for you.','也可以点击下方的“下载报告”并提交到 GitHub issue,我们会专门排查和优化,为您解决这个问题。') : first;- stallLoading = loading;if (hasReport) {const buttonName = el('span', ''); buttonName.style.whiteSpace = 'nowrap';buttonName.textContent = t('Download report', '“下载报告”');@@ -491,10 +557,12 @@ export function createGenerationProgress(t, now = () => Date.now(), {compact = flet holdUntil = 0, holdMode = null, holdFraction = null;function miniTarget() {const key = lastActivity?.key;- const counted = value => Number.isFinite(value?.[0]) && Number.isFinite(value?.[1]) && value[1] > 0+ const ratio = value => Number.isFinite(value?.[0]) && Number.isFinite(value?.[1]) && value[1] > 0? Math.max(0, Math.min(1, value[0] / value[1])) : null;if (key === 'download' || key === 'load' || key === 'lora' || key === 'decode' || key === 'encode') {- const share = counted([state.done, state.total]);+ if (localShare !== null && hasCount(state) && ['load', 'decode'].includes(detail?.key))+ return {mode: 'determinate', fraction: localShare};+ const share = ratio([state.done, state.total]);if (share !== null) return {mode: 'determinate', fraction: share};// Slow without a count (an older engine, an audio pass): sweep only.return {mode: 'indeterminate'};@@ -517,7 +585,7 @@ export function createGenerationProgress(t, now = () => Date.now(), {compact = f// The current stage has lasted 2 s: the stage line names it from now on.function settle(at) {if (stageId !== null && stageId !== labelId && at - stageSince >= 2000) {- labelId = stageId; labelText = lastActivity?.text ?? labelText; away = null;+ labelId = stageId; labelText = lastActivity ? withWorkPercent(lastActivity.text) : labelText; away = null;}}function enterStage(id, at) {@@ -562,17 +630,22 @@ export function createGenerationProgress(t, now = () => Date.now(), {compact = fif (!lastActivity) { labelId = null; return t(...ACTIVITY.prepare); }settle(now());if (labelId === null) { labelId = stageId; away = null; }- if (labelId === stageId) labelText = lastActivity.text;+ if (labelId === stageId) labelText = withWorkPercent(lastActivity.text);return labelText;}+ function withWorkPercent(base) {+ const percent = localShare === null ? null : Math.min(localShare === 1 ? 100 : 99, Math.floor(localShare * 100 + 1e-9));+ // Keep the percentage with its own sentence while a new stage waits to be named.+ return percent !== null && (detail?.key === 'load' || detail?.key === 'decode')+ ? base + t(` (${percent}% of this step)`, `(本步 ${percent}%)`) : base;+ }function drawActivity(age, ended) {- const base = ended ? (overall.status === 'complete' || state.phase === 'complete' ? savedText() : t('Stopped', '已停止'))- : stageText();const paused = !ended && age > 15;- // Two times only (elapsed, remaining): a pause shows on the small bar, not as text.- if (label.textContent !== base) label.textContent = base;+ const base = ended ? (overall.status === 'complete' || state.phase === 'complete' ? savedText() : t('Stopped', '已停止'))+ : paused ? detail?.text || stageText() : stageText();+ const shown = !ended && paused && detail ? withWorkPercent(base) : base;+ if (label.textContent !== shown) label.textContent = shown;drawMini(age, ended);- const firstSlow = state.phase === 'sampling' && state.stage !== 'latent_upscale' && state.done === 0 && paused;const automatic = compatibility?.origin === 'automatic' && compatibility.level > 0;const required = Number.isInteger(compatibility?.recovery_successes_required) && compatibility.recovery_successes_required > 0? compatibility.recovery_successes_required : 3;@@ -583,17 +656,33 @@ export function createGenerationProgress(t, now = () => Date.now(), {compact = f: t(remaining === 1 ? 'Generation is slowed automatically for stability; it speeds up after one more successful generation.': `Generation is slowed automatically for stability; it speeds up after ${remaining} more successful generations.`,`为了稳定,生成已自动放慢;再连续完成 ${remaining} 次后会加快一些。`) : '';- if (compatibilityNote.textContent !== compatibilityText) {- compatibilityNote.textContent = compatibilityText;- compatibilityNote.hidden = !compatibilityText;- layout();+ // All explanations share one row, including automatic compatibility.+ compatibilityNote.hidden = true;+ let pauseText = '';+ if (paused) {+ const elapsed = waitDuration((now() - segmentStartedAt) / 1000, t);+ const typical = segmentTypical(), usual = valid(typical) && typical > 0 ? waitDuration(typical, t) : '';+ const similar = overall.typical_source === 'similar';+ pauseText = t(`${elapsed} so far`, `已进行 ${elapsed}`);+ if (usual) pauseText += similar ? t(` (about ${usual} on similar hardware)`, `(相近配置约 ${usual})`)+ : t(` (usually about ${usual})`, `(通常约 ${usual})`);}- const level = ended ? '' : recovery ? 'retry' : firstSlow ? 'first-step'- : lowMemory ? 'memory' : memoryTight ? 'unified-memory' : compatibility && !automatic && compatibility.level > 0 ? 'compatibility' : trims.size ? 'notice' : '';+ // Only an available engine estimate can supply this long-decode fallback.+ const remainingEstimate = rawRemaining();+ if (!ended && detail?.key === 'decode' && valid(remainingEstimate) && remainingEstimate >= 180) {+ const minutes = Math.ceil(remainingEstimate / 60);+ if (decodeMinutes === null || now() - decodeMinutesAt >= 60000 && Math.abs(minutes - decodeMinutes) >= 1) {+ decodeMinutes = minutes; decodeMinutesAt = now();+ }+ } else { decodeMinutes = null; decodeMinutesAt = -Infinity; }+ const decodeEta = decodeMinutes === null ? '' : t(`About ${decodeMinutes} min left`, `还需约 ${decodeMinutes} 分钟`);+ const progressText = [paused ? pauseText : '', decodeEta].filter(Boolean).join(t(' · ', ','));+ const level = ended ? '' : recovery ? 'retry' : paused ? 'pause'+ : lowMemory ? 'memory' : memoryTight ? 'unified-memory' : automatic ? 'automatic'+ : compatibility && compatibility.level > 0 ? 'compatibility' : trims.size ? 'notice' : '';const explanation = {retry: recovery,- 'first-step': t('The first run at this size, or after an update, takes longer to start.',- '首次使用这个尺寸或更新后,开头要多花一些时间。'),- memory: t('This generation uses low-memory mode; it is slower than usual but will finish.',+ pause: progressText,+ memory: t('This video uses a memory-saving mode, so it takes longer than usual but will finish.','这次生成使用省显存方式,会比平时慢,但能完成。'),// Mac, level 3 with low-memory mode (never both). The measured numbers go to the// report only. Closing applications during the first pass can still give the@@ -605,21 +694,28 @@ export function createGenerationProgress(t, now = () => Date.now(), {compact = f'可用的统一内存较少,这次生成会比平时慢。'),compatibility: compatibility ? t(`Compatibility setting ${compatibility.name_en} is on, so generation is slower than usual.`,`已开启兼容性设置(${compatibility.name_zh}档),生成会比平时慢。`) : '',- notice: trimStatus([...trims.values()], t)}[level] || '';+ automatic: compatibilityText,+ notice: trimStatus([...trims.values()], t)}[level] || (!ended ? progressText : '');if (status.textContent !== explanation) status.textContent = explanation;status.hidden = !explanation; status.dataset.level = level;const announcements = [];- if (paused && !pauseAnnounced) { announcements.push(base); pauseAnnounced = true; }- for (const text of [compatibilityText, explanation !== lastExplanation ? explanation : '']) {+ const pauseKey = `pause:${segmentKey}`;+ if (paused && !pauseAnnounced) {+ if (!announcedMessages.has(pauseKey)) announcements.push(base);+ announcedMessages.add(pauseKey); pauseAnnounced = true;+ }+ // Seconds and local percentages are visual only. Announce the work once.+ const spoken = level === 'pause' || explanation === progressText ? '' : explanation;+ for (const text of [spoken !== lastExplanation ? spoken : '']) {if (!text || announcedMessages.has(text)) continue;announcements.push(text); announcedMessages.add(text);- if (announcementRecord) {- announcementRecord.messages = [...announcedMessages];- try { sessionStorage.setItem(announcementKey, JSON.stringify(Object.fromEntries(requestAnnouncements))); }- catch { /* In-memory deduplication still works. */ }- }}- lastExplanation = explanation;+ if (announcementRecord && announcements.length) {+ announcementRecord.messages = [...announcedMessages];+ try { sessionStorage.setItem(announcementKey, JSON.stringify(Object.fromEntries(requestAnnouncements))); }+ catch { /* Optional storage; in-memory deduplication remains. */ }+ }+ lastExplanation = spoken;if (announcements.length) live.textContent = announcements.join(t(' ', ''));}@@ -735,6 +831,7 @@ export function createGenerationProgress(t, now = () => Date.now(), {compact = frecovery = ''; lowMemory = false; compatibility = null; references = false; trims.clear();memoryTight = null; firstPassOver = false;samplingPlan = {}; secondPass = false; hasHeartbeat = false;+ detail = null; localShare = null; workShares.clear(); decodeMinutes = null; decodeMinutesAt = -Infinity;announcementRecord = null;}if (!placeholderReset && (message.stream_id !== undefined || terminal)) placeholder = false;@@ -753,6 +850,7 @@ export function createGenerationProgress(t, now = () => Date.now(), {compact = fconst heartbeat = beat && previousProgress !== null;if (message.reset === true) {hasHeartbeat = false; lastActivity = null;+ workShares.clear(); localShare = null; decodeMinutes = null; decodeMinutesAt = -Infinity;// A stage restarting its own count (the sampler's start) leaves the// bridge's whole-request estimate standing; a retry starts afresh.if (estimateSource && !message.retry && message.phase !== 'recovery') { completedSteps = 0; previousRemaining = null; }@@ -762,6 +860,14 @@ export function createGenerationProgress(t, now = () => Date.now(), {compact = f// sampler's own start, keeps the stage's clock and the 2 s rule.if (miniFraction > 0) resetMini();}+ if (!heartbeat && message.retry && message.phase === 'recovery') {+ // Resource retries do not carry reset=true. Clear only the new attempt's work.+ const retryId = JSON.stringify(message.retry);+ if (retryId !== JSON.stringify(state.retry)) {+ workShares.clear(); localShare = null; resetMini();+ decodeMinutes = null; decodeMinutesAt = -Infinity;+ }+ }if (beat) hasHeartbeat = true;if (!heartbeat && message.phase === 'sampling' && valid(message.done))completedSteps = Math.max(completedSteps, message.done);@@ -826,13 +932,24 @@ export function createGenerationProgress(t, now = () => Date.now(), {compact = fenterStage(activity.key === 'download' ? `download:${state.stage || state.phase}` : activity.key, receivedAt);lastActivity = activity;}- const key = JSON.stringify([state.phase || state.timing_phase, state.stage,- state.phase === 'sampling' ? [state.done, state.total] : [state.label, lastActivity?.text]]);+ detail = subactivity(state, lastActivity, t);+ localShare = null;+ if (['load', 'decode'].includes(detail.key) && lastActivity?.key !== 'lora') {+ const shareKey = `${detail.key}:${secondPass ? 'second' : 'first'}`;+ const share = hasCount(state) ? state.done / state.total+ : state.label === 'Video model ready' ? 1 : null;+ if (share !== null) workShares.set(shareKey, Math.max(workShares.get(shareKey) ?? 0, share));+ localShare = workShares.get(shareKey) ?? null;+ }+ const key = JSON.stringify([detail.key, detail.sampling ? [lastActivity?.key, state.done] : null]);if (key !== segmentKey || message.reset) {segmentKey = key;- segmentStartedAt = receivedAt - (state.phase === 'sampling' && valid(message.step_elapsed_seconds)+ segmentStartedAt = receivedAt - (detail.sampling && valid(message.step_elapsed_seconds)? message.step_elapsed_seconds * 1000 : 0);pauseAnnounced = false;+ if (detail.sampling && !('estimated_step_seconds' in message)) delete state.estimated_step_seconds;+ } else if (detail.sampling && valid(message.step_elapsed_seconds)) {+ segmentStartedAt = Math.min(segmentStartedAt, receivedAt - message.step_elapsed_seconds * 1000);}element.dataset.phase = message.phase || message.timing_phase || '';if (message.overall && typeof message.overall === 'object') {@@ -850,6 +967,7 @@ export function createGenerationProgress(t, now = () => Date.now(), {compact = fif (timer !== null) clearInterval(timer); timer = null; state = {}; overall = {}; shownFraction = null;stopCount(); countShown = null;resetRemaining(); lastActivity = null; resetMini(); previousProgress = null; segmentKey = ''; status.textContent = ''; live.textContent = '';+ detail = null; localShare = null; workShares.clear(); decodeMinutes = null; decodeMinutesAt = -Infinity;// Last: the layout callback sizes the node from the cleared state.drawStall(0, true);}