Color Fix for VapourSynth
For example for fixing color shift from AI upscaling/restoration models, or transferring color grading from an old release to a remaster. Also known as Color Transfer or Color Matching. See this collection of Comparisons.
Installation
Nvidia
pip install -U vs_colorfix[tensorrt] --extra-index-url https://pypi.nvidia.com/
To enable the Wavelet Color Fix CPU backend, install the ATWT plugin. (optional)
Others
pip install -U vs_colorfix
To enable the Wavelet Color Fix CPU backend, install the ATWT plugin. (optional)
[!TIP] For VapourSynth R73 and older, follow the manual installation steps.
Average Color Fix
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.
import vs_colorfix
clip = vs_colorfix.average(clip, ref, radius=10, planes=[0, 1, 2], fast=False)
clip
Base clip where the colors will be applied to.
Recommended higher than 8-bit to avoid banding.
ref
Reference clip where the colors are taken from.
Check the comparisons to get an idea how close it should match the base clip.
radius
Higher means a more global color match and wider bloom/bleed.
Lower means a more local color match and smaller bloom/bleed. Too low and the reference clip will become visible.
Test values 5 and 30 and this will become more clear.
planes (optional)
Which planes to color fix. Any unmentioned planes will simply be copied.
If not set, all planes will be color-fixed.
fast (optional)
Does the averaging via a downscale instead of a blur, which is much faster, but will produce faint blocky artifacts.
Useful for very large radii where artifacts are no longer noticeable, or to fix something like a prefilter clip.
[!TIP]
Wavelet Color Fix
Fixes color shift by 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 for larger color differences, at the cost of more computation.
import vs_colorfix
clip = vs_colorfix.wavelet(clip, ref, wavelets=4, planes=[0, 1, 2], backend="ncnn", num_streams=2, gpu_id=0, engine_folder=None)
clip
Base clip where the colors will be applied to.
Recommended higher than 8-bit to avoid banding.
ref
Reference clip where the colors are taken from.
Check the comparisons to get an idea how close it should match the base clip.
wavelets
Number of wavelets in the 1-10 range. Around 4 seems to work best in most cases.
Higher means a more global color match and wider bloom/bleed.
Lower means a more local color match and smaller bloom/bleed. Too low and the reference clip will become visible.
Test values 3 and 8 and this will become more clear.
planes (optional)
Which planes to color fix. Any unmentioned planes will simply be copied.
If not set, all planes will be color-fixed.
backend (optional)
The used backend. 16-bit float input is always much faster on GPU, but not supported by older GPUs.
cpuCPU mode (slow).ncnnGPU mode using NCNN. Works on almost any GPU, even Mac (fast).directmlGPU mode using DirectML. Works on most GPUs, Windows only (fast).tensorrtGPU mode using TensorRT. 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).
num_streams (optional)
Number of parallel GPU streams. Higher can be faster, but requires more VRAM. Does not affect the CPU backend.
gpu_id (optional)
Which GPU to use starting from 0. Can be used to switch between iGPU/dGPU. Does not affect the CPU backend.
engine_folder (optional)
Optional path to the TensorRT engine storage location. By default engines are stored in vs_colorfix/engines. Only affects the TensorRT backend.
[!TIP] If your clips are not sufficiently aligned or synchronized, use vs_align to align them first.
Guided Color Fix
Fixes colors guided by a trained AI model that can intelligently transfer colors from a reference while avoiding the bleed/bloom produced by the Average and Wavelet Color Fix when the shift is not uniform, but is much slower.
import vs_colorfix
clip = vs_colorfix.guided(clip, ref, planes=[0, 1, 2], backend="tensorrt", num_streams=1, gpu_id=0, engine_folder=None)
clip
Base clip where the colors will be applied to.
Must be in float format.
ref
Reference clip where the colors are taken from.
Check the comparisons to get an idea how close it should match the base clip.
planes (optional)
Which planes to color fix. Any unmentioned planes will simply be copied.
If not set, all planes will be color-fixed.
backend (optional)
The used backend.
cpuCPU mode (very slow).ncnnGPU mode using NCNN. Works on almost any GPU, even Mac (fast).directmlGPU mode using DirectML. Works on most GPUs, Windows only (faster).tensorrtGPU mode using TensorRT. Requires an Nvidia RTX GPU. On the first run, this mode will automatically build an engine, which may take a few minutes. Changing input dimensions will trigger rebuilding, but build engines are stored (very fast, low vram).
num_streams (optional)
Number of parallel GPU streams. Higher can be faster, but requires more VRAM. Does not affect the CPU backend.
gpu_id (optional)
Which GPU to use starting from 0. Can be used to switch between iGPU/dGPU. Does not affect the CPU backend.
engine_folder (optional)
Optional path to the TensorRT engine storage location. By default engines are stored in vs_colorfix/engines. Only affects the TensorRT backend.
[!TIP] If your clips are not sufficiently aligned or synchronized, use vs_align to align them first.
Benchmarks
Benchmarks were done on a RTX 4090 GPU and a Ryzen 5900X CPU with 16-bit input clips.
|
|
Acknowledgements
Average Color Fix idea from chaiNNer.
Wavelet Color Fix idea from sd-webui-stablesr.
Guided Color Fix architecture created and model training by Bendel.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vs_colorfix-2.2.0.tar.gz.
File metadata
- Download URL: vs_colorfix-2.2.0.tar.gz
- Upload date:
- Size: 32.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9d3538a1bbf4e131946c91b2aa43bf9eb186941d87b8a2efa7bdfc932358dcf
|
|
| MD5 |
2571b0bfec43787292df368809a40224
|
|
| BLAKE2b-256 |
1833074940ca09524d891014136d473ade2c3346a6c5f668350f03217e3c1bdb
|
Provenance
The following attestation bundles were made for vs_colorfix-2.2.0.tar.gz:
Publisher:
publish.yml on pifroggi/vs_colorfix
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vs_colorfix-2.2.0.tar.gz -
Subject digest:
a9d3538a1bbf4e131946c91b2aa43bf9eb186941d87b8a2efa7bdfc932358dcf - Sigstore transparency entry: 2617651293
- Sigstore integration time:
-
Permalink:
pifroggi/vs_colorfix@c1a6092816f56e4b4c5fa709dc9f193d4baed7fe -
Branch / Tag:
refs/tags/v2.2.0 - Owner: https://github.com/pifroggi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c1a6092816f56e4b4c5fa709dc9f193d4baed7fe -
Trigger Event:
release
-
Statement type:
File details
Details for the file vs_colorfix-2.2.0-py3-none-any.whl.
File metadata
- Download URL: vs_colorfix-2.2.0-py3-none-any.whl
- Upload date:
- Size: 32.0 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
942e16bfb84b8ee33a005b58df0aac1667cf4130edc5c410be39fce975494762
|
|
| MD5 |
01f625aca6cc2cc11c6b7ec7774fa38f
|
|
| BLAKE2b-256 |
6f88f85c55d320e8689a0e7d3c1337c8482a10f6bbffc05deef4b2dfd3f77922
|
Provenance
The following attestation bundles were made for vs_colorfix-2.2.0-py3-none-any.whl:
Publisher:
publish.yml on pifroggi/vs_colorfix
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vs_colorfix-2.2.0-py3-none-any.whl -
Subject digest:
942e16bfb84b8ee33a005b58df0aac1667cf4130edc5c410be39fce975494762 - Sigstore transparency entry: 2617651298
- Sigstore integration time:
-
Permalink:
pifroggi/vs_colorfix@c1a6092816f56e4b4c5fa709dc9f193d4baed7fe -
Branch / Tag:
refs/tags/v2.2.0 - Owner: https://github.com/pifroggi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c1a6092816f56e4b4c5fa709dc9f193d4baed7fe -
Trigger Event:
release
-
Statement type: