Upload folder using huggingface_hub
Browse files- README.md +50 -0
- checkpoints/2x_NERVE_release_500k.safetensors +3 -0
- checkpoints/4x_NERVE_OTF_fidelity_135k.safetensors +3 -0
- checkpoints/4x_NERVE_OTF_gan_35k.safetensors +3 -0
- checkpoints/4x_NERVE_release_485k.safetensors +3 -0
- configs/2x_NERVE_release.yml +92 -0
- configs/4x_NERVE_OTF_fidelity.yml +158 -0
- configs/4x_NERVE_OTF_fidelity_v2.yml +163 -0
- configs/4x_NERVE_OTF_gan.yml +166 -0
- configs/4x_NERVE_OTF_gan_v2.yml +169 -0
- configs/4x_NERVE_release.yml +101 -0
- onnx/2x_NERVE_1x3xHxW_fp32_op20.onnx +3 -0
- onnx/4x_NERVE_1x3xHxW_fp32_op20.onnx +3 -0
README.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
library_name: traiNNer-redux
|
| 4 |
+
tags:
|
| 5 |
+
- super-resolution
|
| 6 |
+
- image-restoration
|
| 7 |
+
- image-upscaling
|
| 8 |
+
pipeline_tag: image-to-image
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
# NERVE — Neural Efficient Restoration for Various Edge devices
|
| 12 |
+
|
| 13 |
+
Private backup of the NERVE 4x/2x release checkpoints, ONNX exports and
|
| 14 |
+
training configs. NERVE is a compact norm-free conv super-resolution
|
| 15 |
+
architecture (Conv-ReLU-Conv residual blocks, no attention) designed for
|
| 16 |
+
mobile/edge deployment.
|
| 17 |
+
|
| 18 |
+
## Architecture
|
| 19 |
+
|
| 20 |
+
- `stem`: 5×5 conv opens the receptive field
|
| 21 |
+
- body: `n_blocks` Conv-ReLU-Conv residual blocks (default `dim=48`, `n_blocks=16`)
|
| 22 |
+
- head: PixelShuffle upsampler with **ICNR initialization** (checkerboard-free)
|
| 23 |
+
- global residual + bicubic-input residual
|
| 24 |
+
|
| 25 |
+
Params: ~688K (4x), ~672K (2x). Fully conv — dynamic-shape ONNX export
|
| 26 |
+
(no fused/unfused pairs), NCNN/CoreML friendly.
|
| 27 |
+
|
| 28 |
+
## Models
|
| 29 |
+
|
| 30 |
+
| checkpoint | what | eval (Urban100) |
|
| 31 |
+
|---|---|---|
|
| 32 |
+
| `2x_NERVE_release_500k` | clean bicubic 2x | 31.647 PSNR / 0.9236 SSIM @500k |
|
| 33 |
+
| `4x_NERVE_release_485k` | clean bicubic 4x | 24.9524 PSNR / 0.7473 SSIM @485k |
|
| 34 |
+
| `4x_NERVE_OTF_fidelity_135k` | 4x OTF fidelity (Real-ESRGAN degradation) | 21.95 PSNR / 0.6435 SSIM @135k EMA |
|
| 35 |
+
| `4x_NERVE_OTF_gan_35k` | 4x OTF GAN finetune | topiq 0.4065 / lpips 0.3174 @35k EMA |
|
| 36 |
+
|
| 37 |
+
## ONNX
|
| 38 |
+
|
| 39 |
+
`onnx/*.onnx` are dynamic-shape (1,3,H,W) fp32 exports, opset 20, verified
|
| 40 |
+
against PyTorch on CPU with max abs diff < 5e-5 at 48×48 / 323×711 / 720×1280.
|
| 41 |
+
|
| 42 |
+
## Usage
|
| 43 |
+
|
| 44 |
+
```bash
|
| 45 |
+
# train a stage
|
| 46 |
+
python train.py -opt configs/4x_NERVE_OTF_fidelity_v2.yml --auto_resume
|
| 47 |
+
```
|
| 48 |
+
|
| 49 |
+
Checkpoint files are plain `net_g` EMA state dicts (no wrapper) — load with
|
| 50 |
+
`traiNNer.archs.nerve_arch.nerve(scale=N, dim=48, n_blocks=16)`.
|
checkpoints/2x_NERVE_release_500k.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a783adb6f3300a49e7e79449a3a1a04d7351521b27dd9274429eee5df2893ef9
|
| 3 |
+
size 2692592
|
checkpoints/4x_NERVE_OTF_fidelity_135k.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:29ce83a227cb4325e2475a72acf885b81336011e6e704ed9bf5590de67420288
|
| 3 |
+
size 2754800
|
checkpoints/4x_NERVE_OTF_gan_35k.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a2d13329265e7f9b41542cab86ab2a05fb2bc31db3124390f1650e9573073a59
|
| 3 |
+
size 2754800
|
checkpoints/4x_NERVE_release_485k.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ed0e0d8e245abe9fe6100a8b36c4598d9a9f9e5dd774c876f9a7e95ccf5548ba
|
| 3 |
+
size 2754800
|
configs/2x_NERVE_release.yml
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# yaml-language-server: $schema=https://raw.githubusercontent.com/the-database/traiNNer-redux/refs/heads/master/schemas/redux-config.schema.json
|
| 2 |
+
#########################################################################################
|
| 3 |
+
# NERVE 2x release training (clean bicubic fidelity)
|
| 4 |
+
#
|
| 5 |
+
# Canonical NERVE: norm-free, dim 48, n_blocks 16, ~672K params (2x head is
|
| 6 |
+
# smaller than 4x). Trained on LUCID CC0 v2 HC-512 (license-clean) paired with
|
| 7 |
+
# chainner CubicCatrom lr_x2. This is also the warm start for the 4x release:
|
| 8 |
+
# the 4x run loads this model's BODY weights (strict_load_g: false resets the
|
| 9 |
+
# scale-specific PixelShuffle head).
|
| 10 |
+
#########################################################################################
|
| 11 |
+
name: 2x_NERVE_release
|
| 12 |
+
scale: 2
|
| 13 |
+
use_amp: true
|
| 14 |
+
amp_bf16: true
|
| 15 |
+
use_channels_last: true
|
| 16 |
+
fast_matmul: false
|
| 17 |
+
use_compile: true
|
| 18 |
+
compile_mode: default
|
| 19 |
+
num_gpu: auto
|
| 20 |
+
manual_seed: 1024
|
| 21 |
+
|
| 22 |
+
datasets:
|
| 23 |
+
train:
|
| 24 |
+
name: LUCID Train
|
| 25 |
+
type: pairedimagedataset
|
| 26 |
+
dataroot_gt: [datasets/train/lucid_hc512/hr]
|
| 27 |
+
dataroot_lq: [datasets/train/lucid_hc512/lr_x2]
|
| 28 |
+
lq_size: 96
|
| 29 |
+
use_hflip: true
|
| 30 |
+
use_rot: true
|
| 31 |
+
num_worker_per_gpu: 8
|
| 32 |
+
batch_size_per_gpu: 8
|
| 33 |
+
accum_iter: 1
|
| 34 |
+
val:
|
| 35 |
+
name: Urban100 Val
|
| 36 |
+
type: pairedimagedataset
|
| 37 |
+
dataroot_gt: [datasets/val/urban100/hr]
|
| 38 |
+
dataroot_lq: [datasets/val/urban100/lr_x2]
|
| 39 |
+
filename_tmpl: "{}x2"
|
| 40 |
+
|
| 41 |
+
network_g:
|
| 42 |
+
type: nerve
|
| 43 |
+
dim: 48
|
| 44 |
+
n_blocks: 16
|
| 45 |
+
|
| 46 |
+
path:
|
| 47 |
+
param_key_g: ~
|
| 48 |
+
strict_load_g: true
|
| 49 |
+
resume_state: ~
|
| 50 |
+
|
| 51 |
+
train:
|
| 52 |
+
ema_decay: 0.999
|
| 53 |
+
ema_power: 0.75
|
| 54 |
+
grad_clip: false
|
| 55 |
+
grad_clip_max_norm: 100
|
| 56 |
+
optim_g:
|
| 57 |
+
type: AdamW
|
| 58 |
+
lr: !!float 2e-4
|
| 59 |
+
weight_decay: 0
|
| 60 |
+
betas: [0.9, 0.99]
|
| 61 |
+
scheduler:
|
| 62 |
+
type: MultiStepLR
|
| 63 |
+
milestones: [200000, 350000, 450000]
|
| 64 |
+
gamma: 0.5
|
| 65 |
+
total_iter: 500000
|
| 66 |
+
warmup_iter: -1
|
| 67 |
+
losses:
|
| 68 |
+
- type: charbonnierloss
|
| 69 |
+
loss_weight: 1.0
|
| 70 |
+
|
| 71 |
+
val:
|
| 72 |
+
val_enabled: true
|
| 73 |
+
val_freq: 5000
|
| 74 |
+
save_img: false # disk-safe: metrics only; visuals on demand via inference scripts
|
| 75 |
+
tile_size: 0
|
| 76 |
+
tile_overlap: 8
|
| 77 |
+
metrics_enabled: true
|
| 78 |
+
metrics:
|
| 79 |
+
psnr:
|
| 80 |
+
type: calculate_psnr
|
| 81 |
+
crop_border: 2
|
| 82 |
+
test_y_channel: true
|
| 83 |
+
ssim:
|
| 84 |
+
type: calculate_ssim
|
| 85 |
+
crop_border: 2
|
| 86 |
+
test_y_channel: true
|
| 87 |
+
|
| 88 |
+
logger:
|
| 89 |
+
print_freq: 100
|
| 90 |
+
save_checkpoint_freq: 5000
|
| 91 |
+
save_checkpoint_format: safetensors
|
| 92 |
+
use_tb_logger: true
|
configs/4x_NERVE_OTF_fidelity.yml
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# yaml-language-server: $schema=https://raw.githubusercontent.com/the-database/traiNNer-redux/refs/heads/master/schemas/redux-config.schema.json
|
| 2 |
+
#########################################################################################
|
| 3 |
+
# NERVE 4x OTF fidelity pretrain (Real-ESRGAN-style degradation)
|
| 4 |
+
#
|
| 5 |
+
# Degradation + losses mirror HEART's 4x_HEART_OTF_v2 so the NERVE OTF model is
|
| 6 |
+
# directly comparable to the HEART OTF model. Network is canonical NERVE
|
| 7 |
+
# (norm-free, dim 48, n_blocks 16). Charbonnier + MS-SSIM + small perceptual.
|
| 8 |
+
#
|
| 9 |
+
# Start from the clean release weights (see path.pretrain_network_g); if that
|
| 10 |
+
# model is not available yet, set pretrain_network_g to ~ and train from
|
| 11 |
+
# scratch (slower to converge, same recipe).
|
| 12 |
+
#
|
| 13 |
+
# lq_size 96 has no window-alignment meaning for NERVE (no attention) but is
|
| 14 |
+
# kept to match HEART's degradation/eval pipeline.
|
| 15 |
+
#########################################################################################
|
| 16 |
+
name: 4x_NERVE_OTF_fidelity
|
| 17 |
+
scale: 4
|
| 18 |
+
use_amp: true
|
| 19 |
+
amp_bf16: true
|
| 20 |
+
use_channels_last: true
|
| 21 |
+
fast_matmul: false
|
| 22 |
+
use_compile: true
|
| 23 |
+
compile_mode: default
|
| 24 |
+
num_gpu: auto
|
| 25 |
+
manual_seed: 1024
|
| 26 |
+
|
| 27 |
+
high_order_degradation: true
|
| 28 |
+
high_order_degradations_debug: false
|
| 29 |
+
high_order_degradations_debug_limit: 100
|
| 30 |
+
|
| 31 |
+
lq_usm: true
|
| 32 |
+
lq_usm_radius_range: [1, 25]
|
| 33 |
+
|
| 34 |
+
blur_prob: 0.6
|
| 35 |
+
resize_prob: [0.2, 0.7, 0.1]
|
| 36 |
+
resize_mode_list: ['bilinear', 'bicubic', 'nearest-exact', 'lanczos']
|
| 37 |
+
resize_mode_prob: [0.25, 0.25, 0.25, 0.25]
|
| 38 |
+
resize_range: [0.4, 1.5]
|
| 39 |
+
gaussian_noise_prob: 0.4
|
| 40 |
+
noise_range: [1, 15]
|
| 41 |
+
poisson_scale_range: [0.05, 2]
|
| 42 |
+
gray_noise_prob: 0.1
|
| 43 |
+
jpeg_prob: 0.4
|
| 44 |
+
jpeg_range: [40, 95]
|
| 45 |
+
|
| 46 |
+
blur_prob2: 0.3
|
| 47 |
+
resize_prob2: [0.3, 0.4, 0.3]
|
| 48 |
+
resize_mode_list2: ['bilinear', 'bicubic', 'nearest-exact', 'lanczos']
|
| 49 |
+
resize_mode_prob2: [0.25, 0.25, 0.25, 0.25]
|
| 50 |
+
resize_range2: [0.6, 1.2]
|
| 51 |
+
gaussian_noise_prob2: 0.3
|
| 52 |
+
noise_range2: [1, 10]
|
| 53 |
+
poisson_scale_range2: [0.05, 1.5]
|
| 54 |
+
gray_noise_prob2: 0.05
|
| 55 |
+
jpeg_prob2: 0.3
|
| 56 |
+
jpeg_range2: [40, 95]
|
| 57 |
+
|
| 58 |
+
resize_mode_list3: ['bilinear', 'bicubic', 'nearest-exact', 'lanczos']
|
| 59 |
+
resize_mode_prob3: [0.25, 0.25, 0.25, 0.25]
|
| 60 |
+
|
| 61 |
+
queue_size: 120
|
| 62 |
+
|
| 63 |
+
datasets:
|
| 64 |
+
train:
|
| 65 |
+
name: LUCID OTF Train
|
| 66 |
+
type: realesrgandataset
|
| 67 |
+
dataroot_gt: [datasets/train/lucid_hc512/hr]
|
| 68 |
+
|
| 69 |
+
blur_kernel_size: 12
|
| 70 |
+
kernel_list: ['iso', 'aniso', 'generalized_iso', 'generalized_aniso', 'plateau_iso', 'plateau_aniso']
|
| 71 |
+
kernel_prob: [0.45, 0.25, 0.12, 0.03, 0.12, 0.03]
|
| 72 |
+
kernel_range: [5, 17]
|
| 73 |
+
blur_sigma: [0.2, 2]
|
| 74 |
+
betag_range: [0.5, 4]
|
| 75 |
+
betap_range: [1, 2]
|
| 76 |
+
|
| 77 |
+
blur_kernel_size2: 12
|
| 78 |
+
kernel_list2: ['iso', 'aniso', 'generalized_iso', 'generalized_aniso', 'plateau_iso', 'plateau_aniso']
|
| 79 |
+
kernel_prob2: [0.45, 0.25, 0.12, 0.03, 0.12, 0.03]
|
| 80 |
+
kernel_range2: [5, 17]
|
| 81 |
+
blur_sigma2: [0.2, 1]
|
| 82 |
+
betag_range2: [0.5, 4]
|
| 83 |
+
betap_range2: [1, 2]
|
| 84 |
+
|
| 85 |
+
final_kernel_range: [5, 17]
|
| 86 |
+
|
| 87 |
+
lq_size: 96
|
| 88 |
+
use_hflip: true
|
| 89 |
+
use_rot: true
|
| 90 |
+
num_worker_per_gpu: 8
|
| 91 |
+
batch_size_per_gpu: 8
|
| 92 |
+
accum_iter: 1
|
| 93 |
+
|
| 94 |
+
val:
|
| 95 |
+
name: Urban100 OTF Val
|
| 96 |
+
type: pairedimagedataset
|
| 97 |
+
dataroot_gt: [datasets/val/urban100/hr]
|
| 98 |
+
dataroot_lq: [datasets/val/urban100_otf_x4]
|
| 99 |
+
|
| 100 |
+
network_g:
|
| 101 |
+
type: nerve
|
| 102 |
+
dim: 48
|
| 103 |
+
n_blocks: 16
|
| 104 |
+
|
| 105 |
+
path:
|
| 106 |
+
pretrain_network_g: experiments/4x_NERVE_release/models/net_g_ema_latest.safetensors
|
| 107 |
+
param_key_g: ~
|
| 108 |
+
strict_load_g: true
|
| 109 |
+
resume_state: ~
|
| 110 |
+
|
| 111 |
+
train:
|
| 112 |
+
ema_decay: 0.999
|
| 113 |
+
ema_power: 0.75
|
| 114 |
+
grad_clip: false
|
| 115 |
+
grad_clip_max_norm: 100
|
| 116 |
+
optim_g:
|
| 117 |
+
type: AdamW
|
| 118 |
+
lr: !!float 1e-4
|
| 119 |
+
weight_decay: 0
|
| 120 |
+
betas: [0.9, 0.99]
|
| 121 |
+
scheduler:
|
| 122 |
+
type: MultiStepLR
|
| 123 |
+
milestones: [100000, 180000]
|
| 124 |
+
gamma: 0.5
|
| 125 |
+
total_iter: 200000
|
| 126 |
+
warmup_iter: -1
|
| 127 |
+
losses:
|
| 128 |
+
- type: charbonnierloss
|
| 129 |
+
loss_weight: 1.0
|
| 130 |
+
- type: perceptualloss
|
| 131 |
+
criterion: charbonnier
|
| 132 |
+
loss_weight: 0.01
|
| 133 |
+
- type: mssimloss
|
| 134 |
+
loss_weight: 0.5
|
| 135 |
+
|
| 136 |
+
val:
|
| 137 |
+
val_enabled: true
|
| 138 |
+
val_freq: 5000
|
| 139 |
+
save_img: false # disk-safe: metrics only; visuals on demand via inference scripts
|
| 140 |
+
tile_size: 0
|
| 141 |
+
tile_overlap: 8
|
| 142 |
+
metrics_enabled: true
|
| 143 |
+
metrics:
|
| 144 |
+
psnr:
|
| 145 |
+
type: calculate_psnr
|
| 146 |
+
crop_border: 4
|
| 147 |
+
test_y_channel: true
|
| 148 |
+
ssim:
|
| 149 |
+
type: calculate_ssim
|
| 150 |
+
crop_border: 4
|
| 151 |
+
test_y_channel: true
|
| 152 |
+
|
| 153 |
+
logger:
|
| 154 |
+
print_freq: 100
|
| 155 |
+
save_checkpoint_freq: 5000
|
| 156 |
+
save_checkpoint_format: safetensors
|
| 157 |
+
use_tb_logger: true
|
| 158 |
+
|
configs/4x_NERVE_OTF_fidelity_v2.yml
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# yaml-language-server: $schema=https://raw.githubusercontent.com/the-database/traiNNer-redux/refs/heads/master/schemas/redux-config.schema.json
|
| 2 |
+
#########################################################################################
|
| 3 |
+
# NERVE 4x OTF fidelity pretrain v2 (Real-ESRGAN-style degradation)
|
| 4 |
+
#
|
| 5 |
+
# Changes vs 4x_NERVE_OTF_fidelity:
|
| 6 |
+
# * ICNR init on the PixelShuffle head at build + icnr_reinit_g scrubs the
|
| 7 |
+
# warm-started head (kills sub-pixel checkerboard learned by v1).
|
| 8 |
+
# * lq_phase_jitter: random sub-pixel shift of the final LQ per sample to
|
| 9 |
+
# break the PixelShuffle/degradation phase lock.
|
| 10 |
+
# * Final resize-back no longer uses nearest-exact (phase-locked + aliasing);
|
| 11 |
+
# only anti-aliased bilinear/bicubic/lanczos.
|
| 12 |
+
#
|
| 13 |
+
# Warm-started from the clean release weights. Same losses/recipe as v1 so the
|
| 14 |
+
# checkerboard-vs-clean tradeoff can be compared 1:1.
|
| 15 |
+
#########################################################################################
|
| 16 |
+
name: 4x_NERVE_OTF_fidelity_v2
|
| 17 |
+
scale: 4
|
| 18 |
+
use_amp: true
|
| 19 |
+
amp_bf16: true
|
| 20 |
+
use_channels_last: true
|
| 21 |
+
fast_matmul: false
|
| 22 |
+
use_compile: true
|
| 23 |
+
compile_mode: default
|
| 24 |
+
num_gpu: auto
|
| 25 |
+
manual_seed: 1024
|
| 26 |
+
|
| 27 |
+
high_order_degradation: true
|
| 28 |
+
high_order_degradations_debug: false
|
| 29 |
+
high_order_degradations_debug_limit: 100
|
| 30 |
+
|
| 31 |
+
lq_usm: true
|
| 32 |
+
lq_usm_radius_range: [1, 25]
|
| 33 |
+
|
| 34 |
+
lq_phase_jitter: true
|
| 35 |
+
lq_phase_jitter_range: 0.5
|
| 36 |
+
|
| 37 |
+
blur_prob: 0.6
|
| 38 |
+
resize_prob: [0.2, 0.7, 0.1]
|
| 39 |
+
resize_mode_list: ['bilinear', 'bicubic', 'nearest-exact', 'lanczos']
|
| 40 |
+
resize_mode_prob: [0.25, 0.25, 0.25, 0.25]
|
| 41 |
+
resize_range: [0.4, 1.5]
|
| 42 |
+
gaussian_noise_prob: 0.4
|
| 43 |
+
noise_range: [1, 15]
|
| 44 |
+
poisson_scale_range: [0.05, 2]
|
| 45 |
+
gray_noise_prob: 0.1
|
| 46 |
+
jpeg_prob: 0.4
|
| 47 |
+
jpeg_range: [40, 95]
|
| 48 |
+
|
| 49 |
+
blur_prob2: 0.3
|
| 50 |
+
resize_prob2: [0.3, 0.4, 0.3]
|
| 51 |
+
resize_mode_list2: ['bilinear', 'bicubic', 'nearest-exact', 'lanczos']
|
| 52 |
+
resize_mode_prob2: [0.25, 0.25, 0.25, 0.25]
|
| 53 |
+
resize_range2: [0.6, 1.2]
|
| 54 |
+
gaussian_noise_prob2: 0.3
|
| 55 |
+
noise_range2: [1, 10]
|
| 56 |
+
poisson_scale_range2: [0.05, 1.5]
|
| 57 |
+
gray_noise_prob2: 0.05
|
| 58 |
+
jpeg_prob2: 0.3
|
| 59 |
+
jpeg_range2: [40, 95]
|
| 60 |
+
|
| 61 |
+
# anti-aliased final resize-back only (no nearest-exact: phase-locked + aliasing)
|
| 62 |
+
resize_mode_list3: ['bilinear', 'bicubic', 'lanczos']
|
| 63 |
+
resize_mode_prob3: [0.3333, 0.3333, 0.3334]
|
| 64 |
+
|
| 65 |
+
queue_size: 120
|
| 66 |
+
|
| 67 |
+
datasets:
|
| 68 |
+
train:
|
| 69 |
+
name: LUCID OTF Train
|
| 70 |
+
type: realesrgandataset
|
| 71 |
+
dataroot_gt: [datasets/train/lucid_hc512/hr]
|
| 72 |
+
|
| 73 |
+
blur_kernel_size: 12
|
| 74 |
+
kernel_list: ['iso', 'aniso', 'generalized_iso', 'generalized_aniso', 'plateau_iso', 'plateau_aniso']
|
| 75 |
+
kernel_prob: [0.45, 0.25, 0.12, 0.03, 0.12, 0.03]
|
| 76 |
+
kernel_range: [5, 17]
|
| 77 |
+
blur_sigma: [0.2, 2]
|
| 78 |
+
betag_range: [0.5, 4]
|
| 79 |
+
betap_range: [1, 2]
|
| 80 |
+
|
| 81 |
+
blur_kernel_size2: 12
|
| 82 |
+
kernel_list2: ['iso', 'aniso', 'generalized_iso', 'generalized_aniso', 'plateau_iso', 'plateau_aniso']
|
| 83 |
+
kernel_prob2: [0.45, 0.25, 0.12, 0.03, 0.12, 0.03]
|
| 84 |
+
kernel_range2: [5, 17]
|
| 85 |
+
blur_sigma2: [0.2, 1]
|
| 86 |
+
betag_range2: [0.5, 4]
|
| 87 |
+
betap_range2: [1, 2]
|
| 88 |
+
|
| 89 |
+
final_kernel_range: [5, 17]
|
| 90 |
+
|
| 91 |
+
lq_size: 96
|
| 92 |
+
use_hflip: true
|
| 93 |
+
use_rot: true
|
| 94 |
+
num_worker_per_gpu: 8
|
| 95 |
+
batch_size_per_gpu: 8
|
| 96 |
+
accum_iter: 1
|
| 97 |
+
|
| 98 |
+
val:
|
| 99 |
+
name: Urban100 OTF Val
|
| 100 |
+
type: pairedimagedataset
|
| 101 |
+
dataroot_gt: [datasets/val/urban100/hr]
|
| 102 |
+
dataroot_lq: [datasets/val/urban100_otf_x4]
|
| 103 |
+
|
| 104 |
+
network_g:
|
| 105 |
+
type: nerve
|
| 106 |
+
dim: 48
|
| 107 |
+
n_blocks: 16
|
| 108 |
+
icnr: true
|
| 109 |
+
|
| 110 |
+
path:
|
| 111 |
+
pretrain_network_g: experiments/4x_NERVE_release/models/net_g_ema_latest.safetensors
|
| 112 |
+
param_key_g: ~
|
| 113 |
+
strict_load_g: true
|
| 114 |
+
icnr_reinit_g: true
|
| 115 |
+
resume_state: ~
|
| 116 |
+
|
| 117 |
+
train:
|
| 118 |
+
ema_decay: 0.999
|
| 119 |
+
ema_power: 0.75
|
| 120 |
+
grad_clip: false
|
| 121 |
+
grad_clip_max_norm: 100
|
| 122 |
+
optim_g:
|
| 123 |
+
type: AdamW
|
| 124 |
+
lr: !!float 1e-4
|
| 125 |
+
weight_decay: 0
|
| 126 |
+
betas: [0.9, 0.99]
|
| 127 |
+
scheduler:
|
| 128 |
+
type: MultiStepLR
|
| 129 |
+
milestones: [100000, 180000]
|
| 130 |
+
gamma: 0.5
|
| 131 |
+
total_iter: 200000
|
| 132 |
+
warmup_iter: -1
|
| 133 |
+
losses:
|
| 134 |
+
- type: charbonnierloss
|
| 135 |
+
loss_weight: 1.0
|
| 136 |
+
- type: perceptualloss
|
| 137 |
+
criterion: charbonnier
|
| 138 |
+
loss_weight: 0.01
|
| 139 |
+
- type: mssimloss
|
| 140 |
+
loss_weight: 0.5
|
| 141 |
+
|
| 142 |
+
val:
|
| 143 |
+
val_enabled: true
|
| 144 |
+
val_freq: 5000
|
| 145 |
+
save_img: false # disk-safe: metrics only; visuals on demand via inference scripts
|
| 146 |
+
tile_size: 0
|
| 147 |
+
tile_overlap: 8
|
| 148 |
+
metrics_enabled: true
|
| 149 |
+
metrics:
|
| 150 |
+
psnr:
|
| 151 |
+
type: calculate_psnr
|
| 152 |
+
crop_border: 4
|
| 153 |
+
test_y_channel: true
|
| 154 |
+
ssim:
|
| 155 |
+
type: calculate_ssim
|
| 156 |
+
crop_border: 4
|
| 157 |
+
test_y_channel: true
|
| 158 |
+
|
| 159 |
+
logger:
|
| 160 |
+
print_freq: 100
|
| 161 |
+
save_checkpoint_freq: 5000
|
| 162 |
+
save_checkpoint_format: safetensors
|
| 163 |
+
use_tb_logger: true
|
configs/4x_NERVE_OTF_gan.yml
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# yaml-language-server: $schema=https://raw.githubusercontent.com/the-database/traiNNer-redux/refs/heads/master/schemas/redux-config.schema.json
|
| 2 |
+
#########################################################################################
|
| 3 |
+
# NERVE 4x OTF GAN finetune (mirrors 4x_HEART_OTF_gan_lq96)
|
| 4 |
+
#
|
| 5 |
+
# Same degradation + losses as the HEART OTF GAN finetune; the generator is
|
| 6 |
+
# canonical NERVE (norm-free, dim 48, n_blocks 16, ~688K params). Discriminator
|
| 7 |
+
# is dunet like HEART. No attention windows, so the lq-96 window-alignment fix
|
| 8 |
+
# that HEART needed does not apply here; lq 96 is kept to match the degradation
|
| 9 |
+
# pipeline and evaluation.
|
| 10 |
+
#
|
| 11 |
+
# Two-stage recipe (like HEART):
|
| 12 |
+
# 1. 4x_NERVE_OTF_fidelity.yml (OTF fidelity pretrain)
|
| 13 |
+
# 2. this file (GAN finetune on top of it)
|
| 14 |
+
#########################################################################################
|
| 15 |
+
name: 4x_NERVE_OTF_gan
|
| 16 |
+
scale: 4
|
| 17 |
+
use_amp: true
|
| 18 |
+
amp_bf16: true
|
| 19 |
+
use_channels_last: true
|
| 20 |
+
fast_matmul: false
|
| 21 |
+
use_compile: false # keep default: inductor errors on discriminator step
|
| 22 |
+
compile_mode: default
|
| 23 |
+
num_gpu: auto
|
| 24 |
+
manual_seed: 1024
|
| 25 |
+
|
| 26 |
+
high_order_degradation: true
|
| 27 |
+
high_order_degradations_debug: false
|
| 28 |
+
high_order_degradations_debug_limit: 100
|
| 29 |
+
|
| 30 |
+
lq_usm: true
|
| 31 |
+
lq_usm_radius_range: [1, 25]
|
| 32 |
+
|
| 33 |
+
blur_prob: 0.6
|
| 34 |
+
resize_prob: [0.2, 0.7, 0.1]
|
| 35 |
+
resize_mode_list: ['bilinear', 'bicubic', 'nearest-exact', 'lanczos']
|
| 36 |
+
resize_mode_prob: [0.25, 0.25, 0.25, 0.25]
|
| 37 |
+
resize_range: [0.4, 1.5]
|
| 38 |
+
gaussian_noise_prob: 0.4
|
| 39 |
+
noise_range: [1, 15]
|
| 40 |
+
poisson_scale_range: [0.05, 2]
|
| 41 |
+
gray_noise_prob: 0.1
|
| 42 |
+
jpeg_prob: 0.4
|
| 43 |
+
jpeg_range: [40, 95]
|
| 44 |
+
|
| 45 |
+
blur_prob2: 0.3
|
| 46 |
+
resize_prob2: [0.3, 0.4, 0.3]
|
| 47 |
+
resize_mode_list2: ['bilinear', 'bicubic', 'nearest-exact', 'lanczos']
|
| 48 |
+
resize_mode_prob2: [0.25, 0.25, 0.25, 0.25]
|
| 49 |
+
resize_range2: [0.6, 1.2]
|
| 50 |
+
gaussian_noise_prob2: 0.3
|
| 51 |
+
noise_range2: [1, 10]
|
| 52 |
+
poisson_scale_range2: [0.05, 1.5]
|
| 53 |
+
gray_noise_prob2: 0.05
|
| 54 |
+
jpeg_prob2: 0.3
|
| 55 |
+
jpeg_range2: [40, 95]
|
| 56 |
+
|
| 57 |
+
resize_mode_list3: ['bilinear', 'bicubic', 'nearest-exact', 'lanczos']
|
| 58 |
+
resize_mode_prob3: [0.25, 0.25, 0.25, 0.25]
|
| 59 |
+
|
| 60 |
+
queue_size: 120
|
| 61 |
+
|
| 62 |
+
datasets:
|
| 63 |
+
train:
|
| 64 |
+
name: LUCID OTF Train
|
| 65 |
+
type: realesrgandataset
|
| 66 |
+
dataroot_gt: [datasets/train/lucid_hc512/hr]
|
| 67 |
+
|
| 68 |
+
blur_kernel_size: 12
|
| 69 |
+
kernel_list: ['iso', 'aniso', 'generalized_iso', 'generalized_aniso', 'plateau_iso', 'plateau_aniso']
|
| 70 |
+
kernel_prob: [0.45, 0.25, 0.12, 0.03, 0.12, 0.03]
|
| 71 |
+
kernel_range: [5, 17]
|
| 72 |
+
blur_sigma: [0.2, 2]
|
| 73 |
+
betag_range: [0.5, 4]
|
| 74 |
+
betap_range: [1, 2]
|
| 75 |
+
|
| 76 |
+
blur_kernel_size2: 12
|
| 77 |
+
kernel_list2: ['iso', 'aniso', 'generalized_iso', 'generalized_aniso', 'plateau_iso', 'plateau_aniso']
|
| 78 |
+
kernel_prob2: [0.45, 0.25, 0.12, 0.03, 0.12, 0.03]
|
| 79 |
+
kernel_range2: [5, 17]
|
| 80 |
+
blur_sigma2: [0.2, 1]
|
| 81 |
+
betag_range2: [0.5, 4]
|
| 82 |
+
betap_range2: [1, 2]
|
| 83 |
+
|
| 84 |
+
final_kernel_range: [5, 17]
|
| 85 |
+
|
| 86 |
+
lq_size: 96
|
| 87 |
+
use_hflip: true
|
| 88 |
+
use_rot: true
|
| 89 |
+
num_worker_per_gpu: 8
|
| 90 |
+
batch_size_per_gpu: 4 # NERVE generator is small; batch 4 at lq96 fits easily
|
| 91 |
+
accum_iter: 1
|
| 92 |
+
|
| 93 |
+
val:
|
| 94 |
+
name: Urban100 OTF Val
|
| 95 |
+
type: pairedimagedataset
|
| 96 |
+
dataroot_gt: [datasets/val/urban100/hr]
|
| 97 |
+
dataroot_lq: [datasets/val/urban100_otf_x4]
|
| 98 |
+
|
| 99 |
+
network_g:
|
| 100 |
+
type: nerve
|
| 101 |
+
dim: 48
|
| 102 |
+
n_blocks: 16
|
| 103 |
+
|
| 104 |
+
network_d:
|
| 105 |
+
type: dunet
|
| 106 |
+
|
| 107 |
+
path:
|
| 108 |
+
pretrain_network_g: experiments/4x_NERVE_OTF_fidelity/models/net_g_ema_135000.safetensors
|
| 109 |
+
param_key_g: ~
|
| 110 |
+
strict_load_g: true
|
| 111 |
+
resume_state: ~
|
| 112 |
+
|
| 113 |
+
train:
|
| 114 |
+
ema_decay: 0.999
|
| 115 |
+
ema_power: 0.75
|
| 116 |
+
grad_clip: false
|
| 117 |
+
grad_clip_max_norm: 100
|
| 118 |
+
optim_g:
|
| 119 |
+
type: AdamW
|
| 120 |
+
lr: !!float 1e-4
|
| 121 |
+
weight_decay: 0
|
| 122 |
+
betas: [0.9, 0.99]
|
| 123 |
+
optim_d:
|
| 124 |
+
type: AdamW
|
| 125 |
+
lr: !!float 1e-4
|
| 126 |
+
weight_decay: 0
|
| 127 |
+
betas: [0.9, 0.99]
|
| 128 |
+
scheduler:
|
| 129 |
+
type: MultiStepLR
|
| 130 |
+
milestones: [75000, 120000]
|
| 131 |
+
gamma: 0.5
|
| 132 |
+
total_iter: 150000
|
| 133 |
+
warmup_iter: -1
|
| 134 |
+
losses:
|
| 135 |
+
- type: mssimloss
|
| 136 |
+
loss_weight: 0.5
|
| 137 |
+
- type: perceptualloss
|
| 138 |
+
criterion: charbonnier
|
| 139 |
+
loss_weight: 0.01
|
| 140 |
+
- type: hsluvloss
|
| 141 |
+
criterion: charbonnier
|
| 142 |
+
loss_weight: 1.0
|
| 143 |
+
- type: ganloss
|
| 144 |
+
gan_type: vanilla
|
| 145 |
+
loss_weight: 0.1
|
| 146 |
+
|
| 147 |
+
val:
|
| 148 |
+
val_enabled: true
|
| 149 |
+
val_freq: 5000
|
| 150 |
+
save_img: false # disk-safe: metrics only; visuals on demand via inference scripts
|
| 151 |
+
tile_size: 0
|
| 152 |
+
tile_overlap: 8
|
| 153 |
+
metrics_enabled: true
|
| 154 |
+
metrics:
|
| 155 |
+
topiq:
|
| 156 |
+
type: calculate_topiq
|
| 157 |
+
lpips:
|
| 158 |
+
type: calculate_lpips
|
| 159 |
+
better: lower
|
| 160 |
+
|
| 161 |
+
logger:
|
| 162 |
+
print_freq: 100
|
| 163 |
+
save_checkpoint_freq: 5000
|
| 164 |
+
save_checkpoint_format: safetensors
|
| 165 |
+
use_tb_logger: true
|
| 166 |
+
|
configs/4x_NERVE_OTF_gan_v2.yml
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# yaml-language-server: $schema=https://raw.githubusercontent.com/the-database/traiNNer-redux/refs/heads/master/schemas/redux-config.schema.json
|
| 2 |
+
#########################################################################################
|
| 3 |
+
# NERVE 4x OTF GAN finetune v2 (mirrors 4x_HEART_OTF_gan_lq96)
|
| 4 |
+
#
|
| 5 |
+
# Changes vs 4x_NERVE_OTF_gan:
|
| 6 |
+
# * Degradation fixes carried from 4x_NERVE_OTF_fidelity_v2:
|
| 7 |
+
# - lq_phase_jitter: random sub-pixel LQ shift per sample
|
| 8 |
+
# - final resize-back is anti-aliased only (no nearest-exact)
|
| 9 |
+
# * Warm-starts from the fixed fidelity v2 model (which has an ICNR-clean
|
| 10 |
+
# PixelShuffle head), so the head is kept, not re-scrubbed.
|
| 11 |
+
#
|
| 12 |
+
# Same losses/recipe as v1 for 1:1 comparison.
|
| 13 |
+
#########################################################################################
|
| 14 |
+
name: 4x_NERVE_OTF_gan_v2
|
| 15 |
+
scale: 4
|
| 16 |
+
use_amp: true
|
| 17 |
+
amp_bf16: true
|
| 18 |
+
use_channels_last: true
|
| 19 |
+
fast_matmul: false
|
| 20 |
+
use_compile: false # keep default: inductor errors on discriminator step
|
| 21 |
+
compile_mode: default
|
| 22 |
+
num_gpu: auto
|
| 23 |
+
manual_seed: 1024
|
| 24 |
+
|
| 25 |
+
high_order_degradation: true
|
| 26 |
+
high_order_degradations_debug: false
|
| 27 |
+
high_order_degradations_debug_limit: 100
|
| 28 |
+
|
| 29 |
+
lq_usm: true
|
| 30 |
+
lq_usm_radius_range: [1, 25]
|
| 31 |
+
|
| 32 |
+
lq_phase_jitter: true
|
| 33 |
+
lq_phase_jitter_range: 0.5
|
| 34 |
+
|
| 35 |
+
blur_prob: 0.6
|
| 36 |
+
resize_prob: [0.2, 0.7, 0.1]
|
| 37 |
+
resize_mode_list: ['bilinear', 'bicubic', 'nearest-exact', 'lanczos']
|
| 38 |
+
resize_mode_prob: [0.25, 0.25, 0.25, 0.25]
|
| 39 |
+
resize_range: [0.4, 1.5]
|
| 40 |
+
gaussian_noise_prob: 0.4
|
| 41 |
+
noise_range: [1, 15]
|
| 42 |
+
poisson_scale_range: [0.05, 2]
|
| 43 |
+
gray_noise_prob: 0.1
|
| 44 |
+
jpeg_prob: 0.4
|
| 45 |
+
jpeg_range: [40, 95]
|
| 46 |
+
|
| 47 |
+
blur_prob2: 0.3
|
| 48 |
+
resize_prob2: [0.3, 0.4, 0.3]
|
| 49 |
+
resize_mode_list2: ['bilinear', 'bicubic', 'nearest-exact', 'lanczos']
|
| 50 |
+
resize_mode_prob2: [0.25, 0.25, 0.25, 0.25]
|
| 51 |
+
resize_range2: [0.6, 1.2]
|
| 52 |
+
gaussian_noise_prob2: 0.3
|
| 53 |
+
noise_range2: [1, 10]
|
| 54 |
+
poisson_scale_range2: [0.05, 1.5]
|
| 55 |
+
gray_noise_prob2: 0.05
|
| 56 |
+
jpeg_prob2: 0.3
|
| 57 |
+
jpeg_range2: [40, 95]
|
| 58 |
+
|
| 59 |
+
# anti-aliased final resize-back only (no nearest-exact: phase-locked + aliasing)
|
| 60 |
+
resize_mode_list3: ['bilinear', 'bicubic', 'lanczos']
|
| 61 |
+
resize_mode_prob3: [0.3333, 0.3333, 0.3334]
|
| 62 |
+
|
| 63 |
+
queue_size: 120
|
| 64 |
+
|
| 65 |
+
datasets:
|
| 66 |
+
train:
|
| 67 |
+
name: LUCID OTF Train
|
| 68 |
+
type: realesrgandataset
|
| 69 |
+
dataroot_gt: [datasets/train/lucid_hc512/hr]
|
| 70 |
+
|
| 71 |
+
blur_kernel_size: 12
|
| 72 |
+
kernel_list: ['iso', 'aniso', 'generalized_iso', 'generalized_aniso', 'plateau_iso', 'plateau_aniso']
|
| 73 |
+
kernel_prob: [0.45, 0.25, 0.12, 0.03, 0.12, 0.03]
|
| 74 |
+
kernel_range: [5, 17]
|
| 75 |
+
blur_sigma: [0.2, 2]
|
| 76 |
+
betag_range: [0.5, 4]
|
| 77 |
+
betap_range: [1, 2]
|
| 78 |
+
|
| 79 |
+
blur_kernel_size2: 12
|
| 80 |
+
kernel_list2: ['iso', 'aniso', 'generalized_iso', 'generalized_aniso', 'plateau_iso', 'plateau_aniso']
|
| 81 |
+
kernel_prob2: [0.45, 0.25, 0.12, 0.03, 0.12, 0.03]
|
| 82 |
+
kernel_range2: [5, 17]
|
| 83 |
+
blur_sigma2: [0.2, 1]
|
| 84 |
+
betag_range2: [0.5, 4]
|
| 85 |
+
betap_range2: [1, 2]
|
| 86 |
+
|
| 87 |
+
final_kernel_range: [5, 17]
|
| 88 |
+
|
| 89 |
+
lq_size: 96
|
| 90 |
+
use_hflip: true
|
| 91 |
+
use_rot: true
|
| 92 |
+
num_worker_per_gpu: 8
|
| 93 |
+
batch_size_per_gpu: 4 # NERVE generator is small; batch 4 at lq96 fits easily
|
| 94 |
+
accum_iter: 1
|
| 95 |
+
|
| 96 |
+
val:
|
| 97 |
+
name: Urban100 OTF Val
|
| 98 |
+
type: pairedimagedataset
|
| 99 |
+
dataroot_gt: [datasets/val/urban100/hr]
|
| 100 |
+
dataroot_lq: [datasets/val/urban100_otf_x4]
|
| 101 |
+
|
| 102 |
+
network_g:
|
| 103 |
+
type: nerve
|
| 104 |
+
dim: 48
|
| 105 |
+
n_blocks: 16
|
| 106 |
+
icnr: true
|
| 107 |
+
|
| 108 |
+
network_d:
|
| 109 |
+
type: dunet
|
| 110 |
+
|
| 111 |
+
path:
|
| 112 |
+
pretrain_network_g: experiments/4x_NERVE_OTF_fidelity_v2/models/net_g_ema_latest.safetensors
|
| 113 |
+
param_key_g: ~
|
| 114 |
+
strict_load_g: true
|
| 115 |
+
resume_state: ~
|
| 116 |
+
|
| 117 |
+
train:
|
| 118 |
+
ema_decay: 0.999
|
| 119 |
+
ema_power: 0.75
|
| 120 |
+
grad_clip: false
|
| 121 |
+
grad_clip_max_norm: 100
|
| 122 |
+
optim_g:
|
| 123 |
+
type: AdamW
|
| 124 |
+
lr: !!float 1e-4
|
| 125 |
+
weight_decay: 0
|
| 126 |
+
betas: [0.9, 0.99]
|
| 127 |
+
optim_d:
|
| 128 |
+
type: AdamW
|
| 129 |
+
lr: !!float 1e-4
|
| 130 |
+
weight_decay: 0
|
| 131 |
+
betas: [0.9, 0.99]
|
| 132 |
+
scheduler:
|
| 133 |
+
type: MultiStepLR
|
| 134 |
+
milestones: [75000, 120000]
|
| 135 |
+
gamma: 0.5
|
| 136 |
+
total_iter: 150000
|
| 137 |
+
warmup_iter: -1
|
| 138 |
+
losses:
|
| 139 |
+
- type: mssimloss
|
| 140 |
+
loss_weight: 0.5
|
| 141 |
+
- type: perceptualloss
|
| 142 |
+
criterion: charbonnier
|
| 143 |
+
loss_weight: 0.01
|
| 144 |
+
- type: hsluvloss
|
| 145 |
+
criterion: charbonnier
|
| 146 |
+
loss_weight: 1.0
|
| 147 |
+
- type: ganloss
|
| 148 |
+
gan_type: vanilla
|
| 149 |
+
loss_weight: 0.1
|
| 150 |
+
|
| 151 |
+
val:
|
| 152 |
+
val_enabled: true
|
| 153 |
+
val_freq: 5000
|
| 154 |
+
save_img: false # disk-safe: metrics only; visuals on demand via inference scripts
|
| 155 |
+
tile_size: 0
|
| 156 |
+
tile_overlap: 8
|
| 157 |
+
metrics_enabled: true
|
| 158 |
+
metrics:
|
| 159 |
+
topiq:
|
| 160 |
+
type: calculate_topiq
|
| 161 |
+
lpips:
|
| 162 |
+
type: calculate_lpips
|
| 163 |
+
better: lower
|
| 164 |
+
|
| 165 |
+
logger:
|
| 166 |
+
print_freq: 100
|
| 167 |
+
save_checkpoint_freq: 5000
|
| 168 |
+
save_checkpoint_format: safetensors
|
| 169 |
+
use_tb_logger: true
|
configs/4x_NERVE_release.yml
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# yaml-language-server: $schema=https://raw.githubusercontent.com/the-database/traiNNer-redux/refs/heads/master/schemas/redux-config.schema.json
|
| 2 |
+
#########################################################################################
|
| 3 |
+
# NERVE 4x release training (clean bicubic fidelity)
|
| 4 |
+
#
|
| 5 |
+
# Canonical NERVE: norm-free, dim 48, n_blocks 16, ~688K params. Pure conv, no
|
| 6 |
+
# attention, no normalization. Trained on LUCID CC0 v2 HC-512 (license-clean)
|
| 7 |
+
# paired with chainner CubicCatrom lr_x4. This is the fidelity tier; the OTF
|
| 8 |
+
# fidelity + GAN configs fine-tune on top of this family of weights.
|
| 9 |
+
#
|
| 10 |
+
# Warm start (EDSR-style multi-scale init) from the 2x release body:
|
| 11 |
+
# train 2x_NERVE_release.yml first, then this file loads its body weights;
|
| 12 |
+
# strict_load_g: false resets the scale-specific PixelShuffle head.
|
| 13 |
+
#
|
| 14 |
+
# No window-alignment constraints (NERVE has no attention windows), so crop
|
| 15 |
+
# size and batch are free to pick for throughput; lq 96 matches the HEART
|
| 16 |
+
# pipeline for comparability.
|
| 17 |
+
#########################################################################################
|
| 18 |
+
name: 4x_NERVE_release
|
| 19 |
+
scale: 4
|
| 20 |
+
use_amp: true
|
| 21 |
+
amp_bf16: true
|
| 22 |
+
use_channels_last: true
|
| 23 |
+
fast_matmul: false
|
| 24 |
+
use_compile: true
|
| 25 |
+
compile_mode: default # conv-only net: 'default' is stable and export-safe
|
| 26 |
+
num_gpu: auto
|
| 27 |
+
manual_seed: 1024
|
| 28 |
+
|
| 29 |
+
datasets:
|
| 30 |
+
train:
|
| 31 |
+
name: LUCID Train
|
| 32 |
+
type: pairedimagedataset
|
| 33 |
+
dataroot_gt: [datasets/train/lucid_hc512/hr]
|
| 34 |
+
dataroot_lq: [datasets/train/lucid_hc512/lr_x4]
|
| 35 |
+
lq_size: 96
|
| 36 |
+
use_hflip: true
|
| 37 |
+
use_rot: true
|
| 38 |
+
num_worker_per_gpu: 8
|
| 39 |
+
batch_size_per_gpu: 8
|
| 40 |
+
accum_iter: 1
|
| 41 |
+
val:
|
| 42 |
+
name: Urban100 Val
|
| 43 |
+
type: pairedimagedataset
|
| 44 |
+
dataroot_gt: [datasets/val/urban100/hr]
|
| 45 |
+
dataroot_lq: [datasets/val/urban100/lr_x4]
|
| 46 |
+
filename_tmpl: "{}x4"
|
| 47 |
+
|
| 48 |
+
network_g:
|
| 49 |
+
type: nerve
|
| 50 |
+
dim: 48
|
| 51 |
+
n_blocks: 16
|
| 52 |
+
|
| 53 |
+
path:
|
| 54 |
+
pretrain_network_g: experiments/2x_NERVE_release/models/net_g_ema_latest.safetensors
|
| 55 |
+
param_key_g: ~
|
| 56 |
+
strict_load_g: false # loads the body; resets the scale-specific head
|
| 57 |
+
resume_state: ~
|
| 58 |
+
|
| 59 |
+
train:
|
| 60 |
+
ema_decay: 0.999
|
| 61 |
+
ema_power: 0.75
|
| 62 |
+
grad_clip: false
|
| 63 |
+
grad_clip_max_norm: 100
|
| 64 |
+
optim_g:
|
| 65 |
+
type: AdamW
|
| 66 |
+
lr: !!float 2e-4
|
| 67 |
+
weight_decay: 0
|
| 68 |
+
betas: [0.9, 0.99]
|
| 69 |
+
scheduler:
|
| 70 |
+
type: MultiStepLR
|
| 71 |
+
milestones: [200000, 350000, 450000]
|
| 72 |
+
gamma: 0.5
|
| 73 |
+
total_iter: 500000
|
| 74 |
+
warmup_iter: -1
|
| 75 |
+
losses:
|
| 76 |
+
- type: charbonnierloss
|
| 77 |
+
loss_weight: 1.0
|
| 78 |
+
|
| 79 |
+
val:
|
| 80 |
+
val_enabled: true
|
| 81 |
+
val_freq: 5000
|
| 82 |
+
save_img: false # disk-safe: metrics only; visuals on demand via inference scripts
|
| 83 |
+
tile_size: 0
|
| 84 |
+
tile_overlap: 8
|
| 85 |
+
metrics_enabled: true
|
| 86 |
+
metrics:
|
| 87 |
+
psnr:
|
| 88 |
+
type: calculate_psnr
|
| 89 |
+
crop_border: 4
|
| 90 |
+
test_y_channel: true
|
| 91 |
+
ssim:
|
| 92 |
+
type: calculate_ssim
|
| 93 |
+
crop_border: 4
|
| 94 |
+
test_y_channel: true
|
| 95 |
+
|
| 96 |
+
logger:
|
| 97 |
+
print_freq: 100
|
| 98 |
+
save_checkpoint_freq: 5000
|
| 99 |
+
save_checkpoint_format: safetensors
|
| 100 |
+
use_tb_logger: true
|
| 101 |
+
|
onnx/2x_NERVE_1x3xHxW_fp32_op20.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:54557cbe6b82a31dbbc2a635d06afca67834558c6a01e5814a24deef1747c849
|
| 3 |
+
size 106686
|
onnx/4x_NERVE_1x3xHxW_fp32_op20.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:37338cdbd5916f879cbf0a7a731a785f5ca83bcaf28aef31e0394984ce3dfdbc
|
| 3 |
+
size 106687
|