image-to-image (neural style transfer) Β· vision Β· WASM Β· ~6.6 MB / style
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.
| Model | onnxmodelzoo/{candy,mosaic,udnie,pointilism,rain-princess}-9 β fast-neural-style, one ONNX per style |
|---|---|
| Task | image-to-image (neural style transfer) β run via raw ONNX Runtime Web (see note below) |
| Runtime | onnxruntime-web 1.21 (transformers.js has no style-transfer class / no neural-style task) |
| Input | input1 [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) |
| Output | output1 [1, 3, 224, 224] float32 in ~0β255 β the painted image, clamped and resized to your photo's aspect |
| Quantization | fp32 ONNX (single file per style) β runs on the plain WASM execution provider, no WebGPU needed |
| Backend | WebAssembly (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) |
| License | Apache-2.0 (ONNX Model Zoo) |
| Web APIs | WebAssembly, Web Workers, OffscreenCanvas, ImageBitmap β all Baseline widely available |
Pick a photo, choose an artistic style, and repaint it. Drag the divider to compare the photo with its painted version.
The wipe above is the real evidence β slide it to watch the photo become a painting. βRestyle amountβ is the mean per-pixel change from the photo; it's far above what a colour filter would do, because a whole feed-forward network repaints the image.
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).
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.
Notice the model doesn't just recolour β it imposes the target painting's brushwork: mosaic tiles, pointillist dots, swirling strokes. That structural texture, learned from one artwork, is what makes it read as a painting rather than a filtered photo. The fixed 224Β² network keeps it fast; the result is resized to your photo's shape.
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.
Pick a photo and a style, then paint it β wipe between the photo and its painted version.
Turn your own photo into a painting and download it as a PNG for a print or poster.
Gallery wall: run all five styles on one photo side by side and compare the painters.
Paint β anime: run a fine-art style, then AnimeGANv2, to see two very different stylizers on one photo.
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.