How to Create QR Code Art using Stable Diffusion

Urvashi
5 min readJun 18, 2023

A few days back, a user on Reddit shared these images:

Try and scan them! 😄

These are fully functional QR codes created using Stable Diffusion and ControlNet. There has been rumours that the OP decided against sharing their process and the ControlNet model they created because someone paid them money not to. However, they are rumours and I do not know how much truth there is to it.

Even though the OP didn’t really share their process on how they created the QR codes, curious users online have tried to generate these themselves. Here are some other tutorials about this topic:

QR Code Makeup with AI, Stable Diffusion and ControlNet extension.

How to make a QR code with Stable Diffusion

In this post, I will share my process (which is highly influenced by these tutorials I have mentioned above) on how I tried to create my own fancy QR codes.

(Sometimes, it might require you to step back and scan from a distance for the codes to work.)

Requirements

You’ll need to have the following things set up before we can start creating the QR codes:

How does this work?

What is ControlNet?

ControlNet lets you control the output of diffusion models. It allows you to manipulate expressions, poses, the composition etc.

Learn more about them using this link.

We are working with 2 ControlNet models : brightness and tile.

What does the brightness model do?

The brightness model allows you to control the brightness, useful to create the dark and light patches of imagery.

What does the tile model do?

The tile model allows you to control the image details.

How do QR codes work?

QR codes, or Quick Response codes, are a type of barcode that can store information such as text, URLs, or other data.

They work by encoding this information in a pattern of black and white squares.

A QR code is surrounded by some whitespace known as the “quiet zone”. It acts as a buffer space or margin to ensure accurate scanning and decoding of the QR code.

The three big squares, also known as the “finder patterns”, are used to identify the code as a QR code and to determine its position and orientation.

For larger patterns, there may be one or more “alignment patterns” present in the QR code.

Components of a QR code

QR codes incorporate error correction techniques, allowing them to be partially damaged or obstructed and still readable. Error correction algorithms can recover any missing or corrupted data.

Setting a high fault tolerance enables you to manipulate the code into art and still make it work.

Let’s get started!

Step 1: Enable Multi ControlNet from the Settings tabs

Go to Settings > ControlNet and increase the Multi ControlNet amount to 2.

Step 2: Generate a sample QR code from

Go to https://qrbtf.com/ and generate a QR code.

(Note that this website is in Chinese, you can translate it to English using Google Translate and it works perfectly.)

I’ve used the text “hey” for my QR code so that the generated pattern is not that complex.

Also, set the fault tolerance to 30%.

Step 3: Set the control images

Set the QR code as both the images and use the following settings:

The Control Weight is how much you want the ControlNet to influence the generated image relative to the text prompt.

The Starting Control Step is used to control when you want ControlNet to start taking effect during the image generation, where 0 means you want it to start at the first step.

The Ending Control Step is used to control when you want ControlNet to stop effecting the image generation, where 1 means you want it to stop at the last step.

Here’s a complete guide to ControlNet that I highly recommend you to read.

Step 4: Generate the art

Prompt: traditional village, thatched roofs, mountains

Sampling method: Euler a

Steps: 20

Model: Deliberate

Results:

Conclusion & Tips

You can play around with the ControlNet settings to manipulate results according to the prompt, reducing or increasing the control weights.

This process works better with smaller QR codes and high fault tolerance.

It might take some tries to generate the right image.

Hope you enjoyed this post!

--

--