All articles
9 min readPhoto RestorationTutorialAI

Restore Old Photos in Your Browser: An AI Photo Restoration Guide

Scratch removal, face enhancement, and upscaling combined in one on-device pipeline. How LaMa inpainting, GFPGAN face restoration, and Swin2SR super-resolution work together — and where each one helps or falls short.

A box of family photographs in the attic, a shoebox of prints from a grandparent’s house, a folder of scans from a local archive. Old photos carry irreplaceable faces, but the prints themselves are fading, scratched, and cracked. Digitizing them is step one. Making them look good again is the harder problem — and the usual answer involves uploading them to a cloud restoration service that charges per photo and keeps your family’s faces on its servers.

Restoration is now a pipeline that runs entirely in a browser tab. But understanding what each stage does — and which stage to use for which defect — is the difference between a photo that looks restored and one that looks painted over. This guide covers the three models behind the tool, how they chain together, and the honest limits of each.

Three models, three jobs

Photo restoration is not one problem. A scratched print, a faded face, and a low-resolution scan are three different defects that require three different neural networks. The tool ships all three and chains them in the right order:

ModelDownloadWhat it fixes
Swin2SR~200 MBResolution, blur, JPEG artifacts, sensor noise. The same super-resolution network used in the standalone upscaler, run here in denoise mode to clean the whole image before the other models see it.
GFPGAN v1.4~340 MBFace detail. Detects faces with a lightweight BlazeFace model, then restores each one through a GAN trained specifically on facial structure and skin texture.
LaMa~208 MBScratches, tears, dust spots, unwanted objects. An inpainting network that fills masked regions by reasoning about the surrounding pixels.

Each model downloads on first use and is cached by the browser afterward. The full restoration pipeline runs on WebGPU when available, with a WebAssembly fallback on older browsers or machines without a suitable GPU.

The restore pipeline: clean, fix faces, revive colour

The one-click Restore mode chains three stages in the order that produces the best result:

  • Stage 1 — Super-resolution denoise. Swin2SR runs in denoise mode: the image is upscaled 4× through the model, then rescaled back to its original dimensions. This strips JPEG artifacts, sensor noise, and scan-line interference without changing the image size. The model has been trained on real-world degradations, so it recognizes compression noise as something to remove, not preserve.
  • Stage 2 — Face restoration. GFPGAN v1.4 takes the cleaned image, detects each face with a MediaPipe BlazeFace model, crops and aligns the face to 512×512, and runs it through a GAN trained to restore facial detail — eyes, teeth, skin texture, hair. The restored face is blended back into the image at a weight of 0.85, meaning the original is not fully overwritten. That blend ratio is deliberate: it preserves likeness while adding sharpness, rather than replacing the person’s face with a plausible-but-different one.
  • Stage 3 — Colour revival. Auto-levels stretches the histogram to restore contrast and colour balance that has faded over decades. A 0.85 strength prevents the over-saturated look that full auto-levels produces on already-faded photos — the goal is to revive, not to exaggerate.

Each stage is optional. If the photo has no faces — a landscape, a building, a still life — turning face restoration off skips the 340 MB GFPGAN download and the face-detection pass entirely, producing a faster result. If the colours are fine, turning colour revival off preserves them exactly.

The fill pipeline: LaMa and the mask brush

Scratches and tears are not fixed by super-resolution or face restoration. They require inpainting — telling the model exactly where the damage is, so it can fill that region from the surrounding context.

LaMa (Large Mask inpainting) is the model that does this. It is built around Fourier Feed-Forward Convolution (FFC) blocks, which give it an unusually large receptive field for its size. In practice that means LaMa can fill a scratch by looking at pixels far from the damage — it understands the broader structure of the image, not just the immediate neighbours of the masked region.

The tool gives you a brush to paint the mask yourself. This is deliberate. Automatic scratch detection exists but is unreliable on textured backgrounds — a model that tries to find scratches automatically will also mask wrinkles, fabric texture, and tree bark. A human knows the difference. The brush lets you mark exactly what is damage and what is not:

  • Paint mode marks regions for LaMa to fill. The semi-transparent red overlay shows what will be replaced.
  • Erase mode removes mask from regions you marked by mistake.
  • Brush size is adjustable from 8 to 96 pixels, for everything from a hairline scratch to a torn corner.

