Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 11

Schema Design for Meal Image Annotation

Recommended resources

Welcome to the first lesson of Module 3. In the previous module, we did the crucial work of translating the complex, real-world problem of meal quality monitoring into a set of precise, measurable machine learning tasks. We concluded by formally stating the assumptions and limitations of this approach, giving us a clear and realistic foundation for the project.

Now, we shift from abstract problem-framing to the tangible work of creating the "ground truth" for your models. This lesson begins that process by focusing on your image data. Our goal is to design a structured annotation schema—a formal blueprint for labeling meal photos—that can consistently capture the key violation indicators: poor quality, insufficient quantity, and lack of variety.

The Data-Centric Mindset

Before we dive into the details of the schema, it's important to adopt the right mindset. In machine learning, it's often tempting to focus entirely on the model architecture—the code—as the primary way to improve performance. However, for many real-world applications, a more effective approach is to focus on the data itself. This is the core idea behind data-centric AI.

Data centric AI development From Big Data to Good Data Andrew Ng

Andrew Ng, a leading figure in AI, provides a clear introduction to this concept. His perspective will frame our work for this entire module.

First, watch the segment from the beginning to understand the shift from a model-centric to a data-centric approach. Then, jump to the section from this timestamp where he reframes data cleaning not as a one-time task, but as a core part of the iterative development process.

Your project, with its messy, real-world data and need for domain-specific nuance, is a perfect candidate for a data-centric approach. The time you invest now in meticulously designing your labels will have a far greater return than weeks spent tweaking a neural network architecture. Your goal is not just "big data," but "good data."


Deconstructing a Meal Image: Quality, Quantity, Variety

To create "good data," we need to break down our high-level goals into concrete, answerable questions that an annotator can address just by looking at an image. Let's tackle each of our three pillars: quantity, variety, and quality.

1. Capturing Quantity

The PM POSHAN guidelines specify exact gram amounts for food components. However, estimating a precise weight from a 2D image is notoriously difficult and prone to error. A more pragmatic approach is to use coarse classification. Instead of asking "How many grams of rice are there?", we ask "Is the quantity of rice sufficient?"

This requires defining what "sufficient" looks like. We can create visual heuristics, much like the common guides for estimating food portions using your hand.

This guide illustrates how everyday objects, like one's hand, can be used as a practical analogy for estimating food portion sizes. We will need to create a similar, context-specific guide for our annotators.

For your project, the official guidelines are the ultimate source of truth.

[PDF] guidelines of the PM Poshan scheme - Ministry of Education

These guidelines provide the objective basis for our quantity and variety labels.

First, review the section on "Food and Nutrition norms". Find the table that specifies the food norms per child for primary and upper primary classes. Note the gram amounts for the key components. Next, scroll down to the section "Information, Education and Communication (IEC)". Note that schools are required to display these entitlements publicly. This confirms that these norms are the official standard we should be measuring against.

Based on these guidelines (e.g., 100g of food grains for primary), we can define our quantity categories. A label for quantity might look like: quantity_assessment: "insufficient" | "sufficient" | "excessive".

2. Capturing Variety (Food Groups)

The guidelines also mandate the core food groups that should be present in a meal. This naturally lends itself to a multi-label classification problem. An image is not just one thing; it can have multiple attributes simultaneously. A meal might have grains but be missing pulses, or have both but be missing vegetables.

This flowchart illustrates the decision process for choosing a classification type. Our problem falls into the multi-label category because a meal image can have multiple "winning labels" (e.g., it contains both a grain and a pulse) or flags for violations.

To capture variety, our schema should include a set of boolean flags corresponding to the required food groups.

[PDF] guidelines of the PM Poshan scheme - Ministry of Education

The guidelines also discuss the importance of variety and local ingredients.

In the section "Menu under scheme", read the points about variety and the importance of green leafy vegetables, whole legumes, and millets.

Based on this, we can define variety-focused labels like:

  • has_grain_component: true/false
  • has_pulse_component: true/false
  • has_vegetable_component: true/false

3. Capturing Quality

Quality is the most subjective and challenging attribute. We must break it down into observable, physical proxies. The PM POSHAN guidelines provide an extensive list of safety and hygiene rules that can help us define what a "low quality" meal might look like.

[PDF] guidelines of the PM Poshan scheme - Ministry of Education

This document provides a wealth of information on what constitutes a quality meal, which we can use to define our labels.

First, skim the section on "Quality and safety aspects under the scheme". Pay attention to the types of contaminants mentioned. Then, read the subsection "Food Safety Measures", particularly the points about cleaning food and the importance of tasting and inspection. Finally, look at Annexure IV, which lists "Indicative parameters for verification during Social Audit." Note the parameters that can be visually assessed, such as "Safety and hygiene aspects" and "Quality and quantity of the served Meal."

