How to Create QR Code Art with Stable Diffusion

Updated
How to Create QR Code Art with Stable Diffusion
In a recent post on Reddit, attention was drawn to aesthetically pleasing QR codes produced using Stable Diffusion and a customized ControlNet model. In this article, we will dive into creating QR codes within Stable Diffusion without requiring a custom model.

1. Introduction

A QR code, known as Quick Response code, is a type of image that contains encoded information, including text or URLs. By utilizing a smartphone's camera, these codes can be scanned, granting immediate access to the content they encode. QR codes have gained widespread popularity across different fields, ranging from marketing initiatives to contactless transactions. Discover how to create visually appealing QR codes by harnessing the power of Stable Diffusion.

2. QR Codes Requirements Stable Diffusion

To create QR codes with Stable Diffusion, we will utilize the AUTOMATIC1111 Stable Diffusion GUI.

Make sure you have the following installed to create stunning QR codes:

Once you have downloaded the right model (control_v11f1e_sd15_tile.pth file) using the provided link, you can simply move it to the designated directory as indicated below: save_tile_model_inside_extensions_models_stablediffusion_controlnet_nextdiffusion.png

These will be necessary for our QR code generation process.

Stable Diffusion in the Cloud⚡️Run Automatic1111 in your browser in under 90 seconds
20% bonus on first deposit

3. Generating QR Code

Before proceeding with Stable Diffusion, you need a QR code that meets certain criteria for better results. Ensure that the QR code:

  • Uses a high fault tolerance setting (30%).
  • Has a white margin (quiet zone) around it.
  • Utilizes a basic square fill with a black-and-white pattern.
  • Avoids generators that introduce thin white lines between black elements.
  • Press the "Generate" button.
  • Download the QR Code as PNG file.

Use a Free QR Code Generator to meet the above criteria.

Using the website above we created the following QR code, which leads to our website: url_link_qr_code_nextdiffusion_stablediffusion.png qr_code_stablediffusion_next_diffusion_link.png

After successfully generating a QR Code you can you can download the QR code as a PNG file. save_qr_code_as_png_stablediffusion_nextdiffusion.png

4. Stable Diffusion Settings

The process of creating visually appealing QR codes involves using Stable Diffusion's img2img function. By generating an image similar to the QR code, we lay the foundation. However, to produce a valid QR code, we utilize the ControlNet model during the sampling steps. Towards the end of the sampling process, ControlNet is turned off to enhance the image's consistency.

  1. Access the Img2img page in the AUTOMATIC1111 WebUI.
  2. Select a checkpoint model.
  3. Enter a prompt and a negative prompt. The choice of prompts is crucial for success.
  4. Upload the QR code to the img2img canvas.
  5. Set the image-to-image settings as follows:
  • Resize mode: Just resize
  • Sampling method: DPM++2M Karras
  • Sampling step: 50
  • Width: 512
  • Height: 512
  • CFG Scale: 7
  • Denoising strength: 0.75 qr_code_img2img_settings.png
  1. Now also upload the QR code to the ControlNet's image canvas.
  2. Configure the 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 qr_code_controlnet_settings_best_settings.png
  1. Press "Generate" and see the amazing results yourself.
Stable Diffusion in the Cloud⚡️Run Automatic1111 in your browser in under 90 seconds

5. Tips for Generating QR Codes

  • QR codes with shorter text tend to have a higher success rate due to simpler patterns.
  • Not all QR codes work the same way; some may only be readable from a specific distance. Depending on your generated image, some generated QR codes might not be scannable at all.
  • Certain prompts blend more naturally with QR codes. Experiment with prompts that share visual elements for better results.
  • Adjust parameters such as denoising strength, control weight, starting control step, and ending control step to achieve a desired blend between the QR code and the prompt.

Keep in mind that by using the method described in this article, not every QR code will scan. To get better results we recommend using custom ControlNet models and multiple ControlNet units to enhance the chance of scannable QR Codes. This does require a better GPU. Interested? You can read more in this comprehensive guide: How to Create Amazing QR Code Art with Stable Diffusion.

6. Examples

Below you can find some amazing QR code examples:

Example 1: 00010-922400902.png

  • Positive Prompt: (masterpiece, best quality:1.4), cinematic light, colorful, high contrast, monster in jungle, jungle background, large monster, weird monster, futuristic monster
  • Negative Prompt: (worst quality:1.2), (low quality:1.2), (lowres:1.1), (monochrome:1.1), (greyscale), multiple views, comic, sketch, (((bad anatomy))), (((deformed))), (((disfigured))), watermark, multiple_views, mutation hands, mutation fingers, extra fingers, missing fingers, watermark,
  • Steps: 30
  • Sampler: DPM++ 2M Karras
  • CFG scale: 7
  • Size: 512x512
  • Model: revAnimated
  • Clip Skip: 2

Example 2: 00171-4252117085.png

  • Positive Prompt: (masterpiece, best quality:1.4), cinematic light, colorful, high contrast, astronaut, astronaut in space, spaceship
  • Negative Prompt: (worst quality:1.2), (low quality:1.2), (lowres:1.1), (monochrome:1.1), (greyscale), multiple views, comic, sketch, (((bad anatomy))), (((deformed))), (((disfigured))), watermark, multiple_views, mutation hands, mutation fingers, extra fingers, missing fingers, watermark,
  • Steps: 30
  • Sampler: DPM++ 2M Karras
  • CFG scale: 7
  • Size: 512x512
  • Model: revAnimated
  • Clip Skip: 2
  • Denoising strength: 0.6
Stable Diffusion in the Cloud⚡️Run Automatic1111 in your browser in under 90 seconds

7. Conclusion

In conclusion, Stable Diffusion unlocks a new realm of creativity for QR codes. By following the step-by-step guide and experimenting with different prompts, we can generate visually stunning QR codes that merge artistry and functionality. With the right parameters and adjustments, QR codes can become captivating visual pieces. Embrace the potential of Stable Diffusion and QR codes to create remarkable and memorable experiences in visual communication.