Work 06 / 18
Teaching a small model to denoise like a big one
Photos taken in dim rooms come out grainy. I replaced the old denoiser with SCUNet, which fixed its artefacts, then distilled SCUNet into a convolution-only student a quarter of its size that runs on a CPU.

Noise addedDenoisedPSNR against the photo before I added noise: 24.5 dB with the noise, 30.07 dB after the student model.

Noise addedDenoisedPSNR against the photo before I added noise: 25.03 dB with the noise, 28.55 dB after the student model.

Noise addedDenoisedPSNR against the photo before I added noise: 25.41 dB with the noise, 29.52 dB after the student model.
Photos: Interior, Duncan House, Polymath Park, Acme,… by w_lemay, CC BY-SA 2.0; NIND Saint-Remi ISOH1 by Trougnouf, CC BY 4.0; Kitchen, Paul Schweiker House and Studio, Me… by w_lemay, CC BY-SA 2.0. What I changed.
- Teacher → student
- 17.9M → 5.2M
- Parameters; ONNX 68.6 MB → 19.8 MB
- Student against teacher
- 48–51 dB
- PSNR; above 40 dB the difference is not visible
- Clean photos needed
- none
- The teacher makes the targets
- Training
- about 4–5 h
- 40,000 iterations on one L4 GPU
The problem
The old denoiser, FFDNet, needed an estimate of how noisy each photo was and a gate that decided whether to run at all. It left soft lines and shifted black areas towards green. Switching to SCUNet fixed both and let me delete the noise estimate and the gate. The service still accepts the old noise field so that callers did not break, and ignores it.
Distillation
SCUNet uses Swin attention and is heavy for a CPU. So I froze it as a teacher and trained a convolution-only UNet student, with a global residual, to copy its output. That needs no clean ground truth: the teacher’s output on a noisy photo is the target.
The loss is a Charbonnier loss on pixels plus 0.1 times a Charbonnier loss on image gradients, which keeps edges sharp. Training used 256-pixel crops from about 20,000 noisy photos: 40,000 iterations at batch 16 on one L4 GPU, about four to five hours.
- Noisy photoAbout 20,000, no clean versions
- SCUNet teacherFrozen, 17.9M parameters
- TargetThe teacher’s output
- UNet studentConvolutions only, 5.2M parameters
Running it
The student takes any input size. Large photos are cut into overlapping tiles padded to a multiple of 8 and blended back together with feathered edges, with dithering on the way out so smooth walls do not band. The output is always the same size as the input.
Limits
The student can only be as good as the teacher. Its 48–51 dB measures how closely it matches the teacher. It says nothing about how good the photo looks. I did not keep a CPU timing, so I don’t quote a speed-up.
Tools
SCUNet (teacher), PyTorch, ONNX Runtime, FFDNet (replaced).
The teacher model is SCUNet (Zhang et al., 2023).
The full write-up
There is a longer write-up of this project. It has client details in it, so email me if you’d like a redacted copy.