Skip to content
WebAI

Super-resolution, denoising and deblurring all land on Swin2SR

The super-resolution, restoration and enhancement demos share one set of controls, and with real weights wired up, four differently named cards resolve to three repositories, all Swin2SR exports. Here is how the substitutes map out, and why the task selector stops responding in real mode.

Four cards with four different names resolved to just three repositories once the real weights were wired up, and every one of them is a Swin2SR export. The controls on super-resolution, image restoration and image enhancement were already identical: a task selector, strength from 0 to 1, and a reference toggle. The UI shares a single restoration output kind. Demo mode sends the task to canvas pixel operations, while the real-weights branch calls enhanceImage().

EntryMeasured sizeReal weightsSubstitute
Swin2SR (real-world x4)~14.8 MiB · q4f16Xenova/swin2sr-classical-sr-x2-64 (q4)Yes, 2x in practice
ESRGAN Slim (UpscalerJS)~0.9 MiBXenova/swin2sr-classical-sr-x2-64 (q4)Yes, TFJS format will not load
NAFNet (Denoise)Not measured (historic estimate ~25 MB)Xenova/swin2SR-lightweight-x2-64 (q8)Yes
Real-ESRGAN~32.2 MiB · fp16Xenova/swin2SR-realworld-sr-x4-64-bsrgan-psnr (q4)Yes
Measured sizes for the restoration entries and the repositories actually loaded

The documentation link for that entry points at the realworld x4 export, but the demo loads the q4 classical x2 checkpoint. The x4 export stands in for Real-ESRGAN on the enhancement page. ESRGAN-slim from UpscalerJS ships as TFJS, which Transformers.js cannot read. NAFNet has no browser ONNX weights, so a lightweight Swin2SR takes over. In all four cases the output pixels are reconstructed by a real model, and the name on the card does not match the repository that ran. The result bar carries an asterisk and explains this.

The task selector does nothing in real mode

The real branch looks up the weights table by card and hands the image to enhanceImage(). The task value is unused, so denoise, deblur and super-resolution do not switch networks in that mode. Switching networks means switching cards. Strength is the control that still does something. Below 1, the original is drawn at the generated size first, then the output is composited on top with globalAlpha = strength. In demo mode both controls feed canvas algorithms and behave differently.

Strength blending inside enhanceImage
const out = await run.call(imageSrc);
const generated = await toCanvas(out);
if (strength < 1) {
  ctx.drawImage(original, 0, 0, generated.width, generated.height);
  ctx.globalAlpha = Math.max(0, strength);
  ctx.drawImage(generated, 0, 0);
  return blended.toDataURL('image/png');
}
return generated.toDataURL('image/png');

Getting a PNG out caused one more detour. On the web, RawImage.toCanvas() from Transformers.js returns an OffscreenCanvas, which has no toDataURL, so the pixels go back through a DOM canvas before the page gets a PNG. All three pages ship degraded samples with clean references (street-noisy.png and street-lowres.png against street.png) and the reference toggle lets you flip between them. A 2x or 4x run changes the output size, and the strength blend stretches the original to that size too.

Both depth cards

vision/depth is the one page in this group where both cards run their own weights. DPT-Hybrid-MiDaS is ~113 MiB · q4f16 at the smallest tier and Depth Anything v2 Small is ~18.2 MiB · q4f16. Both use the depth-estimation pipeline and regress a relative depth value per pixel. The page starts from a greyscale map, applies gray, turbo or viridis, and blends with the source from 0 to 0.8. The sixfold size gap comes from the encoder. The street and desk samples are there to compare the two maps.

NAFNet stays empty because it has no measured file listing. The first run downloads and caches, and a second run of the same card reports zero downloaded bytes in the result bar. The numbers in the table were read off the weight files on the host.

All posts →

← Back to all posts