Background
Over the past few months, there has been growing interest in combining Stable Diffusion with ControlNet to create artistic QR codes. This post was originally developed as part of an AWS workshop demonstrating how to deploy and use Stable Diffusion on AWS infrastructure.
This post shares practical tips for working with Stable Diffusion and walks through the best practices for generating artistic QR codes.
We will use QR codes as ControlNet input, integrating QR code data points into artistic images while keeping them scannable by QR code readers. With this technology, you can transform any QR code into a unique piece of art, expressing and conveying information in an entirely new way. Here are some examples:

Stable Diffusion Practical Tips
As the ancient Chinese saying goes: “The beginning is always the hardest” and “Seek breadth while perfecting the details.” These correspond to the two most common challenges when working with Stable Diffusion: first, how to choose the right prompt strategy to generate images that meet expectations; and second, how to fine-tune image details so the final output meets production-quality requirements.
Based on our experience helping users work with Stable Diffusion, we have compiled the following best practices for reference.
Prompt Engineering
As Stable Diffusion versions continue to evolve and AI’s understanding of semantics gets closer to “common sense,” the requirements for effective prompts are becoming increasingly demanding. Many common prompt misconceptions can sometimes have adverse effects on image generation.
Basic Concepts
Prompts are divided into positive prompts (what you want) and negative prompts (what you don’t want), telling the AI what to include and what to exclude.
Common Misconceptions
- Precision over quantity — describing a scene with the shortest words is more effective than natural language.
- Quality-improving descriptors should not be mindlessly stacked; more is not better.
- Common starters like “masterpiece” and “best quality” often become dead weight in prompts. These words were meaningful in the NovelAI era, when they were heavily used during model training for image evaluation. However, after continuous model refinement by authors on Civitai, these prompts barely show their intended effect in modern models.
Adjusting Prompt Weights
- The default weight of each token is 1, decreasing from left to right.
- Prompt weights significantly affect the generated image.
- Use parentheses + colon + number to specify weight, e.g.,
(one girl:1.5).
Mind the Prompt Order
- Landscape tags first = smaller characters; character tags first = larger characters or half-body shots.
- Choose the correct order and syntax for prompts to more effectively render the desired scene.
Emojis in Prompts
- Prompts support emojis, and they work with good expressiveness.
- For specific facial expressions or actions, adding emojis can achieve the desired effect.
- To prevent semantic drift, prefer emojis and minimize unnecessary complex syntax.
Recommended Camera Angle Prompts
| Parameter | Description |
|---|---|
| extreme closeup | Face close-up |
| close up | Head |
| medium close up | ID photo |
| medium shot | Half body |
| cowboy shot | No legs |
| medium full shot | No feet |
| full shot | Full body |
Image Optimization
Often we generate an image that’s not quite satisfactory and want to further optimize it, but don’t know where to start. Here are some best practices for parameter tuning:
Which Parameters to Adjust
- CFG Scale: The correlation between the image and the prompt. Higher values mean greater prompt influence and closer adherence to the prompt.
- CFG 2–6: Creative but may be too distorted, not following the prompt. Fun for short prompts.
- CFG 7–10: Recommended for most prompts.
- CFG 10–15: Use when the prompt is detailed and clear.
- CFG 16–20: Not recommended unless the prompt is very detailed.
- CFG >20: Almost unusable.
- Sampling Steps: More steps mean smaller, more precise adjustments per step, but proportionally increase generation time. For most samplers, more iterations produce better results, but beyond 50 steps, improvements become negligible.
- Sampling Method: Different methods have different optimal step counts; comprehensive comparison is needed.
- Euler a: Creative; different step counts produce different images. An efficient method for quickly testing prompt effects.
- DPM2 a Karras: Good for realistic models, hard to control after 30 steps.
- DPM++ 2M Karras: Excellent at high step counts, more details.
- DDIM: Fast convergence but low efficiency; good for inpainting.
- Different model and sampler combinations produce different results; the above is for reference only. When choosing sampling methods, it’s best to use X/Y/Z plots for comparison.
- Seed: The random seed often has a huge impact on composition and is the main source of randomness in SD. With the same seed and all other parameters fixed, you can reproduce (nearly) identical images. Once you find a suitable composition, fix the seed and fine-tune details — this is the recommended approach.
How to Find Optimal Parameters
Use X/Y/Z plots to clearly compare results under different parameters, quickly locate suitable parameter ranges, and perform further generation control.

