HomeAI News
QR codes can also be highly creative: a deep dive into the creative process of making AI-powered QR codes.

QR codes can also be highly creative: a deep dive into the creative process of making AI-powered QR codes.

Hayo News
Hayo News
July 20th, 2023

Do you want to have the same trendy artistic QR code effect that has been popular recently? This tutorial will guide you through how to create artistic QR codes like this using Stable Diffusion!

The principle of QR codes can be roughly understood as shown in the diagram below. After recognizing the positioning points, the information inside the QR code is decoded. The more information it contains, the denser the points inside the QR code will be.

When scanning a QR code, it reads the information inside the QR code after recognizing the positioning points.

Handling QR codes:

  • First, we install the QR Toolkit plugin in SD by visiting the following link: https://github.com/antfu/sd-webui-qrcode-toolkit.

To the extension interface, copy the address above, and then click on "Install from URL" to proceed with the installation.

  • A basic and easy-to-integrate QR code is the foundation. There are two aspects to consider in the preprocessing of QR codes: changing the style of the positioning points and making the QR code more concise.

Firstly, changing the style of the positioning points will result in QR codes without obvious positioning point frames. However, the recognition rate may decrease accordingly. Therefore, it's necessary to find a balance between both aspects and the parameters.

In QR Toolkit, you can find different styles for various types of points. You can try different combinations of styles, and these combinations can significantly impact the generated QR code, including its content and recognition rate. Different prompts will also have varying visual effects on QR codes with different styles. It's essential to experiment multiple times to find the optimal combination.

Secondly, it's essential to keep the information in the QR code as minimal as possible, as simpler patterns result in easier-to-scan QR codes. In QR Toolkit, you can set the QR code's error correction level, ranging from 7% to 30%, from left to right. We need to ensure a relatively high error correction level, but higher levels correspond to more complex images. Generally, 25% and 30% are recommended. In this tutorial, we will use 25% (Q) as an example.

To configure ControlNet, we need to download two unofficial controlnet models: QR Code Monster v1.0 and Brightness. You can download them from the following links:

  1. QR Code Monster v1.0: https://huggingface.co/monster-labs/control_v1p_sd15_qrcode_monster/tree/main
  2. Brightness: https://huggingface.co/ioclab/ioc-controlnet/tree/main/models

Brightness is a controlnet similar to depth, enabling control over lighting and shadow composition from 0 to 1 stages. QR Code Monster, on the other hand, controls the image to look more like a QR code.

To load the two models into their respective controlnet channels with the preprocessor set to "none," follow these steps:

  1. Load the QR Code Monster model into the corresponding controlnet channel with a recommended weight greater than 1.2.
  2. Load the Brightness model into the other controlnet channel with a recommended weight between 0.2 and 0.4. This weight represents the strength of controlnet intervention. The larger the weight and intervention range, the greater the contrast in the final image, and the fusion between the QR code and the image will be poorer, making it look more like a QR code.
  3. Control the onset/termination timing of the controlnet, which determines the step range in which the controlnet is effective. For better results, it is recommended to let the AI work freely towards the end. Adjusting the intervention range larger will make the final image look more like a QR code and more scannable. Conversely, adjusting it smaller will increase the fusion between the prompts and the QR code, but the scanning success rate may decrease.

Please note that the data is not absolute, and the parameters provided in the tutorial are not the optimal solutions. Achieving relatively good results may still require a significant amount of experimentation.

To generate an image with the desired parameters, you can follow these guidelines:

Model: Use the "breakdomain_M2150" model.

Steps: Set the number of sampling steps to 30.

Sampler: Choose the "Euler a" sampler.

CFG scale: Set the CFG scale to 8.

For the prompts, you can write words that can easily blend with QR codes, such as "ribbon," "forest," "waves," or "flowers." Increasing the number of sampling steps will improve the high-definition restoration effect, so you can set it higher.

It is recommended to generate images with a pixel size larger than 1000 for better results.

Remember, continuous experimentation is the key to obtaining easy-to-scan, highly fused, and aesthetically pleasing QR codes. So, start trying and create your unique QR codes!


no dataCoffee time! Feel free to comment