| --- |
| license: mit |
| tags: |
| - food-recognition |
| - computer-vision |
| - calorie-estimation |
| - efficientnet |
| - nutrition |
| - health |
| pipeline_tag: image-classification |
| --- |
| |
| # Food Recognition and Calorie Estimation Model |
|
|
| A comprehensive deep learning system for food recognition, object detection, and calorie estimation using TensorFlow, YOLO, and EfficientNet. |
|
|
| ## Model Description |
|
|
| This model combines multiple deep learning approaches to provide accurate food recognition and calorie estimation: |
|
|
| - **Food Classification**: EfficientNet-B0 based multi-label classifier for 101 food categories |
| - **Object Detection**: YOLO v8 for detecting multiple food items in images |
| - **Portion Size Estimation**: Computer vision techniques for size estimation |
| - **Calorie Calculation**: Integration with USDA nutritional database |
|
|
| ## Model Performance |
|
|
| | Metric | Value | |
| |--------|-------| |
| | Classification Accuracy | >85% | |
| | Object Detection mAP | >0.75 | |
| | Calorie Estimation Accuracy | ±20% | |
| | Inference Speed | <2 seconds/image | |
|
|
| ## Usage |
|
|
| ### Basic Usage |
|
|
| ```python |
| from transformers import pipeline |
| |
| # Load the model |
| classifier = pipeline("image-classification", model="BinhQuocNguyen/food-recognition-model") |
| |
| # Analyze a food image |
| result = classifier("path/to/food_image.jpg") |
| print(f"Detected foods: {result}") |
| ``` |
|
|
| ### Advanced Usage |
|
|
| ```python |
| import torch |
| from transformers import AutoModel, AutoImageProcessor |
| from PIL import Image |
| |
| # Load model and processor |
| model = AutoModel.from_pretrained("BinhQuocNguyen/food-recognition-model") |
| processor = AutoImageProcessor.from_pretrained("BinhQuocNguyen/food-recognition-model") |
| |
| # Process image |
| image = Image.open("food_image.jpg") |
| inputs = processor(images=image, return_tensors="pt") |
| |
| # Get predictions |
| with torch.no_grad(): |
| outputs = model(**inputs) |
| predictions = torch.nn.functional.softmax(outputs.logits, dim=-1) |
| ``` |
|
|
| ## Training Data |
|
|
| The model was trained on: |
| - **Food-101 Dataset**: 101,000 images across 101 food categories |
| - **Additional Datasets**: Food-11, Recipe1M+ (where available) |
| - **Data Augmentation**: Rotation, flip, brightness, contrast adjustments |
|
|
| ## Nutritional Database |
|
|
| The model includes nutritional information for 101 food categories with: |
| - Calories per 100g |
| - Protein, carbohydrate, and fat content |
| - Portion size estimation capabilities |
|
|
| ## Limitations |
|
|
| - Accuracy may vary with image quality and lighting conditions |
| - Calorie estimates are approximate and should not replace professional dietary advice |
| - Model performance depends on food items being within the trained categories |
| - Portion size estimation is based on visual cues and may not be accurate for all cases |
|
|
| ## Citation |
|
|
| ```bibtex |
| @misc{food-recognition-model, |
| title={Food Recognition and Calorie Estimation Model}, |
| author={BinhQuocNguyen}, |
| year={2024}, |
| publisher={Hugging Face}, |
| howpublished={\url{https://huggingface.co/BinhQuocNguyen/food-recognition-model}} |
| } |
| ``` |
|
|
| ## License |
|
|
| This model is licensed under the MIT License. |
|
|
| ## Contact |
|
|
| For questions or issues, please contact: |
| - GitHub: [Food Recognition Repository](https://github.com/BinhQuocNguyen/food-recognition-model) |
|
|
| ## Acknowledgments |
|
|
| - Food-101 dataset creators |
| - TensorFlow team |
| - Hugging Face team |
| - USDA Food Database |
| - OpenCV community |
|
|