Image Size Optimization
- Image quality is not directly tied to image size.
- However, size does affect the subject and content to some extent.
- When the output size is too wide, multiple subjects may appear.
- Sizes above 1024 may produce undesirable results, and GPU memory pressure becomes significant. Small resolution + upscaling is recommended.
Optimizing Multi-Character and Wide-Format Generation
- Using txt2img alone cannot effectively specify individual character features in multi-character scenarios.
- The recommended approach is to create a draft + img2img or ControlNet.
- For wide-format single-character generation, draft a sketch with color blocking to determine the main subject, or use ControlNet’s OpenPose for character skeleton.
- For multi-character scenes, use ControlNet’s OpenPose to specify character count; this also works for three-view drawings of the same character.
Hand Repair
Send the image to img2img inpaint with similar prompts, placing “hand” prompts at the front. Set denoising strength based on how much you want hand features to change (below 0.25 if you just want completeness), keeping steps and CFG the same as txt2img. For more precise hand control, find a satisfactory hand reference image and use ControlNet’s Canny or OpenPose_hands preprocessor + model combined with inpaint.
Face Repair
When drawing images with small character subjects, facial distortion frequently occurs. Especially in the artistic QR code generation process described later, faces often break due to QR code data points. For facial inpainting, the ADetailer plugin is recommended. It uses the YOLO algorithm for object detection — we configure it to detect character faces and provide prompts and models for facial inpainting. The plugin performs localized inpainting at detected face locations to complete the repair. ADetailer can handle both face and hand detection and repair, and can also reference LoRA models for localized inpainting.

Generating Artistic QR Codes with ControlNet
Step 1: Optimize the QR Code
A QR code is a pattern of black and white geometric shapes distributed in 2D space that records symbolic data. There are multiple encoding methods; we use the most universal and fundamental one: QR Code.
The input QR code is one of the most important factors when generating artistic QR codes with SD. We mainly care about two characteristics:

1. Information contained in the QR code
Regardless of the encoding method, the more character information a QR code carries, the more complex its visual black-and-white structure becomes. Complex structures heavily constrain artistic creativity during generation. Therefore, we first need to simplify the content length.
For the most common use case — web links — shorten the URL first. There are many URL shortening tools available; choose freely. Note that within mainland China, use platforms with registered domain names, otherwise links may be blocked by WeChat, browsers, etc.

2. How the QR code is presented
With technological development, QR codes no longer only support black and white square patterns; both positioning points and modules support diverse presentation styles.
In practice, try different module styles to achieve the desired generation effect. The following images show how different QR code styles affect the final result:

Generation parameters:
| |
Step 2: Create the Base QR Code
After understanding the key points above, use a QR code generation tool to create a base QR code for SD input. There are many web-based generators available; choose freely. For convenience, here is a useful WebUI plugin:
- Anthony’s QR Toolkit: Integrated QR code generation and optimization tool for WebUI

After creating the QR code, click “Download” to save it locally, or click “Send to ControlNet” to pass it directly for the next step.
Step 3: Determine the Art Style
The core of creating art with Stable Diffusion is choosing the right model + prompts. Before creating artistic QR codes, we recommend generating an image without ControlNet first to test the style.

