Condition-Aware Neural Network for Controlled Image Generation

Han Cai, Muyang Li, Zhuoyang Zhang, Qinsheng Zhang, Ming-Yu Liu, Song HanCVPR 2024

Abstract

We present Condition-Aware Neural Network (CAN), a new method for adding control to image generative models. In parallel to prior conditional control methods, CAN controls the image generation process by dynamically manipulating the weight of the neural network. This is achieved by introducing a condition-aware weight generation module that generates conditional weight for convolution/linear layers based on the input condition. We test CAN on class-conditional image generation on ImageNet and text-to-image generation on COCO. CAN consistently delivers significant improvements for diffusion transformer models, including DiT and UViT. In particular, CAN combined with EfficientViT (CaT) achieves 2.78 FID on ImageNet 512x512, surpassing DiT-XL/2 while requiring 52x fewer MACs per sampling step.

Introduction

In the field of generative AI, "control" is essential for directing models to produce specific content based on instructions like text prompts or class labels. Most current state-of-the-art models, such as Diffusion Transformers, achieve this control through feature space manipulation. Techniques like adaptive normalization or cross-attention are used to inject conditional information into the feature maps as they pass through the network. However, the underlying weights of the network—the parameters of the convolutional or linear layers—typically remain static regardless of the input condition.

The authors of this paper argue that static weights lead to "negative transfer," where a single set of parameters must compromise to handle vastly different generation tasks. To overcome this, they propose the Condition-Aware Neural Network (CAN), which dynamically adapts the network's weights themselves based on the input condition.

Methodology

The fundamental innovation of CAN is the Condition-Aware Weight Generation Module. Instead of merely modifying the data flowing through the network, CAN introduces a lightweight module that processes a condition embedding (comprising class labels, text, and diffusion timesteps) to produce a conditional weight ($W_c$).

Comparison between standard feature manipulation and CAN's weight manipulation.

This conditional weight is added to a base static weight ($W$). During inference, these components are fused into a single kernel ($W + W_c$), effectively specializing the model for the specific prompt on the fly. To optimize performance, CAN is selectively applied to specific layers such as patch embeddings, output projections, and depthwise convolutions. An efficient implementation using "kernel fusion" via grouped convolutions allows the model to process batches with varying conditions in parallel.

By integrating CAN with the EfficientViT architecture, the researchers developed the CaT (CAN + EfficientViT) model family, designed for high-quality, low-latency generation.

Experimental Setup

The researchers evaluated CAN across several standard benchmarks:

  • ImageNet (256×256 and 512×512): For class-conditional image generation.
  • MS-COCO (256×256): For text-to-image generation.

Results and Discussion

Experimental results demonstrate that weight manipulation is a significantly more potent mechanism for control than feature manipulation alone. CAN allows a single model to function as an ensemble of specialized "experts" without the prohibitive memory cost of storing multiple full models.

FID vs. GMACs on ImageNet 512x512, highlighting CaT-L0's efficiency.

On the ImageNet 512×512 benchmark, the CaT-L0 model achieved a state-of-the-art FID of 2.78, outperforming the widely used DiT-XL/2 (3.04 FID). Remarkably, CaT-L0 achieved this while requiring 52× fewer MACs per sampling step. Real-world testing on edge hardware like the NVIDIA Jetson AGX Orin showed a 229× speedup over DiT-XL/2, making high-quality local generation feasible. Similar gains were observed in text-to-image tasks on COCO, where CaT-S1 surpassed UViT-S-Deep/2 in both quality and computational efficiency.

Conclusion

Condition-Aware Neural Networks represent a significant advancement in controlled image generation, shifting the paradigm from feature-based to weight-based conditioning. While the current implementation introduces a minor training overhead, the gains in inference speed and image quality are substantial. Future research will explore scaling CAN to larger datasets and extending its application to other generative tasks, such as video synthesis.

Summary updated

BibTeX
@inproceedings{cai2024condition,
  author = {Han Cai and Muyang Li and Zhuoyang Zhang and Qinsheng Zhang and Ming-Yu Liu and Song Han},
  title = {{Condition-Aware Neural Network for Controlled Image Generation}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2024},
  url = {https://openreview.net/forum?id=jWAF7PM8wj},
}
Figure