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.

Give the image generation models a download list of their own

Bowen Xuee175f031aaac
diff --git a/freevideo_engine/launcher/Main.qml b/freevideo_engine/launcher/Main.qml
index 824d96f..43ced31 100644
--- a/freevideo_engine/launcher/Main.qml
+++ b/freevideo_engine/launcher/Main.qml
@@ -36,7 +36,7 @@ ApplicationWindow {
property bool compact: width < 1000
property bool narrow: width < 640
property bool shortWindow: height < 700
- onModelInfoOpenChanged: if (modelInfoOpen) backend.prepareDownloadList()
+ onModelInfoOpenChanged: if (modelInfoOpen) backend.prepareDownloadList(); else backend.setDownloadScope("video")
readonly property bool manualEnvironment: s.offline.runtime_supported !== false && s.form.new_comfy && s.form.environment_method === "manual"
readonly property bool usingRuntime: manualEnvironment && s.offline.runtime
readonly property bool needsRuntime: s.page === "comfy" && manualEnvironment && !s.offline.runtime
@@ -634,7 +634,7 @@ ApplicationWindow {
delegate: FButton { required property var modelData; required property int index; objectName: "offlineShare-" + index; text: t("Download from Quark ↗", "打开夸克网盘 ↗"); onClicked: backend.link(modelData.url) }
}
FText { objectName: "offlinePackageGuide"; text: s.offline.guide; color: theme.muted; font.pixelSize: theme.micro; Layout.fillWidth: true }
- FButton { objectName: "otherModelLinks"; text: downloads.copy.title + " ›"; flat: true; enabled: !s.busy; implicitHeight: theme.heightSm; leftPadding: 0; font.pixelSize: theme.micro + 1; onClicked: modelInfoOpen = true }
+ FButton { objectName: "otherModelLinks"; text: downloads.copy.title + " ›"; flat: true; enabled: !s.busy; implicitHeight: theme.heightSm; leftPadding: 0; font.pixelSize: theme.micro + 1; onClicked: { backend.setDownloadScope("video"); modelInfoOpen = true } }
}
ColumnLayout {
Layout.fillWidth: true; Layout.preferredWidth: 1; Layout.alignment: Qt.AlignTop; spacing: 10
@@ -800,7 +800,7 @@ ApplicationWindow {
}
// What this group downloads, as in the plan; nothing for one already here.
FText { objectName: "modelSize-" + modelData.id; visible: modelData.download > 0; text: bytes(modelData.download).replace(" ", "\u00a0"); font.pixelSize: theme.micro; color: theme.muted; font.features: { "tnum": 1 } }
- FButton { objectName: "modelFiles-" + modelData.id; text: downloads.copy.title + " ›"; implicitHeight: theme.heightSm; flat: true; font.pixelSize: theme.micro + 1; visible: s.form.model_method === "manual"; onClicked: modelInfoOpen = true }
+ FButton { objectName: "modelFiles-" + modelData.id; text: downloads.copy.title + " ›"; implicitHeight: theme.heightSm; flat: true; font.pixelSize: theme.micro + 1; visible: s.form.model_method === "manual"; onClicked: { backend.setDownloadScope(modelData.id === "image" ? "image" : "video"); modelInfoOpen = true } }
}
}
}
@@ -1617,13 +1617,13 @@ ApplicationWindow {
RowLayout {
objectName: "downloadListActions"; Layout.fillWidth: true; Layout.minimumWidth: 0; spacing: 8
// The actions share what the Close button leaves, so a long label wraps instead of leaving the dialog.
- readonly property int actionCount: checkDownloadList.visible ? 3 : 2
+ readonly property int actionCount: (checkDownloadList.visible ? 1 : 0) + (downloads.scope === "image" ? 1 : 2)
readonly property real actionWidth: Math.max(80, Math.floor((width - closeDownloadList.implicitWidth - (actionCount + 1) * spacing) / actionCount))
FButton { id: closeDownloadList; text: downloads.copy.close; flat: true; onClicked: modelInfoOpen = false }
Item { Layout.fillWidth: true }
- FButton { id: checkDownloadList; objectName: "checkDownloadList"; Layout.maximumWidth: parent.actionWidth; visible: !downloads.available || s.download_list.needs_check; text: downloads.copy.check; enabled: !s.busy; onClicked: backend.prepareDownloadList() }
- FButton { objectName: "useDownloadedFolder"; Layout.maximumWidth: parent.actionWidth; text: downloads.copy.use_folder; enabled: s.can_manage; onClicked: backend.useDownloadedFolder() }
- FButton { objectName: "exportDownloadList"; Layout.maximumWidth: parent.actionWidth; text: downloads.copy.export; primary: true; enabled: downloads.available && !s.busy; onClicked: backend.exportDownloadList() }
+ FButton { id: checkDownloadList; objectName: "checkDownloadList"; Layout.maximumWidth: parent.actionWidth; visible: downloads.scope !== "image" && (!downloads.available || s.download_list.needs_check); text: downloads.copy.check; enabled: !s.busy; onClicked: backend.prepareDownloadList() }
+ FButton { objectName: "useDownloadedFolder"; visible: downloads.scope !== "image"; Layout.maximumWidth: parent.actionWidth; text: downloads.copy.use_folder; enabled: s.can_manage; onClicked: backend.useDownloadedFolder() }
+ FButton { objectName: "exportDownloadList"; Layout.maximumWidth: parent.actionWidth; text: downloads.copy.export; primary: true; enabled: downloads.available && (downloads.scope === "image" || !s.busy); onClicked: backend.exportDownloadList() }
}
}
}
diff --git a/freevideo_engine/launcher_session.py b/freevideo_engine/launcher_session.py
index 7107733..311d1b3 100644
--- a/freevideo_engine/launcher_session.py
+++ b/freevideo_engine/launcher_session.py
@@ -21,7 +21,8 @@ from .launcher_copy import ACTION_COPY, size_text
from .launcher_terminal import Tail
from .model_status import FAMILIES, NAMES
from .model_guidance import (package_instructions, video_instructions, runtime_packages_supported, download_view,
- export_download_list, DownloadListError, DOWNLOAD_COPY)
+ export_download_list, DownloadListError, DOWNLOAD_COPY,
+ image_download_view, export_image_download_list, IMAGE_COPY)
from .setup_progress import LineHold, ModelLine, progress_text
from .terminal_ui import clean, duration
from .model_upgrade import TARGET
@@ -145,6 +146,9 @@ class Session:
self.image_installer = self.prompt_installer = None
self.download_export = self.download_error = self.download_error_key = ''
self._download_view = None
+ # 'image' opens the image model's own list, which needs no file check; any other value is the video list.
+ self.download_scope = 'video'
+ self._image_download_view = None
self.browser_attempted = False
self.browser_url = None
self.port_notice_url = None
@@ -346,7 +350,15 @@ class Session:
kept = [p for p in self.form['model_dirs'] if io_path(Path(p).expanduser()).is_dir()]
self.edit('model_dirs', library_roots(kept + [folder]))
+ def set_download_scope(self, scope):
+ scope = 'image' if scope == 'image' else 'video'
+ if scope != self.download_scope:
+ self.download_scope = scope
+ self.download_export = self.download_error = self.download_error_key = ''
+
def prepare_download_list(self):
+ if self.download_scope == 'image':
+ return
if self.controller.busy or self.importer.busy or self.cleaner.busy:
return
if (self.controller.state.get('plan', {}).get('download_files_verified')
@@ -361,12 +373,14 @@ class Session:
def export_downloads(self, folder):
"""The dialog shows a worded error; nothing raises into a traceback."""
self.download_export = self.download_error = self.download_error_key = ''
- if self.controller.busy or self.controller.state.get('status') != 'review':
+ image = self.download_scope == 'image'
+ if not image and (self.controller.busy or self.controller.state.get('status') != 'review'):
self.download_error = self.t('Wait for the file check to finish.', '请等待文件检查完成。')
return
preferences = download_preferences(self.engine_root() / 'download-settings.json')
try:
- self.download_export = export_download_list(self.controller.state.get('plan', {}), folder, preferences['source'])
+ self.download_export = (export_image_download_list(folder, preferences['source'], self._image_location()[0]) if image else
+ export_download_list(self.controller.state.get('plan', {}), folder, preferences['source']))
except DownloadListError as error:
self.download_error_key = error.key
reason = ''
@@ -376,7 +390,8 @@ class Session:
from .failure_details import redacted_launcher_error
print('Download list export failed (%s): %s' % (error.reason, redacted_launcher_error(error.original_error)),
file=sys.stderr)
- self.download_error = self.t(*DOWNLOAD_COPY['error_' + error.key]).format(reason=reason)
+ texts = dict(DOWNLOAD_COPY, error_changed=IMAGE_COPY['error_changed']) if image else DOWNLOAD_COPY
+ self.download_error = self.t(*texts['error_' + error.key]).format(reason=reason)
def use_downloaded_folder(self, folder):
if not self.can_manage():
@@ -388,6 +403,12 @@ class Session:
self.prepare_download_list()
def downloads_view(self):
+ if self.download_scope == 'image':
+ zh, decimal_sizes = self.language.startswith('zh'), sys.platform == 'darwin'
+ key = (zh, decimal_sizes)
+ if self._image_download_view is None or self._image_download_view[0] != key:
+ self._image_download_view = (key, image_download_view(zh, decimal_sizes=decimal_sizes))
+ return self._image_download_view[1]
row = self.controller.state
plan = row.get('plan', {}) if row.get('status') == 'review' else {}
if not plan.get('download_files_verified', True):
diff --git a/freevideo_engine/model_guidance.py b/freevideo_engine/model_guidance.py
index de39f4e..fd93a26 100644
--- a/freevideo_engine/model_guidance.py
+++ b/freevideo_engine/model_guidance.py
@@ -13,7 +13,7 @@ import time
import uuid
from urllib.parse import urlsplit
-from . import network
+from . import __version__, network
from .long_paths import io_path, plain_errors
from .model_status import FAMILIES, NAMES, family
@@ -129,7 +129,7 @@ def download_files(entries):
return result
-def download_view(plan, zh=False, *, decimal_sizes=False):
+def download_view(plan, zh=False, *, decimal_sizes=False, families=LIST_FAMILIES, extra_copy=None):
from .launcher_copy import size_text
def size(value):
if value < (10**6 if decimal_sizes else 2**20):
@@ -137,9 +137,10 @@ def download_view(plan, zh=False, *, decimal_sizes=False):
return ('不到 1 ' if zh else 'under 1 ') + unit
return size_text(value, decimal_sizes=decimal_sizes)
copy = download_copy(zh)
+ copy.update({key: value[bool(zh)] for key, value in (extra_copy or {}).items()})
rows = plan.get('download_files', [])
groups = []
- for group in LIST_FAMILIES:
+ for group in families:
files = [dict(row, name=row['file'], size=size(row['bytes'])) for row in rows if row['group'] == group]
amount = sum(row['bytes'] for row in files)
groups.append(dict(id=group, title=copy[group], files=files, count=len(files), bytes=amount,
@@ -196,6 +197,10 @@ def export_download_list(plan, folder, source='auto'):
'SHA256SUMS': '\n'.join(sums) + ('\n' if sums else ''),
'urls.txt': '\n'.join(urls) + ('\n' if urls else ''),
'README.txt': DOWNLOAD_COPY['readme'][1] + '\n' + DOWNLOAD_COPY['readme'][0]}
+ return publish_export(folder, documents)
+
+
+def publish_export(folder, documents, folder_name=EXPORT_FOLDER, generator=GENERATOR):
# Finish every file before anything appears or is replaced. No payload is downloaded.
stage = None
try:
@@ -210,7 +215,7 @@ def export_download_list(plan, folder, source='auto'):
# Two launchers exporting into one folder take turns: the five files
# always come from the same export.
with export_lock(folder):
- target, earlier = export_target(folder)
+ target, earlier = export_target(folder, folder_name, generator)
if earlier:
replace_export(stage, target)
else:
@@ -224,6 +229,109 @@ def export_download_list(plan, folder, source='auto'):
return str(target)
+# The optional image model has its own list: files laid out as FreeVideo keeps them, one export folder of its own.
+IMAGE_FOLDER = 'image_gen'
+IMAGE_EXPORT_FOLDER = 'FreeVideo-image-model-download-list'
+IMAGE_GENERATOR = 'FreeVideo image model download list'
+IMAGE_COPY = {
+ 'image': NAMES['image'],
+ 'guide': ('Download the files with the exported list and place them as its README.txt describes. '
+ 'Back in the launcher, choose Resume on Image generation models; FreeVideo checks every file before using it.',
+ '用导出的清单下载这些文件,按清单里 README.txt 的说明放好。'
+ '回到启动器,在“图像生成模型”处点“继续”,FreeVideo 校验每个文件后才会使用。'),
+ # The list needs no re-check, so the shared "Check again" text does not apply.
+ 'error_changed': ('The download list could not be generated. Restart the launcher and try again.',
+ '下载清单未能生成,请重启启动器后再试。'),
+ # {model_folder} is replaced with the folder that holds image_gen.
+ 'readme': (
+ 'FreeVideo image generation models download list\n'
+ '\n'
+ 'Run this command in this folder:\n'
+ 'aria2c --input-file=aria2.txt --continue=true --check-integrity=true\n'
+ '\n'
+ 'You can also import urls.txt into another download tool. urls.txt uses the download source chosen in Settings (Automatic uses Hugging Face).\n'
+ '\n'
+ 'When the download finishes, copy the image_gen folder inside payload into the folder below, merging it with any image_gen folder already there:\n'
+ '{model_folder}\n'
+ 'Then return to the launcher and choose "Resume" on Image generation models. '
+ 'FreeVideo checks every file by its checksum and downloads again any file that is missing or damaged.\n'
+ '\n'
+ 'SHA256SUMS lists the checksum of every file. This list covers only the image generation models; the video model list is exported separately.\n',
+ 'FreeVideo 图像生成模型下载清单\n'
+ '\n'
+ '在这个文件夹里运行下面的命令:\n'
+ 'aria2c --input-file=aria2.txt --continue=true --check-integrity=true\n'
+ '\n'
+ '也可以把 urls.txt 导入其他下载工具。urls.txt 用的是设置里选中的下载源(选“自动”时用 Hugging Face)。\n'
+ '\n'
+ '下载完成后,把 payload 里的 image_gen 文件夹复制到下面这个文件夹,和其中已有的 image_gen 合并:\n'
+ '{model_folder}\n'
+ '然后回到启动器,在“图像生成模型”处点“继续”。FreeVideo 会按校验值逐个检查文件,缺少或损坏的文件会重新下载。\n'
+ '\n'
+ 'SHA256SUMS 列出每个文件的校验值。这份清单只含图像生成模型,视频模型的清单另外导出。\n'),
+}
+
+
+def image_files():
+ """The image model's files as list rows; the catalog ships with the engine and is validated on load."""
+ from .image_gen import image_pack
+ result = []
+ for row in image_pack.rows():
+ ids = {source['id'] for source in row['sources']}
+ link = lambda name: network.model_url(row, name, env={}) if name in ids else ''
+ result.append(dict(group='image', repo=row['repo'], hf_revision=row['revision'],
+ modelscope_repo='', modelscope_revision='', file=row['file'], bytes=row['bytes'], sha256=row['sha256'],
+ relative_path='/'.join(('payload', IMAGE_FOLDER, row['file'])),
+ hf_url=link('official'), hf_mirror_url=link('hf-mirror'), modelscope_url=link('modelscope')))
+ return result
+
+
+def image_download_view(zh=False, *, decimal_sizes=False):
+ view = download_view(dict(download_files=image_files()), zh, decimal_sizes=decimal_sizes,
+ families=('image',), extra_copy=IMAGE_COPY)
+ return dict(view, scope='image', reused='')
+
+
+def export_image_download_list(folder, source='auto', model_folder=None):
+ """Only the image model, with every source; nothing of the video list changes.
+
+ model_folder is where the README tells the user to put image_gen: the folder the
+ launcher looks in, or the installed model folder when none is given.
+ """
+ folder = Path(folder).expanduser().resolve()
+ if not folder.is_dir():
+ raise DownloadListError('folder')
+ if source not in ('auto', 'official', 'hf-mirror', 'modelscope'):
+ raise DownloadListError('changed')
+ if model_folder is None:
+ from .paths import installed_model_root
+ model_folder = installed_model_root()
+ rows = image_files()
+ aria, sums, urls, outputs = [], [], [], set()
+ for row in rows:
+ relative = row['relative_path']
+ path = PurePosixPath(relative)
+ if (path.is_absolute() or any(part in ('', '.', '..') for part in relative.split('/'))
+ or any(char in relative for char in '\\:\r\n\t\x00') or relative in outputs
+ or not re.fullmatch('[0-9a-f]{64}', row['sha256'] or '') or not row['hf_url']
+ or type(row['bytes']) is not int or row['bytes'] <= 0):
+ raise DownloadListError('changed')
+ outputs.add(relative)
+ aria.extend(['\t'.join(url for url in (row['hf_url'], row['hf_mirror_url'], row['modelscope_url']) if url),
+ ' dir=' + path.parent.as_posix(), ' out=' + path.name,
+ ' checksum=sha-256=' + row['sha256']])
+ sums.append(row['sha256'] + ' ' + relative)
+ chosen = {'official': 'hf_url', 'auto': 'hf_url', 'hf-mirror': 'hf_mirror_url', 'modelscope': 'modelscope_url'}[source]
+ urls.append(row[chosen] or row['hf_url'])
+ manifest = dict(schema_version=1, generator=IMAGE_GENERATOR, engine_version=__version__, source=source,
+ total_bytes=sum(row['bytes'] for row in rows), files=rows)
+ documents = {'manifest.json': json.dumps(manifest, ensure_ascii=False, indent=2) + '\n',
+ 'aria2.txt': '\n'.join(aria) + '\n', 'SHA256SUMS': '\n'.join(sums) + '\n',
+ 'urls.txt': '\n'.join(urls) + '\n',
+ 'README.txt': (IMAGE_COPY['readme'][1] + '\n' + IMAGE_COPY['readme'][0]).replace('{model_folder}', str(model_folder))}
+ return publish_export(folder, documents, IMAGE_EXPORT_FOLDER, IMAGE_GENERATOR)
+
+
def export_lock(folder, wait=30.):
"""Hold the cross-process lock of one export folder; waits for another export.
@@ -245,7 +353,7 @@ def export_lock(folder, wait=30.):
time.sleep(.1)
-def earlier_export(path):
+def earlier_export(path, generator=GENERATOR):
"""A folder this launcher exported before, identified by its manifest."""
try:
if path.is_symlink() or not path.is_dir():
@@ -253,18 +361,18 @@ def earlier_export(path):
value = json.loads((path / 'manifest.json').read_text(encoding='utf-8'))
except (OSError, ValueError):
return False
- return isinstance(value, dict) and value.get('generator') == GENERATOR
+ return isinstance(value, dict) and value.get('generator') == generator
-def export_target(folder):
+def export_target(folder, name=EXPORT_FOLDER, generator=GENERATOR):
"""(folder, earlier): our earlier export is refreshed; anything else is left alone."""
for index in range(1, 100):
- path = folder / (EXPORT_FOLDER if index == 1 else '%s-%d' % (EXPORT_FOLDER, index))
+ path = folder / (name if index == 1 else '%s-%d' % (name, index))
if not os.path.lexists(path):
return path, False
- if earlier_export(path):
+ if earlier_export(path, generator):
return path, True
- raise OSError(errno.EEXIST, 'Too many folders named ' + EXPORT_FOLDER)
+ raise OSError(errno.EEXIST, 'Too many folders named ' + name)
def replace_export(stage, target):
diff --git a/freevideo_engine/modern_launcher.py b/freevideo_engine/modern_launcher.py
index 14ce0bd..fac5388 100644
--- a/freevideo_engine/modern_launcher.py
+++ b/freevideo_engine/modern_launcher.py
@@ -191,13 +191,17 @@ def create_ui(session, *, show=True):
if path:
self.invoke(session.add_folder, path) if key == 'model_dirs' else self.invoke(session.edit, key, path)
+ @Slot(str)
+ def setDownloadScope(self, scope):
+ self.invoke(session.set_download_scope, scope)
+
@Slot()
def prepareDownloadList(self):
self.invoke(session.prepare_download_list)
@Slot()
def exportDownloadList(self):
- if session.controller.busy:
+ if session.controller.busy and session.download_scope != 'image':
return
path = QFileDialog.getExistingDirectory(None, session.downloads_view()['copy']['export'], '', QFileDialog.ShowDirsOnly)
if path: