image-to-image · vision · WASM · ~150 MB
Swin2SR is a Swin-Transformer super-resolution model. Give it a small, soft, or compressed picture and it predicts what a 2×-larger, sharper version should look like — inventing plausible edges and texture, not just smoothing. It runs entirely on your device: the image never leaves the tab.
| Model | Xenova/swin2SR-classical-sr-x2-64 |
|---|---|
| Task / pipeline | image-to-image |
| Architecture | Swin2SR — Swin Transformer V2 blocks, classical ×2 super-resolution head |
| Upscale factor | 2× (a 256×192 input becomes 512×384) |
| Quantization | q8 (8-bit) ONNX |
| Backend | WebAssembly (runs anywhere; no WebGPU needed) |
| Download | ~150 MB, cached after first load |
| License | Apache-2.0 (Swin2SR) |
| Web APIs | WebAssembly, Web Workers, OffscreenCanvas / ImageBitmap (input read + upscaled composite happen off the main thread), Canvas 2D, FileReader — all Baseline widely available |
Swin2SR is heavy per pixel, so this page caps the input's long edge to 512 px and processes it in overlapping tiles — bounding memory and giving honest, incremental progress. A bigger upload is shrunk to the cap first (noted below when it happens).
Pick or drop a small image and hit Upscale. When it finishes, drag the slider to wipe between the plain bicubic zoom (left) and Swin2SR's reconstruction (right).
Super-resolution isn't magic — it's a transformer predicting high-frequency detail one tile at a time. Below are the real numbers from your run: how the input grew, how long each tile took, and a sharpness delta — the mean high-frequency edge energy (an absolute-Laplacian proxy) of Swin2SR's output versus a plain bicubic zoom of the same input. A positive delta means the model added genuine edge detail a smooth resize can't.
| tile # | input patch | time |
|---|
Upscaling used to mean either a fuzzy bicubic stretch or a paid cloud API that saw your images. Swin2SR in the browser makes real, learned super-resolution a local function call — private, free per call, and offline.
Upscale a sample 2× and wipe between bicubic and Swin2SR to feel the difference.
Enhance a tiny thumbnail or a heavily-compressed image — the everyday web job.
Upscale 32-px pixel-art or a live webcam frame and watch the model hallucinate detail.
RMBG cuts the subject out → Swin2SR super-resolves just the cutout.
Super-resolution is a one-liner with Transformers.js. The output is a RawImage at 2× the input:
import { pipeline } from "@huggingface/transformers";
const upscaler = await pipeline(
"image-to-image",
"Xenova/swin2SR-classical-sr-x2-64",
); // downloads + caches ~150 MB once
const output = await upscaler(imageURL);
// → RawImage { data: Uint8Array, width, height, channels }
// width/height are exactly 2× the input; data is raw RGB pixels
This page goes one step further: instead of one giant forward pass, it splits the input into overlapping tiles, calls the pipeline per tile inside a Web Worker, crops the overlap, and stitches the cores back together — so memory stays bounded and you get real per-tile progress. The "before" layer in the slider is the browser's own bicubic 2× zoom, for an honest comparison.