DiffQRCoder: Diffusion-based Aesthetic QR Code Generation with Scanning Robustness Guided Iterative Refinement

Research Center for Information Technology Innovation, Academia Sinica 1
National Tawian University 2

WACV 2025

* Equal contribution

teaser
Figure. Aesthetic QR codes generated from DiffQRCoder. Our method takes a QR code and a text prompt as input to generate an aesthetic QR code. We leverage the pre-trained ControlNet and guide the generation process using our proposed Scanning Robust Perceptual Guidance (SRPG) to ensure the generated code is both scannable and attractive.

Abstract

With the success of Diffusion Models for image generation, the technologies also have revolutionized the aesthetic Quick Response (QR) code generation. Despite significant improvements in visual attractiveness for the beautified codes, their scannabilities are usually sacrificed and thus hinder their practical uses in real-world scenarios. To address this issue, we propose a novel Diffusion-based QR Code generator (DiffQRCoder) to effectively craft both scannable and visually pleasing QR codes. The proposed approach introduces Scanning-Robust Perceptual Guidance (SRPG), a new diffusion guidance for Diffusion Models to guarantee the generated aesthetic codes to obey the ground-truth QR codes while maintaining their attractiveness during the denoising process. Additionally, we present another post-processing technique, Scanning Robust Manifold Projected Gradient Descent (SR-MPGD), to further enhance their scanning robustness through iterative latent space optimization. With extensive experiments, the results demonstrate that our approach not only outperforms other compared methods in Scanning Success Rate (SSR) with better or comparable CLIP aesthetic score (CLIP-aes.) but also significantly improves the SSR of the ControlNet-only approach from 60% to 99%. The subjective evaluation indicates that our approach achieves promising visual attractiveness to users as well. Finally, even with different scanning angles and the most rigorous error tolerance settings, our approach robustly achieves over 95% SSR, demonstrating its capability for real-world applications.

Method

Scanning Robust Loss

Scanning Robust Loss (SRL) is designed at the module level, tailored to the QR code mechanism. The process begins by constructing a pixel-wise error matrix that measures the differences between the pixel values of the target QR code and the grayscale image. Subsequently, the error for each module is re-weighted using a Gaussian kernel, and the central submodule is extracted to implement an early-stopping mechanism. The mechanism stops refining the module and evaluating its error once the average pixel value of the central submodule matches the center pixel value of the target module. Finally, SRL can be calculated as the average error across all modules in the code.

srl
Figure. An illustration of Scanning Robust Loss (SRL).

Two-stage Pipeline with Scanning Robust Perceptual Guidance

First, we encode target QR code y\mathbf{y} and prompt pp to embeddings for ControlNet input. In Stage-1, we utilize the pre-trained ControlNet to generate an attractive yet unscannable QR code. In Stage-2, we convert the QR code from Stage-1 into a latent representation z~T\tilde{z}_T by adding Gaussian noise and transforming the y\mathbf{y} to y~\tilde{\mathbf{y}}, which has a more similar pattern as x^\hat{\mathbf{x}}, using Qart. Finally, we feed the latent and the transformed code into ControlNet, guided by Scanning Robust Perceptual Guidance (SRPG), to create an aesthetic QR code with scannability.

two stage generation pipeline
Figure. An overview of our two-stage pipeline with Scanning Robust Perceptual Guidance (SRPG).

Experiments

Evaluation Metrics

We use qr-verify to measure Scanning Success Rate (SSR) of aesthetic QR codes. For the quantitative assessment of aesthetics, we use CLIP aesthetic score predictor to reflect image quality and visual appeal. This score is referred to as the CLIP aesthetic score (CLIP-aes). We also adopt CLIP-score to assess the text-image alignment of generated aesthetic QR codes.

Quantitative Results

As shown in Tab., we present the quantitative results of our method compared to previous generative-based methods. Our method outperforms QR Diffusion and QR Code AI Art in SSR, CLIP aesthetic score, and CLIP-score. Compared with QRBTF, our method significantly enhances the SSR, albeit with a little trade-off with CLIP aesthetic score. Notably, the text-image alignment measured by CLIP-score shows that our method is close to QRBTF, indicating our method adheres to prompts without distortion.

MethodSSR ↑CLIP-aes. ↑CLIP-score ↑User Study Rank ↓
QR Code AI Art90%5.70030.23412.71
QR Diffusion96%5.51500.27803.18
QRBTF56%7.01560.30331.86
DiffQRCoder (Ours)99%6.82330.29922.25

Table. Quantitative comparison with other generative-based methods.

Qualitative Results

DiffQRCoder can generate attractive and scannable QR codes with different encoded messages and prompts.

visual comparisons
Figure. Qualitative comparison with other generative-based methods.
different message
Figure. Qualitative results for different QR code messages.
different level
Figure.Qualitative results for different QR code error correction levels.

BibTeX Citation

    @inproceedings{liao2024diffqrcoder,
  title     = {DiffQRCoder: Diffusion-based Aesthetic QR Code Generation with Scanning Robustness Guided Iterative Refinement},
  author    = {Jia-Wei Liao, Winston Wang, Tzu-Sian Wang, Li-Xuan Peng, Ju-Hsian Weng, Cheng-Fu Chou, Jun-Cheng Chen},
  booktitle = {IEEE/CVF Winter Conference on Applications of Computer Vision (WACV)},
  year      = {2025},
}