upscale 0.5.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- upscale-0.5.1/LICENSE +21 -0
- upscale-0.5.1/NOTICE +6 -0
- upscale-0.5.1/PKG-INFO +149 -0
- upscale-0.5.1/README.md +78 -0
- upscale-0.5.1/pyproject.toml +103 -0
- upscale-0.5.1/setup.cfg +4 -0
- upscale-0.5.1/tests/test_about.py +72 -0
- upscale-0.5.1/tests/test_algorithms.py +235 -0
- upscale-0.5.1/tests/test_api.py +523 -0
- upscale-0.5.1/tests/test_api_queue_gpu_bench.py +131 -0
- upscale-0.5.1/tests/test_cancel.py +32 -0
- upscale-0.5.1/tests/test_checkpoint_quality.py +64 -0
- upscale-0.5.1/tests/test_cli.py +96 -0
- upscale-0.5.1/tests/test_compare_zip_api.py +159 -0
- upscale-0.5.1/tests/test_crop.py +92 -0
- upscale-0.5.1/tests/test_estimates.py +123 -0
- upscale-0.5.1/tests/test_filters.py +61 -0
- upscale-0.5.1/tests/test_help_security.py +61 -0
- upscale-0.5.1/tests/test_io.py +219 -0
- upscale-0.5.1/tests/test_locales.py +103 -0
- upscale-0.5.1/tests/test_mcp.py +32 -0
- upscale-0.5.1/tests/test_models_registry.py +61 -0
- upscale-0.5.1/tests/test_naming.py +56 -0
- upscale-0.5.1/tests/test_onnx_backend.py +90 -0
- upscale-0.5.1/tests/test_output_path.py +69 -0
- upscale-0.5.1/tests/test_passes.py +22 -0
- upscale-0.5.1/tests/test_pause.py +44 -0
- upscale-0.5.1/tests/test_pipeline_mmap.py +49 -0
- upscale-0.5.1/tests/test_resume_checkpoint_api.py +250 -0
- upscale-0.5.1/tests/test_run_server_thread.py +25 -0
- upscale-0.5.1/tests/test_schema.py +43 -0
- upscale-0.5.1/tests/test_seamless_wh.py +119 -0
- upscale-0.5.1/tests/test_security_models.py +62 -0
- upscale-0.5.1/tests/test_slim_import.py +30 -0
- upscale-0.5.1/tests/test_speed_stats.py +114 -0
- upscale-0.5.1/tests/test_spill_cancel.py +79 -0
- upscale-0.5.1/tests/test_strip_checkpoint.py +159 -0
- upscale-0.5.1/tests/test_strip_vs_full.py +56 -0
- upscale-0.5.1/tests/test_suggest_presets.py +55 -0
- upscale-0.5.1/tests/test_tiling.py +67 -0
- upscale-0.5.1/upscale/__init__.py +30 -0
- upscale-0.5.1/upscale/__main__.py +3 -0
- upscale-0.5.1/upscale/about.py +168 -0
- upscale-0.5.1/upscale/algorithms/__init__.py +166 -0
- upscale-0.5.1/upscale/algorithms/classical.py +82 -0
- upscale-0.5.1/upscale/algorithms/plugins/__init__.py +52 -0
- upscale-0.5.1/upscale/algorithms/plugins/texture_residual.py +117 -0
- upscale-0.5.1/upscale/algorithms/plugins/vectorize_scale.py +450 -0
- upscale-0.5.1/upscale/api/__init__.py +17 -0
- upscale-0.5.1/upscale/api/compare_routes.py +243 -0
- upscale-0.5.1/upscale/api/deps.py +18 -0
- upscale-0.5.1/upscale/api/jobs.py +516 -0
- upscale-0.5.1/upscale/api/models_routes.py +107 -0
- upscale-0.5.1/upscale/api/system_routes.py +200 -0
- upscale-0.5.1/upscale/backends/__init__.py +27 -0
- upscale-0.5.1/upscale/backends/onnx_rt.py +265 -0
- upscale-0.5.1/upscale/benchmark.py +96 -0
- upscale-0.5.1/upscale/checkpoint.py +258 -0
- upscale-0.5.1/upscale/cli.py +608 -0
- upscale-0.5.1/upscale/compare.py +202 -0
- upscale-0.5.1/upscale/config.py +56 -0
- upscale-0.5.1/upscale/engine.py +348 -0
- upscale-0.5.1/upscale/estimates.py +338 -0
- upscale-0.5.1/upscale/filters.py +180 -0
- upscale-0.5.1/upscale/help_content.py +94 -0
- upscale-0.5.1/upscale/infer_util.py +22 -0
- upscale-0.5.1/upscale/io_utils.py +616 -0
- upscale-0.5.1/upscale/job_prep.py +318 -0
- upscale-0.5.1/upscale/mcp_server.py +287 -0
- upscale-0.5.1/upscale/models.py +628 -0
- upscale-0.5.1/upscale/naming.py +63 -0
- upscale-0.5.1/upscale/pipeline.py +485 -0
- upscale-0.5.1/upscale/presets.py +127 -0
- upscale-0.5.1/upscale/quality.py +36 -0
- upscale-0.5.1/upscale/schema.py +315 -0
- upscale-0.5.1/upscale/server.py +1056 -0
- upscale-0.5.1/upscale/speed_stats.py +273 -0
- upscale-0.5.1/upscale/suggest.py +93 -0
- upscale-0.5.1/upscale/system.py +102 -0
- upscale-0.5.1/upscale/tiling.py +392 -0
- upscale-0.5.1/upscale/web.py +118 -0
- upscale-0.5.1/upscale.egg-info/PKG-INFO +149 -0
- upscale-0.5.1/upscale.egg-info/SOURCES.txt +85 -0
- upscale-0.5.1/upscale.egg-info/dependency_links.txt +1 -0
- upscale-0.5.1/upscale.egg-info/entry_points.txt +2 -0
- upscale-0.5.1/upscale.egg-info/requires.txt +53 -0
- upscale-0.5.1/upscale.egg-info/top_level.txt +1 -0
upscale-0.5.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Upscale contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
upscale-0.5.1/NOTICE
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
Third-party notices
|
|
2
|
+
===================
|
|
3
|
+
|
|
4
|
+
Third-party model weights (Real-ESRGAN, HAT, SPAN, and community checkpoints)
|
|
5
|
+
remain under their own licenses. Review each model's license before redistribution.
|
|
6
|
+
OpenCV, ONNX Runtime, PyTorch, and other dependencies use their respective licenses.
|
upscale-0.5.1/PKG-INFO
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: upscale
|
|
3
|
+
Version: 0.5.1
|
|
4
|
+
Summary: Local AI image upscaler: chained Real-ESRGAN passes to any scale, seam-free feather-blended tiles
|
|
5
|
+
Author: upscale
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://wwylon.github.io/upscale/
|
|
8
|
+
Project-URL: Repository, https://github.com/wwylon/upscale
|
|
9
|
+
Project-URL: Issues, https://github.com/wwylon/upscale/issues
|
|
10
|
+
Keywords: image-upscaler,super-resolution,real-esrgan,upscaling,pytorch,onnx,mcp,cli
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Topic :: Multimedia :: Graphics
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Image Processing
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
License-File: NOTICE
|
|
26
|
+
Requires-Dist: torch>=2.0
|
|
27
|
+
Requires-Dist: torchvision
|
|
28
|
+
Requires-Dist: spandrel
|
|
29
|
+
Requires-Dist: Pillow
|
|
30
|
+
Requires-Dist: tifffile
|
|
31
|
+
Requires-Dist: imagecodecs
|
|
32
|
+
Requires-Dist: psd-tools>=1.9
|
|
33
|
+
Requires-Dist: tqdm
|
|
34
|
+
Requires-Dist: click
|
|
35
|
+
Requires-Dist: numpy
|
|
36
|
+
Requires-Dist: pydantic>=2.0
|
|
37
|
+
Provides-Extra: ui
|
|
38
|
+
Requires-Dist: gradio>=4.0; extra == "ui"
|
|
39
|
+
Provides-Extra: server
|
|
40
|
+
Requires-Dist: fastapi>=0.110; extra == "server"
|
|
41
|
+
Requires-Dist: uvicorn[standard]>=0.27; extra == "server"
|
|
42
|
+
Requires-Dist: python-multipart>=0.0.9; extra == "server"
|
|
43
|
+
Provides-Extra: mcp
|
|
44
|
+
Requires-Dist: mcp>=1.0; extra == "mcp"
|
|
45
|
+
Provides-Extra: desktop
|
|
46
|
+
Requires-Dist: pywebview>=5.0; extra == "desktop"
|
|
47
|
+
Provides-Extra: slim
|
|
48
|
+
Requires-Dist: upscale[desktop,server]; extra == "slim"
|
|
49
|
+
Requires-Dist: onnxruntime>=1.17; extra == "slim"
|
|
50
|
+
Requires-Dist: Pillow; extra == "slim"
|
|
51
|
+
Requires-Dist: numpy; extra == "slim"
|
|
52
|
+
Requires-Dist: tifffile; extra == "slim"
|
|
53
|
+
Requires-Dist: imagecodecs; extra == "slim"
|
|
54
|
+
Requires-Dist: tqdm; extra == "slim"
|
|
55
|
+
Requires-Dist: click; extra == "slim"
|
|
56
|
+
Requires-Dist: pydantic>=2.0; extra == "slim"
|
|
57
|
+
Provides-Extra: dev
|
|
58
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
59
|
+
Requires-Dist: ruff>=0.4; extra == "dev"
|
|
60
|
+
Requires-Dist: httpx>=0.27; extra == "dev"
|
|
61
|
+
Requires-Dist: mypy>=1.8; extra == "dev"
|
|
62
|
+
Provides-Extra: classical
|
|
63
|
+
Requires-Dist: opencv-python-headless>=4.8; extra == "classical"
|
|
64
|
+
Provides-Extra: vectorize
|
|
65
|
+
Requires-Dist: vtracer>=0.6; extra == "vectorize"
|
|
66
|
+
Requires-Dist: pyautotrace>=0.0.7; extra == "vectorize"
|
|
67
|
+
Requires-Dist: resvg_py>=0.2; extra == "vectorize"
|
|
68
|
+
Provides-Extra: all
|
|
69
|
+
Requires-Dist: upscale[classical,desktop,dev,mcp,server,slim,ui,vectorize]; extra == "all"
|
|
70
|
+
Dynamic: license-file
|
|
71
|
+
|
|
72
|
+
# upscale
|
|
73
|
+
|
|
74
|
+
[](https://github.com/wwylon/upscale/actions/workflows/ci.yml)
|
|
75
|
+
[](LICENSE)
|
|
76
|
+
|
|
77
|
+
Local AI image upscale. Chains Real-ESRGAN passes (via [spandrel](https://github.com/chaiNNer-org/spandrel)) to reach any target scale, with feather-blended overlapping tiles so large outputs have no seams. Runs on CPU or an NVIDIA GPU; nothing leaves your machine except the one-time model download.
|
|
78
|
+
|
|
79
|
+

|
|
80
|
+
|
|
81
|
+

|
|
82
|
+
|
|
83
|
+
> Not related to other projects named "upscaler" on GitHub or PyPI. The package, the import name and the command are all `upscale`.
|
|
84
|
+
|
|
85
|
+
## Install
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
pip install "git+https://github.com/wwylon/upscale.git" # or: pipx install git+https://github.com/wwylon/upscale.git
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
The pip install pulls PyTorch (large, slow first install). A PyTorch-free build exists only as the Windows desktop app (ONNX Runtime); see [docs/develop.md](docs/develop.md).
|
|
92
|
+
|
|
93
|
+
From a clone:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
pip install -e .
|
|
97
|
+
pip install -e ".[server]" # web UI + job API
|
|
98
|
+
pip install -e ".[mcp]" # MCP tools for agents
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## First win
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
upscale upscale input.png output.png --scale 4 --cpu
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Use `--target-size 8000` for a target long edge instead of a factor, drop `--cpu` to use the GPU, and `--fast` for the quick SPAN model. Models download on first use and are hash-verified.
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
upscale models list # built-in models
|
|
111
|
+
upscale suggest input.png # heuristic model pick
|
|
112
|
+
upscale serve # local web UI at http://127.0.0.1:8787/en/
|
|
113
|
+
upscale mcp # MCP tools over stdio
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Equivalent module form: `python -m upscale upscale ...`
|
|
117
|
+
|
|
118
|
+
## Highlights
|
|
119
|
+
|
|
120
|
+
- Exact scale (`--scale`) or target long edge (`--target-size`); extra passes only when needed
|
|
121
|
+
- Tile size chosen from free VRAM; very large frames spill to disk between passes
|
|
122
|
+
- Swappable models: Real-ESRGAN family, HAT, SPAN, community weights, or your own `.pth`
|
|
123
|
+
- Large outputs saved as BigTIFF; alpha preserved
|
|
124
|
+
- Web UI in several languages; Windows desktop build uses ONNX Runtime (no PyTorch)
|
|
125
|
+
- No telemetry
|
|
126
|
+
|
|
127
|
+
## Library
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
from upscale import UpscaleConfig, execute
|
|
131
|
+
|
|
132
|
+
execute(UpscaleConfig(input="in.png", output="out.png", scale=4, cpu=True))
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Documentation
|
|
136
|
+
|
|
137
|
+
- [CLI reference](docs/cli.md)
|
|
138
|
+
- [HTTP and MCP API](docs/api.md)
|
|
139
|
+
- [Development, desktop build, layout](docs/develop.md)
|
|
140
|
+
- [Android skeleton](docs/android.md)
|
|
141
|
+
|
|
142
|
+
## Tests
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
pip install -e ".[dev,server,mcp]"
|
|
146
|
+
pytest
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
MIT licensed. See [CONTRIBUTING.md](CONTRIBUTING.md) and [SECURITY.md](SECURITY.md).
|
upscale-0.5.1/README.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# upscale
|
|
2
|
+
|
|
3
|
+
[](https://github.com/wwylon/upscale/actions/workflows/ci.yml)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
|
|
6
|
+
Local AI image upscale. Chains Real-ESRGAN passes (via [spandrel](https://github.com/chaiNNer-org/spandrel)) to reach any target scale, with feather-blended overlapping tiles so large outputs have no seams. Runs on CPU or an NVIDIA GPU; nothing leaves your machine except the one-time model download.
|
|
7
|
+
|
|
8
|
+

|
|
9
|
+
|
|
10
|
+

|
|
11
|
+
|
|
12
|
+
> Not related to other projects named "upscaler" on GitHub or PyPI. The package, the import name and the command are all `upscale`.
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pip install "git+https://github.com/wwylon/upscale.git" # or: pipx install git+https://github.com/wwylon/upscale.git
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
The pip install pulls PyTorch (large, slow first install). A PyTorch-free build exists only as the Windows desktop app (ONNX Runtime); see [docs/develop.md](docs/develop.md).
|
|
21
|
+
|
|
22
|
+
From a clone:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install -e .
|
|
26
|
+
pip install -e ".[server]" # web UI + job API
|
|
27
|
+
pip install -e ".[mcp]" # MCP tools for agents
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## First win
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
upscale upscale input.png output.png --scale 4 --cpu
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Use `--target-size 8000` for a target long edge instead of a factor, drop `--cpu` to use the GPU, and `--fast` for the quick SPAN model. Models download on first use and are hash-verified.
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
upscale models list # built-in models
|
|
40
|
+
upscale suggest input.png # heuristic model pick
|
|
41
|
+
upscale serve # local web UI at http://127.0.0.1:8787/en/
|
|
42
|
+
upscale mcp # MCP tools over stdio
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Equivalent module form: `python -m upscale upscale ...`
|
|
46
|
+
|
|
47
|
+
## Highlights
|
|
48
|
+
|
|
49
|
+
- Exact scale (`--scale`) or target long edge (`--target-size`); extra passes only when needed
|
|
50
|
+
- Tile size chosen from free VRAM; very large frames spill to disk between passes
|
|
51
|
+
- Swappable models: Real-ESRGAN family, HAT, SPAN, community weights, or your own `.pth`
|
|
52
|
+
- Large outputs saved as BigTIFF; alpha preserved
|
|
53
|
+
- Web UI in several languages; Windows desktop build uses ONNX Runtime (no PyTorch)
|
|
54
|
+
- No telemetry
|
|
55
|
+
|
|
56
|
+
## Library
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
from upscale import UpscaleConfig, execute
|
|
60
|
+
|
|
61
|
+
execute(UpscaleConfig(input="in.png", output="out.png", scale=4, cpu=True))
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Documentation
|
|
65
|
+
|
|
66
|
+
- [CLI reference](docs/cli.md)
|
|
67
|
+
- [HTTP and MCP API](docs/api.md)
|
|
68
|
+
- [Development, desktop build, layout](docs/develop.md)
|
|
69
|
+
- [Android skeleton](docs/android.md)
|
|
70
|
+
|
|
71
|
+
## Tests
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
pip install -e ".[dev,server,mcp]"
|
|
75
|
+
pytest
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
MIT licensed. See [CONTRIBUTING.md](CONTRIBUTING.md) and [SECURITY.md](SECURITY.md).
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "upscale"
|
|
7
|
+
version = "0.5.1"
|
|
8
|
+
description = "Local AI image upscaler: chained Real-ESRGAN passes to any scale, seam-free feather-blended tiles"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
authors = [{ name = "upscale" }]
|
|
13
|
+
keywords = ["image-upscaler", "super-resolution", "real-esrgan", "upscaling", "pytorch", "onnx", "mcp", "cli"]
|
|
14
|
+
dependencies = [
|
|
15
|
+
"torch>=2.0",
|
|
16
|
+
"torchvision",
|
|
17
|
+
"spandrel",
|
|
18
|
+
"Pillow",
|
|
19
|
+
"tifffile",
|
|
20
|
+
"imagecodecs",
|
|
21
|
+
"psd-tools>=1.9",
|
|
22
|
+
"tqdm",
|
|
23
|
+
"click",
|
|
24
|
+
"numpy",
|
|
25
|
+
"pydantic>=2.0",
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
classifiers = [
|
|
29
|
+
"Development Status :: 4 - Beta",
|
|
30
|
+
"Environment :: Console",
|
|
31
|
+
"Intended Audience :: End Users/Desktop",
|
|
32
|
+
"License :: OSI Approved :: MIT License",
|
|
33
|
+
"Operating System :: OS Independent",
|
|
34
|
+
"Programming Language :: Python :: 3",
|
|
35
|
+
"Programming Language :: Python :: 3.10",
|
|
36
|
+
"Programming Language :: Python :: 3.11",
|
|
37
|
+
"Programming Language :: Python :: 3.12",
|
|
38
|
+
"Topic :: Multimedia :: Graphics",
|
|
39
|
+
"Topic :: Scientific/Engineering :: Image Processing",
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
[project.urls]
|
|
43
|
+
Homepage = "https://wwylon.github.io/upscale/"
|
|
44
|
+
Repository = "https://github.com/wwylon/upscale"
|
|
45
|
+
Issues = "https://github.com/wwylon/upscale/issues"
|
|
46
|
+
|
|
47
|
+
[project.optional-dependencies]
|
|
48
|
+
ui = ["gradio>=4.0"]
|
|
49
|
+
server = ["fastapi>=0.110", "uvicorn[standard]>=0.27", "python-multipart>=0.0.9"]
|
|
50
|
+
mcp = ["mcp>=1.0"]
|
|
51
|
+
desktop = ["pywebview>=5.0"]
|
|
52
|
+
# Adds ONNX Runtime + desktop deps for the Windows exe build. Does NOT remove torch (a core
|
|
53
|
+
# dependency); the shipped exe is built without it by desktop/build_windows_slim.ps1.
|
|
54
|
+
slim = [
|
|
55
|
+
"upscale[server,desktop]",
|
|
56
|
+
"onnxruntime>=1.17",
|
|
57
|
+
"Pillow",
|
|
58
|
+
"numpy",
|
|
59
|
+
"tifffile",
|
|
60
|
+
"imagecodecs",
|
|
61
|
+
"tqdm",
|
|
62
|
+
"click",
|
|
63
|
+
"pydantic>=2.0",
|
|
64
|
+
]
|
|
65
|
+
dev = ["pytest>=7.0", "ruff>=0.4", "httpx>=0.27", "mypy>=1.8"]
|
|
66
|
+
# Classical resize prefers OpenCV (C++/SIMD); Pillow fallback always works
|
|
67
|
+
classical = ["opencv-python-headless>=4.8"]
|
|
68
|
+
# Raster→SVG→raster paper path (logos / line art). resvg_py = Windows-friendly SVG→PNG.
|
|
69
|
+
vectorize = ["vtracer>=0.6", "pyautotrace>=0.0.7", "resvg_py>=0.2"]
|
|
70
|
+
all = ["upscale[ui,server,mcp,desktop,slim,dev,classical,vectorize]"]
|
|
71
|
+
|
|
72
|
+
[project.scripts]
|
|
73
|
+
upscale = "upscale.cli:cli"
|
|
74
|
+
|
|
75
|
+
[tool.setuptools.packages.find]
|
|
76
|
+
include = ["upscale*"]
|
|
77
|
+
|
|
78
|
+
[tool.pytest.ini_options]
|
|
79
|
+
testpaths = ["tests"]
|
|
80
|
+
addopts = "-q"
|
|
81
|
+
|
|
82
|
+
[tool.ruff]
|
|
83
|
+
line-length = 100
|
|
84
|
+
target-version = "py310"
|
|
85
|
+
|
|
86
|
+
[tool.ruff.lint]
|
|
87
|
+
# Classic pyflakes + pycodestyle errors (keeps verify/CI stable across ruff minors)
|
|
88
|
+
select = ["E4", "E7", "E9", "F", "I", "B"]
|
|
89
|
+
ignore = [
|
|
90
|
+
"E402", # lazy/optional imports inside functions are intentional
|
|
91
|
+
"E742", # single-letter type names in generics (e.g. I for Image)
|
|
92
|
+
]
|
|
93
|
+
|
|
94
|
+
[tool.ruff.lint.flake8-bugbear]
|
|
95
|
+
# FastAPI / Gradio require these calls in parameter defaults.
|
|
96
|
+
extend-immutable-calls = ["fastapi.File", "fastapi.Form", "gradio.Progress"]
|
|
97
|
+
|
|
98
|
+
[tool.mypy]
|
|
99
|
+
python_version = "3.11"
|
|
100
|
+
ignore_missing_imports = true
|
|
101
|
+
follow_imports = "silent"
|
|
102
|
+
warn_unused_ignores = false
|
|
103
|
+
pretty = true
|
upscale-0.5.1/setup.cfg
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"""About / license / update-check helpers."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
from upscale.about import (
|
|
9
|
+
about_payload,
|
|
10
|
+
check_for_updates,
|
|
11
|
+
license_text,
|
|
12
|
+
models_disk_summary,
|
|
13
|
+
package_version,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def test_package_version():
|
|
18
|
+
assert package_version()
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def test_license_text_mentions_mit():
|
|
22
|
+
text = license_text()
|
|
23
|
+
assert "MIT" in text
|
|
24
|
+
assert "Permission is hereby granted" in text
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def test_about_payload_has_models_policy():
|
|
28
|
+
a = about_payload()
|
|
29
|
+
assert a["name"] == "Upscale"
|
|
30
|
+
assert a["license"] == "MIT"
|
|
31
|
+
assert "models_dir" in a
|
|
32
|
+
assert "on demand" in a["models_policy"].lower() or "download" in a["models_policy"].lower()
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def test_models_disk_summary_shape():
|
|
36
|
+
s = models_disk_summary()
|
|
37
|
+
assert "models_dir" in s
|
|
38
|
+
assert "installed_count" in s
|
|
39
|
+
assert isinstance(s["models"], list)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def test_check_updates_unconfigured():
|
|
43
|
+
r = check_for_updates(releases_url="")
|
|
44
|
+
assert r["status"] == "unconfigured"
|
|
45
|
+
assert r["current"] == package_version()
|
|
46
|
+
assert r["update_available"] is False
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def test_check_updates_from_local_json(tmp_path: Path, monkeypatch):
|
|
50
|
+
data = {"tag_name": "v99.0.0", "html_url": "https://example.com/r"}
|
|
51
|
+
path = tmp_path / "latest.json"
|
|
52
|
+
path.write_text(json.dumps(data), encoding="utf-8")
|
|
53
|
+
# file:// may not work on all platforms via urlopen; use a tiny HTTP stub via data URL is hard —
|
|
54
|
+
# instead monkeypatch urlopen.
|
|
55
|
+
class _Resp:
|
|
56
|
+
def read(self):
|
|
57
|
+
return path.read_bytes()
|
|
58
|
+
|
|
59
|
+
def __enter__(self):
|
|
60
|
+
return self
|
|
61
|
+
|
|
62
|
+
def __exit__(self, *a):
|
|
63
|
+
return False
|
|
64
|
+
|
|
65
|
+
def fake_open(req, timeout=8.0):
|
|
66
|
+
return _Resp()
|
|
67
|
+
|
|
68
|
+
monkeypatch.setattr("urllib.request.urlopen", fake_open)
|
|
69
|
+
r = check_for_updates(releases_url="https://example.com/releases/latest")
|
|
70
|
+
assert r["status"] == "ok"
|
|
71
|
+
assert r["update_available"] is True
|
|
72
|
+
assert r["latest"] == "99.0.0"
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
"""Classical algorithms + plugin registry."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
import numpy as np
|
|
8
|
+
import pytest
|
|
9
|
+
from PIL import Image
|
|
10
|
+
|
|
11
|
+
from upscale.algorithms import (
|
|
12
|
+
list_algorithm_meta,
|
|
13
|
+
list_algorithms,
|
|
14
|
+
register_algorithm,
|
|
15
|
+
resize_with_algorithm,
|
|
16
|
+
unregister_algorithm,
|
|
17
|
+
)
|
|
18
|
+
from upscale.algorithms.classical import BUILTIN_ALGORITHMS, backend_name
|
|
19
|
+
from upscale.algorithms.plugins.texture_residual import texture_residual_resize
|
|
20
|
+
from upscale.config import UpscaleConfig
|
|
21
|
+
from upscale.engine import execute
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def _checker(h: int = 16, w: int = 16) -> np.ndarray:
|
|
25
|
+
img = np.zeros((h, w, 3), dtype=np.uint8)
|
|
26
|
+
img[0 : h // 2, 0 : w // 2] = (255, 0, 0)
|
|
27
|
+
img[h // 2 :, w // 2 :] = (0, 255, 0)
|
|
28
|
+
return img
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@pytest.mark.parametrize("name", list(BUILTIN_ALGORITHMS))
|
|
32
|
+
def test_classical_output_size(name: str):
|
|
33
|
+
img = _checker()
|
|
34
|
+
out = resize_with_algorithm(name, img, 64, 48)
|
|
35
|
+
assert out.shape == (48, 64, 3)
|
|
36
|
+
assert out.dtype == np.uint8
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def test_nearest_preserves_block_colors():
|
|
40
|
+
img = _checker(8, 8)
|
|
41
|
+
out = resize_with_algorithm("nearest", img, 16, 16)
|
|
42
|
+
# Top-left quadrant stays red-ish
|
|
43
|
+
assert int(out[2, 2, 0]) == 255
|
|
44
|
+
assert int(out[2, 2, 1]) == 0
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def test_list_includes_builtins():
|
|
48
|
+
names = list_algorithms()
|
|
49
|
+
for n in BUILTIN_ALGORITHMS:
|
|
50
|
+
assert n in names
|
|
51
|
+
assert backend_name() in ("opencv", "pillow")
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def test_plugins_auto_discovered():
|
|
55
|
+
names = list_algorithms()
|
|
56
|
+
assert "texture_residual" in names
|
|
57
|
+
assert "vectorize_scale" in names
|
|
58
|
+
meta = {m.name: m for m in list_algorithm_meta()}
|
|
59
|
+
assert meta["texture_residual"].group == "paper"
|
|
60
|
+
assert meta["vectorize_scale"].group == "paper"
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def test_unknown_algorithm_fails_cleanly():
|
|
64
|
+
with pytest.raises(ValueError, match="Unknown algorithm"):
|
|
65
|
+
resize_with_algorithm("not_a_real_algo_xyz", _checker(), 32, 32)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def test_plugin_registry_hook():
|
|
69
|
+
def double_then_nearest(img: np.ndarray, tw: int, th: int) -> np.ndarray:
|
|
70
|
+
# Identity-ish plugin: nearest via builtin
|
|
71
|
+
return resize_with_algorithm("nearest", img, tw, th)
|
|
72
|
+
|
|
73
|
+
register_algorithm("test_plugin_double", double_then_nearest, overwrite=True)
|
|
74
|
+
try:
|
|
75
|
+
assert "test_plugin_double" in list_algorithms()
|
|
76
|
+
out = resize_with_algorithm("test_plugin_double", _checker(), 32, 32)
|
|
77
|
+
assert out.shape == (32, 32, 3)
|
|
78
|
+
finally:
|
|
79
|
+
unregister_algorithm("test_plugin_double")
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def test_texture_residual_shape_and_strength_zero():
|
|
83
|
+
img = _checker(24, 24)
|
|
84
|
+
out = resize_with_algorithm("texture_residual", img, 48, 48)
|
|
85
|
+
assert out.shape == (48, 48, 3)
|
|
86
|
+
assert out.dtype == np.uint8
|
|
87
|
+
# strength 0 ≈ Lanczos structure only
|
|
88
|
+
zero = texture_residual_resize(img, 48, 48, strength=0.0)
|
|
89
|
+
lanczos = resize_with_algorithm("lanczos3", img, 48, 48)
|
|
90
|
+
assert np.mean(np.abs(zero.astype(np.int16) - lanczos.astype(np.int16))) < 1.0
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def test_texture_residual_no_torch_import():
|
|
94
|
+
from upscale.algorithms.plugins import texture_residual as tr
|
|
95
|
+
|
|
96
|
+
src = Path(tr.__file__).read_text(encoding="utf-8")
|
|
97
|
+
assert "import torch" not in src
|
|
98
|
+
assert "from torch" not in src
|
|
99
|
+
# Runtime path must not need torch either
|
|
100
|
+
out = tr.texture_residual_resize(_checker(8, 8), 16, 16)
|
|
101
|
+
assert out.shape == (16, 16, 3)
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def test_vectorize_scale_synthetic_icon():
|
|
105
|
+
vtracer = pytest.importorskip("vtracer")
|
|
106
|
+
_ = vtracer
|
|
107
|
+
# Tiny flat icon (hard edges, few colors)
|
|
108
|
+
img = np.zeros((32, 32, 3), dtype=np.uint8)
|
|
109
|
+
img[:, :] = (240, 240, 240)
|
|
110
|
+
img[8:24, 8:24] = (20, 80, 200)
|
|
111
|
+
img[12:20, 12:20] = (255, 200, 40)
|
|
112
|
+
out = resize_with_algorithm("vectorize_scale", img, 64, 64)
|
|
113
|
+
assert out.shape == (64, 64, 3)
|
|
114
|
+
assert out.dtype == np.uint8
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def test_execute_classical_end_to_end(tmp_path: Path):
|
|
118
|
+
src = tmp_path / "in.png"
|
|
119
|
+
Image.fromarray(_checker(32, 40), mode="RGB").save(src)
|
|
120
|
+
out = tmp_path / "out.png"
|
|
121
|
+
cfg = UpscaleConfig(
|
|
122
|
+
input=src,
|
|
123
|
+
output=out,
|
|
124
|
+
scale=2.0,
|
|
125
|
+
algorithm="bilinear",
|
|
126
|
+
quiet=True,
|
|
127
|
+
format="png",
|
|
128
|
+
)
|
|
129
|
+
path = execute(cfg, echo=lambda _m: None)
|
|
130
|
+
assert path.is_file()
|
|
131
|
+
with Image.open(path) as im:
|
|
132
|
+
assert im.size == (80, 64)
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def test_execute_texture_residual(tmp_path: Path):
|
|
136
|
+
src = tmp_path / "in.png"
|
|
137
|
+
Image.fromarray(_checker(32, 32), mode="RGB").save(src)
|
|
138
|
+
out = tmp_path / "out.png"
|
|
139
|
+
cfg = UpscaleConfig(
|
|
140
|
+
input=src,
|
|
141
|
+
output=out,
|
|
142
|
+
scale=2.0,
|
|
143
|
+
algorithm="texture_residual",
|
|
144
|
+
quiet=True,
|
|
145
|
+
format="png",
|
|
146
|
+
)
|
|
147
|
+
path = execute(cfg, echo=lambda _m: None)
|
|
148
|
+
assert path.is_file()
|
|
149
|
+
with Image.open(path) as im:
|
|
150
|
+
assert im.size == (64, 64)
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def test_execute_texture_residual_rgba(tmp_path: Path):
|
|
154
|
+
src = tmp_path / "in.png"
|
|
155
|
+
rgba = np.dstack([_checker(32, 40), np.full((32, 40), 200, dtype=np.uint8)])
|
|
156
|
+
Image.fromarray(rgba, mode="RGBA").save(src)
|
|
157
|
+
out = tmp_path / "out.png"
|
|
158
|
+
cfg = UpscaleConfig(
|
|
159
|
+
input=src,
|
|
160
|
+
output=out,
|
|
161
|
+
scale=2.0,
|
|
162
|
+
algorithm="texture_residual",
|
|
163
|
+
quiet=True,
|
|
164
|
+
format="png",
|
|
165
|
+
)
|
|
166
|
+
path = execute(cfg, echo=lambda _m: None)
|
|
167
|
+
assert path.is_file()
|
|
168
|
+
with Image.open(path) as im:
|
|
169
|
+
assert im.mode == "RGBA"
|
|
170
|
+
assert im.size == (80, 64)
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
def test_execute_vectorize_scale_rgba(tmp_path: Path):
|
|
174
|
+
pytest.importorskip("vtracer")
|
|
175
|
+
src = tmp_path / "in.png"
|
|
176
|
+
rgb = np.zeros((32, 32, 3), dtype=np.uint8)
|
|
177
|
+
rgb[:, :] = (240, 240, 240)
|
|
178
|
+
rgb[8:24, 8:24] = (20, 80, 200)
|
|
179
|
+
rgba = np.dstack([rgb, np.full((32, 32), 220, dtype=np.uint8)])
|
|
180
|
+
Image.fromarray(rgba, mode="RGBA").save(src)
|
|
181
|
+
out = tmp_path / "out.png"
|
|
182
|
+
path = execute(
|
|
183
|
+
UpscaleConfig(
|
|
184
|
+
input=src,
|
|
185
|
+
output=out,
|
|
186
|
+
scale=2.0,
|
|
187
|
+
algorithm="vectorize_scale",
|
|
188
|
+
quiet=True,
|
|
189
|
+
format="png",
|
|
190
|
+
),
|
|
191
|
+
echo=lambda _m: None,
|
|
192
|
+
)
|
|
193
|
+
assert path.is_file()
|
|
194
|
+
with Image.open(path) as im:
|
|
195
|
+
assert im.mode == "RGBA"
|
|
196
|
+
assert im.size == (64, 64)
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
def test_vectorize_params_change_output():
|
|
200
|
+
pytest.importorskip("vtracer")
|
|
201
|
+
from upscale.algorithms.plugins.vectorize_scale import vectorize_scale_resize
|
|
202
|
+
from upscale.schema import VectorizeSettings
|
|
203
|
+
|
|
204
|
+
img = np.zeros((48, 48, 3), dtype=np.uint8)
|
|
205
|
+
img[:, :] = (245, 245, 245)
|
|
206
|
+
img[8:40, 8:40] = (40, 120, 200)
|
|
207
|
+
img[16:32, 16:32] = (220, 60, 40)
|
|
208
|
+
flat = vectorize_scale_resize(
|
|
209
|
+
img, 96, 96, color_precision=2, filter_speckle=8, mode="polygon"
|
|
210
|
+
)
|
|
211
|
+
rich = vectorize_scale_resize(
|
|
212
|
+
img, 96, 96, color_precision=8, filter_speckle=0, mode="spline"
|
|
213
|
+
)
|
|
214
|
+
assert flat.shape == rich.shape == (96, 96, 3)
|
|
215
|
+
# Settings round-trip on JobSettings
|
|
216
|
+
vz = VectorizeSettings(
|
|
217
|
+
engine="autotrace", color_precision=3, mode="polygon", max_trace_edge=512
|
|
218
|
+
)
|
|
219
|
+
assert vz.engine == "autotrace"
|
|
220
|
+
assert vz.color_precision == 3
|
|
221
|
+
assert vz.mode == "polygon"
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
def test_vectorize_autotrace_engine():
|
|
225
|
+
pytest.importorskip("autotrace")
|
|
226
|
+
from upscale.algorithms.plugins.vectorize_scale import vectorize_scale_resize
|
|
227
|
+
|
|
228
|
+
img = np.zeros((40, 40, 3), dtype=np.uint8)
|
|
229
|
+
img[:, :] = (250, 250, 250)
|
|
230
|
+
img[8:32, 8:32] = (20, 90, 200)
|
|
231
|
+
out = vectorize_scale_resize(
|
|
232
|
+
img, 80, 80, engine="autotrace", color_precision=4, filter_speckle=2
|
|
233
|
+
)
|
|
234
|
+
assert out.shape == (80, 80, 3)
|
|
235
|
+
assert out.dtype == np.uint8
|