From these guidelines, we can derive several quality-related flags. The key is to be specific. Instead of a single is_bad_quality label, we should create more granular labels.

The Best Way to Annotate Images for Object Detection

This video from Roboflow, though focused on object detection, makes an excellent point about creating specific labels from the outset.

Watch the first segment from the beginning. The speaker explains why it's better to label "white pawn" and "black pawn" separately rather than just "pawn." The same logic applies to our violation types.

Applying this principle, our quality labels could include:

  • is_contaminated: true/false (for visible foreign objects like hair, insects, etc.)
  • looks_burnt: true/false
  • looks_watery: true/false (for dishes like dal that appear diluted)
  • has_unidentifiable_items: true/false

Drafting the Image Annotation Schema v1.0

Now, let's combine these ideas into a single, structured schema. Using a format like JSON is ideal because it's both human-readable and easily processed by your code later. A well-structured schema serves as a "contract" for what information each labeled image will provide.

For inspiration, look at how professional, large-scale datasets are structured.

Codatta/MM-Food-100K · Datasets at Hugging Face

This dataset page shows a great example of a detailed, multi-modal schema for food images.

Scroll down to the "Dataset Contents" section. Review the list of key fields, such as dish_name, ingredients, portion_size, and nutritional_profile. Notice how they break down a complex concept ("food") into structured, queryable attributes.

Inspired by these examples and based on our project's needs, here is a proposed first version of your image annotation schema:

{
  "image_id": "image_123.jpg",
  "is_usable": true, // Is the image clear and on-topic?
  "food_items_identified": ["rice", "dal", "potato_curry"], // Annotator identifies visible items

  "quantity_assessment": "sufficient", // "insufficient" | "sufficient" | "excessive"

  "variety_flags": {
    "has_grain_component": true,
    "has_pulse_component": true,
    "has_vegetable_component": true
  },

  "quality_flags": {
    "is_contaminated": false,
    "looks_burnt": false,
    "looks_watery": false,
    "has_discoloration": false
  },

  "annotator_notes": "Meal looks standard. No visible issues."
}

This schema is:

  • Structured: It groups related labels under logical headings.
  • Specific: It avoids vague terms in favor of concrete flags.
  • Multi-Label: It uses boolean flags under variety_flags and quality_flags to capture multiple attributes at once.
  • Pragmatic: It includes is_usable for initial data cleaning and annotator_notes to capture nuances that don't fit the structured fields.

The Missing Piece: Labeling Instructions

A schema is only as good as the consistency with which it's applied. Different people can interpret the same label differently. This is why a "label book" or a set of detailed labeling instructions is not optional—it's essential for creating high-quality data.

Data centric AI development From Big Data to Good Data Andrew Ng

Andrew Ng's talk provides excellent insights into why label consistency is so challenging and how to address it.

First, watch from this timestamp where he explains how even well-meaning annotators can be inconsistent. Then, watch the next segment from here where he introduces the concept of a "label book" to define what labels mean. Finally, watch the demo on agreement-based labeling from this timestamp. The key idea is not just to have multiple people vote, but to use their disagreements to find ambiguities in your instructions and fix them.

Your next task, which we will detail in a future lesson, is to write these instructions. For every single field in your schema, you need a clear definition and examples. For instance:

  • For quantity_assessment: "insufficient", you might write: "Flag as 'insufficient' if the total amount of food appears to be less than what would fill a child's cupped hands. For rice, this is less than a fist-sized serving."
  • For looks_watery: true, you might specify: "Flag as true only for dal or liquid curries. The liquid should be opaque. If you can see the pattern of the plate through the liquid, it is watery."

The Best Way to Annotate Images for Object Detection

The Roboflow video also emphasizes this critical point.

Watch this short clip from here on the importance of creating and sharing clear labeling instructions for reproducibility.


Conclusion

In this lesson, you have taken the first and most critical step in building the ground truth for your project. You've moved from high-level goals to a concrete, structured plan for annotating your image data.

Key Takeaways:

  • Adopt a Data-Centric Mindset: The quality of your dataset, especially your labels, is the most powerful lever you have for improving your model's real-world performance.
  • Deconstruct the Problem: Translate abstract goals like "quality" and "quantity" into specific, observable, and classifiable attributes.
  • Design a Structured Schema: Use a multi-label approach to capture the complexity of a meal. A format like JSON provides a clear, machine-readable structure.
  • Prioritize Specificity: Create granular labels for different types of violations. You can always combine them later, but splitting them requires re-labeling everything.
  • Recognize the Need for Guidelines: A schema is incomplete without a detailed set of labeling instructions to ensure every annotator applies the labels consistently.

You now have a solid blueprint for your image labels. In our next lesson, we will apply the same principles to your text data, designing an annotation schema to capture the type and severity of violations reported in parent complaints.