dschandra commited on
Commit
0ddbca6
·
verified ·
1 Parent(s): 9de87c3

Create food_identification.py

Browse files
Files changed (1) hide show
  1. food_identification.py +12 -0
food_identification.py ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+
3
+ def identify_food(image):
4
+ """
5
+ Identify food items in the image using a pretrained model.
6
+ """
7
+ food_recognizer = pipeline("image-classification", model="nateraw/food-recognition")
8
+ predictions = food_recognizer(image)
9
+
10
+ # Extract top predictions
11
+ food_items = [pred["label"] for pred in predictions[:5]]
12
+ return food_items