Vapoursynth GRLIR

From wiki.selur.net
Jump to navigation Jump to search

GRLIR runs the restoration models of GRL, a transformer network that models image structure at several scales: deblurring, demosaicking, denoising and JPEG artifact removal at the input size. It runs on an NVIDIA GPU through PyTorch and is slow; the super-resolution models are in Vapoursynth GRLIR Resize.

Filtering → Vapoursynth → Other

GRLIR controls in Hybrid
GRLIR controls in Hybrid

What it does

Every frame is restored on its own (no temporal processing) by the chosen model; the output keeps the input size.

Requirements

  • Windows, Hybrid's torch add-on and an NVIDIA GPU with CUDA.

Settings

Control Parameter Range / values Hybrid default Meaning
Model model Defocus Deblurring, Motion Deblurring (GoPro), (RealBlur-J), (RealBlur-R), Demosaicking, Denoising (sigma 15/25/50), JPEG compression artifact removal (quality 10/20/30/40) Defocus Deblurring Network; denoising and JPEG models are trained for one noise level or JPEG quality.
GPU ID device_index 0 – 4 0 CUDA device.
Streams num_streams 1 – 64 1 Number of CUDA streams; not more than VapourSynth's thread count.
CUDA Graph cuda_graphs on/off off Uses CUDA graphs.
Tile (x/y) tile_w, tile_h 0 – 8192 0 / 0 Splits the frame into tiles to save GPU memory; 0 = no tiling (both values must be set).
Tile pad tile_pad 0 – 64 16 Overlap of the tiles; only with tiling. Changing the model while tiling sets the model's own pad (16 deblurring/denoising, 12 motion deblurring, 8 demosaicking, 36 JPEG).
FP16 – on/off off Half precision (16-bit float clip); faster and needs less memory.

Example

Default settings on a 10-bit YUV 4:2:0 source (640x356):

# adjusting color space from YUV420P10 to RGBS for vsGRLIRFilter
clip = core.resize.Bicubic(clip=clip, format=vs.RGBS, matrix_in_s="470bg", range_in_s="limited", range_s="full")
# restoring using GRLIR
from vsgrlir import grlir
clip = grlir(clip, model=1)

How Hybrid calls it

  • The clip is converted to 32-bit float RGB (16-bit float with FP16); the plugin pads the frame to its window size itself.
  • The model is always written, and so is the tile pad while tiling is on; GPU ID, streams, tiles and CUDA Graph only when they differ from the defaults.
  • GRLIR also offers the common options (Masked, ApplyOnlyTo, Merge, OnRegion, Gimmick).

Background

GRL

GRL (Li et al., CVPR 2023, "Efficient and Explicit Modelling of Image Hierarchies for Image Restoration") combines regional, local and global attention, so the network sees structure at several distances at once.

vs-grlir

HolyWu's vs-grlir runs GRL in VapourSynth with PyTorch and accepts 16- or 32-bit float RGB. Without an explicit tile pad it picks one per model, which is why Hybrid always writes the value shown.

Sources