Skip to main content

Add Temporal Coherence to AI Upscales in VapourSynth

When using SISR models (single image super resolution) on video, they tend to create slightly different results each frame. TemporalFix is a post filter that averages these results over multiple frames, removing temporal inconsistencies like fizzle or wiggly lines. Also known as stabilization, deshimmering, temporal denoising, or temporal fix.



Installation

Nvidia

pip install -U vs_temporalfix[tensorrt] --extra-index-url https://pypi.nvidia.com/

To enable the CPU/CUDA backends, install PyTorch with CUDA. (optional)

Others

pip install -U vs_temporalfix

To enable the CPU backend, install PyTorch. (optional)


[!TIP] For VapourSynth R73 and older, follow the manual installation steps.


TemporalFix AI Model

The newest and most capable version of temporalfix. It is easy to use and can run very fast on Nvidia GPUs.

import vs_temporalfix
clip = vs_temporalfix.model(clip, strength=2.0, exclude=None, backend="tensorrt", tiles=1, num_streams=1, gpu_id=0, engine_folder=None)

clip
Temporally unstable upscaled clip. Must be in RGBH format.

strength
Suppression strength of temporal inconsistencies in the 0.0-3.0 range. Higher means more aggressive.
Higher resolution tends to need higher strength. Too high may oversmooth small movements.

exclude (optional)
Optionally exclude scenes with intended temporal inconsistencies.
Brackets define excluded frame ranges. Example for two scenes: exclude="[10 20] [600 900]"

backend (optional)
The backend used to run the model:

  • cpu CPU mode (very slow).
  • cuda GPU mode using CUDA. Requires any Nvidia GPU (fast).
  • directml GPU mode using DirectML. Works on most GPUs, but Windows only (faster, high vram).
  • tensorrt GPU 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 strength or input dimensions will trigger rebuilding, but previously build engines are stored (very fast, low vram).

tiles (optional)
A higher amount of tiles will reduce VRAM usage at the cost of speed.
This should only be needed on low end hardware. Default tiles=1 uses the full frame, which is fastest.

num_streams (optional)
Number of parallel TensorRT streams. For high end GPUs higher can be faster, but requires more VRAM. Only affects the TensorRT 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_temporalfix/engines. Only affects the TensorRT backend.

[!TIP] Feedback is much appreciated. If the model does not work well for you or causes issues, feel free to open an issue, or contact me via Discord (pifroggi or tepete) and provide a sample. That will help improve it over time.


TemporalFix Classic

The original CPU based version. It is harder to tune, may miss some areas, and only works well for 2D animation.

import vs_temporalfix
clip = vs_temporalfix.classic(clip, strength=500, tr=6, denoise=False, exclude=None, debug=False)

clip
Temporally unstable upscaled clip. Any format.

strength
Suppression strength of temporal inconsistencies. Higher means more aggressive. 400-700 works great in most cases.
The best way to finetune is to find a static scene and adjust till lines and details are stable.
Reduce if you get blending/ghosting on small movements, especially in dark or hazy scenes.

tr
Temporal radius sets the number of frames to average over.
Higher means more stable, especially on slow pans and zooms, but is slower. 6 works great in most cases.
The best way to finetune is to find a slow pan or zoom and adjust till lines and details are stable.

denoise (optional)
Removes grain and low frequency noise/flicker left over by the main processing step. Only enable if these issues actually exist! It risks to remove some details like every denoiser, but is useful if you're planning to denoise anyway and has the benefit of almost no performance impact compared to using an additional denoising filter.

exclude (optional)
Optionally exclude scenes with intended temporal inconsistencies.
Brackets define excluded frame ranges. Example for two scenes: exclude="[10 20] [600 900]"

debug (optional)
Shows areas that will not be fixed in pink. This includes areas with high motion, scene changes and excluded scenes. Can help while tuning parameters to see if the area is even affected.

[!TIP]

  • Crop any black borders on the input clip! In temporalfix classic they can cause ghosting on bright frames.
  • If slow, try increasing your cache: core.max_cache_size = 10000 (not needed on VapourSynth R78 and up)

Benchmarks

Model benchmarks were done on a RTX 4090 GPU and Classic benchmarks on a Ryzen 5900X CPU.

AI Model
Resolution TensorRT DirectML CUDA
720x480 ~320 fps ~160 fps ~70 fps
1440x1080 ~80 fps ~50 fps ~32 fps
2880x2160 ~20 fps ~14 fps ~8 fps
Classic
Resolution YUV444 YUV420 GRAY
720x480 ~70 fps ~90 fps ~120 fps
1440x1080 ~15 fps ~20 fps ~25 fps
2880x2160 ~7.5 fps ~11 fps ~14 fps

Third-Party Integrations

Several projects integrated TemporalFix to simplify usage without the need for VapourSynth knowledge. Feel free to contact me if you want to be part of this list.

  • Vapourkit (Windows only)
    Video filter and upscaling program with an easy GUI. This is the easiest way to use it. Just click on add filter and add one of the two TemporalFix versions.
  • Hybrid (Windows and Linux)
    Video filter toolbox with a GUI. Can be a bit overwhelming due to the amount of features and filters, but TemporalFix is one of them.
  • VSGAN-tensorrt-docker (Windows and Linux)
    Command line AI upscale and interpolation toolbox that comes with both versions of TemporalFix. Rudimentary knowledge of Docker and VapourSynth is recommended, but the readme also explains it.
  • mpv-cHiDeNoise-AI (Windows only)
    AI upscaling video player based on mpv, which includes the TemporalFix AI Models and a lighter modified version of TemporalFix Classic for real-time playback. Mainly intended for japanese audience.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vs_temporalfix-2.4.0.tar.gz (11.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vs_temporalfix-2.4.0-py3-none-any.whl (11.3 MB view details)

Uploaded Python 3

File details

Details for the file vs_temporalfix-2.4.0.tar.gz.

File metadata

  • Download URL: vs_temporalfix-2.4.0.tar.gz
  • Upload date:
  • Size: 11.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for vs_temporalfix-2.4.0.tar.gz
Algorithm Hash digest
SHA256 6fa03e9d047720b53a02f094f04388436a410ac7937ddab84b6618aa29b1d586
MD5 c194a617e81eeb97f1f029ebffd51628
BLAKE2b-256 988982b2e98a8625db46b5f5a10e35838fc545b53e7ccdddbf23eea528f88183

See more details on using hashes here.

Provenance

The following attestation bundles were made for vs_temporalfix-2.4.0.tar.gz:

Publisher: publish.yml on pifroggi/vs_temporalfix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vs_temporalfix-2.4.0-py3-none-any.whl.

File metadata

  • Download URL: vs_temporalfix-2.4.0-py3-none-any.whl
  • Upload date:
  • Size: 11.3 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for vs_temporalfix-2.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f5176a7b8849ea68e300b464227057e6490316d1e08fa74e90821d8708a369a4
MD5 810d4ef593ca4d231ae06df2542922fd
BLAKE2b-256 33fe30ea505ee8890322a838aa889bcd0adc859bb6f53c9b22dfbaac065b7747

See more details on using hashes here.

Provenance

The following attestation bundles were made for vs_temporalfix-2.4.0-py3-none-any.whl:

Publisher: publish.yml on pifroggi/vs_temporalfix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page