Nutrition Facts label OCR

This article walks you through the building process of an OCR API that extracts data from Nutrition Facts labels using our deep learning engine. It will work for any food brand or label template.

Prerequisites

  1. You’ll need a free account. Sign up and confirm your email to login.
  2. You’ll need at least 20 nutrition facts labels or pdfs to train your OCR.

Define your Nutrition fact label use case

First, we’re going to define what fields we want to extract from your *Nutrition fact label.

Nutrition facts label key data extractionNutrition facts label key data extraction

Nutrition facts label key data extraction

  • Serving size: 170 gram
  • Total fat gram: 2 gram
  • Total fat daily value : 3%
  • Calories per serving: 150

That’s it for our use case. Remember this is an example feel free to add any other relevant data to fit your requirements.

Deploy your API

Once you have defined the list of fields you want to extract, head over to the platform and press the ‘Create a new API’ button.

You land now on the setup page. Here is the image you can use to set up the API. For instance, my setup is as follows:
Set up your modelSet up your model

Set up your model

Once you’re ready, click on the “next” button. We are going to specify the data types for each of the fields we want our API to extract.

Define your modelDefine your model

Define your model

To move forward, you have two possibilities:

Upload a json config
Copy the following JSON into a file and upload it on the interface

{
  "problem_type": {
    "classificator": { "features": [], "features_name": [] },
    "selector": {
      "features": [
        {
          "cfg": { "filter": { "is_integer": 1 } },
          "handwritten": false,
          "name": "serving_size",
          "public_name": "Serving size",
          "semantics": "amount"
        },
        {
          "cfg": { "filter": { "is_integer": -1 } },
          "handwritten": false,
          "name": "total_fat_gram",
          "public_name": "Total fat gram",
          "semantics": "amount"
        },
        {
          "cfg": { "filter": { "alpha": 0, "numeric": -1 } },
          "handwritten": false,
          "name": "total_fat_daily_value",
          "public_name": "Total fat daily value",
          "semantics": "word"
        },
        {
          "cfg": { "filter": { "is_integer": 1 } },
          "handwritten": false,
          "name": "calories_per_serving",
          "public_name": "Calories per serving",
          "semantics": "amount"
        }
      ],
      "features_name": [
        "serving_size",
        "total_fat_gram",
        "total_fat_daily_value",
        "calories_per_serving"
      ]
    }
  }
}

Or build your data model manually
Using the interface, add up to your data model each field.

In our example, here are the different field configurations we used:

  • Serving size: type Integer
  • Total fat gram: type Number
  • Total fat daily value: type String that never contains alpha characters
  • Calories per serving: type Integer

Once you’re done setting up your data model, press the Start training your model button at the bottom of the screen.

Ready to train modelReady to train model

Ready to train model

Train your Nutrition facts labels OCR

Train your modelTrain your model

Train your model

You’re all set!

Now is the time to train your nutrition facts to train deep learning model in the Training section of our API.

After 20 annotated data, your first model is trained and you're now able to use your custom OCR API for parsing nutrition facts labels in your application.

To get more information about the training phase, please refer to the Getting Started tutorial. If you have any question regarding your use case, feel free to reach out on our chat!

Updated 4 months ago


Nutrition Facts label OCR


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.