Background Advisory Ventures Dispatches Contact
How to make an AI-generated QR code
All dispatches

How to make an AI-generated QR code

First shared in my AI club, now Frontier Table, June 6, 2023.

To make an AI-generated QR code, generate the plain QR code first. Then submit it to Stable Diffusion running ControlNet, and what comes back is an image that stays faithful to the original code while looking like whatever you asked for.

If that sounds too simple, it’s because the two hard parts were solved by other people. Stable Diffusion is the open image model released last year. ControlNet is a paper from February by Lvmin Zhang, Anyi Rao and Maneesh Agrawala — “a neural network architecture to add spatial conditioning controls to large, pretrained text-to-image diffusion models” — which in plain terms lets you hand the model a shape and say: whatever you paint, keep this. The clever part of the paper is that it leaves the big model frozen and trains a copy of its encoding layers to carry the condition, so none of the base model’s quality is spent learning your shape. A QR code is a shape.

The reason it’s suddenly everywhere is a Reddit user who posted a set of anime-styled codes today that “can still be read as functional QR codes by smartphone camera apps,” apparently using ControlNet models trained specifically on QR codes. They’re lovely, and they scan.

The prompts did all the work. That surprises people who assume there’s a special QR trick hidden in there. The style and the subject are ordinary prompting — ask for a Kyoto side street at dusk and you get a Kyoto side street at dusk, with the code living in the rooflines and the paving stones. ControlNet’s only job is to hold the code steady underneath while the prompt does the painting.

How far the art can go depends on the art. The data in a QR code is precise, so the artwork has to bend to the code rather than the other way around. There’s some give — QR codes were designed with error correction built in, which is why a scanner can forgive a dragon’s tail crossing a few modules — but the give belongs to the code, and the code decides how much to lend.

Where this started

Most of these dispatches start as posts in the Frontier Table, a group of about 100 builders, founders and operators trading what's actually working with AI.

Robertson Price

Robertson Price

Serial entrepreneur who has built and exited multiple internet companies over 25 years — from search (iWon.com, $750M acquisition) to content networks (32M monthly visitors) to e-commerce (Rebates.com). He now builds enterprise AI infrastructure at Ragu.AI.