Food Recognition Model (UECFOOD256)
This model is a deep learning classifier capable of recognizing 256 different types of food. It was trained using TensorFlow/Keras on the UECFOOD256 dataset.
Model Details
- Model Architecture: [INSERT BASE MODEL HERE, e.g., MobileNetV2 / EfficientNetB0] (Fine-tuned)
- Dataset: UECFOOD256 (256 food categories)
- Framework: TensorFlow / Keras
- Task: Image Classification (Multi-class)
Intended Use
This model is designed to take an image of food as input and output the specific food category name. It is useful for:
- Calorie tracking apps
- Dietary monitoring
- Food logging automation
How to Use
You can load this model directly in Python using the huggingface_hub library.
Important: This model requires a class_names.txt file (included in the repo) to map the model's integer predictions back to readable food names.
Inference Code
import numpy as np
from huggingface_hub import from_pretrained_keras, hf_hub_download
from keras.preprocessing import image
import tensorflow as tf
# 1. Define the Repo ID
repo_id = "Hiratax/food-recognition-model"
# 2. Load the Model
print("Loading model...")
model = from_pretrained_keras(repo_id)
# 3. Load the Class Names Mapping
class_names_path = hf_hub_download(repo_id=repo_id, filename="class_names.txt")
with open(class_names_path, 'r') as f:
class_names = [line.strip() for line in f.readlines()]
# 4. Prediction Function
def predict_food(img_path):
# Resize image to 224x224 (Standard for this model)
img = image.load_img(img_path, target_size=(224, 224))
img_array = image.img_to_array(img)
img_batch = np.expand_dims(img_array, axis=0)
# Predict
predictions = model.predict(img_batch)
predicted_index = np.argmax(predictions[0])
confidence = np.max(predictions[0])
return class_names[predicted_index], confidence
# 5. Run on an image
# food, conf = predict_food("my_sushi.jpg")
# print(f"Prediction: {food} ({conf:.2f})")
- Downloads last month
- 25