AI Image Upscaler (2x and 4x, In Your Browser)
Operator: Abdulla Al Fahad. How tools are built and checked
Stretching a small picture in any ordinary viewer gives you the same pixels, only bigger and softer. A super-resolution network does something different: it has learned from many pairs of small and large images what edges, textures and lettering usually look like, and it draws a larger version that is sharper than simple smoothing. This page runs one of those networks, Swin2SR, inside your browser.
There are two models, one for 2x and one for 4x, both in the Transformers.js ONNX form published as Xenova/swin2SR-classical-sr-x2-64 and Xenova/swin2SR-classical-sr-x4-64. The upstream Swin2SR project is Apache-2.0 licensed. A slider compares the AI result with a plain browser enlargement of the same picture, so you can see what the network added before you save anything.
Key features
- Two Swin2SR models, 2x and 4x, downloaded once (about 54 MB and 55 MB) and then cached by the browser
- Tiles of 128 by 128 pixels with 16 pixels of surrounding context, so memory stays small however large the allowed input is
- WebGPU when available, WebAssembly on the CPU otherwise, with an automatic retry on the CPU if the graphics path fails
- A tile counter in the progress bar and a Stop button that ends the run between tiles
- A compare slider between a plain enlargement and the AI result, over a checkerboard for transparent pictures
- PNG or JPG download with a quality slider and no watermark
Swin2SR tiles, size limits and how transparency is handled
Input can be PNG, JPG, WEBP, GIF (first frame only) or BMP, up to 25 MB, recognised from the file contents. The pixel count is what limits the job: up to 1,000,000 pixels for 2x and 500,000 pixels for 4x. A 1000 by 1000 picture is the largest square that qualifies for 2x, and about 700 by 700 for 4x. A larger picture is refused with a message giving its actual size and the limit; crop it or shrink it and try again. The page also says when a picture is too large for 4x but fits 2x.
Output is exactly 2 or 4 times the width and height. The result can be saved as PNG or as JPG with a quality from 50 to 100. Files are named after the original with -x2 or -x4 appended. A 4x result from a 500,000 pixel picture is 8 megapixels, which is the largest output the page can produce.
Transparency is handled separately. Swin2SR works on colour only, so for a picture with transparent pixels the colour comes from the model and the alpha channel is enlarged with the browser's smooth scaling and recombined. Saving such a picture as JPG flattens it onto white, since JPG cannot hold transparency. EXIF data from the original is not carried into the saved file.
How it works
The picture is split into a grid of 128 by 128 pixel cores. For each core the page takes up to 16 extra pixels on every side that exist in the picture and sends that block to the model. The network needs a width and height that are multiples of 8, so the block is padded on the right and bottom by repeating its edge pixels. Pixel values go in as numbers between 0 and 1 with no further normalisation, which is what this family of models expects.
The model returns a block 2 or 4 times larger. The page throws away the part that came from the 16 pixel margin and keeps only the enlarged core, then writes it into the output image. Because each core was computed with real neighbours around it, the borders between tiles line up and no seam shows. Picture edges simply have less context on the side where the picture ends.
Tiling is also why the picture size is capped by pixels rather than by memory alone. An 800 by 600 picture is 7 by 5 tiles, 35 runs of the model. A 1000 by 1000 picture at 2x is 8 by 8, 64 runs. Each run is short, the page repaints between them and the Stop button is checked before each one.
The plain enlargement on the other side of the slider is drawn by the browser's own high-quality smoothing, so the comparison shows the same size on both sides.
Common use cases
- Enlarging a small supplier product photo for a print flyer or a banner
- Giving an old scanned snapshot or a low-resolution screenshot more pixels before printing it
- Preparing a small logo or icon for a larger placement when the original vector file is lost
- Making a thumbnail-size reference picture large enough to trace over in an editor
How to use this tool
- Load a picture by dropping it on the box, choosing a file or pasting with Ctrl+V. The page tells you whether it fits and how many tiles it needs.
- Pick 2x or 4x. If the picture is too big for 4x, use 2x or crop first.
- Press Upscale. The first run shows the model download; after that you see a tile count.
- Drag the slider to compare the plain enlargement with the AI result, looking at edges and lettering.
- Choose PNG or JPG, set a quality for JPG, and press Download upscaled picture.
Example
An 800 by 600 product photo, enlarged 4x and saved as PNG
Picture 800 x 600 = 480,000 pixels
Scale 4x (limit 500,000 pixels, so it fits)
Format PNGWhat the page plans and saves
Tiles ceil(800 / 128) x ceil(600 / 128) = 7 x 5 = 35
Model Xenova/swin2SR-classical-sr-x4-64, about 55 MB on first run
Saved photo-x4.png, 3200 x 2400 (7.68 megapixels)
A 1200 x 900 picture (1.08 megapixels) is refused at 2x with its size and the 1.0 megapixel limit.Tips for best results
- Crop away what you do not need before upscaling. Fewer pixels in means fewer tiles, a shorter wait and a larger share of the allowed budget spent on the part you care about.
- Use 2x when it is enough. The 4x model has to invent more, and on a noisy source its extra detail can look painted.
- Compare at 100 percent zoom in the slider area on lettering and sharp edges, where this kind of model helps most; skin and foliage can look slightly waxy.
- Run on the CPU only for small inputs. A 0.3 megapixel picture is far more comfortable than a 1 megapixel one without WebGPU.
- Save PNG while you are still editing and JPG only for the final copy; JPG applies a second round of compression.
Common pitfalls
These are the classical Swin2SR models, trained on pictures that were made small by clean bicubic shrinking. A phone photo with heavy noise or JPEG blocks does not match that assumption, and the network can sharpen the noise along with the detail.
The network does not know what a face or a word should look like. Text that is a blur in the source stays a guess in the output, and faces are not restored.
Output is capped by the input limit: 4 megapixels at most for 2x and 8 for 4x. The page cannot enlarge a big picture; reduce it first.
A transparent picture has soft alpha edges from ordinary smoothing, not from the model, so a hard cut-out edge can look slightly less crisp than the colour inside it.
On the CPU a large input can take several minutes. Stopping discards the work done so far, because the output is only complete when all tiles have run.
Common errors and how to fix them
- This picture is ... megapixels. Upscaling 2x is limited to 1.0 megapixels of input
- Crop to the part you need or shrink the picture so it has no more than 1,000,000 pixels (500,000 for 4x), then load it again.
- The model files could not be downloaded
- The 2x model is the onnx/model.onnx file of Xenova/swin2SR-classical-sr-x2-64 (about 54 MB) and the 4x model the same file in the x4-64 repository (about 55 MB), both fetched from huggingface.co. Allow that host, or switch network, and press Upscale again.
- Upscaling failed with a memory or session error
- Reload the page, close other heavy tabs and try again with a smaller picture or the 2x model.
Best practices
- Choose the model for the size you need rather than running 2x twice. A second pass enlarges the first pass's small artefacts, so when the picture fits the 0.5 megapixel limit, the 4x model is the cleaner route to four times the size.
- Do the cropping and colour work before upscaling, and any sharpening afterwards, not the other way around.
- Check the result at the size you will actually use. A picture that looks fine on screen at 50 percent can show artefacts at print size.
Why the size limits are what they are
A Swin2SR block is processed by an attention network whose cost grows quickly with the block size, so the page never sends more than a 160 by 160 block at once. That keeps the graphics or CPU memory use flat regardless of the picture size. The remaining cost is the number of tiles, and the pixel caps keep that number to at most 64 for 2x (a 1000 by 1000 picture) and about 36 for the largest 4x input.
The 4x limit is half the 2x limit because the 4x model produces sixteen output pixels per input pixel. Its output buffer and the plain comparison image are what make large 4x jobs heavy for a phone.
Download, caching and offline use
Each model file is about 54 to 55 MB, loaded from huggingface.co on first use; the runtime helper is served by this site. The browser stores them, so the second run on the same scale starts straight away. Using 2x and 4x each downloads its own model once.
The 4x model's own page does not state a licence, but it is a conversion of the upstream caidas Swin2SR 4x checkpoint, which is published under Apache-2.0; the 2x model page states Apache-2.0 directly.
Frequently asked questions
What exactly is downloaded, and when?
The first run at a given scale fetches that scale's Swin2SR file (about 54 MB for 2x, 55 MB for 4x) from huggingface.co, plus a small WebAssembly helper served by this site. Your picture is not part of those requests; it is cut into tiles and processed in browser memory. The browser keeps the model files, so switching back to a scale you have used does not download it again.
Why won't it take my 12-megapixel photo?
The input is limited to 1 megapixel for 2x and 0.5 for 4x so the tiles fit in memory and the job finishes in reasonable time. Crop to the region you want to enlarge, or shrink the photo first.
Does it fix a blurry photo?
Not in general. It adds plausible sharpness to a clean low-resolution picture. A photo that is blurry from camera shake or focus has no detail for the model to build on, and the output will mostly be a larger blurry picture.
Why are there two models?
One network is trained for each factor. Choosing 2x or 4x loads the matching model; a 4x result is not made by running the 2x model twice.