Conditional synthetic food image generation

Wenjin Fu, Yue Han, Jiangpeng He, Sriram Baireddy, Mridul Gupta, Fengqing Zhu

TL;DR

This paper tackles the unique challenges of generating realistic food images—specifically high intra-class diversity and inter-class similarity—by refining the StyleGAN3 architecture. The authors introduce a two-pronged strategy: training on single food categories to prevent "feature entanglement" (where different foods blend together) and using a patch-based, any-resolution training approach to preserve fine-grained textures. Their synthetic images were so realistic that human subjects mistook them for real photos nearly 65% of the time, and using them as data augmentation boosted food classification accuracy by nearly 10%.

What Problem Does This Paper Address?

Automated dietary assessment (tracking what we eat via photos) is a holy grail for health tech, but deep learning models for food recognition are notoriously data-hungry. Existing datasets are often "long-tailed," meaning there are plenty of photos of burgers but very few of niche or regional dishes.

Generative Adversarial Networks (GANs) should, in theory, be able to manufacture "extra" training data. However, food is difficult for standard GANs like StyleGAN3. Two main issues arise:

  1. Inter-class Feature Entanglement: Because many foods share similar colors or textures (e.g., a golden-brown spring roll vs. a golden-brown cannoli), the GAN often gets "confused," producing a hamburger that has the texture of a spring roll.
  2. Detail Loss: Standard GANs require images to be resized to fixed, often low resolutions (like 256x256). This downsampling wipes out the fine-grained details—the seeds on a bun or the flake of a crust—that make food look appetizing and "real."

Methods

The researchers built their approach on StyleGAN3, the current gold standard for alias-free image generation, but modified the training pipeline in two key ways:

  • Single-Class Training: Instead of training one massive conditional model on many food types simultaneously, they found that training on one category at a time effectively "quarantined" features. This prevented the generator from bleeding characteristics of one food into another.
  • Any-resolution Patch Training (Anyres GAN): To capture high-resolution details without the massive computational cost of training a full high-res GAN, they adopted a two-stage process. First, the model learns the global structure of the food at a low resolution. Second, it is trained on random high-resolution patches cropped from original images. This allows the generator to learn fine-grained textures (like the "fuzz" on a strawberry) that are usually lost during downsampling.

Datasets

The authors primarily used the Food-101 dataset, a standard benchmark in the field. They selected ten diverse classes for their experiments: cannoli, cupcake, donut, hamburger, pancake, panna cotta, pizza, spring roll, shortcake, and strawberry.

To test their "any-resolution" method, they also curated a custom high-resolution dataset by scraping 600 high-res hamburger images from Google, where the median side length was 1,000 pixels (significantly higher than the standard 256 or 512 pixels used in most GAN training).

Key Insights and Ideas

  • The "Uncanny Valley" of Food: The authors noted that while a GAN might converge mathematically (low FID score), the images often looked "artificial" or "distorted" to humans due to feature entanglement. This highlights a gap between standard metrics and human perception.
  • Standard Metrics Fail High-Res: They discovered that the standard Frechet Inception Distance (FID)—the go-to metric for GAN quality—is actually a poor judge of high-resolution detail because it forces images back into a low-resolution (299x299) bottleneck for calculation. To solve this, they used patch-FID (pFID), which evaluates the quality of the high-res crops themselves.
  • Synthetic Data as a "Force Multiplier": One of the most significant insights is that synthetic data doesn't just look good; it's functionally useful. Adding synthetic images to a small "real" dataset provided a significant boost in classification performance, suggesting GANs can effectively fill gaps in rare food categories.

Key Results

  • Visual Realism: In a subjective survey of 82 adults, participants mistook synthetic food images for real ones 64.75% of the time. Spring rolls were the most "convincing" (52.17% mistaken for real), while hamburgers were the most "obvious" (38.29%).
  • Quantitative Texture Improvement: By moving to any-resolution training, the pFID score dropped from 90.113 to 30.863 (lower is better), indicating a massive leap in the quality of fine-grained details.
  • Downstream Performance: In a classification task using ResNet-50:
  • Training on 200 real images: 62.33% accuracy.
    • Training on 200 real + 200 synthetic images: 71.33% accuracy.
    • This nearly 10% jump demonstrates that the synthetic images captured enough "real" features to help the classifier generalize better.

Limitations and Future Work

The authors acknowledge that their current work focuses on single-label images—one food item per photo. In the real world, meals are complex and multi-label (e.g., a plate with chicken, rice, and broccoli).

Future research directions include:

  • Developing a multi-label training strategy to generate complex meal scenes.
  • Applying these high-quality synthetic images to more difficult tasks like food localization (finding the food in the image) and volume estimation (predicting portion size), which are critical for accurate dietary tracking.

Summary updated

BibTeX
@inproceedings{fu2023conditional,
  author = {Wenjin Fu and Yue Han and Jiangpeng He and Sriram Baireddy and Mridul Gupta and Fengqing Zhu},
  title = {{Conditional synthetic food image generation}},
  booktitle = {Electronic},
  year = {2023},
  doi = {10.2352/ei.2023.35.7.image-268},
}

Loading related content...

Figure