“Revolutionize Your QR Codes with Stable Diffusion: Unlocking Limitless Possibilities”

Prathmesh Chavan
4 min readJul 1, 2023

--

QR codes have become a ubiquitous part of our digital landscape, connecting the physical and virtual worlds with a simple scan. But what if there was a way to take QR codes to a whole new level? Enter Stable Diffusion, a revolutionary technique that unleashes the true potential of QR codes, making them more engaging, visually appealing, and versatile than ever before. In this blog post, we will explore how Stable Diffusion can transform your QR codes and open up a world of limitless possibilities.

Software

Use the below links for the installation of the needed software

We will use AUTOMATIC1111 Stable Diffusion GUI to create QR codes. You can use this GUI on Google Colab, Windows, or Mac.

You will need the ControlNet extension installed. Follow this tutorial to install.

If you are using our Colab Notebook, simply select ControlNet at startup.

Generating QR Codes with Fault Tolerance:
To begin our journey, we first need a QR code. However, not all QR codes are created equal. To increase the chances of success and optimal scanning, follow these guidelines:
1. Set a high fault tolerance setting (at least 30%).
2. Ensure there is a white margin (quiet zone) around the QR code.
3. Use a basic square fill with a black-and-white pattern.
4. Avoid generators that introduce thin white lines between black elements.

Qr code download -> Free QR Code generator (34qr.com)

Step 1: Select the text type and enter the text for the QR code.

Step 2: Set fault tolerance to 30%.

Step 3: Press Generate.

Step 4: Download the QR Code as a PNG file.

Decorating QR Codes with Stable Diffusion: Now comes the exciting part — enhancing your QR codes using Stable Diffusion. Follow these step-by-step instructions to create visually stunning QR codes with unique compositions:

Step-by-step guide

In AUTOMATIC1111 WebUI, navigate to the Img2img page.

Step 1: Select a checkpoint model. We will use GhostMix.

Step 2: Enter a prompt and a negative prompt.

The prompt is quite important to your success. Some prompts blend naturally with your QR Code.

We will use the following prompt.

a cubism painting of a town with a lot of houses in the snow with a sky background, Andreas Rocha, matte painting concept art, a detailed matte painting

And the following negative prompt.

ugly, disfigured, low quality, blurry, nsfw

Step 3: Upload the QR code to the img2img canvas.

Step 4: Enter the following image-to-image settings.

  • Resize mode: Just resize
  • Sampling method: DPM++2M Karras
  • Sampling step: 50
  • Width: 768
  • Height: 768
  • CFG Scale: 7
  • Denoising strength: 0.75

Step 5: Upload the QR code to ControlNet‘s image canvas.

Step 6: Enter the following ControlNet settings.

  • Enable: Yes
  • Control Type: Tile
  • Preprocessor: tile_resample
  • Model: control_xxx_tile
  • Control Weight: 0.87
  • Starting Control Step: 0.23
  • Ending Control Step: 0.9

Step 7: Press Generate.

Step 6: Check the QR code with your phone. Make sure to check with different sizes on the screen. Some tend to have issues when they are large.

You won’t get a functional QR Code with every single image. The success rate is about one in four. Generate more images and check for the keepers.

Tips for Success:

QR codes with shorter text have a higher success rate due to simpler patterns.

Experiment with different prompts to find the perfect blend with your QR code.

Adjust parameters like denoising strength, control weight, starting control step, and ending control step to fine-tune the composition.

Keep in mind that not all generated images will result in functional QR codes. Generate multiple images and select the ones that work best.

Follow me :)

--

--

Prathmesh Chavan

Full Stack Developer | Experienced with Next.js, Angular, Node.js, Express.js | AWS