PythonMLOpenCVFlask

Image Style Transfer

Upload any photo and apply a famous art style: Van Gogh, Munch, Picasso, and more. Uses fast neural style transfer models running on the server with OpenCV DNN — no GPU required.

Models

7 styles

Backend

Flask + OpenCV

Inference

CPU only

Max input

10 MB

How it works

1Image Upload
2Preprocess & Resize
3Load Style Model
4Forward Pass
5De-normalise
6Encode JPEG
7Return Base64

Approach

Upload image and style, preprocess (decode, resize ≤1024px, DNN blob with mean subtraction), run inference through pre-trained fast neural style net (.t7 format), de-normalise output, clip values, encode as JPEG, return base64. Available styles: Starry Night, The Scream, La Muse, Candy, Mosaic, Udnie, Feathers.

Decisions

OpenCV DNN over PyTorch: 30 MB vs 700 MB — memory is critical on a VPS. Pre-trained feed-forward nets over arbitrary style transfer for faster, more predictable results. CPU-only inference is fast enough on Hetzner CX23 (~3-8s). Base64 response lets the frontend show results immediately without a second round-trip.

Security

  • Input validation: file type check, max 10 MB, resize ≤1024px
  • No uploaded images stored — processed and discarded

Want something like this built for your business?

I'll look at your problem, figure out the right approach, and ship working software. No slideshows.

Book a free consultation