Files
AnyImage/docs/internals/operators/upscale.md
nan 32bcd45d7b Add new node asset scripts for geometry and shader operations
- Implemented `build_mesh_plane.py` to create a geometry node group for mesh planes with customizable parameters.
- Created `build_shadeless.py` for a shader node group that displays color without scene lighting while preserving shadows and reflections.
- Added `validate.py` to validate the integrity of the newly created node groups and their inputs.
- Introduced `validate_cutout.py` to ensure the functionality of cutout node groups and their dependencies.
- Developed `validate_mesh_plane.py` to test the mesh plane creation and its modifier settings.
2026-08-30 00:17:29 +08:00

2.0 KiB
Raw Blame History

Upscale

本页对应 src/anyimage/operators/upscale.py。该模块读取扩展首选项中的模型与全局 AI 输入长边上限,提交 4× 高清任务,并维护高清结果到原始 Image 的引用。

对应文件

src/anyimage/
├── operators/
│   ├── upscale.py                 # Blender 入口、任务参数与结果替换
│   └── common/image.py            # 媒体输入准备与结果 Image 创建
└── server/
    ├── jobs/upscale.py            # 单图与多帧任务编排
    ├── media/resolution.py        # 共用长边限制与等比缩放
    ├── models/upscale.py          # 输入约束与 Alpha 合并
    └── models/onnx_upscale.py     # 分块 4× ONNX 推理

主流程

flowchart TD
    Empty["Image Empty"] --> Source["解析原始 Image"]
    Source --> Prepare["准备媒体输入"]
    Prepare --> Job["upscale-image Job"]
    Job --> Limit["按全局输入长边上限等比缩放"]
    Limit --> RGB["分块执行 4× RGB 推理"]
    Limit --> Alpha["独立缩放 Alpha"]
    RGB --> Merge["合并 RGBA 结果"]
    Alpha --> Merge
    Merge --> Replace["导入并替换当前 Image"]

模型以 256×256 分块处理 RGB,并带入相邻上下文以减弱块边界;Alpha 按同一受限输入尺寸单独缩放,最后合并为 RGBA。max_input_size 来自全局 Maximum AI Input Size,默认 2048,只约束送入模型的长边;4× 输出长边因此默认为最多 8192。输入尺寸不超过上限时不会发生预缩放。

结果以 _upscale.png 结尾,并通过 Image.anyimage_upscale_source 保存原图引用。再次对高清结果执行时,Operator 会从原图重新生成,而不是继续放大上一次输出。模型与全局输入上限在每次执行时从 Preferences 读取,再写入可序列化的隐藏属性交给 Job。Provider 资源错误会释放当前 Upscale Session,并提示降低全局输入上限或改用 CPU。