vs-colorfix 2.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.
Files changed (49) hide show
  1. vs_colorfix-2.1.0/.github/workflows/publish.yml +76 -0
  2. vs_colorfix-2.1.0/LICENSE +201 -0
  3. vs_colorfix-2.1.0/PKG-INFO +217 -0
  4. vs_colorfix-2.1.0/README.md +192 -0
  5. vs_colorfix-2.1.0/README_img.png +0 -0
  6. vs_colorfix-2.1.0/pyproject.toml +47 -0
  7. vs_colorfix-2.1.0/vs_colorfix/__init__.py +2 -0
  8. vs_colorfix-2.1.0/vs_colorfix/average_color_fix.py +146 -0
  9. vs_colorfix-2.1.0/vs_colorfix/models/waveletcolorfix_w10_c1_fp16.onnx +0 -0
  10. vs_colorfix-2.1.0/vs_colorfix/models/waveletcolorfix_w10_c1_fp32.onnx +0 -0
  11. vs_colorfix-2.1.0/vs_colorfix/models/waveletcolorfix_w10_c3_fp16.onnx +0 -0
  12. vs_colorfix-2.1.0/vs_colorfix/models/waveletcolorfix_w10_c3_fp32.onnx +0 -0
  13. vs_colorfix-2.1.0/vs_colorfix/models/waveletcolorfix_w1_c1_fp16.onnx +0 -0
  14. vs_colorfix-2.1.0/vs_colorfix/models/waveletcolorfix_w1_c1_fp32.onnx +0 -0
  15. vs_colorfix-2.1.0/vs_colorfix/models/waveletcolorfix_w1_c3_fp16.onnx +0 -0
  16. vs_colorfix-2.1.0/vs_colorfix/models/waveletcolorfix_w1_c3_fp32.onnx +0 -0
  17. vs_colorfix-2.1.0/vs_colorfix/models/waveletcolorfix_w2_c1_fp16.onnx +0 -0
  18. vs_colorfix-2.1.0/vs_colorfix/models/waveletcolorfix_w2_c1_fp32.onnx +0 -0
  19. vs_colorfix-2.1.0/vs_colorfix/models/waveletcolorfix_w2_c3_fp16.onnx +0 -0
  20. vs_colorfix-2.1.0/vs_colorfix/models/waveletcolorfix_w2_c3_fp32.onnx +0 -0
  21. vs_colorfix-2.1.0/vs_colorfix/models/waveletcolorfix_w3_c1_fp16.onnx +0 -0
  22. vs_colorfix-2.1.0/vs_colorfix/models/waveletcolorfix_w3_c1_fp32.onnx +0 -0
  23. vs_colorfix-2.1.0/vs_colorfix/models/waveletcolorfix_w3_c3_fp16.onnx +0 -0
  24. vs_colorfix-2.1.0/vs_colorfix/models/waveletcolorfix_w3_c3_fp32.onnx +0 -0
  25. vs_colorfix-2.1.0/vs_colorfix/models/waveletcolorfix_w4_c1_fp16.onnx +0 -0
  26. vs_colorfix-2.1.0/vs_colorfix/models/waveletcolorfix_w4_c1_fp32.onnx +0 -0
  27. vs_colorfix-2.1.0/vs_colorfix/models/waveletcolorfix_w4_c3_fp16.onnx +0 -0
  28. vs_colorfix-2.1.0/vs_colorfix/models/waveletcolorfix_w4_c3_fp32.onnx +0 -0
  29. vs_colorfix-2.1.0/vs_colorfix/models/waveletcolorfix_w5_c1_fp16.onnx +0 -0
  30. vs_colorfix-2.1.0/vs_colorfix/models/waveletcolorfix_w5_c1_fp32.onnx +0 -0
  31. vs_colorfix-2.1.0/vs_colorfix/models/waveletcolorfix_w5_c3_fp16.onnx +0 -0
  32. vs_colorfix-2.1.0/vs_colorfix/models/waveletcolorfix_w5_c3_fp32.onnx +0 -0
  33. vs_colorfix-2.1.0/vs_colorfix/models/waveletcolorfix_w6_c1_fp16.onnx +0 -0
  34. vs_colorfix-2.1.0/vs_colorfix/models/waveletcolorfix_w6_c1_fp32.onnx +0 -0
  35. vs_colorfix-2.1.0/vs_colorfix/models/waveletcolorfix_w6_c3_fp16.onnx +0 -0
  36. vs_colorfix-2.1.0/vs_colorfix/models/waveletcolorfix_w6_c3_fp32.onnx +0 -0
  37. vs_colorfix-2.1.0/vs_colorfix/models/waveletcolorfix_w7_c1_fp16.onnx +0 -0
  38. vs_colorfix-2.1.0/vs_colorfix/models/waveletcolorfix_w7_c1_fp32.onnx +0 -0
  39. vs_colorfix-2.1.0/vs_colorfix/models/waveletcolorfix_w7_c3_fp16.onnx +0 -0
  40. vs_colorfix-2.1.0/vs_colorfix/models/waveletcolorfix_w7_c3_fp32.onnx +0 -0
  41. vs_colorfix-2.1.0/vs_colorfix/models/waveletcolorfix_w8_c1_fp16.onnx +0 -0
  42. vs_colorfix-2.1.0/vs_colorfix/models/waveletcolorfix_w8_c1_fp32.onnx +0 -0
  43. vs_colorfix-2.1.0/vs_colorfix/models/waveletcolorfix_w8_c3_fp16.onnx +0 -0
  44. vs_colorfix-2.1.0/vs_colorfix/models/waveletcolorfix_w8_c3_fp32.onnx +0 -0
  45. vs_colorfix-2.1.0/vs_colorfix/models/waveletcolorfix_w9_c1_fp16.onnx +0 -0
  46. vs_colorfix-2.1.0/vs_colorfix/models/waveletcolorfix_w9_c1_fp32.onnx +0 -0
  47. vs_colorfix-2.1.0/vs_colorfix/models/waveletcolorfix_w9_c3_fp16.onnx +0 -0
  48. vs_colorfix-2.1.0/vs_colorfix/models/waveletcolorfix_w9_c3_fp32.onnx +0 -0
  49. vs_colorfix-2.1.0/vs_colorfix/wavelet_color_fix.py +466 -0
