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.

Editor shows the image model download state

Bowen Xue22f7bd62727b
diff --git a/freevideo_engine/image_gen/image_pack.py b/freevideo_engine/image_gen/image_pack.py
index f4d7088..79e64b3 100644
--- a/freevideo_engine/image_gen/image_pack.py
+++ b/freevideo_engine/image_gen/image_pack.py
@@ -8,6 +8,7 @@ or an optional busy callback. The CLI writes atomic, read-only status snapshots.
"""
from collections import deque
from contextlib import ExitStack, contextmanager
+import errno
import json
import logging
from pathlib import Path, PurePosixPath
@@ -263,6 +264,32 @@ def ready(root=None):
return status(root)['ready']
+def downloading(root=None, engine_root=None) -> bool:
+ """Probe the existing pack lease without creating files or waiting."""
+ try:
+ path = _path(base(root), 'pack.lock')
+ # install() holds this lease through transfers and generation pauses.
+ # A separate descriptor also detects a holder in this process.
+ with path.open('rb') as stream:
+ if sys.platform == 'win32':
+ import msvcrt
+ try:
+ msvcrt.locking(stream.fileno(), msvcrt.LK_NBRLCK, 1)
+ except OSError as error:
+ if error.errno not in (errno.EACCES, errno.EAGAIN, errno.EDEADLK):
+ raise
+ return True
+ else:
+ import fcntl
+ try:
+ fcntl.flock(stream, fcntl.LOCK_EX | fcntl.LOCK_NB)
+ except BlockingIOError:
+ return True
+ return False
+ except Exception:
+ return False
+
+
@contextmanager
def _lease(root, engine_root=None, destructive=False):
if root is None and engine_root is None:
diff --git a/freevideo_engine/image_gen/service.py b/freevideo_engine/image_gen/service.py
index 9dae7ed..ebdc69f 100644
--- a/freevideo_engine/image_gen/service.py
+++ b/freevideo_engine/image_gen/service.py
@@ -89,9 +89,11 @@ class Service:
return self._busy
def info(self):
- _, machine = self.installation()
+ engine_root, machine = self.installation()
spec = image_pack.catalog()
- return dict(ready=image_pack.ready(machine['model_root']), model=spec['repo'],
+ ready = image_pack.ready(machine['model_root'])
+ return dict(ready=ready, model=spec['repo'],
+ downloading=not ready and image_pack.downloading(machine['model_root'], engine_root),
bytes=sum(row['bytes'] for row in spec['groups']['image']), busy=self.busy(),
max_images=MAX_IMAGES)
diff --git a/web/image_generation.js b/web/image_generation.js
index 5144aed..52f7aa2 100644
--- a/web/image_generation.js
+++ b/web/image_generation.js
@@ -5,7 +5,7 @@ import {orientMatrix, rasterKinds, scaleSelection} from './image_editor_engine.j
export const IMAGE_GEN_PROTOCOL = Object.freeze({
root: '/freevideo/image-gen', header: 'X-FreeVideo-Image', upload: '/upload/image',
- installed: 'ready', phase: 'phase', bytes: 'bytes',
+ installed: 'ready', phase: 'phase', bytes: 'bytes', downloading: 'downloading',
token: 'token', job: 'job', prompt: 'prompt', width: 'width', height: 'height', images: 'images', seed: 'seed',
stage: 'stage', fraction: 'fraction', file: 'file', error: 'error', name: 'name', subfolder: 'subfolder',
states: {starting: 'queued', progress: 'running', complete: 'done', failed: 'error',
@@ -100,12 +100,16 @@ export function imagePackMessage(info, t) {
return t(`Download "${name}" in the launcher first, ${size}.`, `先在启动器里下载“${name}”,${size}。`);
}
export function imageGenError(code, info, t) {
- if (code === 'pack_missing') return imagePackMessage(info, t);
+ if (code === 'pack_missing') return imagePackUnavailableMessage(info, t);
if (code === 'busy_video') return t('A video is generating. Try again when it finishes.', '视频正在生成,完成后再试。');
if (code === 'no_memory') return t('Not enough GPU memory. Make the picture smaller in "Image size…" and try again.',
'显存不足。在“图像大小…”里缩小后再试。');
return t('The image could not be generated. Try again.', '没有生成成功,请再试一次。');
}
+function imagePackUnavailableMessage(info, t) {
+ return info?.[IMAGE_GEN_PROTOCOL.downloading]
+ ? t('Downloading. Available when finished.', '正在下载,完成后可用。') : imagePackMessage(info, t);
+}
// The service accepts 256..2048 on each side; a larger canvas is generated at its
// fitted size and the result is laid over the canvas like any other layer.
@@ -368,7 +372,7 @@ export function createImageGeneration({client, renderer, t, getDoc, getSelection
action.classList.toggle('fv-ie-primary', !state.running);
action.disabled = !state.running && (disabled || !prompt.trim()); action.hidden = !!missing;
const percent = Math.floor(state.fraction * 100) + '%';
- note.textContent = missing ? imagePackMessage(state.info, t) : state.error ? imageGenError(state.error, state.info, t)
+ note.textContent = missing ? imagePackUnavailableMessage(state.info, t) : state.error ? imageGenError(state.error, state.info, t)
: state.running ? (state.stage === 'load' ? t('Loading the model', '加载模型') + ' ' : '') + percent : '';
note.hidden = !note.textContent;
bar.dataset.running = String(state.running); bar.dataset.message = String(!!missing || !!state.error);