refactor: merge Final2x-core into the Final2x repo - #704
Conversation
Add a precision config field (fp32/fp16/bf16, default fp32) and map it to cccv's fp16/bf16 arguments. bf16 avoids the fp16 numerical overflow that yields NaN output on some transformer models, at the same VRAM savings as fp16. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add a precision selector to the settings page (default fp32) that is sent to the core. bf16 keeps fp16's VRAM savings without the overflow that produces black/NaN output on some transformer models. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request integrates the Python-based core backend (packages/core) directly into the monorepo, replacing the external Final2x-core repository. It adds image super-resolution processing using cccv and PyTorch, introduces new precision settings (FP32, FP16, BF16) with corresponding UI controls and localization, and sets up build and version synchronization scripts. Feedback on the changes includes addressing a potential AttributeError when image decoding fails, leveraging Pydantic's built-in validation for configuration fields, supporting device indices in PyTorch device selection, and cleaning up redundant code and misleading error messages.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
Pull request overview
Refactors Final2x into a monorepo by bringing the Python “core” backend into packages/core, aligning desktop + PyPI releases on a single version source, and updating CI/release automation to build core artifacts locally instead of downloading prebuilt bundles.
Changes:
- Added a precision (fp32/fp16/bf16) setting to the renderer UI and included it in the core config payload.
- Introduced monorepo core version sync + local core bundling/staging scripts; removed the old “download core release” script.
- Reworked CI and Release workflows to run frontend checks, core lint/tests/builds, package publishing, and GitHub releases in one pipeline.
Reviewed changes
Copilot reviewed 47 out of 64 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/shared/type/core.ts | Extends shared core config typing with precision. |
| src/renderer/src/views/Final2xSettings.vue | Adds precision selector UI and wiring to the settings store. |
| src/renderer/src/utils/SROptions.ts | Defines selectable precision options for the UI. |
| src/renderer/src/utils/getFinal2xCoreConfig.ts | Includes precision in the generated core config payload. |
| src/renderer/src/store/SRSettingsStore.ts | Adds persisted precision setting (default fp32). |
| src/renderer/src/locales/zh.ts | Adds locale strings for precision UI/help text. |
| src/renderer/src/locales/ja.ts | Adds locale strings for precision UI/help text. |
| src/renderer/src/locales/fr.ts | Adds locale strings for precision UI/help text. |
| src/renderer/src/locales/en.ts | Adds locale strings for precision UI/help text. |
| scripts/sync-core-version.mjs | Adds version/tag validation and sync between desktop and Python core. |
| scripts/stage-core.mjs | Stages locally-built core bundle into resources/Final2x-core. |
| resources/download-core.js | Removes legacy script that downloaded core bundles from a separate repo release. |
| README.md | Updates project references to reflect the new monorepo core location/versioning. |
| pnpm-workspace.yaml | Introduces pnpm workspace config and attempted overrides/built-deps settings. |
| packages/core/tests/util.py | Test helpers for loading images and validating SR output. |
| packages/core/tests/test_targetscale.py | Adds tests for target scale behavior. |
| packages/core/tests/test_srqueue.py | Adds tests for queue behavior and invalid image handling. |
| packages/core/tests/test_singleton.py | Adds tests for singleton utilities. |
| packages/core/tests/test_save_format.py | Adds tests for output save format variations. |
| packages/core/tests/test_progresslog.py | Adds tests for progress logging behavior. |
| packages/core/tests/test_device.py | Adds tests for device parsing behavior. |
| packages/core/tests/test_config.py | Adds tests for config parsing/serialization and precision validation. |
| packages/core/tests/init.py | Initializes core test package. |
| packages/core/scripts/post_pyinstaller.py | Post-processes PyInstaller output (copies config into dist bundle). |
| packages/core/scripts/gen_pretrained_model_name.py | Generates checked-in frontend model options from Python registry. |
| packages/core/scripts/gen_config.py | Generates example config YAML for core/CI usage. |
| packages/core/scripts/CItestpip.py | Adds a CLI smoke-test script for CI usage. |
| packages/core/README.md | Documents the Python core package now maintained in the monorepo. |
| packages/core/pyproject.toml | Defines Python package metadata, dependencies, and tooling config. |
| packages/core/Makefile | Adds core dev/test/lint/build shortcuts (uv/ruff/mypy/pytest/pyinstaller). |
| packages/core/LICENSE | Adds BSD-3-Clause license for the core package. |
| packages/core/Final2x_core/util/singleton.py | Adds singleton utility implementation. |
| packages/core/Final2x_core/util/progressLog.py | Adds progress logging singleton used by core processing. |
| packages/core/Final2x_core/util/device.py | Adds device parsing/resolution helper for torch/DirectML/default device. |
| packages/core/Final2x_core/util/init.py | Exposes core utility helpers. |
| packages/core/Final2x_core/SRqueue.py | Adds SR queue processing logic for batches of images. |
| packages/core/Final2x_core/SRclass.py | Adds SR wrapper for cccv model inference with precision options. |
| packages/core/Final2x_core/config.py | Adds pydantic config model + validation (precision, target_scale, device). |
| packages/core/Final2x_core/main.py | Adds CLI entrypoint for the core package. |
| packages/core/Final2x_core/init.py | Exposes core API surface (SRConfig/SRWrapper/sr_queue). |
| packages/core/.gitignore | Ignores venv/build/dist/artifacts for the core package. |
| package.json | Adds monorepo scripts (version sync/check, core lint/test/build/bundle) and pnpm metadata. |
| eslint.config.js | Updates lint ignores for Python/core artifacts and staged core bundle. |
| electron-builder.yml | Excludes core sources from app packaging inputs while shipping staged core via extraResources. |
| docs/releasing.md | Documents new release model, version syncing, and PyPI Trusted Publisher setup. |
| .gitignore | Ignores core build outputs, core venv, and coverage artifacts. |
| .github/workflows/Release.yml | Reworks release workflow to validate version/tag, build artifacts, publish PyPI, and create GitHub Release. |
| .github/workflows/CI-test.yml | Splits CI into frontend, core, and python-package jobs with generation checks and coverage upload. |
| .github/workflows/CI-build.yml | Updates build workflow to build desktop artifacts per-platform with locally-built core bundles. |
Comments suppressed due to low confidence (1)
electron-builder.yml:19
resources/Final2x-coreis gitignored and is only created bycore:bundle, but Linux CI jobs build the desktop app without runningcore:bundle. BecauseextraResourcesis configured at the top level,electron-builderwill fail when the directory is missing. ScopeextraResourcesto Windows/macOS (or ensure the directory exists for Linux builds).
- '!packages/core/**'
- '!resources/Final2x-core/**'
asarUnpack:
- resources/*.png
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Final2x-coreproject under the top-levelcore/directorypackage.jsonCI and release model
Frontend checks remain in
CI-test.yml. The newCI-test-core.ymlpreserves the former Final2x-core coverage:All Core commands are invoked through root pnpm shortcuts. GitHub Actions dependency caching is explicitly disabled for every
setup-uvuse.Release.ymlcontains no smoke tests or test suites. Its validate job checks only the shared version and tag. Desktop jobs build their artifacts normally. The PyPI job checks out the same commit, builds wheel and sdist in place, and publishes directly through GitHub OIDC without transferring Python distributions between jobs.package.jsonremains the release version source.pnpm run version:syncupdates the Python PEP 621 version and lockfile. One-time maintainer setup is documented indocs/releasing.md.Desktop bundle flow
The original Final2x workflows downloaded Core into
resources/Final2x-corebeforepnpm run build:*. The monorepo workflows preserve that boundary:core:bundlecreatescore/dist/Final2x-core, then CI-build and Release copy it directly intoresources/before the desktop build. macOS usescp -Rto preserve PyInstaller relative symlinks, Windows usesCopy-Item -Recurse, and no custom staging script is involved.The self-contained macOS regression check stays in CI-build, where tests belong. It is intentionally absent from Release.
Local validation
Precision switching is not part of this migration because the pinned CCCV version does not support the proposed behavior. It can be implemented in a follow-up PR after the dependency supports it.