← All models

image-to-image · vision · WASM · ~150 MB

Swin2SR — upscale an image 2× and reconstruct the detail

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.

At a glance

ModelXenova/swin2SR-classical-sr-x2-64
Task / pipelineimage-to-image
ArchitectureSwin2SR — Swin Transformer V2 blocks, classical ×2 super-resolution head
Upscale factor2× (a 256×192 input becomes 512×384)
Quantizationq8 (8-bit) ONNX
BackendWebAssembly (runs anywhere; no WebGPU needed)
Download~150 MB, cached after first load
LicenseApache-2.0 (Swin2SR)
Web APIsWebAssembly, 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).

Run it

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).

Drop an image here, or click to choose
Low-res photo of two cats Low-res photo of a bedroom Low-res riverside photo A tiny 32-pixel pixel-art mushroom

See inside

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.

Run an upscale to see the per-tile timing and sharpness delta.

Why it matters

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.

Use cases

Basics

Upscale a sample 2× and wipe between bicubic and Swin2SR to feel the difference.

Practical

Enhance a tiny thumbnail or a heavily-compressed image — the everyday web job.

Wild

Upscale 32-px pixel-art or a live webcam frame and watch the model hallucinate detail.

Multi-model

RMBG cuts the subject out → Swin2SR super-resolves just the cutout.

How the API works

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.

References