Images & Recipes: Retrieval in the cooking context

Micael Carvalho, Rémi Cadène, David Picard, Laure Soulier, Matthieu Cord · DOI · OpenReview

Abstract Recent advances in the machine learning community allowed different use cases to emerge, as its association to domains like cooking which created the computational cuisine. In this paper, we tackle the picture-recipe alignment problem, having as target application the large-scale retrieval task (finding a recipe given a picture, and vice versa). Our approach is validated on the Recipe1M dataset, composed of one million image-recipe pairs and additional class information, for which we achieve state-of-the-art results.

Introduction

In the burgeoning field of "computational cuisine," bridging the gap between heterogeneous data types remains a significant challenge. A typical recipe comprises structured ingredients and unstructured instructional text, while a dish is visually represented by an image. Previous research often simplified this into a classification task (e.g., identifying a dish as "pizza"). However, classification lacks the granularity required for effective retrieval—the ability to pinpoint a specific recipe among thousands of visually similar dishes. This paper addresses the "picture-recipe alignment problem," proposing a framework to map food photos and their corresponding recipes into a shared semantic space where they can be directly compared.

Methodology

The proposed architecture employs a dual-branch neural network to project both visual and textual modalities into a common latent semantic space.

System architecture showing the dual-branch encoder for recipes and images, aligned via triplet loss in a semantic space.
  • Image Branch: Visual features are extracted using a ResNet-50 architecture, pre-trained on ImageNet.
  • Recipe Branch: This branch handles two distinct textual inputs. Ingredients are processed via a bidirectional LSTM. Cooking instructions are handled by a hierarchical LSTM that first captures word-level semantics (utilizing skip-thoughts) and then aggregates them into sentence-level representations.
  • Alignment via Triplet Loss: To align these branches, the model utilizes a triplet loss function. This objective ensures that a query (e.g., an image) is mathematically closer to its matching recipe (positive) than to any non-matching recipe (negative) by a predefined margin. The framework incorporates both instance-based triplets (exact pair matching) and semantic-based triplets (matching within the same food category) to capture both fine-grained and high-level similarities.

Dataset

The model was trained and evaluated on Recipe1M, the largest dataset of its kind at the time of publication. It consists of approximately one million recipe-image pairs, including structured ingredient lists, sequences of instructions, and class labels for 1,000 food categories. These labels are instrumental in guiding the semantic alignment process.

Key Results and Insights

The framework achieved a significant performance leap over existing baselines, such as the original Im2Recipe model.

  • Quantitative Performance: On a retrieval task involving 1,000 items, the model achieved a Median Rank (MedR) of 1.0 for both image-to-recipe and recipe-to-image tasks. This indicates that for the median query, the correct match was the top-ranked result. Furthermore, the Recall@1 (R@1) reached approximately 40%, nearly doubling the performance of previous state-of-the-art models (~24-25%).
  • Semantic Arithmetic: The learned vector space allows for "recipe surgery." For instance, subtracting the vector for "broccoli" from a dish's representation enables the retrieval of similar images without that specific ingredient, proving the model captures meaningful ingredient-level semantics.
Qualitative retrieval results showing top-ranked images for various recipe queries.

Conclusion and Future Work

While the model demonstrates high retrieval accuracy, challenges remain in handling precise ingredient quantities and ensuring diversity in retrieval results. Future research could integrate external culinary knowledge—such as flavor pairings or nutritional data—to further refine the semantic space. This architecture serves as a foundation for advanced applications like automated calorie tracking, shopping list generation, and intelligent menu composition.

Summary updated

BibTeX
@inproceedings{carvalho2018images,
  author = {Micael Carvalho and Rémi Cadène and David Picard and Laure Soulier and Matthieu Cord},
  title = {{Images \& Recipes: Retrieval in the cooking context}},
  booktitle = {Workshops @ ICDE},
  year = {2018},
  url = {https://openreview.net/forum?id=Zf5bhHj8j9},
}
Figure