Food Recognition

The /vision/ endpoint is used to detect food items in images. To analyze your images post them to the API using JSON with source_url, base64 or id keys, or as a multi-part form with a file name file.

idid of a previously posted image
source_urlurl of an image that should be downloaded
base64base64 encoded image bytes
fileimage file passed using multi part form
curl -X POST \
https://api-beta.bite.ai/vision/ \
-H 'content-type: multipart/form-data' \
-F file=@/home/user/pictures/sandwich.JPG
biteai.recognize(path='/home/user/pictures/sandwich.JPG')

The response includes a ranked list of most likely recognized items and their scores.

{
"id": "0299622f-b708-4ccd-91ed-3272c42bb34c",
"image": "6e17eb33-1e50-456c-8184-111e89c4e19d",
"model": "698ce742-7a49-472c-b00d-eb9b54c9a8fb",
"items": [
{
"score": 0.16014,
"item": {
"id": "9ab62c33-9b8c-4e02-83d2-ecbb16fa115e",
"name": "Sandwich",
"details": null,
"description": null,
"brand": null,
"type": null,
"text_ingredients": null,
"ingredients": [],
"parents": [],
"children": [
{
"id": "3a17acfc-d346-4d31-8eae-da4b9500f4e6",
"name": "Bacon Egg And Cheese Sandwich",
"brand": null,
"details": null,
"categorizations": {},
"is_generic": true
},
{
"id": "505e8a36-b2d2-430f-a47a-3a47b2b34cef",
"name": "Club Sandwich",
"brand": null,
"details": null,
"categorizations": {},
"is_generic": true
}
],
"nutrition_facts": [],
"is_generic": true,
"categorizations": {}
}
}
]
}

Image Size Impacts Latency

The size of the image has a large impact on the latency of the request. It's usually best to resize the image before sending it to the API, especially on mobile networks.

Contextual Recognition with Food Logging API

If your app contains users and you are posting multiple images per user then the meal logging endpoint will probably give you more accurate results since it uses context to improve the recognition suggestions and can recognize previously logged meals.