gRestorer is a GPU-first video pipeline for mosaic detection and restoration:
NVDEC (PyNvVideoCodec) → RGB/RGBP → BGR → Detect → (Track → Clip Restore → Composite) → NVENC → FFmpeg remux
It’s built to be measurable first, optimized second: the CLI prints per-stage timings so you can tune performance and quality surgically.
- Decode frames on GPU using
PyNvVideoCodec(NVDEC) - Convert decoder output RGB/RGBP → BGR (LADA-style models expect BGR ordering)
- (Optional) Detect mosaics using a YOLO segmentation model (Ultralytics)
- Restore
none: passthrough baseline (decode + conversion + encode cost)pseudo: draw ROI boxes + fill mosaic regions (visual sanity-check)pseudo_clip: clip-mode pipeline (tracker/compositor validation)basicvsrpp: clip restoration using a BasicVSR++-style model checkpoint
- Encode on GPU using
PyNvVideoCodec(NVENC) - Remux to MP4 with FFmpeg (optionally copying audio/subtitles from the source)
python -m gRestorer.cli— main pipeline (decode → [detect] → restore → encode → remux)python -m gRestorer.cli.add-mosaic— GPU synth mosaic generator (for creating SFW test clips)
Both commands default to loading ./config.json if present.
gRestorer/
cli/ # CLI entry + pipeline orchestration
core/ # scene/clip tracking logic
detector/ # mosaic detector wrapper (YOLO seg)
restorer/ # restorers: none, pseudo, pseudo_clip, basicvsrpp
utils/ # config + visualization helpers
video/ # NVDEC/NVENC wrappers: decoder.py, encoder.py
synthmosaic/ # mosaic addition functions
pyproject.toml
requirements.txt
config.json # optional; loaded by CLI if present
README.md
py -3.13 -m venv venv
.\venv\Scripts\Activate.ps1
python -m pip install -U pipAt same folder level as venv above
git clone git clone <url>
cd gRestorer
pip install -r requirements.txtInstall the torch build that matches your machine (CUDA / CPU / Intel XPU). Example (CUDA):
# Example only — choose the correct index URL for your CUDA version
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu128pip install -e .
python -m gRestorer.cli --helppython -m gRestorer.cli `
--input "D:\Videos\Test\sample.mp4" `
--output "D:\Videos\Test\out_none.mp4" `
--restorer nonepython -m gRestorer.cli `
--input "D:\Videos\Test\sample.mp4" `
--output "D:\Videos\Test\out_pseudo.mp4" `
--restorer pseudo `
--det-model "D:\Models\lada\lada_mosaic_detection_model_v3.1_accurate.pt" `
--debugpython -m gRestorer.cli `
--input "D:\Videos\Test\sample.mp4" `
--output "D:\Videos\Test\out_pseudoClip.mp4" `
--restorer pseudo_clip `
--det-model "D:\Models\lada\lada_mosaic_detection_model_v3.1_accurate.pt" `
--debugpython -m gRestorer.cli `
--input "D:\Videos\Test\sample.mp4" `
--output "D:\Videos\Test\out_basicvsrpp.mp4" `
--restorer basicvsrpp `
--det-model "D:\Models\lada\lada_mosaic_detection_model_v3.1_accurate.pt" `
--rest-model "D:\Models\lada\lada_mosaic_restoration_model_generic_v1.2.pth" `
--debugGenerate controlled SFW mosaics (fixed ROIs) for testing:
python -m gRestorer.cli.add-mosaic `
--input "D:\Videos\Test\sample.mp4" `
--output "D:\Videos\Mosaic\sample-M3.mp4"ROIs can be specified either via CLI (--roi t,l,b,r, repeatable) or in config.json under synth_mosaic.rois.
config.json is optional; CLI flags override config values.
Common knobs:
detection.batch_size,detection.imgsz,detection.conf_threshold,detection.iou_threshold,detection.fp16restoration.max_clip_length,restoration.clip_size,restoration.border_ratio,restoration.pad_mode,restoration.fp16restoration.feather_radius— compositor feather blending at ROI boundary- Recommended default:
0(larger values can reintroduce mosaic-edge artifacts)
- Recommended default:
roi_dilate— expand ROI boxes (pixels) before cropping/restoringencoder.*— codec/preset/profile/qp and remux behavior- Remux uses FFmpeg and may optionally copy audio/subtitles from the input (if enabled in your encoder settings)
The pipeline reports:
- per-stage timings (
decode / det / track / restore / encode) - processing time without mux
- total time with mux (FFmpeg remux duration shown separately)
ffprobe -v error -select_streams v:0 -count_frames `
-show_entries stream=nb_read_frames -of default=nk=1:nw=1 "VIDEO.mp4"- Set
restoration.feather_radiusto0(recommended) - If needed: increase
roi_dilateslightly (+2 px)
- Increase
detection.imgsz(e.g., 640 → 1280) - For synth mosaics, use a sufficiently large mosaic block size so artifacts survive scaling
This project draws heavily from:
- lada – for the detection and restoration models and the original mmagic‑based pipeline.

- BasicVSR++ – for the underlying video restoration architecture.
Please check the upstream projects for full training code, original implementations, and model weights.