local-upscaler 0.1.0__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.
- local_upscaler-0.1.0/LICENSE +202 -0
- local_upscaler-0.1.0/PKG-INFO +269 -0
- local_upscaler-0.1.0/README.md +221 -0
- local_upscaler-0.1.0/local_upscaler.egg-info/PKG-INFO +269 -0
- local_upscaler-0.1.0/local_upscaler.egg-info/SOURCES.txt +73 -0
- local_upscaler-0.1.0/local_upscaler.egg-info/dependency_links.txt +1 -0
- local_upscaler-0.1.0/local_upscaler.egg-info/entry_points.txt +2 -0
- local_upscaler-0.1.0/local_upscaler.egg-info/requires.txt +41 -0
- local_upscaler-0.1.0/local_upscaler.egg-info/top_level.txt +1 -0
- local_upscaler-0.1.0/pyproject.toml +55 -0
- local_upscaler-0.1.0/setup.cfg +4 -0
- local_upscaler-0.1.0/tests/test_architecture.py +120 -0
- local_upscaler-0.1.0/tests/test_background.py +43 -0
- local_upscaler-0.1.0/tests/test_batch_and_mockup.py +62 -0
- local_upscaler-0.1.0/tests/test_build_demo.py +17 -0
- local_upscaler-0.1.0/tests/test_cli_convert.py +68 -0
- local_upscaler-0.1.0/tests/test_cli_parity.py +137 -0
- local_upscaler-0.1.0/tests/test_cli_pdf.py +50 -0
- local_upscaler-0.1.0/tests/test_codeformer.py +91 -0
- local_upscaler-0.1.0/tests/test_colorize.py +73 -0
- local_upscaler-0.1.0/tests/test_config.py +34 -0
- local_upscaler-0.1.0/tests/test_convert.py +62 -0
- local_upscaler-0.1.0/tests/test_crop_preview.py +86 -0
- local_upscaler-0.1.0/tests/test_deblur_memory.py +378 -0
- local_upscaler-0.1.0/tests/test_document.py +44 -0
- local_upscaler-0.1.0/tests/test_engine_progress.py +61 -0
- local_upscaler-0.1.0/tests/test_exact_size.py +117 -0
- local_upscaler-0.1.0/tests/test_face.py +47 -0
- local_upscaler-0.1.0/tests/test_fbcnn.py +68 -0
- local_upscaler-0.1.0/tests/test_fit.py +193 -0
- local_upscaler-0.1.0/tests/test_highsev_fixes.py +74 -0
- local_upscaler-0.1.0/tests/test_inpaint.py +70 -0
- local_upscaler-0.1.0/tests/test_library.py +37 -0
- local_upscaler-0.1.0/tests/test_manage.py +122 -0
- local_upscaler-0.1.0/tests/test_medlow_fixes.py +101 -0
- local_upscaler-0.1.0/tests/test_nafnet.py +67 -0
- local_upscaler-0.1.0/tests/test_oldarch_convert.py +63 -0
- local_upscaler-0.1.0/tests/test_onnx.py +120 -0
- local_upscaler-0.1.0/tests/test_output_memory.py +236 -0
- local_upscaler-0.1.0/tests/test_panel.py +253 -0
- local_upscaler-0.1.0/tests/test_panel_app.py +68 -0
- local_upscaler-0.1.0/tests/test_panel_presets.py +59 -0
- local_upscaler-0.1.0/tests/test_registry_guard.py +38 -0
- local_upscaler-0.1.0/tests/test_restore_guard.py +31 -0
- local_upscaler-0.1.0/tests/test_spandrel_loader.py +130 -0
- local_upscaler-0.1.0/tests/test_video.py +202 -0
- local_upscaler-0.1.0/tests/test_weights.py +28 -0
- local_upscaler-0.1.0/upscaler/__init__.py +8 -0
- local_upscaler-0.1.0/upscaler/background.py +129 -0
- local_upscaler-0.1.0/upscaler/cli.py +640 -0
- local_upscaler-0.1.0/upscaler/colorize.py +59 -0
- local_upscaler-0.1.0/upscaler/config.py +54 -0
- local_upscaler-0.1.0/upscaler/convert.py +135 -0
- local_upscaler-0.1.0/upscaler/deblur.py +340 -0
- local_upscaler-0.1.0/upscaler/document.py +43 -0
- local_upscaler-0.1.0/upscaler/engine.py +530 -0
- local_upscaler-0.1.0/upscaler/face.py +129 -0
- local_upscaler-0.1.0/upscaler/fit.py +178 -0
- local_upscaler-0.1.0/upscaler/inpaint.py +68 -0
- local_upscaler-0.1.0/upscaler/library.py +98 -0
- local_upscaler-0.1.0/upscaler/manage.py +202 -0
- local_upscaler-0.1.0/upscaler/memory.py +177 -0
- local_upscaler-0.1.0/upscaler/models/__init__.py +25 -0
- local_upscaler-0.1.0/upscaler/models/nafnet.py +150 -0
- local_upscaler-0.1.0/upscaler/models/registry.py +368 -0
- local_upscaler-0.1.0/upscaler/models/rrdbnet.py +105 -0
- local_upscaler-0.1.0/upscaler/models/weights.py +101 -0
- local_upscaler-0.1.0/upscaler/onnx_engine.py +263 -0
- local_upscaler-0.1.0/upscaler/onnx_export.py +107 -0
- local_upscaler-0.1.0/upscaler/panel.py +813 -0
- local_upscaler-0.1.0/upscaler/panel_presets.py +113 -0
- local_upscaler-0.1.0/upscaler/pipeline.py +43 -0
- local_upscaler-0.1.0/upscaler/restore.py +55 -0
- local_upscaler-0.1.0/upscaler/sharpen.py +31 -0
- local_upscaler-0.1.0/upscaler/video.py +274 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: local-upscaler
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Local, open-source image upscaling + sharpening. Wraps pretrained Real-ESRGAN weights.
|
|
5
|
+
Author: Upscaler contributors
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/Maty3k/Upscaler
|
|
8
|
+
Project-URL: Issues, https://github.com/Maty3k/Upscaler/issues
|
|
9
|
+
Keywords: super-resolution,upscaling,real-esrgan,image-enhancement,sharpening
|
|
10
|
+
Requires-Python: >=3.9
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Requires-Dist: torch>=2.0
|
|
14
|
+
Requires-Dist: numpy>=1.23
|
|
15
|
+
Requires-Dist: Pillow>=9.0
|
|
16
|
+
Requires-Dist: tqdm>=4.64
|
|
17
|
+
Provides-Extra: dev
|
|
18
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
19
|
+
Requires-Dist: gradio>=6.0; extra == "dev"
|
|
20
|
+
Requires-Dist: onnxruntime>=1.16; extra == "dev"
|
|
21
|
+
Requires-Dist: onnx>=1.15; extra == "dev"
|
|
22
|
+
Requires-Dist: onnxscript>=0.1; extra == "dev"
|
|
23
|
+
Requires-Dist: pypdfium2>=4; extra == "dev"
|
|
24
|
+
Requires-Dist: pillow-heif>=0.13; extra == "dev"
|
|
25
|
+
Requires-Dist: imageio-ffmpeg>=0.4; extra == "dev"
|
|
26
|
+
Provides-Extra: gui
|
|
27
|
+
Requires-Dist: gradio>=6.0; extra == "gui"
|
|
28
|
+
Requires-Dist: pypdfium2>=4; extra == "gui"
|
|
29
|
+
Requires-Dist: pillow-heif>=0.13; extra == "gui"
|
|
30
|
+
Requires-Dist: onnxruntime>=1.16; extra == "gui"
|
|
31
|
+
Provides-Extra: pdf
|
|
32
|
+
Requires-Dist: pypdfium2>=4; extra == "pdf"
|
|
33
|
+
Provides-Extra: onnx
|
|
34
|
+
Requires-Dist: onnxruntime>=1.16; extra == "onnx"
|
|
35
|
+
Requires-Dist: onnx>=1.15; extra == "onnx"
|
|
36
|
+
Requires-Dist: onnxscript>=0.1; extra == "onnx"
|
|
37
|
+
Provides-Extra: directml
|
|
38
|
+
Requires-Dist: onnxruntime-directml>=1.17; extra == "directml"
|
|
39
|
+
Requires-Dist: onnx>=1.15; extra == "directml"
|
|
40
|
+
Requires-Dist: onnxscript>=0.1; extra == "directml"
|
|
41
|
+
Provides-Extra: video
|
|
42
|
+
Requires-Dist: imageio-ffmpeg>=0.4; extra == "video"
|
|
43
|
+
Provides-Extra: face
|
|
44
|
+
Requires-Dist: spandrel>=0.4; extra == "face"
|
|
45
|
+
Requires-Dist: spandrel_extra_arches>=0.2; extra == "face"
|
|
46
|
+
Requires-Dist: opencv-python-headless>=4.9; extra == "face"
|
|
47
|
+
Dynamic: license-file
|
|
48
|
+
|
|
49
|
+
# Upscaler
|
|
50
|
+
|
|
51
|
+
Local, open-source image **upscaling + sharpening**. Runs entirely on your
|
|
52
|
+
machine (CPU, NVIDIA CUDA, or Apple-Silicon MPS) on top of pretrained
|
|
53
|
+
[Real-ESRGAN](https://github.com/xinntao/Real-ESRGAN) weights — no cloud, no API keys.
|
|
54
|
+
|
|
55
|
+
> Upscaling, deblur, a Gradio GUI, and an ONNX backend all work end-to-end.
|
|
56
|
+
> See [`docs/PROJECT_NOTES.md`](docs/PROJECT_NOTES.md) for full planning, design
|
|
57
|
+
> decisions, the "why it can make photos worse" lesson, and the
|
|
58
|
+
> train-your-own-model playbook (incl. AMD/Windows/ROCm).
|
|
59
|
+
|
|
60
|
+
## Install
|
|
61
|
+
|
|
62
|
+
Python **3.9–3.12** recommended (PyTorch wheels).
|
|
63
|
+
|
|
64
|
+
> **On a Windows PC with an AMD GPU?** See
|
|
65
|
+
> [`docs/SETUP-WINDOWS-AMD.md`](docs/SETUP-WINDOWS-AMD.md) for a full
|
|
66
|
+
> GPU-accelerated setup (WSL2 + ROCm) — dramatically faster than CPU/MPS for video.
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
pip install "local-upscaler[gui]"
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
That's it — the `upscaler` command is now available, and model weights download
|
|
73
|
+
automatically (with checksum verification) the first time you use them.
|
|
74
|
+
Extras: `[gui]` (GUI), `[onnx]` (ONNX backend), `[face]` (face restore),
|
|
75
|
+
`[video]` (bundled ffmpeg).
|
|
76
|
+
|
|
77
|
+
<details>
|
|
78
|
+
<summary>Install from source instead (development)</summary>
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
git clone https://github.com/Maty3k/Upscaler.git && cd Upscaler
|
|
82
|
+
python -m venv .venv && source .venv/bin/activate # .venv\Scripts\activate on Windows
|
|
83
|
+
pip install -e ".[gui]" # or ".[dev]" for tests
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
</details>
|
|
87
|
+
|
|
88
|
+
## Usage
|
|
89
|
+
|
|
90
|
+
### CLI
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
# 4x upscale (default model)
|
|
94
|
+
upscaler photo.jpg -o photo_4x.png
|
|
95
|
+
|
|
96
|
+
# 2x, and apply a sharpening pass afterwards
|
|
97
|
+
upscaler photo.jpg --scale 2 --sharpen
|
|
98
|
+
|
|
99
|
+
# deblur motion blur (NAFNet) before upscaling
|
|
100
|
+
upscaler blurry.jpg --deblur --scale 4
|
|
101
|
+
|
|
102
|
+
# stronger sharpen, explicit device
|
|
103
|
+
upscaler photo.jpg --sharpen 1.5 --device mps
|
|
104
|
+
|
|
105
|
+
# batch a whole folder
|
|
106
|
+
upscaler ./input_dir -o ./output_dir --scale 4
|
|
107
|
+
|
|
108
|
+
# anime / illustration model
|
|
109
|
+
upscaler art.png --model realesrgan-x4plus-anime
|
|
110
|
+
|
|
111
|
+
# restore faces after upscaling (GFPGAN; needs the [face] extra)
|
|
112
|
+
upscaler portrait.jpg --scale 4 --face --face-strength 0.8
|
|
113
|
+
|
|
114
|
+
# upscale a video frame-by-frame (offline, keeps audio; needs ffmpeg)
|
|
115
|
+
upscaler video clip.mp4 -o clip_2x.mp4 --scale 2
|
|
116
|
+
|
|
117
|
+
# ONNX Runtime backend (exports once from the .pth, then torch-free + often
|
|
118
|
+
# faster on CPU). Works with --deblur and batching too.
|
|
119
|
+
upscaler photo.jpg --scale 4 --onnx
|
|
120
|
+
|
|
121
|
+
upscaler --list-models
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
#### Convert formats (no AI)
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
upscaler convert photo.png -o photo.webp # format from extension
|
|
128
|
+
upscaler convert photo.png -f JPEG -q 80 # explicit format + quality
|
|
129
|
+
upscaler convert photo.png -o out.webp --lossless
|
|
130
|
+
upscaler convert ./folder -o ./out -f WebP # batch a directory
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Supports PNG / JPEG / WebP / AVIF / HEIC / JPEG 2000 / TIFF / GIF / BMP / ICO /
|
|
134
|
+
ICNS / TGA / PCX / DIB / SGI / PPM (AVIF needs Pillow ≥ 11.2 or pillow-heif;
|
|
135
|
+
HEIC needs pillow-heif). Alpha is flattened onto a white background for formats
|
|
136
|
+
that can't store it (JPEG/BMP/PPM/PCX).
|
|
137
|
+
|
|
138
|
+
#### Remove background & batch
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
upscaler removebg photo.jpg -o cutout.png # transparent PNG (needs [onnx])
|
|
142
|
+
upscaler removebg ./folder -o ./out --feather 2 # batch a directory
|
|
143
|
+
upscaler batch ./folder -o ./out --op upscale --scale 2 # upscale every image
|
|
144
|
+
upscaler batch ./folder -o ./out --op convert -f WebP # convert every image
|
|
145
|
+
upscaler batch ./folder -o ./out --op removebg # cut out every image
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
`batch` runs one operation over many images and skips unreadable files without
|
|
149
|
+
aborting. The GUI also has **Colorize** (DDColor) and **Inpaint / object removal**
|
|
150
|
+
(LaMa) tabs — both fully local; Colorize needs the `[face]` extra, Inpaint needs
|
|
151
|
+
only torch.
|
|
152
|
+
|
|
153
|
+
### Video (frame-by-frame)
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
upscaler video clip.mp4 -o clip_2x.mp4 --scale 2 # keeps audio
|
|
157
|
+
upscaler video clip.mp4 -o clip_2x_60.mp4 --scale 2 --fps 60 # + smooth to 60fps
|
|
158
|
+
upscaler video clip.mp4 -o clip_4k.mp4 --scale 4 --size 3840 # fit longest edge to 4K
|
|
159
|
+
upscaler video clip.mp4 -o test.mp4 --scale 2 --start 0 --end 5 # trim: first 5s only
|
|
160
|
+
upscaler video ./clips -o ./out --scale 2 # batch a whole folder
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Offline frame-by-frame upscaling (split → upscale each frame → re-encode + mux
|
|
164
|
+
audio). `--fps` adds motion-interpolated frames (ffmpeg `minterpolate`) for
|
|
165
|
+
smoother motion — duration unchanged, audio stays in sync, but it's slow. Needs
|
|
166
|
+
**ffmpeg** (system install, or `pip install -e ".[video]"` for a bundled binary). It's a render-and-wait feature — minutes per minute of footage —
|
|
167
|
+
and since frames are upscaled independently, very fine detail can shimmer slightly
|
|
168
|
+
between frames (a temporal model would be needed to fully remove that).
|
|
169
|
+
|
|
170
|
+
#### Image ⇄ PDF
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
upscaler pdf build a.png b.png c.png -o out.pdf # images → multi-page PDF
|
|
174
|
+
upscaler pdf build ./folder -o out.pdf # all images in a directory
|
|
175
|
+
upscaler pdf extract in.pdf -o ./pages --dpi 200 # PDF pages → PNGs
|
|
176
|
+
upscaler pdf extract in.pdf # → ./in_pages/ next to the PDF
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Weights download automatically on first use and are cached under
|
|
180
|
+
`upscaler/weights/` (override with `UPSCALER_WEIGHTS_DIR`).
|
|
181
|
+
|
|
182
|
+
### GUI (drag-and-drop)
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
pip install -e ".[gui]"
|
|
186
|
+
python app.py # opens a local web UI at http://127.0.0.1:7860
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
A full local web app with a tab per tool: **Upscale & Enhance** (with deblur /
|
|
190
|
+
denoise, JPEG de-blocking, face restore), **Colorize** (DDColor), **Remove
|
|
191
|
+
Objects** (LaMa inpainting), **Remove BG**, **Video** upscaling, **Convert &
|
|
192
|
+
Documents** (formats + image ⇄ PDF), **Batch**, a **Lian Li Screen** composer
|
|
193
|
+
for the 8.8″ case panel, and a **Library** of everything you export. Runs
|
|
194
|
+
entirely on your machine — nothing is uploaded anywhere. (PDF support uses
|
|
195
|
+
`pypdfium2`, included in the `.[gui]` extra or installable on its own via
|
|
196
|
+
`.[pdf]`.)
|
|
197
|
+
|
|
198
|
+
### Library
|
|
199
|
+
|
|
200
|
+
```python
|
|
201
|
+
from PIL import Image
|
|
202
|
+
from upscaler import Upscaler, enhance
|
|
203
|
+
|
|
204
|
+
# reuse one loaded model across many images
|
|
205
|
+
up = Upscaler(scale=4, device="auto")
|
|
206
|
+
up.upscale_file("in.jpg", "out.png")
|
|
207
|
+
|
|
208
|
+
# one-shot upscale + sharpen
|
|
209
|
+
result = enhance(Image.open("in.jpg"), scale=2, sharpen=1.0)
|
|
210
|
+
result.save("out.png")
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
## How it works
|
|
214
|
+
|
|
215
|
+
- `upscaler/models/rrdbnet.py` — the RRDBNet generator, vendored so we don't
|
|
216
|
+
depend on the fragile `basicsr`/`realesrgan` stack. Layer names match the
|
|
217
|
+
official checkpoints, which load with `strict=True`.
|
|
218
|
+
- `upscaler/models/registry.py` + `weights.py` — model registry and lazy,
|
|
219
|
+
integrity-checked weight download.
|
|
220
|
+
- `upscaler/engine.py` — device selection and **tiled inference** (large images
|
|
221
|
+
are processed in padded tiles to bound memory and avoid seams).
|
|
222
|
+
- `upscaler/models/nafnet.py` + `deblur.py` — vendored **NAFNet** and the deblur
|
|
223
|
+
stage. NAFNet's channel attention pools globally, so it runs on the whole image
|
|
224
|
+
(not tiled) and is applied at native resolution before upscaling.
|
|
225
|
+
- `upscaler/pipeline.py` + `sharpen.py` — `enhance()`: optional deblur → upscale
|
|
226
|
+
→ optional unsharp mask.
|
|
227
|
+
- `upscaler/onnx_export.py` + `onnx_engine.py` — export each model to ONNX with
|
|
228
|
+
dynamic shapes (one-time, needs torch) and run it via ONNX Runtime. The engines
|
|
229
|
+
import only `onnxruntime`/`numpy`/`Pillow`, so cached `.onnx` files run
|
|
230
|
+
torch-free. Verified to match the torch output (≤1/255 per pixel).
|
|
231
|
+
|
|
232
|
+
## Performance notes
|
|
233
|
+
|
|
234
|
+
- **CPU works** but is slow on large images; keep `--tile` at 512 or lower.
|
|
235
|
+
- **Apple Silicon:** `--device mps` is much faster than CPU.
|
|
236
|
+
- **CUDA:** add `--fp16` for a speed/memory win.
|
|
237
|
+
- **AMD / Intel GPU on native Windows:** torch can't reach these, but the ONNX
|
|
238
|
+
engine can via DirectML — `pip uninstall onnxruntime` then
|
|
239
|
+
`pip install -e ".[directml]"`, and add `--onnx` (CLI) or tick the ONNX
|
|
240
|
+
checkbox (GUI Upscale/Video → Advanced). For maximum AMD speed use WSL2 +
|
|
241
|
+
ROCm instead: see `docs/SETUP-WINDOWS-AMD.md`.
|
|
242
|
+
|
|
243
|
+
## Testing
|
|
244
|
+
|
|
245
|
+
```bash
|
|
246
|
+
pip install -e ".[dev]"
|
|
247
|
+
pytest # architecture + tiling tests; run on CPU, no weights download
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
## Roadmap
|
|
251
|
+
|
|
252
|
+
- [x] Phase 0 — scaffold, packaging, license
|
|
253
|
+
- [x] Phase 1 — Real-ESRGAN upscaling (lib + CLI), tiling, lazy weights, unsharp sharpen
|
|
254
|
+
- [x] Phase 2 — model-based deblur stage (NAFNet) for genuinely blurry input
|
|
255
|
+
- [x] Phase 3 — Gradio drag-and-drop GUI (`app.py`)
|
|
256
|
+
- [x] Phase 4 — ONNX Runtime path for faster, PyTorch-free CPU inference (`--onnx`)
|
|
257
|
+
|
|
258
|
+
## Licensing
|
|
259
|
+
|
|
260
|
+
This project is **Apache-2.0** (see `LICENSE`). Pretrained weights are
|
|
261
|
+
downloaded at runtime and never redistributed in this repo; each carries its own
|
|
262
|
+
upstream terms. The core Real-ESRGAN weights are BSD-3-Clause, but several
|
|
263
|
+
optional models are **not**: the community upscalers (4x-UltraSharp, Remacri,
|
|
264
|
+
NMKD) and the CodeFormer face restorer are non-commercial — their dropdown
|
|
265
|
+
entries say so; check upstream terms before commercial use. Credit to
|
|
266
|
+
Xintao Wang et al. for Real-ESRGAN and to BasicSR for the RRDBNet architecture,
|
|
267
|
+
and to Chen et al. / megvii-research for NAFNet (MIT). NAFNet deblur weights are
|
|
268
|
+
mirrored on Hugging Face (`nyanko7/nafnet-models`); the upstream originals are on
|
|
269
|
+
the official NAFNet Google Drive.
|