After LaMa fills the masked region, the result becomes the new working image. This means you can fill a scratch, see the result, then fill another — iteratively, without starting over each time. The mask is cleared after each pass, so each fill is a clean operation.

The 512×512 constraint

Both LaMa and GFPGAN take a fixed 512×512 input. This is not a maximum — it is the resolution the model graph expects. For GFPGAN, this is fine: faces are cropped to 512×512, restored, and blended back at their original position and size. For LaMa, it means the masked region and its surrounding context are processed at 512×512, regardless of the photo’s actual resolution.

The working image itself is capped at 1024 pixels on its longest edge before any processing. This is a memory ceiling: a 4000-pixel scan would produce intermediates that overwhelm the browser’s heap. The cap means a scanned 4×6 print at 600 DPI (3600×2400 pixels) is downsampled to 1024 before restoration begins, and the result is upscaled back afterward via super-resolution if you use the Sharpen mode afterwards.

The practical implication: restoration quality is best on photos that fit within or near the 1024-pixel working size. Very large scans do not get more detail from the models — they get the same 512×512 view as a smaller image would.

Sharpen: standalone super-resolution

The Sharpen mode is the standalone upscaler from the previous guide, available here as a post-restoration step. After cleaning scratches and restoring faces, you can upscale the result 2× or 4× with Swin2SR, or run it through the denoise pass again for additional cleanup.

A typical workflow for a badly damaged photo: Restore first (which denoises and fixes faces), then use Fill to paint out scratches, then Sharpen to 2× for a final result that is both cleaner and larger than the original scan.

ID photos: a practical side effect

The restoration pipeline includes a mode that has nothing to do with old photos but is genuinely useful: passport and ID photos. The same MODNet segmentation model used for background removal can cut out the subject from any photo, and the tool composites the cutout onto a coloured background at standard ID photo sizes (1-inch, 2-inch, square).

For old photos, this means you can restore a family portrait, cut out the subject, and produce a clean ID-style photo from a damaged print — all without uploading the image to a passport photo service. The face restoration from GFPGAN makes the result look better than the original scan, which is an unusual advantage for an ID photo.

Limits worth knowing

  • Deeply faded or water-damaged photos. If the face is unrecognizable, GFPGAN cannot restore what is not there. It will produce a plausible face, but it may not be the right face. Manual masking of the damaged region before restoration can help LaMa fill the worst areas first.
  • Large scratches across faces. LaMa fills from context, and a face is high-frequency, low-redundancy context. A scratch across a cheek may fill plausibly; a scratch across an eye may produce a result that looks right at a glance but wrong on inspection. Use the brush to mask only the damage, not the whole face, and consider running face restoration afterward.
  • Colour revival is a histogram stretch, not a colourizer. Auto-levels revives faded colour that still exists in the scan. It does not add colour to a black-and-white photo. For colourization, a different model is needed.
  • Group photos. GFPGAN detects and restores each face independently. In a group photo with small faces, the 512×512 crop per face may be too zoomed-out for the model to add useful detail. The result is still cleaner, but the dramatic improvement seen on single-face portraits is less visible.

Why this belongs on your own machine

Old family photographs are the most personal images most people own. The people in them may not be alive. The prints may be the only copy. Uploading them to a cloud restoration service means the faces of your family — possibly including children, possibly including people who never consented to having their image on a third-party server — are now in someone else’s data centre, governed by a retention policy you did not write.

Running locally, the scan is decoded in the browser’s memory, the models run on your hardware, and the restored image is saved to your disk. The only network request is the one-time model download. After that, the tool works offline — which matters if you are digitizing a box of photos in a relative’s house with no Wi-Fi.

Try it with the photo restorer — start with a moderately damaged photo, run Restore first, then use Fill on the remaining scratches. The before-and-after slider on a single face is usually enough to calibrate how much to trust each stage.

Try the tools

Everything described here runs for free in your browser — no sign-up, no uploads. Explore the full matrix of on-device AI tools from the homepage, or read the end-to-end workflows.

Back to the matrix