Dongyu Yao† Keling Yao† Junhong Zhou† Yinghao Zhang†
†: Equal contribution
Carnegie Mellon University
CaLoRAify is a novel project aimed at addressing the obesity epidemic (the "heavy" issue) by leveraging Vision-Language Models (VLMs), fine-tuning techniques, and Retrieval-Augmented Generation (RAG) methods to estimate meal calorie content. The system serves as a virtual dietitian, offering users calorie analyses and dietary recommendations based on meal photos.
- Ingredient Recognition: Analyze meal images to identify individual ingredients.
- Calorie Estimation: Use advanced models like MiniGPT-4 for accurate calorie computations.
- Retrieval-Augmented Generation (RAG): Enhance estimates with scientific nutritional data.
- Interactive Feedback: Support multi-turn dialogues for recalculating results based on user feedback.
- Real-World Adaptation: Address challenges in food presentation variability and ingredient complexity.
- Recipe1M+ Dataset: Base dataset for ingredient recognition.
- USDA Food Calorie Database: Reference for granular nutritional data.
Our self-constructed dataset store here.
- Fine-tuning MiniGPT-4, using LoRA and QLoRA methods.
The loss function combines cross-entropy and mean squared error (MSE):
Adjust weights
- Multi-task Learning: Train for ingredient classification and calorie estimation simultaneously.
- Evaluation Metrics:
- Precision and Recall for ingredient prediction.
- Mean Squared Error (MSE) for calorie estimates.
- Apply prompt engineering to minimize ambiguity in meal identification.
- Implement interactive recalculations for dynamic user interactions.
- NVIDIA GPU with at least 48 GB memory
- Python environment compatible with CUDA
-
Clone the repository:
git clone https://github.com/KennyYao2001/16824-CaLORAify.git cd 16824-CaLORAify
-
Create and activate the environment:
conda env create -f environment.yml
conda activate minigptv
- Download the pre-trained MiniGPT-4 weights:
- Configure model paths:
- Update the configuration file at eval_configs/minigptv2_eval.yaml with the path to downloaded weights.
Running the Demo
Launch the calorie estimation demo locally:
python demo_v2.py --cfg-path eval_configs/minigptv2_eval.yaml --gpu-id 0