How sunny2109/rdg works
1. This repository is a BasicSR-based research package for one primary task: efficient video super-resolution for real-time rendering, using the RDG architecture. The codebase is organized around the standard BasicSR lifecycle: dataset preparation, model training, validation/testing, metric evaluation, and checkpoint packaging.
2. The main execution entry points are basicsr/train.py and basicsr/test.py, both driven by YAML configs in options/train and options/test. Those configs are the central wiring layer: they select datasets, model wrappers, losses, optimizers, schedulers, logging behavior, and output locations.
3. The core network lives in basicsr/archs/rdg_arch.py and basicsr/archs/rdg_block.py. RDG is described in the README as an asymmetric UNet-style super-resolution network with a dynamic feature modulator and auxiliary G-buffer guidance, which means the architecture is not a plain image SR backbone; it is designed to fuse rendering buffers and image features during decoding.
4. Model-level training logic is separated from the network definition. The basicsr/models package provides BasicSR model wrappers such as base_model.py, sr_model.py, video_*_model.py, and GAN/SR variants. These classes own optimization, checkpointing, EMA or scheduler logic, and the training/validation step orchestration, while the arch files provide the forward network itself.
5. Data handling is a major subsystem. basicsr/data contains multiple dataset types for paired images, single images, video datasets, real-world SR datasets, FFHQ, REDS, Vimeo90K, and render-oriented data. For RDG, the render/video-oriented loaders are the important boundary because they feed aligned LR frames, HR targets, and auxiliary guidance such as G-buffers or render metadata.
6. The data pipeline is configurable and modular. It includes sampling, transforms, degradation simulation, LMDB access, prefetching, and dataset-specific metadata files under basicsr/data/meta_info. This makes the training input path flexible: raw image folders, LMDB databases, and video sequences can all be normalized into BasicSR dataloaders.
7. Dataset creation and preprocessing are handled by scripts in scripts/data_preparation. These cover LMDB generation, subimage extraction, meta-info generation, TFRecord extraction, and dataset downloads. The README also shows the project’s domain-specific data source: Blender/Cycles renders producing paired HR/LR video and auxiliary buffers for the rendering scenario.
8. Evaluation is split into library metrics and standalone scripts. basicsr/metrics implements PSNR/SSIM, FID, and NIQE, while scripts/metrics provides command-line calculators for folders and benchmark sets. Test runs write outputs into results/, which also stores logs for reproducibility.
9. The repo includes custom low-level CUDA/C++ ops under basicsr/ops: deformable convolution, fused bias/activation, and upsample-filter-downsample kernels. These are performance-critical building blocks used by some models in the broader BasicSR family and indicate that the repository supports both accuracy-oriented and efficiency-oriented architectures.
10. Common infrastructure is concentrated in basicsr/utils: option parsing, registries, distributed training utilities, logging, file clients, image/flow/color helpers, LMDB helpers, and miscellaneous math/image processing utilities. This layer is what makes the architecture configurable and portable across local disks, LMDB-backed datasets, and distributed GPU training.
11. The repository also ships pretrained checkpoints in checkpoints/ and example results in results/, so the operational flow is reproducible without retraining. Release automation is present through GitHub Actions and packaging files, showing that the project is meant to be installed as a Python package as well as run as a research codebase.
12. For architecture diagram purposes, the main boundaries are: external datasets and pretrained weights; the BasicSR config-and-registry layer; dataset/preprocessing pipeline; RDG network architecture; model/training wrappers; metrics/output artifacts. The key end-to-end flow is data preparation → dataloader → RDG forward pass with guidance buffers → loss/optimization → checkpointing → evaluation on test sets → metrics and rendered outputs.
Main entry points: video_render_model.py SR Models · transforms.py Data Utils · test.py Test · train_RDG_x4.yml Train YAMLs
Components 16
BasicSR Wiring
Entry points and configuration layer that assemble the run.
- Train · Main training script.
basicsr/train.py - Test · Main evaluation script.
basicsr/test.py - Train YAMLs · Training options for RDG variants.
options/train/train_RDG_x4.yml - Test YAMLs · Testing options for RDG variants.
options/test/test_RDG_x4.yml
Data Pipeline
Dataset loaders and preprocessing for image, video, and render data.
- Data Utils · Transforms, sampling, prefetching, degradation, and dataset helpers.
basicsr/data/transforms.py - Render Data · Render-oriented loaders for paired frames and auxiliary guidance.
basicsr/data/render_dataset.py - Video Data · Video sequence loaders used for SR training and testing.
basicsr/data/reds_dataset.py - Image Data · Paired and single-image datasets for generic SR workflows.
basicsr/data/paired_image_dataset.py
RDG Core
Network definition and training wrappers.
- SR Models · Base model classes and video/render-specific orchestration.
basicsr/models/video_render_model.py - RDG Arch · Asymmetric UNet-style SR backbone with guidance fusion.
basicsr/archs/rdg_arch.py - RDG Blocks · Building blocks and modulation components for RDG.
basicsr/archs/rdg_block.py - Losses · Pixel, perceptual, and GAN loss implementations.
basicsr/losses/basic_loss.py
Evaluation
Metrics and result artifacts.
Connections 18
- Train → Train YAMLs: loads · Training entry point is driven by YAML options.
- Test → Test YAMLs: loads · Testing entry point is driven by YAML options.
- Train YAMLs → Registry: builds · Config values instantiate datasets, models, losses, and logging.
- Test YAMLs → Registry: builds · Config values instantiate test-time datasets and metrics.
- Registry → Data Utils: creates · Registry and helpers assemble dataloading and preprocessing.
- Data Utils → Image Data: feeds · Transforms and sampling support image datasets.
- Data Utils → Video Data: feeds · Transforms and sampling support video datasets.
- Data Utils → Render Data: feeds · Transforms and metadata support render-oriented datasets.
- Train YAMLs → SR Models: selects · Config chooses the model wrapper used for optimization.
- SR Models → RDG Arch: runs · Model wrapper calls the RDG network forward pass.
- SR Models → RDG Blocks: depends on · Wrapper uses RDG architectural components indirectly through the network.
- SR Models → Losses: optimizes · Training wrapper owns loss computation and backprop.
- RDG Arch → CUDA Ops: accelerates · Network variants can rely on custom CUDA/C++ operators.
- RDG Blocks → CUDA Ops: accelerates · Block implementations may use fused and deformable ops.
- Test → Metrics: evaluates · Testing pipeline computes image quality metrics.
- SR Models → Metrics: reports · Validation hooks compare outputs using metrics.
- Test → Results: writes · Inference outputs and logs are stored under results/.
- Train → Results: logs · Training and validation artifacts are written to output directories.