Generation parameters:
| |
Step 4: Import QR Code into ControlNet
After confirming the image style, upload the unprocessed QR code to ControlNet. Pay attention to these configuration options:
- “Enable” button: Check to ensure ControlNet is active during generation
- Model selector: Select
control_v1p_sd15_qrcode_monsterto strengthen QR code control - Control weight: For the qrcode_monster model, we recommend setting it between 1.1–1.6
- Guidance start/end timing: Start timing recommended between 0–0.1, end timing recommended at 1

In the txt2img configuration, adjust two key values:
- Sampling steps: Recommended 30–50 (the default of 20 is insufficient for generating high-quality QR code images)
- Width/Height: Match the original QR code aspect ratio from ControlNet

After all parameters are configured, click generate. Here we can see a good result — the QR code passes scanning tests on mobile phones.
If the generated QR code doesn’t meet expectations, try fine-tuning the following parameters and increase the total batch count, iterating to approach the desired result:
- Prompts
- Sampling method
- ControlNet control weight
- ControlNet guidance start/end timing

When necessary, use the X/Y/Z Plot in “Scripts” to compare QR code generation effects under different parameters. Here we compared ControlNet’s control weight and guidance start timing:

Enhancing QR Codes with OpenPose
Building on the QR code techniques above, we can take it further by combining OpenPose with QR codes to create even more dynamic and artistic results. OpenPose generates skeleton maps of human poses, which serve as an additional ControlNet input to control character poses in the generated image.
Example Showcase
Here are some example results combining OpenPose pose control with QR code generation:
![]() | ![]() |
The prompt used for the example above:
| |
Environment Setup: Enable Multiple ControlNet Units
To use OpenPose and QR Code ControlNet simultaneously, you need at least 2 ControlNet Units enabled:
- Go to Settings → ControlNet
- Set the Multi ControlNet unit count to 2 (or more)
- Click Apply Settings, then Reload UI




Import Skeleton Data and Enable OpenPose
- Open the OpenPose Editor extension
- Click Load JSON to import your prepared skeleton pose data
- Click Send to txt2img to transfer the pose to ControlNet
- In ControlNet Unit 0, enable ControlNet and select the model control_v11p_sd15_openpose


Import QR Code and Configure Generation
- Switch to ControlNet Unit 1
- Upload your QR code image
- Select the model control_v1p_sd15_qrcode_monster with a Control Weight of 1.7
- Set Sampling Steps to 30–50 for better quality
- Adjust Width/Height to match your desired output resolution


Prompts and Generation
Set your prompts for the final generation:
Positive prompt:
| |
Negative prompt:
| |

Results
Here is the final generated result combining OpenPose and QR code:

By cleverly offsetting the QR code position and applying composition techniques, the viewer’s focus is effectively shifted from the QR code to the character itself, creating a more natural and harmonious overall image.
![]() | ![]() |
|---|
Fine-Tuning Tips
To achieve the best results when combining OpenPose with QR codes, consider adjusting:
- Prompts: Experiment with different scene descriptions and character poses
- Sampling method: Try different samplers (Euler a, DPM++ 2M Karras, etc.)
- Skeleton structure and position: Adjust the pose skeleton to avoid overlapping with QR code critical areas
- Control weight: Balance between OpenPose (pose accuracy) and QR code (scannability) weights
- Guidance start/end timing: Fine-tune when each ControlNet kicks in during the denoising process
Appendix: ControlNet QRCode Model Selection
To date, QRCode Monster is the model with the highest QR code control success rate and best image fusion effect. It can be downloaded from HuggingFace:
Another option is QR Pattern v2.0, best used with IoC Lab’s Brightness model as an auxiliary to improve local contrast. However, based on our testing, this model introduces more interference that may significantly alter the image style. Downloads:
References
- AIGC Stable Diffusion Workshop
- QR Toolkit by Anthony Fu
- QRCode Monster - HuggingFace
- IoC Lab ControlNet - HuggingFace
Original post: Art QR Code Generation with ControlNet - AI Painting Solution Based on Stable Diffusion



