Stable Diffusion QR Codes
QR Codes are machine-readable codes that hold text information like URLs. Modern smartphones are able to use their cameras to process the qr codes and pull up a webpage that is encoded within the QR code. QR codes have mostly been a single color or a gradient to some extent to bring style to an individual QR code. However, now we can use AI to really push the boundaries of what a QR code can look like and still be functional.
![qr code with an ai styling of a forest and mountain background that links to https://mrpalumbo.com](images/qr-code-forest.png)
![qr code with an ai styling of a forest that links to https://mrpalumbo.com](images/qr-code-forest2.png)
![forrest with evergreen trees, mountain background, photo-realistic, concept art, volumetric light, cinematic epic + rule of thirds octane render, 8k, corona render, octane render, cinematic, trending on artstation, cinematic composition , ultra-detailed, realistic , hyper-realistic , volumetric lighting, 8k –ar 2:3 –test –uplight | Negative prompt: blurry, low quality, snow | Steps: 50, Sampler: DPM++ 2M Karras, CFG scale: 7, Seed: 3532770226, Size: 512x512, Model hash: e3edb8a26f, Model: ghostmix_v20Bakedvae, Denoising strength: 0.74, ControlNet 0: 'preprocessor: tile_resample, model: control_v11f1e_sd15_tile [a371b31b], weight: 1.5, starting/ending: (0.29, 0.75), resize mode: Just Resize, pixel perfect: False, control mode: Balanced, preprocessor params: (512, 1, -1)', Version: v1.3.2 qr code with an ai styling of a forest and creek that links to https://mrpalumbo.com](images/qr-code-forest3.png)
![qr code with an ai styling of a stair case in a home that links to https://mrpalumbo.com](images/qr-code-stairs.png)
![downtown city, foggy morning, cityscape, photo-realistic, cinematic epic + rule of thirds octane render, 8k, octane render, cinematic, trending on artstation, cinematic composition , ultra-detailed, realistic , hyper-realistic , volumetric lighting, 8k –ar 2:3 –test –uplight | Negative prompt: blurry, low quality, glow | Steps: 50, Sampler: DPM++ 2M Karras, CFG scale: 7, Seed: 2597113158, Size: 512x512, Model hash: e3edb8a26f, Model: ghostmix_v20Bakedvae, Denoising strength: 0.79, ControlNet 0: 'preprocessor: tile_resample, model: control_v11f1e_sd15_tile [a371b31b], weight: 1.25, starting/ending: (0.29, 0.8), resize mode: Just Resize, pixel perfect: False, control mode: Balanced, preprocessor params: (512, 1, -1)'', Version: v1.3.2 qr code with an ai styling of a stair case in a home that links to https://mrpalumbo.com](images/qr-code-city.png)
![field of flowers, sunset, rainy day, dark clouds, ultra realistic, 8k, realistic light, shadows, forrest line in background, mansion home | Negative prompt: blurry, low quality | Steps: 50, Sampler: DPM++ 2M Karras, CFG scale: 7, Seed: 3663504112, Size: 512x512, Model hash: e3edb8a26f, Model: ghostmix_v20Bakedvae, Denoising strength: 0.8, ControlNet 0: 'preprocessor: tile_resample, model: control_v11f1e_sd15_tile [a371b31b], weight: 1.6, starting/ending: (0.35, 0.9), resize mode: Just Resize, pixel perfect: False, control mode: Balanced, preprocessor params: (512, 1, -1)', Version: v1.3.2 qr code with an ai styling of a mansion in a field of flowers that links to https://mrpalumbo.com](images/qr-code-mansion.png)
Automatic1111
Automatic1111 is a broswer based user interface for Stable Diffusion. Stable Diffusion can be used from the command line but having a user interface helps when working with multiple models. We need to download and run Automatic1111 to be able to use this workflow for creating Stable Diffusion QR codes.
Automatic1111Checkpoints
Stable diffusion needs models to be able to generate images. Models that are used are sometimes referred to as checkpoint files which are pre-trained stable diffusion weights created to generated general images or a more specific niche of images. We can train our own model from base models like Stable Diffusion v1.4 or v1.5 but we are going to use the GhostMix model on CivitAi since it will allow us to jump right in to generating images.
CivitAi
CivitAi is a helpful site to find stable diffusion models. This website is great because you can see example images that have been generated with given models. For this workflow I have chosen the GhostMix Model linked below.
CivitAi GhostMix ModelHugging Face
Hugging Face is a community driven website full of machine learning information. For creating QR code images with stable diffusion we will only be using a small portion of Hugging Face. Definitely check out this website to see what they are up to if you are interested in doing more with machine learning.
Hugging FaceControlNet
ControlNet is a neural network structure that allows for adding conditional control to text-to-image diffusion models. To create QR code images with Stable Diffusion we need to download ControlNet in Automatic1111. Paste the ControlNet Git link below into the "Install from URL" form input on the Extensions tab in Automatic1111.
ControlNet Git ControlNet ArxivTile
After the ControlNet extension is installed we need to get the ControlNet tile model from HuggingFace. We only need the control_xxxx_tile.pth file for this workflow. The file will be around 3GB in size.
ControlNet ModelsWorkflow
Now that every dependency is installed we can begin to create the QR code images. The below workflow is a good starting point to generate nice styles. Remember that the QR code you input will also have an effect on the output so what you get will not necessarily be the same as the above QR codes showcased.
- Go to the img2img tab
- Stable Diffusion checkpoint: ghostmix
- Enter the prompt for the image
- Enter the negative prompt for the image
- Add the QR code you have created to the first image input
- Sampling method: DPM++ 2M KARRAS
- Sampling Steps: 50
- Width: 512
- Height: 512
- CFG Scale: 7
- Denoising strength: 0.75
- Open the dropdown for the ControlNet extension
- Add the QR code you have created to the image input
- Check the "Enable" checkbox
- Preprocessor: tile_resample
- Model: control_xxxx_tile (Note: xxxx will be the version of the model you downloaded)
- Control Weight: 0.75
- Starting Control Step: 0.23
- Ending Control Step: 0.9
- Control Mode: Balanced
- Click Generate
Tips
QR code Not Working
Not every output will be a working QR code. Some of the generated QR codes will only work at a certain distance when checking with your phone. The smaller the link in the QR code the better off you will be since there will be less pixels needed to make up the QR code. Having a small QR code is not always possible so continue to generate images and you will get one that works after changing the inputs to be more or less like your control.
Seed or No
You will not get the same output unless you keep the same seed. Having the seed set to -1 will use a random seed for each generation. I found it helpful to create random QR code images until I found a theme that I liked and then recycling the seed while changing some of the inputs.