Skip to content

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.

Name the reference-image waits: upload and read stages in image generation, a spinner on the...

Bowen Xue2309bc6a446f
diff --git a/freevideo_engine/comfy_editor.py b/freevideo_engine/comfy_editor.py
index 29d36e5..55287b0 100644
--- a/freevideo_engine/comfy_editor.py
+++ b/freevideo_engine/comfy_editor.py
@@ -844,6 +844,7 @@ def list_imports(root):
fields = ('id', 'name', 'kind', 'state', 'fraction', 'reason', 'frames', 'fps', 'width', 'height',
'preview_width', 'preview_height', 'has_audio')
row = {k: value.get(k) for k in fields}
+ row['started'] = bool(value.get('started'))
for side in ('width', 'height'):
row['preview_' + side] = value.get('preview_' + side, value.get(side))
row['preview'] = '/freevideo/editor/media?' + urlencode(dict(id=child.name, file='preview')) if value['state'] == 'ready' else None
@@ -929,7 +930,7 @@ def transcode(root, identity):
if vin is None and ain is None:
raise ValueError('No media')
kind = 'video' if vin is not None else 'audio'
- _import_update(root, identity, kind=kind)
+ _import_update(root, identity, kind=kind, started=True)
seconds = max((clip_seconds(reader, s) or 0 for s in (vin, ain) if s is not None), default=0)
origin = Fraction(vin.start_time or 0) * vin.time_base if vin is not None else Fraction(ain.start_time or 0) * ain.time_base
with av.open(str(partial), 'w', format='mp4' if vin is not None else 'ipod', options={'movflags': 'faststart'}) as writer:
diff --git a/freevideo_engine/image_gen/qwen_pipeline.py b/freevideo_engine/image_gen/qwen_pipeline.py
index b0eeb89..475cfa6 100644
--- a/freevideo_engine/image_gen/qwen_pipeline.py
+++ b/freevideo_engine/image_gen/qwen_pipeline.py
@@ -306,8 +306,8 @@ class QwenImageGenerator:
ref_latents = []
if vae_images:
with self._stage("encode"):
- for image in vae_images:
- check_cancel()
+ for index, image in enumerate(vae_images):
+ report("encode", index / len(vae_images))
# Always tiled, whatever the memory plan: the latents (and so the picture)
# must not depend on the card, and the tiled pass needs far less memory.
encoded = _encoded_latents(
@@ -315,7 +315,7 @@ class QwenImageGenerator:
mean, std = self._stats(encoded)
encoded = (encoded - mean) / std
ref_latents.append(self._pack_latents(encoded, 1, channels, *encoded.shape[-2:]).to(embeds.dtype))
- check_cancel()
+ report("encode", 1.0)
keep_latents = cell_mask = None
if edit_mask is not None:
from . import region_edit
diff --git a/web/editor.css b/web/editor.css
index fa1681a..fbeee9c 100644
--- a/web/editor.css
+++ b/web/editor.css
@@ -115,6 +115,10 @@
.fv-ed-ref-chip{border-color:transparent;background:var(--fv-bg)}
.fv-ed-ref-add:not(:disabled):not([aria-disabled=true]):hover,.fv-ed-ref-add[aria-expanded=true],.fv-ed-ref-chip:not(:disabled):not([aria-disabled=true]):hover{border-color:var(--fv-accent);color:var(--fv-ink)}
.fv-ed-ref-add:disabled,.fv-ed-ref-chip:disabled,.fv-ed-ref-add[aria-disabled=true],.fv-ed-ref-chip[aria-disabled=true]{opacity:.4;cursor:default}
+.fv-ed-ref-add[data-uploading=true]{opacity:1;color:transparent}
+.fv-ed-ref-add[data-uploading=true]::after{content:'';position:absolute;inset:0;margin:auto;width:12px;height:12px;border:2px solid var(--fv-accent);border-right-color:transparent;border-radius:50%;animation:fv-ref-spin .9s linear infinite}
+@keyframes fv-ref-spin{to{transform:rotate(360deg)}}
+@media(prefers-reduced-motion:reduce){.fv-ed-ref-add[data-uploading=true]::after{animation:none}}
.fv-ed-ref-thumb{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;font-size:11px;color:var(--fv-muted)}
.fv-ed-ref-thumb img{display:block;width:100%;height:100%;object-fit:cover}
.fv-ed-ref-menu{position:absolute;bottom:calc(100% - 4px);min-width:180px;max-width:260px;padding:6px;background:var(--fv-card);border:1px solid var(--fv-border);border-radius:8px;z-index:12;display:flex;flex-direction:column;font:13px var(--fv-font)}
diff --git a/web/editor_library.js b/web/editor_library.js
index 17a1526..261d2ac 100644
--- a/web/editor_library.js
+++ b/web/editor_library.js
@@ -80,8 +80,12 @@ export function createEditorLibrary(host, {store, t, actions, state}) {
if (ready) picture.append(el('span', 'fv-ed-source-time', stamp(metadata(row, kind).frames)));
else if (row.state === 'failed') {
picture.append(el('span', 'fv-ed-source-preparing', row.reason === 'disk_full' ? t('Disk full', '磁盘已满') : t('Cannot open', '打不开')));
- } else picture.append(el('span', 'fv-ed-source-preparing', t('Preparing', '准备中')
- + (Number.isFinite(row.fraction) ? ` ${Math.round(Math.max(0, Math.min(1, row.fraction)) * 100)}%` : '')));
+ } else {
+ // Sending, then waiting behind another import, then being made; only the first and the last have a percentage.
+ const percent = Number.isFinite(row.fraction) ? ` ${Math.round(Math.max(0, Math.min(1, row.fraction)) * 100)}%` : '';
+ picture.append(el('span', 'fv-ed-source-preparing', row.sending ? t('Uploading', '上传中') + percent
+ : row.started ? t('Processing', '处理中') + percent : t('Queued', '排队中')));
+ }
button.append(picture);
const used = el('span', 'fv-ed-source-used'); used.append(editorIcon('check')); used.setAttribute('aria-label', t('Used', '已用')); used.hidden = true; picture.append(used);
button.ondblclick = () => requestAdd(row, kind);
@@ -220,7 +224,7 @@ export function createEditorLibrary(host, {store, t, actions, state}) {
const place = Number.isSafeInteger(at) && at >= 0 ? {at} : null;
for (const value of files) {
if (disposed) break;
- const id = 'upload-' + Math.random(), row = {id, name: value.name, kind: value.type.startsWith('audio') ? 'audio' : 'video', state: 'preparing', fraction: 0};
+ const id = 'upload-' + Math.random(), row = {id, name: value.name, kind: value.type.startsWith('audio') ? 'audio' : 'video', state: 'preparing', fraction: 0, sending: true};
uploading.set(id, row); render();
try {
const item = await store.upload(value, fraction => { row.fraction = fraction; render(); });
diff --git a/web/editor_references.js b/web/editor_references.js
index 35c0087..1dfc1d6 100644
--- a/web/editor_references.js
+++ b/web/editor_references.js
@@ -24,7 +24,7 @@ export function createEditorReferences({t, source, size = () => null, error = ()
const menu = el('div', 'fv-ed-ref-menu'); menu.hidden = true; menu.setAttribute('role', 'menu');
const picker = el('input'); picker.type = 'file'; picker.accept = 'image/*'; picker.multiple = true; picker.hidden = true;
root.append(add, chips, menu, picker);
- let shown = false, continuing = false, busy = false, working = false, opener = null, disposed = false, entries = [], waited = false;
+ let shown = false, continuing = false, busy = false, working = false, uploading = false, opener = null, disposed = false, entries = [], waited = false;
const active = () => source.rows().map((row, index) => ({row, index})).filter(({row}) => row.enabled !== false);
const isImage = file => IMAGE.test(file || '');
// The pictures this part uses: all of them, or the first reference images of a part that continues
@@ -80,7 +80,7 @@ export function createEditorReferences({t, source, size = () => null, error = ()
};
async function addFiles(files) {
if (working) return;
- working = true; update();
+ working = uploading = true; update();
let skipped = false;
try {
for (const file of files) {
@@ -91,7 +91,7 @@ export function createEditorReferences({t, source, size = () => null, error = ()
}
if (skipped && !disposed) notify(t('Could not read this picture. Please choose another one.', '无法读取这张图片,请换一张。'), ['Editor reference images', '剪辑器参考图']);
} catch (value) { error(value); }
- finally { working = false; picker.value = ''; update(); }
+ finally { working = uploading = false; picker.value = ''; update(); }
}
async function generate() {
if (working) return;
@@ -151,8 +151,9 @@ export function createEditorReferences({t, source, size = () => null, error = ()
const isFull = full();
// While a part is being made the controls stay clickable and say why they do nothing.
add.disabled = working;
+ add.dataset.uploading = String(uploading);
add.setAttribute('aria-disabled', String(busy || isFull));
- add.title = busy ? waitText() : isFull ? fullText() : t('Reference image', '参考图');
+ add.title = uploading ? t('Uploading reference image…', '正在上传参考图…') : busy ? waitText() : isFull ? fullText() : t('Reference image', '参考图');
chips.replaceChildren(...used().map(entry => {
const chip = el('button', 'fv-ed-ref-chip'); chip.type = 'button'; chip.disabled = working; chip.setAttribute('aria-disabled', String(busy));
chip.dataset.role = entry.row.role || 'reference';
diff --git a/web/image_generation.js b/web/image_generation.js
index 875a63e..c2dd08b 100644
--- a/web/image_generation.js
+++ b/web/image_generation.js
@@ -463,11 +463,13 @@ export function createImageGenSession({client, prepare, apply, onChange = () =>
async function start(request) {
if (state.running || disposed || !request.prompt.trim() || !state.info?.installed) return;
const current = ++epoch;
- emit({running: true, job: null, fraction: 0, stage: '', error: '', report_id: null, waiting: '', fitted: null});
+ // A picture that is edited sends its reference images first; there is no job to report on yet.
+ emit({running: true, job: null, fraction: 0, stage: request.mode === 'edit' ? 'upload' : '', error: '', report_id: null, waiting: '', fitted: null});
const alive = () => current === epoch && !disposed;
try {
const {context, images = [], mask} = await prepare(request, alive);
if (!alive()) return;
+ if (state.stage === 'upload') emit({stage: ''});
const withImages = images.length > 0;
const row = await client.generate({prompt: request.prompt, width: context.width, height: context.height, images, mask});
const {job} = row;
@@ -736,7 +738,9 @@ export function createImageGeneration({client, renderer, t, getDoc, getSelection
: state.running && state.waiting ? t(...(QUEUE_LABELS[state.waiting] || QUEUE_LABELS.image))
: state.running && state.fitted ? t(...memoryWords([`Not enough GPU memory. Retrying at ${state.fitted.width}\u00a0×\u00a0${state.fitted.height}`,
`显存不足,改用 ${state.fitted.width}\u00a0×\u00a0${state.fitted.height} 重试`], state.info?.unified_memory)) + ' · ' + percent
- : state.running ? (state.stage === 'load' ? t('Loading the model', '加载模型') + ' ' : '') + percent
+ : state.running && state.stage === 'upload' ? t('Uploading reference images', '正在上传参考图')
+ : state.running ? (state.stage === 'load' ? t('Loading the model', '加载模型') + ' '
+ : state.stage === 'encode' ? t('Reading reference images', '读取参考图') + ' ' : '') + percent
: state.fitted ? fittedNote(state.fitted, t, state.info?.unified_memory) : '';
}
note.hidden = !note.textContent;