CAR: Consolidation, Augmentation and Regulation for Recipe Retrieval

Fangzhou Song, Bin Zhu, Yanbin Hao, Shuo Wang, Xiangnan He

Abstract

Learning recipe and food image representation in common embedding space is non-trivial but crucial for cross-modal recipe retrieval. In this paper, we propose a new perspective for this problem by utilizing foundation models for data augmentation. Leveraging on the remarkable capabilities of foundation models (i.e., Llama2 and SAM), we propose to augment recipe and food image by extracting alignable information related to the counterpart. Specifically, Llama2 is employed to generate a textual description from the recipe, aiming to capture the visual cues of a food image, and SAM is used to produce image segments that correspond to key ingredients in the recipe. To make full use of the augmented data, we introduce Data Augmented Retrieval framework (DAR) to enhance recipe and image representation learning for cross-modal retrieval. We first inject adapter layers to pre-trained CLIP model to reduce computation cost rather than fully fine-tuning all the parameters. In addition, multi-level circle loss is proposed to align the original and augmented data pairs, which assigns different penalties for positive and negative pairs. On the Recipe1M dataset, our DAR outperforms all existing methods by a large margin. Extensive ablation studies validate the effectiveness of each component of DAR.

Introduction

Cross-modal recipe retrieval—finding a recipe from a photo or a photo from a recipe—suffers from a fundamental data misalignment. Recipes are long, procedural documents containing "hidden" visual information mixed with non-visual instructions (e.g., "preheat the oven" or "marinate for two hours"). Conversely, food images contain "noisy" visual information irrelevant to the recipe, such as the plate, cutlery, or background. Standard models struggle to map these two very different types of data into a shared embedding space because they are trying to align "how to cook" with "how it looks."

The DAR Framework

The researchers introduce the Data Augmented Retrieval (DAR) framework, which leverages foundation models to bridge this gap through two main augmentation strategies:

  1. Textual Augmentation (LLM): They use Llama2-13b-chat to transform a recipe into a "visual imagination description." By prompting the LLM to act as a helpful assistant, they generate a concise (~30 word) description focusing solely on the dish's visual appearance, effectively stripping away procedural noise.
  2. Visual Augmentation (SAM): They use the Segment Anything Model (SAM) to decompose a food image into multiple segments. These segments typically correspond to individual ingredients, allowing the model to focus on the "what" of the dish rather than the "where" (background).
High-level overview of the DAR framework showing how SAM and LLMs augment the data for better alignment.

Architecture and Implementation

Instead of fully fine-tuning a massive model, the authors use a pre-trained CLIP (ViT-B/16) model and inject lightweight adapter layers. This keeps the bulk of the model frozen, reducing trainable parameters to just 8% of the total, which prevents over-fitting and saves compute.

Detailed architecture of the DAR framework, including the adapter-based CLIP encoder and the multi-level circle loss.

Multi-Level Circle Loss

To make full use of the augmented data, the authors employ a multi-level circle loss. Unlike the standard triplet loss, circle loss allows for different penalties for positive and negative pairs, offering more flexibility during optimization. The loss aligns four distinct pairs: (Image, Recipe), (Segments, Recipe), (Image, Imagination), and (Recipe components with each other).

Experimental Results

The study primarily uses Recipe1M, the gold standard for this field, consisting of approximately 238k training pairs. The DAR framework sets a new bar on this benchmark:

  • 1k Setup: On image-to-recipe retrieval, DAR++ achieved a Recall@1 of 77.3%, outperforming the previous best (MALM) by 3.3%.
  • 10k Setup: In the more challenging 10k retrieval task, DAR++ reached 47.8% R@1, a significant jump over existing methods.
  • Parameter Efficiency: Despite the performance gains, the image encoder uses only 43.6M trainable parameters compared to the ~300M-400M used by competing CLIP-based fine-tuning methods.

Key Insights

  • Foundation Models as "Cleaners": The most significant innovation is using foundation models to translate data into a more "retrievable" format. Llama2 acts as a filter for text, and SAM acts as a filter for pixels.
  • Test-Time Augmentation: Interestingly, the "visual imaginations" and "segments" aren't just for training. At test time, the model can generate an imagination for a query recipe to help find the right image (DAR++), proving that the augmented data contains superior retrieval cues.
  • Efficiency via Adapters: The paper demonstrates that you don't need to retrain CLIP from scratch. By using bottleneck adapters (downsampling/upsampling projections), the model learns the specific domain of "food" without losing the general knowledge CLIP already possesses.

Limitations and Future Work

While effective, the authors note that SAM’s "everything" mode can sometimes over-segment (breaking a single cake into many tiny pieces) or miss small, irregular ingredients. Additionally, while prompts are designed to be objective, LLMs can still occasionally imagine garnishes or textures not present in the original recipe. Future work may explore using recipe text to "guide" SAM toward specific ingredients rather than segmenting blindly.

Summary updated

BibTeX
@inproceedings{song2024car,
  author = {Fangzhou Song and Bin Zhu and Yanbin Hao and Shuo Wang and Xiangnan He},
  title = {{CAR: Consolidation, Augmentation and Regulation for Recipe Retrieval}},
  booktitle = {European Conference on Computer Vision},
  year = {2024},
  doi = {10.1007/978-3-031-72983-6\_7},
}
Figure