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.

Keep package names off the install card, keep the working card for imports, and keep retry...

Bowen Xueebba7600d670
diff --git a/freevideo_engine/bootstrap.py b/freevideo_engine/bootstrap.py
index 63c5270..784f697 100644
--- a/freevideo_engine/bootstrap.py
+++ b/freevideo_engine/bootstrap.py
@@ -1399,7 +1399,7 @@ class Installer:
key = str(index) + '-' + label
title, detail = setup_task(label)
if label == 'models' and self.plan.get('local_models'):
- title, detail = 'Reuse models / download missing files', 'Import verified local models; source files stay in place'
+ title, detail = 'Reuse models / download missing files', 'Uses models already on this computer; original files stay in place'
self.ui.begin(key, title, detail=str(log) if self.ui.verbose else detail)
initial = ('Python downloading' if title == 'Install Python' else
'Environment creating' if title == 'Create Python environment' else '')
@@ -1408,6 +1408,7 @@ class Installer:
progress = LogProgress(log)
parallel_tasks = set()
models_step = label == 'models'
+ build_step = label == 'sage2-build'
def update_progress(*, final=False):
self.ui.update(key, **progress.read(final=final))
if progress.model_groups is not None:
@@ -1415,6 +1416,9 @@ class Installer:
if models_step and getattr(self, 'model_bytes_callback', None):
self.model_bytes_callback(progress.model_groups)
progress.model_groups = None
+ fraction = progress.compile_fraction()
+ if build_step and fraction is not None and getattr(self, 'build_callback', None):
+ self.build_callback(min(fraction, .95))
for name, details in progress.take_tasks().items():
subkey = key + '-' + name
label, state = details.pop('label'), details.pop('state')
@@ -2022,11 +2026,12 @@ class Installer:
tasks, pythons, comfy = self.component_tasks(uv)
total = len(tasks) + 4 # Bootstrap, preparation, checks and final readiness.
phase = 'Install with space saver' if self.plan.get('disk_mode') == 'extreme' else 'Install components in parallel'
- weighted = dict(finished=set(), fetched=0, shown=1.)
+ weighted = dict(finished=set(), fetched=0, built=0., shown=1.)
+ build_bytes = INSTALL_PHASE_BUILD_BYTES if self.system != 'Windows' and 'sage' in tasks else 0
def publish():
with self.state_lock:
units = install_phase_units(len(tasks), weighted['finished'], self.plan.get('model_download_bytes') or 0,
- weighted['fetched'])
+ weighted['fetched'], build_bytes, weighted['built'])
# Never step back: a restarted file may report fewer bytes for a moment.
weighted['shown'] = done = max(weighted['shown'], 1 + units)
self.ui.phase(phase, done, total)
@@ -2044,6 +2049,12 @@ class Installer:
for group in groups or ())
publish()
self.model_bytes_callback = model_bytes
+ def built(fraction):
+ if fraction <= weighted['built']:
+ return # A repeated heartbeat adds nothing to show.
+ weighted['built'] = fraction
+ publish()
+ self.build_callback = built
self.ui.phase(phase, 1, total)
results = run(tasks, self.cancel, progress=scheduling,
workers=1 if self.plan.get('disk_mode') == 'extreme' else 3)
@@ -2080,19 +2091,32 @@ class Installer:
INSTALL_PHASE_OTHER_BYTES = 6 * 2**30
-def install_phase_units(tasks, finished, download_bytes, fetched_bytes):
+# The GPU acceleration build is one task of the phase but takes minutes, so it
+# weighs in the same way: as a share of the phase that advances with its counter.
+INSTALL_PHASE_BUILD_BYTES = 3 * 2**30
+
+
+def install_phase_units(tasks, finished, download_bytes, fetched_bytes, build_bytes=0, built=0.):
"""Units of the parallel install phase completed, out of ``tasks``.
Counting finished tasks left the overall bar still for the whole model
download (one task, most of the time). That task now takes a share of the
- phase in proportion to its bytes and advances with the bytes fetched.
+ phase in proportion to its bytes and advances with the bytes fetched. With
+ ``build_bytes`` the compile task does the same, advancing with ``built``
+ (the fraction of its compile steps done).
"""
- if download_bytes <= 0:
+ if download_bytes <= 0 and build_bytes <= 0:
return len(finished)
- share = download_bytes / (download_bytes + INSTALL_PHASE_OTHER_BYTES)
- others = len(finished - {'models'})
- models = 1. if 'models' in finished else min(1., max(0, fetched_bytes) / download_bytes)
- return tasks * ((1 - share) * others / max(1, tasks - 1) + share * models)
+ # Only a task that has its own share leaves the ordinary count; one without
+ # (nothing to download, no build on this platform) counts like any other.
+ weighted = ({'models'} if download_bytes > 0 else set()) | ({'sage'} if build_bytes > 0 else set())
+ others = len(finished - weighted)
+ count = max(1, tasks - len(weighted))
+ models = 1. if 'models' in finished else min(1., max(0, fetched_bytes) / download_bytes) if download_bytes > 0 else 0.
+ build = 1. if 'sage' in finished else min(1., max(0., built))
+ done = (INSTALL_PHASE_OTHER_BYTES * others / count
+ + max(0, download_bytes) * models + max(0, build_bytes) * build)
+ return tasks * done / (INSTALL_PHASE_OTHER_BYTES + max(0, download_bytes) + max(0, build_bytes))
class Prefetcher:
diff --git a/freevideo_engine/comfy_launcher_runtime.py b/freevideo_engine/comfy_launcher_runtime.py
index 94ea39b..81d8795 100644
--- a/freevideo_engine/comfy_launcher_runtime.py
+++ b/freevideo_engine/comfy_launcher_runtime.py
@@ -853,6 +853,16 @@ class Controller:
return
offset += count
+ def open_ceiling(self):
+ """How far through the last section the start-up wait may show: the whole bar stays under 97%."""
+ total = sum(count for _, count in self.sections)
+ offset = 0
+ for key, count in self.sections:
+ if key == 'open':
+ return max(0., min(.9, (.97 * total - offset) / count)) if count else 0.
+ offset += count
+ return 0.
+
@property
def busy(self):
return self.thread is not None and self.thread.is_alive()
@@ -1308,8 +1318,16 @@ class Controller:
self.state = dict(self.state, task=dict(progress=dict(label='Starting ComfyUI', detail='Loading nodes and the web interface'), log=plain(directory)))
waiting_since = time.monotonic()
extended = False
+ shown = 0.
+ # Start-up has no countable steps. The bar creeps through the last section and stays below the
+ # displayed 97%, so a long start never reads as nearly done and then waits there.
+ ceiling = self.open_ceiling()
while True:
now = time.monotonic()
+ fraction = round(ceiling * (1 - 1 / (1 + (now - waiting_since) / 30)), 2)
+ if self.section == 'open' and fraction >= shown + .02:
+ shown = fraction
+ self.stage('open', done=fraction, label=(self.state.get('overall') or {}).get('label', 'Open ComfyUI'))
if self.cancelled.is_set():
with self._server_lock:
if self.server is server:
diff --git a/freevideo_engine/launcher/Main.qml b/freevideo_engine/launcher/Main.qml
index d2f5b53..f2554ce 100644
--- a/freevideo_engine/launcher/Main.qml
+++ b/freevideo_engine/launcher/Main.qml
@@ -254,7 +254,8 @@ ApplicationWindow {
Rectangle {
Layout.fillWidth: true; Layout.bottomMargin: 8; implicitHeight: busyBody.implicitHeight + 28
radius: theme.radiusMd; color: theme.surface; border.color: theme.border
- opacity: s.busy ? 1 : 0; visible: opacity > 0
+ // Waiting for the person to confirm the plan is not work in progress.
+ opacity: s.working ? 1 : 0; visible: opacity > 0
Behavior on opacity { NumberAnimation { duration: 240; easing.type: Easing.OutCubic } }
ColumnLayout {
id: busyBody; x: 14; y: 14; width: parent.width - 28; spacing: 8
@@ -938,7 +939,7 @@ ApplicationWindow {
text: s.setup_pending ? s.setup_wait_text : s.busy ? t("Working…", "正在处理…") : primaryText()
enabled: !s.busy && !s.setup_pending && !(s.page === "launcher" && s.needs_consent && !accepted)
&& !(s.page === "progress" && s.status === "review" && !s.retry_kind && (!accepted || !!s.error))
- onClicked: { if (s.retry_kind) { backend.action("retry", accepted); return } if (needsRuntime) { backend.browseRuntimePackage(); return } if (needsPackages) { backend.browsePackages(); return } if (updateFirst) { backend.update(""); return } backend.action(s.page === "launcher" && s.status === "open" ? "browser" : "primary", accepted); if (s.busy && s.page === "launcher") terminalOpen = true }
+ onClicked: { if (s.retry_kind) { backend.action("retry", accepted); return } if (needsRuntime) { backend.browseRuntimePackage(); return } if (needsPackages) { backend.browsePackages(); return } if (updateFirst) { backend.update(""); return } backend.action(s.page === "launcher" && s.status === "open" ? "browser" : "primary", accepted) }
}
}
}
diff --git a/freevideo_engine/launcher_copy.py b/freevideo_engine/launcher_copy.py
index d34e076..88eb37b 100644
--- a/freevideo_engine/launcher_copy.py
+++ b/freevideo_engine/launcher_copy.py
@@ -153,7 +153,10 @@ ZH.update([
('Packages preparing', '正在准备组件'), ('Packages removing', '正在移除旧组件'),
('Model files verifying', '正在校验模型文件'), ('Model files preparing', '正在准备模型文件'),
('Model files assembling', '正在合并模型文件'),
- ('Package files', '离线包文件'),
+ ('Package files', '离线包文件'), ('Connecting to download server', '正在连接下载服务器'),
+ ('Runtime components', '运行组件'), ('video model', '视频模型'), ('video decoder', '视频解码器'),
+ ('model files', '模型文件'), ('runtime components', '运行组件'),
+ ('Uses models already on this computer; original files stay in place', '使用电脑上已有的模型,不移动原文件'),
])
# Card lines for steps that only report counts (the terminal keeps the counts).
ZH.update([('Downloading components', '正在下载组件'), ('Preparing components', '正在准备组件'),
@@ -192,8 +195,63 @@ def lan_error(value, zh=False):
return value
+MODEL_FILE = re.compile(r'[\w.+-]+\.(?:safetensors|gguf|bin|pth?|ckpt|onnx|json|txt|model)', re.I)
+# A whole path to a model file, with a folder the user chose and any characters in its names.
+MODEL_PATH = re.compile(r'(?:[A-Za-z]:)?[\\/][^·]*[\\/][^\\/·]+\.(?:safetensors|gguf|bin|pth?|ckpt|onnx)', re.I)
+# One downloaded package or archive: MinGit-2.55.0.5.zip, a wheel with a local version, uv.zip.
+PACKAGE_FILE = re.compile(r'[\w.+-]+\.(?:zip|whl|tar\.gz|tgz|tar\.xz|7z|exe|msi)', re.I)
+SHARD_FILE = re.compile(r'diffusion_pytorch_model-\d+-of-(\d+)\.safetensors')
+# Components are named, never their file or package names.
+FILE_GROUPS = {14: 'video model', 3: 'video decoder'}
+
+
+def file_group(name):
+ """The group a model file belongs to, in lower case for use inside a sentence."""
+ name = re.sub(r' · shard \d+ / \d+$', '', name)
+ name = name.replace('\\', '/').rsplit('/', 1)[-1]
+ shard = SHARD_FILE.fullmatch(name)
+ if shard:
+ return FILE_GROUPS.get(int(shard[1]), 'model files')
+ if MODEL_FILE.fullmatch(name):
+ return 'model files'
+ if PACKAGE_FILE.fullmatch(name):
+ return 'runtime components'
+ return re.sub(r' · shard \d+ / \d+$', '', name)
+
+
+def names_a_file(rest):
+ """Whether what follows a verb is one file or group name; a sentence or a count such as "3 / 2" is not."""
+ rest = re.sub(r' · shard \d+ / \d+$', '', rest)
+ return bool(rest) and ' · ' not in rest and ' / ' not in rest and not rest.startswith('/')
+
+
+def without_names(value):
+ """Lines the launcher shows, without file or package names; known sentences and states stay as they are."""
+ if value in ZH or value in SOURCES:
+ return value
+ match = re.fullmatch(r'Connecting to [^·]+(?: · .*)?', value)
+ if match:
+ return 'Connecting to download server'
+ for prefix in ('Verified ', 'Verify ', 'Download ', 'Assemble downloaded parts · '):
+ if value.startswith(prefix) and names_a_file(value[len(prefix):]):
+ group = file_group(value[len(prefix):])
+ if group[:1].isupper() and group.split(' ')[0].lower() in ('video', 'audio', 'text', 'model'):
+ group = group[:1].lower() + group[1:]
+ return prefix.split(' · ')[0].rstrip() + ('' if prefix.startswith('Assemble') else ' ' + group)
+ if ' · ' in value:
+ return ' · '.join('Model files' if MODEL_FILE.fullmatch(part) else
+ 'Runtime components' if PACKAGE_FILE.fullmatch(part) else part for part in value.split(' · '))
+ if MODEL_FILE.fullmatch(value) or MODEL_PATH.fullmatch(value):
+ return 'Model files'
+ if PACKAGE_FILE.fullmatch(value):
+ return 'Runtime components'
+ if re.fullmatch(r'[a-z0-9][a-z0-9_.]*[-_.][a-z0-9_.-]*', value) and re.search(r'[a-z]', value):
+ return 'Runtime components'
+ return value
+
+
def display(value, zh=False):
- value = clean(value)
+ value = without_names(clean(value))
if not zh:
# English names for stages whose internal names describe how they run, not what they do.
return {'检查配套包': 'Checking packages', '下载模型': 'Downloading models',
@@ -208,10 +266,10 @@ def display(value, zh=False):
return ' · '.join(display(part, True) for part in value.split(' · '))
for prefix, translated in (
MODEL_REPAIR_PROGRESS,
- ('Switched current download to ', '已切换至 '), ('Connecting to ', '正在连接 '),
+ ('Switched current download to ', '已切换至 '), ('Connecting to ', '正在连接'),
('Assemble downloaded parts', '合并已下载文件'), ('Reuse verified FP8 ', '复用模型缓存 '),
- ('Prepare FP8 ', '准备模型缓存 '), ('Verified ', '已校验 '), ('Verify ', '正在校验 '),
- ('Download ', '下载 '), ('Prepare ', '准备 '), ('Source: ', '下载源:'), ('Log: ', '日志:'),
+ ('Prepare FP8 ', '准备模型缓存 '), ('Verified ', '已校验'), ('Verify ', '正在校验'),
+ ('Download ', '正在下载'), ('Prepare ', '准备 '), ('Source: ', '下载源:'), ('Log: ', '日志:'),
):
if value.startswith(prefix):
return translated + display(value[len(prefix):], True)
diff --git a/freevideo_engine/launcher_session.py b/freevideo_engine/launcher_session.py
index 5f1ca3c..4196df3 100644
--- a/freevideo_engine/launcher_session.py
+++ b/freevideo_engine/launcher_session.py
@@ -1886,6 +1886,10 @@ class Session:
zh = self.language.startswith('zh')
row = self.controller.state
busy = self.controller.busy or self.importer.busy or self.cleaner.busy
+ # The sidebar card shows work being done; a plan waiting for confirmation is not work, but an
+ # import or a cleanup started from that page is.
+ working = bool(self.importer.busy or self.cleaner.busy
+ or (self.controller.busy and row.get('status') != 'review'))
task = row.get('task', {})
port_from = int(row['moved_from']) if row.get('status') == 'open' and 'moved_from' in row else 0
port_to = (urlsplit(row.get('selection', {}).get('url') or row['url']).port or 80) if port_from else 0
@@ -2060,7 +2064,7 @@ class Session:
download_state.update(error=self.t(*DOWNLOAD_COPY['error_read']), needs_check=True)
return plain_data(dict(download_list=download_state, sampling_cache_bytes=total_bytes(), version=__version__, image_pack=image_pack,
disk=disk, decimal_sizes=sys.platform == 'darwin', zh=self.language.startswith('zh'), form=dict(self.form),
- page=self.page, status=row.get('status', 'idle'), busy=busy,
+ page=self.page, status=row.get('status', 'idle'), busy=busy, working=working,
action_notice=self.t(*ACTION_COPY[self.action_notice]) if self.action_notice else '',
setup_pending=bool(self.pending_action), setup_wait_text=self.t(*ACTION_COPY['setup_queued']),
can_manage=self.can_manage(), busy_reason=self.t(*ACTION_COPY['busy']),
diff --git a/freevideo_engine/setup_progress.py b/freevideo_engine/setup_progress.py
index fb3baa7..29b6082 100644
--- a/freevideo_engine/setup_progress.py
+++ b/freevideo_engine/setup_progress.py
@@ -11,6 +11,13 @@ def number(value):
and math.isfinite(value) and value >= 0)
+MODEL_ACTIVITIES = ('download', 'verify', 'assemble', 'copy', 'copy_bytes', 'check', 'resume')
+
+
+VERB_ACTIVITIES = ('verify', 'assemble', 'copy_bytes', 'check', 'copy', 'download')
+COMPONENT_NAMES = ('Video ', 'Text ', 'Sampling ', 'Image ', 'Model', 'Runtime components')
+
+
class ProgressState:
def __init__(self):
self.phase = {}
@@ -26,8 +33,11 @@ class ProgressState:
self.model_groups = event.get('groups', [])
return
if event.get('kind') == 'phase':
+ # A parallel compiler re-sends the running phase with a larger count
+ # every moment; only a different phase ends a retry notice.
+ if event.get('label') != self.phase.get('label'):
+ self.download_notices.clear()
self.phase = event
- self.download_notices.clear()
return
key = str(event.get('key', 'current'))
if event.get('kind') == 'progress' and key.startswith('download-patient-'):
@@ -53,8 +63,12 @@ class ProgressState:
def snapshot(self, now=None):
now = time.monotonic() if now is None else now
active = [self._view(row, now) for row in self.tasks.values() if row.get('state') == 'running']
- # Keep a download visible while a parallel compiler reports a heartbeat.
- active.sort(key=lambda row: (number(row.get('total')) and row['total'] > 0,
+ # Keep model work visible while a parallel compiler reports a heartbeat,
+ # also in the moments a file is only being connected or verified (no
+ # byte total yet); otherwise the line would alternate between the two.
+ def models(row):
+ return (row.get('unit') == 'bytes' or row.get('activity') in MODEL_ACTIVITIES) and row['age_seconds'] <= 30
+ active.sort(key=lambda row: (models(row), number(row.get('total')) and row['total'] > 0,
row.get('unit') == 'bytes'), reverse=True)
current = active[0] if active else self._view(self.last, now)
if self.download_notices:
@@ -101,6 +115,11 @@ def progress_text(event, zh=False, *, decimal_sizes=False):
"""One activity line for the launcher, including known transfer and scan counts."""
t = lambda en, cn: cn if zh else en
activity, name = event.get('activity'), event.get('name') or ''
+ # A Chinese name follows its verb directly; a Latin one (Python) keeps a space.
+ gap = ' ' if name[:1].isascii() and name[:1].isalnum() else ''
+ if not zh and activity in VERB_ACTIVITIES and (
+ name.startswith(COMPONENT_NAMES) or any(name == en for en, _ in NAMES.values())):
+ name = name[:1].lower() + name[1:] # In the middle of a sentence.
if activity == 'count':
done, total = event.get('done'), event.get('total')
if number(done) and number(total) and total > 0 and done <= total:
@@ -110,21 +129,20 @@ def progress_text(event, zh=False, *, decimal_sizes=False):
verb = {'verify': ('Verifying ', '正在校验'), 'assemble': ('Assembling ', '正在合并'),
'copy_bytes': ('Copying ', '正在复制')}[activity]
# MiB rather than tenths of GiB: even slow disks change the visible text.
- parts = [t(*verb) + name]
+ parts = [t(verb[0], verb[1] + gap) + name]
done, total = event.get('done'), event.get('total')
- if event.get('unit') == 'bytes' and number(done) and number(total) and total > 0 and done <= total:
+ if event.get('unit') == 'bytes' and number(done) and number(total) and total >= 2**20 and done <= total:
parts.append('%d / %d %s' % (done // 2**20, total // 2**20, 'MiB'))
return ' · '.join(parts)
if activity == 'resume':
return t('The connection dropped; resuming the download and keeping what was already downloaded',
'连接中断,正在继续下载,已下载的部分会保留')
if activity in ('check', 'copy'):
- # Mid-sentence, a model family name starts in lower case in English; Chinese has no space after the verb.
- name = name[:1].lower() + name[1:] if any(name == en for en, _ in NAMES.values()) else name
- parts = [t('Checking ', '正在校验') + name if activity == 'check'
- else t('Copying ', '正在复制') + name]
+ parts = [t('Checking ', '正在校验' + gap) + name if activity == 'check'
+ else t('Copying ', '正在复制' + gap) + name]
done, total = event.get('done'), event.get('total')
- if event.get('unit') == 'bytes' and number(done) and number(total) and total > 0 and done <= total:
+ # Below 1 KiB the size would read "0 / 0 KiB".
+ if event.get('unit') == 'bytes' and number(done) and number(total) and total >= 1024 and done <= total:
parts.extend(transfer_parts(done, total, event.get('rate'), decimal_sizes))
return ' · '.join(parts)
if activity == 'note':
@@ -135,6 +153,6 @@ def progress_text(event, zh=False, *, decimal_sizes=False):
return ' · '.join(parts + transfer_parts(0, 0, event.get('rate'), decimal_sizes))
if activity == 'download':
total = event.get('total') if event.get('unit') == 'bytes' else 0
- return ' · '.join([t('Downloading ', '正在下载 ') + name] +
+ return ' · '.join([t('Downloading ', '正在下载' + gap) + name] +
transfer_parts(event.get('done'), total or 0, event.get('rate'), decimal_sizes))
return ''
diff --git a/freevideo_engine/terminal_ui.py b/freevideo_engine/terminal_ui.py
index 730e16f..e6ef021 100644
--- a/freevideo_engine/terminal_ui.py
+++ b/freevideo_engine/terminal_ui.py
@@ -328,6 +328,23 @@ class LogProgress:
self.model_backend = ''
self.parallel_tasks = {}
self.model_groups = None
+ # Ninja runs several times during one build, each with its own count.
+ self.compile_before, self.compile_last, self.compile_runs = 0, (0, 0), 0
+
+ def compile_fraction(self):
+ """How far the compile has advanced, never reaching 1; None before any step.
+
+ The number of runs is unknown until the build ends, so a finished run
+ cannot mean "done": each run advances the share of the range still left
+ by half, in proportion to its own counter. A first run of two steps
+ followed by one of a hundred keeps moving instead of stopping at the
+ end of the first.
+ """
+ done, total = self.compile_last
+ if total <= 0:
+ return None
+ inside = min(1., max(0., done / total))
+ return 1 - .5 ** self.compile_runs + .5 ** (self.compile_runs + 1) * inside
def take_tasks(self):
tasks, self.parallel_tasks = self.parallel_tasks, {}
@@ -421,7 +438,18 @@ class LogProgress:
package_phase = ('remove', 'Packages removing') if 'Uninstalling' in text else (
('prepare', 'Packages preparing') if 'Preparing packages' in text else (
('install', 'Packages installing') if self.installing_packages else ('compile', 'GPU acceleration building')))
- update(done=int(match[1]), total=int(match[2]),
+ if package_phase[0] == 'compile':
+ done, total = int(match[1]), int(match[2])
+ if total != self.compile_last[1] or done < self.compile_last[0]:
+ self.compile_before += self.compile_last[1]
+ self.compile_runs += self.compile_last[1] > 0
+ self.compile_last = (done, total)
+ shown_done, shown_total = int(match[1]), int(match[2])
+ if package_phase[0] == 'compile':
+ # One count across the runs, so it never restarts from 1.
+ shown_done += self.compile_before
+ shown_total += self.compile_before
+ update(done=shown_done, total=shown_total,
activity='count', name=package_phase[1],
detail='Installing packages' if self.installing_packages else 'Compiling CUDA kernels',
scope='package-' + package_phase[0], unit='items')