@@ -0,0 +1,76 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ permissions:
8
+ contents: read
9
+
10
+ jobs:
11
+ build:
12
+ name: Build distributions
13
+ if: ${{ !github.event.release.prerelease }}
14
+ runs-on: ubuntu-latest
15
+
16
+ steps:
17
+ - name: Check out released tag
18
+ uses: actions/checkout@v6
19
+ with:
20
+ ref: ${{ github.event.release.tag_name }}
21
+ persist-credentials: false
22
+
23
+ - name: Set up Python
24
+ uses: actions/setup-python@v6
25
+ with:
26
+ python-version: "3.12"
27
+
28
+ - name: Check tag matches package version
29
+ shell: bash
30
+ run: |
31
+ VERSION="$(python -c 'import tomllib; print(tomllib.load(open("pyproject.toml", "rb"))["project"]["version"])')"
32
+ TAG="${{ github.event.release.tag_name }}"
33
+ TAG_VERSION="${TAG#v}"
34
+
35
+ if [ "$TAG_VERSION" != "$VERSION" ]; then
36
+ echo "Release tag $TAG does not match pyproject.toml version $VERSION"
37
+ exit 1
38
+ fi
39
+
40
+ - name: Install build tools
41
+ run: python -m pip install --upgrade build twine
42
+
43
+ - name: Build wheel and source distribution
44
+ run: python -m build
45
+
46
+ - name: Validate distributions
47
+ run: python -m twine check dist/*
48
+
49
+ - name: Upload distributions
50
+ uses: actions/upload-artifact@v5
51
+ with:
52
+ name: python-package-distributions
53
+ path: dist/
54
+ if-no-files-found: error
55
+
56
+ publish:
57
+ name: Publish distributions to PyPI
58
+ needs: build
59
+ runs-on: ubuntu-latest
60
+
61
+ environment:
62
+ name: pypi
63
+ url: https://pypi.org/p/vs_colorfix
64
+
65
+ permissions:
66
+ id-token: write
67
+
68
+ steps:
69
+ - name: Download distributions
70
+ uses: actions/download-artifact@v6
71
+ with:
72
+ name: python-package-distributions
73
+ path: dist/
74
+
75
+ - name: Publish to PyPI
76
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 pifroggi
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,217 @@
1
+ Metadata-Version: 2.4
2
+ Name: vs_colorfix
3
+ Version: 2.1.0
4
+ Summary: Color Fix, Color Transfer, or Color Match for VapourSynth.
5
+ Project-URL: Homepage, https://github.com/pifroggi/vs_colorfix
6
+ Project-URL: Repository, https://github.com/pifroggi/vs_colorfix
7
+ Project-URL: Issues, https://github.com/pifroggi/vs_colorfix/issues
8
+ Author: pifroggi
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE
11
+ Keywords: color fix,color matching,color transfer,filtering,vapoursynth,video
12
+ Classifier: Environment :: GPU
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Topic :: Multimedia :: Video
15
+ Requires-Python: >=3.12
16
+ Requires-Dist: vapoursynth-mlrt-ncnn
17
+ Requires-Dist: vapoursynth-mlrt-ort; sys_platform == 'win32'
18
+ Requires-Dist: vapoursynth-vszip
19
+ Requires-Dist: vapoursynth>=74
20
+ Provides-Extra: tensorrt
21
+ Requires-Dist: cuda-python; (sys_platform == 'win32' or sys_platform == 'linux') and extra == 'tensorrt'
22
+ Requires-Dist: tensorrt-cu13>=11.1.0.106; (sys_platform == 'win32' or sys_platform == 'linux') and extra == 'tensorrt'
23
+ Requires-Dist: vapoursynth-mlrt-trt>=16.0; (sys_platform == 'win32' or sys_platform == 'linux') and extra == 'tensorrt'
24
+ Description-Content-Type: text/markdown
25
+
26
+ # Color Fix for VapourSynth
27
+
28
+ For example for fixing color shift from AI upscaling/restoration models, or transfering color grading from an old release to a remaster. Also known as Color Transfer or Color Matching. See this collection of [Comparisons](https://slow.pics/c/abXjnKn3).
29
+
30
+ <br />
31
+
32
+ <p align="center">
33
+ <a href="https://slow.pics/c/abXjnKn3">
34
+ <img src="https://raw.githubusercontent.com/pifroggi/vs_colorfix/refs/heads/main/README_img.png" width="600" />
35
+ </a>
36
+ </p>
37
+
38
+ ## Installation
39
+
40
+ ### Nvidia
41
+ ```
42
+ pip install -U vs_colorfix[tensorrt] --extra-index-url https://pypi.nvidia.com/
43
+ ```
44
+ To enable the Wavelet Color Fix CPU backend, install the plugin [Vapoursynth-ATWT](https://github.com/yuygfgg/Vapoursynth-ATWT). *(optional)*
45
+ ### Others
46
+ ```
47
+ pip install -U vs_colorfix
48
+ ```
49
+ To enable the Wavelet Color Fix CPU backend, install the plugin [Vapoursynth-ATWT](https://github.com/yuygfgg/Vapoursynth-ATWT). *(optional)*
50
+
51
+ <br />
52
+
53
+ > [!TIP]
54
+ > For VapourSynth R73 and older, follow the [manual installation steps](https://github.com/pifroggi/vs_colorfix/wiki/Manual-Installation).
55
+
56
+ <br />
57
+
58
+
59
+ ## Average Color Fix
60
+ Fixes color shift by matching the average color of a clip to a reference clip. A very fast way to transfer colors from one clip to another. For large color differences, the Wavelet Color Fix is more accurate.
61
+
62
+ ```python
63
+ import vs_colorfix
64
+ clip = vs_colorfix.average(clip, ref, radius=10, planes=[0, 1, 2], fast=False)
65
+ ```
66
+
67
+ __*`clip`*__
68
+ Base clip where the colors will be applied to.
69
+ Recommended higher than 8-bit to avoid banding.
70
+
71
+ __*`ref`*__
72
+ Reference clip where the colors are taken from.
73
+ Check the [comparisons](https://slow.pics/c/abXjnKn3) to get an idea how close it should match the base clip.
74
+
75
+ __*`radius`*__
76
+ Higher means a more global color match and wider bloom/bleed.
77
+ Lower means a more local color match and smaller bloom/bleed. Too low and the reference clip will become visible.
78
+ Test values 5 and 30 and this will become more clear.
79
+
80
+ __*`planes`* (optional)__
81
+ Which planes to color fix. Any unmentioned planes will simply be copied.
82
+ If not set, all planes will be color-fixed.
83
+
84
+ __*`fast`* (optional)__
85
+ Does the averaging via a downscale instead of a blur, which is much faster, but will produce faint blocky artifacts.
86
+ I found it useful for radius > 60 where artifacts are no longer noticable, or to fix something like a prefilter clip.
87
+
88
+ > [!TIP]
89
+ > * If your clips are not sufficiently aligned or synchronized, use [vs_align](https://github.com/pifroggi/vs_align) to align them first.
90
+ > * To replicate chaiNNers Average Color Fix, you can convert % to radius: `radius = (100/percentage-1)/2`
91
+ > ChaiNNer works like fast=True does here, but it is recommended to leave it off for better results.
92
+
93
+ <br />
94
+
95
+ ## Wavelet Color Fix
96
+ Fixes color shift by first converting into wavelets, then matching the average color of a clip to a reference clip. Works similarly to the Average Color Fix, but more accurate when the color differences are large, at the cost of more computation.
97
+
98
+ ```python
99
+ import vs_colorfix
100
+ clip = vs_colorfix.wavelet(clip, ref, wavelets=4, planes=[0, 1, 2], backend="ncnn", num_streams=2, gpu_id=0, engine_folder=None)
101
+ ```
102
+
103
+ __*`clip`*__
104
+ Base clip where the colors will be applied to.
105
+ Recommended higher than 8-bit to avoid banding.
106
+
107
+ __*`ref`*__
108
+ Reference clip where the colors are taken from.
109
+ Check the [comparisons](https://slow.pics/c/abXjnKn3) to get an idea how close it should match the base clip.
110
+
111
+ __*`wavelets`*__
112
+ Number of wavelets in the 1-10 range. Around 4 seems to work best in most cases.
113
+ Higher means a more global color match and wider bloom/bleed.
114
+ Lower means a more local color match and smaller bloom/bleed. Too low and the reference clip will become visible.
115
+ Test values 3 and 8 and this will become more clear.
116
+
117
+ __*`planes`* (optional)__
118
+ Which planes to color fix. Any unmentioned planes will simply be copied.
119
+ If not set, all planes will be color-fixed.
120
+
121
+ __*`backend`* (optional)__
122
+ The used backend. **16-bit float input is always much faster on GPU, but not supported by older GPUs.**
123
+ * `cpu` CPU mode using the vapoursynth-ATWT plugin *(slow)*.
124
+ * `ncnn` GPU mode using vs-mlrt with NCNN support. Works on almost any GPU, even Mac *(fast)*.
125
+ * `directml` GPU mode using vs-mlrt with DirectML support. Works on most GPUs, Windows only *(fast)*.
126
+ * `tensorrt` GPU mode using vs-mlrt with TensorRT support. Requires an Nvidia RTX GPU. On the first run, this mode will automatically build an engine, which may take a few minutes. Changing wavelets or input dimensions will trigger rebuilding, but build engines are stored *(very fast)*.
127
+
128
+ __*`num_streams`* (optional)__
129
+ Number of parallel GPU streams. Higher can be faster, but requires more VRAM. Does not affect the CPU backend.
130
+
131
+ __*`gpu_id`* (optional)__
132
+ Which GPU to use starting from 0. Can be used to switch between iGPU/dGPU. Does not affect the CPU backend.
133
+
134
+ __*`engine_folder`* (optional)__
135
+ Optional path to the TensorRT engine storage location. By default engines are stored in `vs_colorfix/engines`. Only affects the TensorRT backend.
136
+
137
+ > [!TIP]
138
+ > * On low end GPUs, the NCNN backend can be faster than TensorRT and DirectML.
139
+ > * If your clips are not sufficiently aligned or synchronized, use [vs_align](https://github.com/pifroggi/vs_align) to align them first.
140
+
141
+ <br />
142
+
143
+ ## Benchmarks
144
+ Benchmarks were done on a RTX 4090 GPU and a Ryzen 5900X CPU with 16-bit input clips.
145
+
146
+ <table>
147
+ <tr>
148
+ <td valign="top">
149
+
150
+ <table>
151
+ <thead>
152
+ <tr align="center">
153
+ <th colspan="5">Wavelet Color Fix</th>
154
+ </tr>
155
+ <tr align="center">
156
+ <th>Resolution</th>
157
+ <th>TensorRT</th>
158
+ <th>DirectML</th>
159
+ <th>NCNN</th>
160
+ <th>CPU</th>
161
+ </tr>
162
+ </thead>
163
+ <tbody>
164
+ <tr align="center">
165
+ <td>1440x1080</td>
166
+ <td>~360 fps</td>
167
+ <td>~250 fps</td>
168
+ <td>~250 fps</td>
169
+ <td>~20 fps</td>
170
+ </tr>
171
+ <tr align="center">
172
+ <td>2880x2160</td>
173
+ <td>~80 fps</td>
174
+ <td>~60 fps</td>
175
+ <td>~60 fps</td>
176
+ <td>~5 fps</td>
177
+ </tr>
178
+ </tbody>
179
+ </table>
180
+
181
+ </td>
182
+ <td valign="top">
183
+
184
+ <table>
185
+ <thead>
186
+ <tr align="center">
187
+ <th colspan="3">Average Color Fix</th>
188
+ </tr>
189
+ <tr align="center">
190
+ <th>Resolution</th>
191
+ <th>fast=False</th>
192
+ <th>fast=True</th>
193
+ </tr>
194
+ </thead>
195
+ <tbody>
196
+ <tr align="center">
197
+ <td>1440x1080</td>
198
+ <td>~250 fps</td>
199
+ <td>~850 fps</td>
200
+ </tr>
201
+ <tr align="center">
202
+ <td>2880x2160</td>
203
+ <td>~60 fps</td>
204
+ <td>~150 fps</td>
205
+ </tr>
206
+ </tbody>
207
+ </table>
208
+
209
+ </td>
210
+ </tr>
211
+ </table>
212
+
213
+ <br />
214
+
215
+ ## Acknowledgements
216
+ Average Color Fix idea from [chaiNNer](https://github.com/chaiNNer-org/chaiNNer).
217
+ Wavelet Color Fix idea from [sd-webui-stablesr](https://github.com/pkuliyi2015/sd-webui-stablesr/blob/master/srmodule/colorfix.py).
@@ -0,0 +1,192 @@
1
+ # Color Fix for VapourSynth
2
+
3
+ For example for fixing color shift from AI upscaling/restoration models, or transfering color grading from an old release to a remaster. Also known as Color Transfer or Color Matching. See this collection of [Comparisons](https://slow.pics/c/abXjnKn3).
4
+
5
+ <br />
6
+
7
+ <p align="center">
8
+ <a href="https://slow.pics/c/abXjnKn3">
9
+ <img src="https://raw.githubusercontent.com/pifroggi/vs_colorfix/refs/heads/main/README_img.png" width="600" />
10
+ </a>
11
+ </p>
12
+
13
+ ## Installation
14
+
15
+ ### Nvidia
16
+ ```
17
+ pip install -U vs_colorfix[tensorrt] --extra-index-url https://pypi.nvidia.com/
18
+ ```
19
+ To enable the Wavelet Color Fix CPU backend, install the plugin [Vapoursynth-ATWT](https://github.com/yuygfgg/Vapoursynth-ATWT). *(optional)*
20
+ ### Others
21
+ ```
22
+ pip install -U vs_colorfix
23
+ ```
24
+ To enable the Wavelet Color Fix CPU backend, install the plugin [Vapoursynth-ATWT](https://github.com/yuygfgg/Vapoursynth-ATWT). *(optional)*
25
+
26
+ <br />
27
+
28
+ > [!TIP]
29
+ > For VapourSynth R73 and older, follow the [manual installation steps](https://github.com/pifroggi/vs_colorfix/wiki/Manual-Installation).
30
+
31
+ <br />
32
+
33
+
34
+ ## Average Color Fix
35
+ Fixes color shift by matching the average color of a clip to a reference clip. A very fast way to transfer colors from one clip to another. For large color differences, the Wavelet Color Fix is more accurate.
36
+
37
+ ```python
38
+ import vs_colorfix
39
+ clip = vs_colorfix.average(clip, ref, radius=10, planes=[0, 1, 2], fast=False)
40
+ ```
41
+
42
+ __*`clip`*__
43
+ Base clip where the colors will be applied to.
44
+ Recommended higher than 8-bit to avoid banding.
45
+
46
+ __*`ref`*__
47
+ Reference clip where the colors are taken from.
48
+ Check the [comparisons](https://slow.pics/c/abXjnKn3) to get an idea how close it should match the base clip.
49
+
50
+ __*`radius`*__
51
+ Higher means a more global color match and wider bloom/bleed.
52
+ Lower means a more local color match and smaller bloom/bleed. Too low and the reference clip will become visible.
53
+ Test values 5 and 30 and this will become more clear.
54
+
55
+ __*`planes`* (optional)__
56
+ Which planes to color fix. Any unmentioned planes will simply be copied.
57
+ If not set, all planes will be color-fixed.
58
+
59
+ __*`fast`* (optional)__
60
+ Does the averaging via a downscale instead of a blur, which is much faster, but will produce faint blocky artifacts.
61
+ I found it useful for radius > 60 where artifacts are no longer noticable, or to fix something like a prefilter clip.
62
+
63
+ > [!TIP]
64
+ > * If your clips are not sufficiently aligned or synchronized, use [vs_align](https://github.com/pifroggi/vs_align) to align them first.
65
+ > * To replicate chaiNNers Average Color Fix, you can convert % to radius: `radius = (100/percentage-1)/2`
66
+ > ChaiNNer works like fast=True does here, but it is recommended to leave it off for better results.
67
+
68
+ <br />
69
+
70
+ ## Wavelet Color Fix
71
+ Fixes color shift by first converting into wavelets, then matching the average color of a clip to a reference clip. Works similarly to the Average Color Fix, but more accurate when the color differences are large, at the cost of more computation.
72
+
73
+ ```python
74
+ import vs_colorfix
75
+ clip = vs_colorfix.wavelet(clip, ref, wavelets=4, planes=[0, 1, 2], backend="ncnn", num_streams=2, gpu_id=0, engine_folder=None)
76
+ ```
77
+
78
+ __*`clip`*__
79
+ Base clip where the colors will be applied to.
80
+ Recommended higher than 8-bit to avoid banding.
81
+
82
+ __*`ref`*__
83
+ Reference clip where the colors are taken from.
84
+ Check the [comparisons](https://slow.pics/c/abXjnKn3) to get an idea how close it should match the base clip.
85
+
86
+ __*`wavelets`*__
87
+ Number of wavelets in the 1-10 range. Around 4 seems to work best in most cases.
88
+ Higher means a more global color match and wider bloom/bleed.
89
+ Lower means a more local color match and smaller bloom/bleed. Too low and the reference clip will become visible.
90
+ Test values 3 and 8 and this will become more clear.
91
+
92
+ __*`planes`* (optional)__
93
+ Which planes to color fix. Any unmentioned planes will simply be copied.
94
+ If not set, all planes will be color-fixed.
95
+
96
+ __*`backend`* (optional)__
97
+ The used backend. **16-bit float input is always much faster on GPU, but not supported by older GPUs.**
98
+ * `cpu` CPU mode using the vapoursynth-ATWT plugin *(slow)*.
99
+ * `ncnn` GPU mode using vs-mlrt with NCNN support. Works on almost any GPU, even Mac *(fast)*.
100
+ * `directml` GPU mode using vs-mlrt with DirectML support. Works on most GPUs, Windows only *(fast)*.
101
+ * `tensorrt` GPU mode using vs-mlrt with TensorRT support. Requires an Nvidia RTX GPU. On the first run, this mode will automatically build an engine, which may take a few minutes. Changing wavelets or input dimensions will trigger rebuilding, but build engines are stored *(very fast)*.
102
+
103
+ __*`num_streams`* (optional)__
104
+ Number of parallel GPU streams. Higher can be faster, but requires more VRAM. Does not affect the CPU backend.
105
+
106
+ __*`gpu_id`* (optional)__
107
+ Which GPU to use starting from 0. Can be used to switch between iGPU/dGPU. Does not affect the CPU backend.
108
+
109
+ __*`engine_folder`* (optional)__
110
+ Optional path to the TensorRT engine storage location. By default engines are stored in `vs_colorfix/engines`. Only affects the TensorRT backend.
111
+
112
+ > [!TIP]
113
+ > * On low end GPUs, the NCNN backend can be faster than TensorRT and DirectML.
114
+ > * If your clips are not sufficiently aligned or synchronized, use [vs_align](https://github.com/pifroggi/vs_align) to align them first.
115
+
116
+ <br />
117
+
118
+ ## Benchmarks
119
+ Benchmarks were done on a RTX 4090 GPU and a Ryzen 5900X CPU with 16-bit input clips.
120
+
121
+ <table>
122
+ <tr>
123
+ <td valign="top">
124
+
125
+ <table>
126
+ <thead>
127
+ <tr align="center">
128
+ <th colspan="5">Wavelet Color Fix</th>
129
+ </tr>
130
+ <tr align="center">
131
+ <th>Resolution</th>
132
+ <th>TensorRT</th>
133
+ <th>DirectML</th>
134
+ <th>NCNN</th>
135
+ <th>CPU</th>
136
+ </tr>
137
+ </thead>
138
+ <tbody>
139
+ <tr align="center">
140
+ <td>1440x1080</td>
141
+ <td>~360 fps</td>
142
+ <td>~250 fps</td>
143
+ <td>~250 fps</td>
144
+ <td>~20 fps</td>
145
+ </tr>
146
+ <tr align="center">
147
+ <td>2880x2160</td>
148
+ <td>~80 fps</td>
149
+ <td>~60 fps</td>
150
+ <td>~60 fps</td>
151
+ <td>~5 fps</td>
152
+ </tr>
153
+ </tbody>
154
+ </table>
155
+
156
+ </td>
157
+ <td valign="top">
158
+
159
+ <table>
160
+ <thead>
161
+ <tr align="center">
162
+ <th colspan="3">Average Color Fix</th>
163
+ </tr>
164
+ <tr align="center">
165
+ <th>Resolution</th>
166
+ <th>fast=False</th>
167
+ <th>fast=True</th>
168
+ </tr>
169
+ </thead>
170
+ <tbody>
171
+ <tr align="center">
172
+ <td>1440x1080</td>
173
+ <td>~250 fps</td>
174
+ <td>~850 fps</td>
175
+ </tr>
176
+ <tr align="center">
177
+ <td>2880x2160</td>
178
+ <td>~60 fps</td>
179
+ <td>~150 fps</td>
180
+ </tr>
181
+ </tbody>
182
+ </table>
183
+
184
+ </td>
185
+ </tr>
186
+ </table>
187
+
188
+ <br />
189
+
190
+ ## Acknowledgements
191
+ Average Color Fix idea from [chaiNNer](https://github.com/chaiNNer-org/chaiNNer).
192
+ Wavelet Color Fix idea from [sd-webui-stablesr](https://github.com/pkuliyi2015/sd-webui-stablesr/blob/master/srmodule/colorfix.py).
Binary file