← All models

image-to-image (neural style transfer) Β· vision Β· WASM Β· ~6.6 MB / style

Fast Neural Style Transfer β€” repaint a photo as art

Give this model any photo and it repaints it in a famous artistic style β€” the swirls of Rain Princess, the mosaic tiles of Mosaic, the pointillist dots of Pointilism. These are the classic fast neural style transfer networks (Johnson et al. 2016) β€” the feed-forward models that first made real-time style transfer possible: one tiny generator per style, each trained to reproduce one painting's look. Runs entirely on your device via ONNX Runtime Web; the photo never leaves the tab.

At a glance

Modelonnxmodelzoo/{candy,mosaic,udnie,pointilism,rain-princess}-9 β€” fast-neural-style, one ONNX per style
Taskimage-to-image (neural style transfer) β€” run via raw ONNX Runtime Web (see note below)
Runtimeonnxruntime-web 1.21 (transformers.js has no style-transfer class / no neural-style task)
Inputinput1 [1, 3, 224, 224] float32 in 0–255 β€” NCHW, a fixed 224Γ—224 (the photo is stretched to fit, then the result is resized back)
Outputoutput1 [1, 3, 224, 224] float32 in ~0–255 β€” the painted image, clamped and resized to your photo's aspect
Quantizationfp32 ONNX (single file per style) β€” runs on the plain WASM execution provider, no WebGPU needed
BackendWebAssembly (single-threaded on GitHub Pages) β€” ~0.4 s per pass (the fixed 224Β² makes it fast)
Download~6.6 MB per style, cached after first load (styles load lazily; auto-inits on return)
LicenseApache-2.0 (ONNX Model Zoo)
Web APIsWebAssembly, Web Workers, OffscreenCanvas, ImageBitmap β€” all Baseline widely available

Run it

Pick a photo, choose an artistic style, and repaint it. Drag the divider to compare the photo with its painted version.

β—€ photopainting β–Ά
Drop / choose your own photo

Everything runs on your device β€” the photo and every painted pixel never leave the tab. Gallery images are rights-cleared samples (see each caption for the source).

See inside

Each style is a separate trained network, not a filter with parameters. Johnson's method trains one small feed-forward generator per target painting, so at run time a single pass produces the style β€” no slow optimisation loop like the original Gatys method. That's why it's called fast style transfer, and why each style is its own ~6.6 MB model. Switch styles below and re-run the same photo to see how differently each network paints it.

Paint a photo, then switch styles and run again to compare.

Why it matters

Turning a photo into a painting on-device makes art from any picture, privately and free per image:

These are the original fixed-style networks β€” one model per look. They render a stylistic interpretation, and the fixed 224Β² input means very fine detail is simplified.

Use cases

Basics

Pick a photo and a style, then paint it β€” wipe between the photo and its painted version.

Practical

Turn your own photo into a painting and download it as a PNG for a print or poster.

Wild

Gallery wall: run all five styles on one photo side by side and compare the painters.

Multi-model

Paint β†’ anime: run a fine-art style, then AnimeGANv2, to see two very different stylizers on one photo.

How the API works

transformers.js has no style-transfer class and no neural-style task, so we run the ONNX graph directly with ONNX Runtime Web. Note the fixed 224Γ—224 input and the 0–255 range:

import * as ort from "onnxruntime-web";

const session = await ort.InferenceSession.create(styleBytes, { executionProviders: ["wasm"] });

// photo stretched to 224Γ—224 β†’ [1,3,224,224] float32 in [0,255] (NCHW, un-normalised bytes)
const input = new ort.Tensor("float32", toNCHW255(photo, 224, 224), [1, 3, 224, 224]);
const { output1 } = await session.run({ input1: input });

// output1 is [1,3,224,224] in ~[0,255] β†’ clamp to RGBA and resize back to the photo's aspect
const painting = tensorToImage(output1.data, 224, 224);

Inference and the whole output composite run in a Web Worker so the UI never blocks; each ~6.6 MB style is fetched through Cache Storage the first time you pick it, so a returning visit auto-initialises with no re-download.

References