You can try this app on Streamlit:
Nutrients Tracker
This Streamlit web app assists you in tracking your nutrient intake by leveraging Google's GenerativeAI service (Gemini Pro Vision) to analyze images and estimate calorie counts.
- Image Upload: Upload a photo of your food for analysis.
- Text Prompt: Provide additional context (optional).
- Calorie Estimation: Get an estimated breakdown of calories in the image.
- Python 3.x
- Streamlit (
pip install streamlit
) dotenv
library (pip install python-dotenv
)- Google Cloud Project with GenerativeAI API enabled (GenerativeAI)
- Create a virtual environment (recommended):
python -m venv venv
orconda create -p venv python==3.x -y
- Activate the environment:
source venv/bin/activate
(Windows:venv\Scripts\activate
) or 'conda activate venv' - Install dependencies:
pip install streamlit python-dotenv
- Create a
.env
file in the project directory:- Add
GOOGLE_API_KEY=<YOUR_API_KEY>
(replace with your GenerativeAI API key)
- Add
- Open a terminal in the project directory.
- Run the app:
streamlit run app.py
- Access the app in your web browser at http://localhost:8501.
- Upload an image of your food.
- (Optional) Provide a text prompt for additional information.
- Click the "Tell me the total calories" button.
The app will display the estimated calorie breakdown from the image analysis using Google GenerativeAI.
- The user uploads the picture of his food and ask a question, "Is this food healthy?":
- When the prompt is passed, the system replies:
Why not try with your food?
This is a basic example using a free-tier API. Calorie estimates may not be perfectly accurate. Consider using a reliable nutrition database for detailed information.
- You can explore advanced Streamlit features for layout customization and interactivity.
- Integrate error handling and user feedback mechanisms for a more robust experience.
- Be mindful of API usage limits and potential costs when employing cloud services.
This application and its output are for informational purposes only and should not be taken as medical advice. Always consult a licensed healthcare professional for personalized guidance on nutrition and calorie intake.