Skip to content

Releases

DeJPEGNet v2

Choose a tag to compare

@Miosp Miosp released this 01 Nov 20:26

DeJPEGNet v2

A new default model for dejpeg. It removes JPEG artifacts without being told the quality, and it beats FBCNN on PSNR, LPIPS and DISTS at every quality tested on LIVE1, with about a fifth of the parameters (7.47M vs 35.7M).

Try it: https://dejpeg.ludwina.top

Files

File Size Use
dejpeg-v2.onnx 15.4 MB Default model. Stays closest to the original.
dejpeg-v2-texture.onnx 15.3 MB The same model with a texture control: a float input g of shape [1, 1], from 0 to 1.
dejpeg-c40.onnx 5.4 MB DeJPEGNet v1, re-exported as the web app ships it, included so the app can be built from one release.

The v2 files use FP16 weights, FP32 I/O, opset 17 and dynamic N/H/W axes. The texture layers use FP32 weights: dejpeg-v2-texture.onnx was replaced after the first upload because the FP16 version returned NaN on GPUs that flush subnormals to zero. The input is input and the output is output, RGB in [0, 1], and each side must be a multiple of 16. They run in ONNX Runtime Web on WebGPU or WASM.

The Python package (models/dejpeg) still loads v1. The v2 weights are published as ONNX only, and the v2 training code is not in this repository.

Results

LIVE1, one pass with no flip ensemble, PSNR (dB) / LPIPS / DISTS. Lower is better for LPIPS and DISTS.

Model QF10 QF20 QF30 QF40
JPEG input 25.69 / 0.3013 / 0.2387 28.06 / 0.1799 / 0.1653 29.37 / 0.1292 / 0.1315 30.28 / 0.1005 / 0.1126
FBCNN 27.77 / 0.2503 / 0.1785 30.11 / 0.1583 / 0.1319 31.43 / 0.1187 / 0.1083 32.34 / 0.0965 / 0.0936
v2 28.05 / 0.2389 / 0.1742 30.37 / 0.1516 / 0.1287 31.70 / 0.1134 / 0.1055 32.61 / 0.0920 / 0.0913
v2 + Texture, 0.5 28.04 / 0.2280 / 0.1581 30.33 / 0.1415 / 0.1115 31.65 / 0.1037 / 0.0887 32.54 / 0.0828 / 0.0750
v2 + Texture, 1.0 27.97 / 0.2096 / 0.1374 30.23 / 0.1245 / 0.0906 31.50 / 0.0881 / 0.0693 32.35 / 0.0683 / 0.0570
  • Classic5, v2: 30.01 / 32.23 / 33.47 / 34.29 dB at QF10 to QF40, which is 0.17 to 0.22 dB above FBCNN.
  • Speed, v2: about 55 ms per 512x512 tile and 206 ms per 1024x1024 tile, measured in Edge on WebGPU on one NVIDIA GPU. Other hardware will differ.
  • Speed, v2 + Texture: about 70 ms per 512x512 tile.

Which model to use

  • v2 is the choice for fidelity to the original.
  • v2 + Texture looks crisper as the slider goes up, and it scores better on LPIPS and DISTS. The grain it adds is synthetic, not recovered detail, so don't use it where accuracy matters.
  • v1 is a much smaller download and was tuned for perceptual quality rather than PSNR. Its published DISTS on LIVE1 (0.1292 / 0.0895 / 0.0699 / 0.0602) is lower than plain v2's. Those figures come from the v1.0.0 evaluation, whose protocol differs slightly, so treat that comparison as approximate.

Web app changes

  • v2 is now the default, and visitors move to it automatically. v1 stays in the model menu.
  • Tile origins stay on a fixed grid, and tiles past the image edge are mirrored instead of padded with black. Black padding cost up to 0.19 dB on the last 16 pixels.
  • A model picked while another is loading now loads afterwards instead of being ignored.
  • /tool now redirects properly instead of showing source text.

Limitations

  • Trained only on JPEG degradation. It is not a general denoiser or restoration model.
  • The numbers above are from the LIVE1 and Classic5 benchmark sets, and those images are not distributed here.

License

Apache-2.0, like the rest of the repository.

DeJPEG v1 weights

Choose a tag to compare

@Miosp Miosp released this 27 Aug 12:45

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.