Stable Diffusion Dataset Generation for Downstream Classification Tasks

Eugenio Lomurno, Matteo D'Oria, Matteo Matteucci

Introduction

Generating high-quality synthetic datasets for training downstream classifiers remains a significant challenge. While models like Stable Diffusion (SD) excel at text-to-image generation, their application to discrete classification tasks is hindered by information gaps, high resource requirements, and slow generation speeds. This paper presents a pipeline to adapt SD 2.0 for class-conditional generation, optimizing it specifically for the creation of informative synthetic training sets.

Methodology

The researchers proposed a four-stage adaptation pipeline designed to bridge the gap between generative capability and classification utility:

  1. Class-Encoder Integration: The standard Text-Encoder was replaced with a "Class-Encoder"—a fully-connected layer mapping one-hot encoded class vectors into the model's latent space.
  2. Initial Hyper-parameter Optimization (HPO): Bayesian optimization (Tree-Structured Parzen Estimator) was used to find the best combination of Inference Steps (IS), Unconditioned Guidance Scale (UGS), and training epochs before fine-tuning.
  3. U-Net Fine-Tuning: The core diffusion model was fine-tuned on the target dataset using the new Class-Encoder.
  4. Final HPO: A second round of optimization refined the generation parameters (IS and UGS) for the newly fine-tuned model.

To measure success, the authors used the Classification Accuracy Score (CAS), where a ResNet20 model is trained entirely on synthetic data and tested on real-world images.

Experimental Results

The pipeline was evaluated across six 32x32 RGB datasets, including general-purpose (CIFAR10/100) and medical (MedMNIST) images. The results demonstrate a clear progression in classification performance as the pipeline stages are applied.

Table 1: Classification Accuracy Score (CAS) and Generation Time across the four pipeline stages.

As shown in Table 1, the full optimization pipeline (After 4.) yields substantial improvements in CAS compared to the baseline. For instance, PathMNIST accuracy increased from 39.95% to 78.95%. Furthermore, the optimization process improved efficiency, reducing generation latency by identifying the minimum necessary inference steps to maintain quality.

Scaling Synthetic Data

A key finding of this research is that the inherent "information deficit" of individual synthetic images can be mitigated by increasing the volume of generated data. By scaling the synthetic dataset size beyond the original real-world dataset (from 1x to 10x), the researchers observed significant performance gains.

Table 2: Comparison of CAS for real data versus synthetic datasets of varying sizes (x1 to x10).

Table 2 highlights that for CIFAR10 and RetinaMNIST, classifiers trained on large synthetic datasets (7x and 4x respectively) actually outperformed those trained on the original real-world data. This suggests that the fine-tuned generative model effectively performs a sophisticated form of data augmentation, filling in gaps in the original distribution.

Key Insights and Conclusion

The study revealed that the Unconditioned Guidance Scale (UGS) is the most critical hyper-parameter for generating informative datasets, outweighing the number of inference steps. While synthetic data does not always match real data at a 1:1 ratio, the ability to scale generation allows synthetic sets to meet or exceed real-world performance in specific tasks. Future work will focus on active learning and automated refinement steps to further filter and enhance the utility of generated samples.

Summary updated

BibTeX
@inproceedings{lomurno2024stable,
  author = {Eugenio Lomurno and Matteo D'Oria and Matteo Matteucci},
  title = {{Stable Diffusion Dataset Generation for Downstream Classification Tasks}},
  booktitle = {ESANN},
  year = {2024},
  doi = {10.14428/esann/2024.es2024-100},
}
Figure