Inverse Cooking: Recipe Generation From Food Images.

Amaia Salvador, Michal Drozdzal, Xavier Giró i Nieto, Adriana Romero

Abstract

People enjoy food photography because they appreciate food. Behind each meal there is a story described in a complex recipe and, unfortunately, by simply looking at a food image we do not have access to its preparation process. Therefore, in this paper we introduce an inverse cooking system that recreates cooking recipes given food images. Our system predicts ingredients as sets by means of a novel architecture, modeling their dependencies without imposing any order, and then generates cooking instructions by attending to both image and its inferred ingredients simultaneously. We extensively evaluate the whole system on the large-scale Recipe1M dataset and show that (1) we improve performance w.r.t. previous baselines for ingredient prediction; (2) we are able to obtain high quality recipes by leveraging both image and ingredients; (3) our system is able to produce more compelling recipes than retrieval-based approaches according to human judgment.

Introduction

Most computer vision tasks in the food domain focus on simple classification: identifying whether a dish is a pizza or a salad. However, understanding food is much more complex. Ingredients are often chopped, blended, or hidden under sauces, and the same dish can look vastly different depending on the chef. Traditional approaches to finding recipes from images rely on retrieval: searching a massive database for the most similar-looking photo and returning its associated recipe. This paper shifts the paradigm from retrieval to generation, proposing a system that reconstructs the recipe by first identifying ingredients and then reasoning about how they were likely combined.

Methodology

The authors propose a two-stage pipeline: ingredient prediction followed by instruction generation.

Ingredient Prediction (The Set Transformer)

Instead of predicting ingredients as a list (which implies a specific order), the model treats them as an unordered set. They introduce a novel "Set Transformer" (TFset) that uses an auto-regressive approach but applies a max-pooling operation across time steps. This ensures the model learns the dependencies between ingredients (e.g., if there is flour, there is likely sugar) without being penalized for the order in which it predicts them.

Overview of the inverse cooking system architecture, showing the flow from image to ingredients to instructions.

Instruction Generation (The Multi-modal Transformer)

Once the ingredients are predicted, they are fed into an instruction decoder along with the original image features. The authors experimented with three ways to fuse these two types of data:

  • Concatenated Attention: Combining image and ingredient features into one long sequence.
  • Independent Attention: Processing image and ingredients in separate layers and summing the results.
  • Sequential Attention: Attending to the image first, then the ingredients (or vice versa).
Detailed Transformer model architecture and the various fusion strategies (Concatenated, Independent, and Sequential) evaluated for instruction generation.

The Concatenated Attention strategy proved most effective, as it allowed the model to flexibly decide whether to focus on the visual evidence (the image) or the semantic concepts (the ingredients) at any given step of the recipe generation.

Datasets and Preprocessing

The model was trained and evaluated on Recipe1M, a massive dataset containing over 1 million recipes and 800,000 images. The authors cleaned the data by merging redundant ingredients (e.g., "virgin olive oil" and "spanish olive oil" became "olive oil") and discarding rare items. This reduced the ingredient vocabulary from 16,000 to a more manageable 1,488 unique items. After filtering, approximately 252,000 recipes were used for training.

Key Results and Insights

  • Ingredient Accuracy: The proposed TFset model achieved a Global IoU of 31.80 and an F1 score of 48.26, significantly outperforming standard feed-forward baselines and retrieval methods.
  • Recipe Quality: In human evaluations, the generated recipes were preferred over those found via retrieval. The "success rate" (how often a human thought the recipe matched the image) was 55.47% for the generative model, compared to 48.81% for the retrieval-based system.
  • The Power of Intermediate Concepts: The model performs better when it predicts ingredients before generating instructions. The ingredients act as a semantic bridge; it is easier for a model to go from "Image -> Ingredients -> Instructions" than to jump directly from pixels to text.

Conclusion and Future Work

While the system shows significant promise, limitations remain. The vocabulary misses the "long tail" of exotic ingredients, and instructions can occasionally be generic. Furthermore, the model currently predicts ingredient types but not quantities (e.g., it knows there is salt, but not if it's a teaspoon or a tablespoon). Future work will focus on incorporating quantities and caloric information into the generation process.

Summary updated

BibTeX
@inproceedings{salvador2019inverse,
  author = {Amaia Salvador and Michal Drozdzal and Xavier Giró i Nieto and Adriana Romero},
  title = {{Inverse Cooking: Recipe Generation From Food Images.}},
  booktitle = {CVPR},
  year = {2019},
  url = {https://openreview.net/forum?id=rQCZn-XxuTB},
}
Figure