How to Create Amazing QR Code Art with Stable Diffusion

Updated
How to Create Amazing QR Code Art with Stable Diffusion
Unlock the art of creating cool QR codes with Stable Diffusion and ControlNet! Learn innovative techniques and design tips to create visually captivating QR codes in this article.

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 amzing looking QR codes by harnessing the power of Stable Diffusion and ControlNet.

2. Requirements and Downloads QR Code Art

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 models using the provided links, you can simply move them to your ControlNet models folder. stable-diffusion-webui\extensions\sd-webui-controlnet\models path.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. Generate a 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.
  • 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 stunning QR codes involves using Stable Diffusion's txt2img function alongside the 2 ControlNet models. By generating a random image, we lay the foundation. However, to produce a valid QR code, we utilize the two ControlNet models download before during the sampling steps. Towards the end of the sampling process, ControlNet is turned off to enhance the image's consistency.

  1. Access the txt2img page in the AUTOMATIC1111 WebUI.
  2. Select a checkpoint model of your choice.
  3. Enter a prompt and a negative prompt. The choice of prompts is crucial for success.
  4. Set the text-to-image settings as follows:
  • Sampling method: DPM++2M Karras
  • Sampling step: 25-50 (You can play around with the sampling method but 25 is the recommended minimum)
  • Width: 512
  • Height: 512
  • CFG Scale: 4-7
  • Seed: -1 (-1 is the default for a random seed)

sampling-method-qr-code-stable-diffusion-txt2img.PNG

Stable Diffusion in the Cloud⚡️Run Automatic1111 in your browser in under 90 seconds

5. ControlNet Settings

Now the basic settings are set up we move to the a little more advanced ControlNet settings. Make sure you have at least 2 ControlNet Units available, if you only have 1 go to the Stable Diffusion settings tab, click on ControlNet and set Multi ControlNet to at least 2. Apply the settings and press on Reload UI. controlnet-multicontrolnet-settings.PNG

Now you should have at least 2 ControlNet Units available, upload your QR Code to both the ControlNet units. In the first ControlNet Unit (ControlNet Unit 0) select inpaint_global_harmonious as the Preproccesor, for our Model we will use control_v1p_sd15_brightness. Set the Control Weight to 0,5 and the Ending Control Step to 0,75. You can leave the rest as it is. controlnet-brightness-settings-qr-code-stable-diffusion-txt2img.PNG

In the second ControlNet Unit (ControlNet Unit 1) select inpaint_global_harmonious as the Preproccesor, for our Model we will use control_v11p_sd15_lineart. Set the Control Weight to 0,35 and the Ending Control Step to 0,75. You can leave the rest as it is. controlnet-lineart-settings-qr-code-stable-diffusion-txt2img.PNG

Make sure both ControlNet Units are enabled. I also recommend checking the Low VRAM box in both the ControlNet Units, this is not necessary if you have a 16GB GPU or higher.

Now you're all set to generate you awesome looking QR Codes!

6. Tips for Generating QR Codes

Keep in mind that there is not a 100% success rate, some codes will scan better than others. If you're having trouble getting your QR Code to scan try these tips:

  • Increase the Control Weight and/or the Ending Control Step on both the ControlNet Units a tiny bit.
  • QR codes with shorter text tend to have a higher success rate due to simpler patterns, if you have a long URL try to shorten it by using websites like Bitly.
  • 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.
Stable Diffusion in the Cloud⚡️Run Automatic1111 in your browser in under 90 seconds

7. Examples

Example 1 example-qr-code-txt2img-01.webp

  • Positive Prompt: (best quality, masterpiece), japanese styled dojo, snowy mountain, intricate details,
  • Negative Prompt: (worst quality, low quality)
  • Steps: 30
  • Sampler: DPM++ 2M Karras
  • CFG scale: 7
  • Seed: 1808948535
  • Size: 512x512
  • Model: dreamshaper_6BakedVae
  • Clip Skip: 2

Example 2 mountain-river-qr-code.webp

  • Positive Prompt: (masterpiece, best quality:1.4), cinematic light, colorful, high contrast, mountain, grass, tree, night, (mon(masterpiece, best quality:1.4), (captivating digital art), cinematic lighting, colorful, high contrast, eerie mountain landscape, lush grass, twisted trees, rain pouring down, river flowing,
  • 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: 25
  • Sampler: DPM++ 2M Karras
  • CFG scale: 5
  • Seed: 2672010349
  • Size: 512x512
  • Model: dreamshaper_6BakedVae
  • Clip Skip: 2

Example 3 qr_code_example_3.webp

  • Positive Prompt: (masterpiece, best quality:1.4), cinematic light, colorful, high contrast, mountain, grass, tree, night, (horror (theme):1.2), (mon(masterpiece, best quality:1.4), (captivating digital art), cinematic lighting, colorful, high contrast, eerie mountain landscape, lush grass, twisted trees, night scene, (horror theme:1.2), (menacing monster:1.2) lurking in shadows, dark atmosphere, blood rain pouring down, blood-red river flowing, haunting blood moon in the sky, chilling and intense visual experiencester:1.2), dark, blood rain, blood river, blood moon,
  • 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: 50
  • Sampler: DPM++ 2M Karras
  • CFG scale: 5
  • Seed: 3678082853
  • Size: 512x512
  • Model: dreamshaper_6BakedVae
  • Clip Skip: 2

8. 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.