Skip to content

DeJPEG v1 weights

Choose a tag to compare

@Miosp Miosp released this 27 Aug 12:45
· 12 commits to master since this release

DeJPEGNet v1 (dejpeg-c40)

Compact JPEG artifact removal model. 2.63M parameters, activation-free U-Net: it removes blocking, ringing, and banding from JPEG-compressed images while keeping texture natural. Full architecture, training recipe, and reproduction steps live in models/dejpeg/.

Files

File Size Use
dejpeg-c40.onnx 5.1 MiB Browser inference via ONNX Runtime Web (WebGPU primary, WASM fallback). FP16, opset 17, dynamic H/W axes, reparameterized convs.
dejpeg-c40-fp16.pt 5.1 MiB PyTorch. FP16 state dict, loaded by dejpeg.load_model().

Quick use (Python)

pip install "dejpeg @ git+https://github.com/Miosp/dejpeg#subdirectory=models/dejpeg"
from dejpeg import load_model, restore_image

model = load_model()                    # downloads this release to ~/.cache/dejpeg
restore_image("input.jpg", "restored.png", model)

Overrides: $DEJPEG_WEIGHTS (local file), $DEJPEG_WEIGHTS_URL, $DEJPEG_CACHE_DIR.

Results

Scored against pristine originals on Classic5 and LIVE1, JPEG re-encoded at each quality factor with 4:2:0 chroma subsampling. FBCNN (35.7M parameters) was re-run under the identical protocol. Lower DISTS is better.

Suite QF Input FBCNN (35.7M) DeJPEGNet (2.6M)
Classic5 10 0.2412 0.1938 0.1191
Classic5 20 0.1536 0.1597 0.0911
Classic5 30 0.1215 0.1405 0.0743
Classic5 40 0.1054 0.1268 0.0642
LIVE1 10 0.2387 0.1855 0.1292
LIVE1 20 0.1653 0.1372 0.0895
LIVE1 30 0.1315 0.1126 0.0699
LIVE1 40 0.1126 0.0973 0.0602

LPIPS follows the same pattern (Classic5 QF10: 0.1804 vs FBCNN's 0.2594). PSNR is where FBCNN keeps a roughly 1 dB distortion-metric lead (Classic5 QF10: 29.80 vs 28.81); this model optimizes for how images look, not pixel averages. A built-in unsharp post-process (exposed as --sharpness, on by default) restores some of that crispness at negligible perceptual cost.

Training summary

  • Degradations are synthesized on the fly from a folder of clean images; no paired JPEG corpus is needed.
  • Perceptual loss (VGG-LPIPS) on random 128px crops; bf16 autocast, AdamW with beta=(0.9, 0.9), cosine schedule to zero.
  • Identity anchor (10% of pairs undegraded) so the model learns when not to act.
  • Grayscale anchor (25%) to prevent chroma hallucination on desaturated content.
  • EMA weights (decay 0.999) are evaluated and shipped, never the raw weights.

Details and the full recipe: models/dejpeg/README.md.

Intended use and limitations

  • Removes JPEG compression artifacts from images, blind to quality factor.
  • Optimized for perceptual quality (DISTS/LPIPS), not PSNR; distortion metrics favor larger models like FBCNN.
  • Trained only on JPEG degradation; not a general denoiser or restoration model.
  • The --sharpness post-process is on by default; disable it for pixel-faithful output.

License

Apache-2.0. The Classic5/LIVE1 benchmark images used for the tables above are not distributed with this release; obtain them from their original sources to reproduce the numbers.