This is a submission for the Open Source AI Challenge with pgai and Ollama
What I Built
NutritionAI is an AI-powered application that helps users track their dietary habits by allowing them to upload images of their meals. The app analyzes these images to provide detailed nutritional insights and personalized recommendations based on individual dietary goals and preferences.
How it Works
- Diet Preferences: Users first input their dietary goals and health needs, which are sent to the backend. This data is embedded using the Mistral model and stored in a pgvector database.
This is the schema for the user's diet preferences
CREATE TABLE users (
id SERIAL PRIMARY KEY,
age INT NOT NULL,
height FLOAT NOT NULL,
weight FLOAT NOT NULL,
caloric_target INT NOT NULL,
protein_target INT NOT NULL,
dietary_preferences TEXT[],
complications TEXT[],
embedding VECTOR
);
Meal Upload & Image Analysis: Once on the main page, users can upload a meal image. The backend processes the image and sends it to the Llava model, which identifies food items and dishes.
Nutritional Analysis: The identified food items are passed to the Mistral model to generate nutritional information. These stats are embedded as vectors, saved in the database for future use.
This schema represents the food items.
CREATE TABLE food_items (
id SERIAL PRIMARY KEY,
name VARCHAR(255) NOT NULL,
embedding VECTOR,
nutrition_info JSONB
);
Similarity Check: The new meal vector is compared with the user's dietary preferences using cosine similarity (via pgai) to evaluate alignment with the user's goals.
Personalized Recommendations: Based on similarity scores, NutritionAI analyzes the nutritional data and suggests diet adjustments that best meet the user's preferences and health objectives.
Architecture
Demo
Here's the link to the working project
nutrition-ai-bay
Disclaimer: The generation of nutritional stats and personalized recommendations may take around 5-10 minutes, as the Node.js application is hosted on an Amazon EC2 t2.large instance.
Source code:
Ritesh2351235 / nutrition-ai
NutritionAI is an AI-driven application that allows users to upload meal images for nutritional analysis. It provides personalized dietary recommendations based on user profiles and food item embeddings.
NutritionAI
This is a submission for the Open Source AI Challenge with pgai and Ollama
NutritionAI is an innovative application designed to help users achieve their dietary goals by providing personalized nutritional insights. By allowing users to upload pictures of their daily meals, the app analyzes the nutritional content and offers tailored recommendations based on individual dietary needs.
NutritionAI simplifies the journey to healthier eating by enabling users to sign up easily, upload meal images, and receive detailed nutritional statistics that align with their diet goals.
Key Features
- Sign Up Form: Create a personalized account to track your dietary journey.
- Meal Upload: Easily upload pictures of your meals for analysis.
- Nutritional Insights: Receive detailed nutritional information for each meal.
- Personalized Recommendations: Get tailored dietary suggestions based on your profile and preferences.
- Daily Tracking: Track your nutritional intake and progress towards goals.
- Health Considerations: Recommendations…
Screenshots
Diet Preferences Page
Tools Used
- React: Framework for building dynamic user interfaces.
- Tailwind CSS: Utility-first CSS framework for styling.
- Node.js: JavaScript runtime for backend development.
- Express: Framework for handling API requests and routing.
- Multer: Middleware for processing file uploads.
-
Ollama Models:
- Llava Model: Analyzes meal images to identify dishes.
- Mistral Model: Generates nutritional content and embeddings.
- TimescaleDB (PostgreSQL): Database for storing user and nutritional data.
- pgvector: Utilized for storing and querying vector embeddings of user profiles and food items, enhancing the accuracy of recommendations.
- pgai: Integrated to leverage AI capabilities for generating insightful nutritional content and recommendations based on user data.
- Amazon EC2 (Ubuntu t2.large): Hosts the Node.js application.
- Vercel: Deploys the frontend application efficiently.
Final Thoughts
Building NutritionAI has been an exciting project(PS: Took me 5 whole days to build this), especially with the challenges of implementing real-time image analysis and generating personalized nutritional recommendations through advanced AI models. With Ollama’s models and PostgreSQL extensions, I was able to create an engaging, user-friendly experience that brings detailed nutritional insights to users' fingertips.
In the future, I plan to enhance NutritionAI with additional features, such as a personalized fitness plan that aligns with users' dietary habits, and tailored meal planning suggestions. Improvements could also include faster processing times and even more advanced dietary analytics.
Prize categories:
Open Souce Models from Ollama
All the extensions.
Top comments (10)
Great work !
You deserve a lot of praise for your efforts.
This is an excellent initiative—truly something unique! I'm excited to give it a try.
Quite an incredible job!! Quite impressed about the short time taken to implement such complex code!! Also a very much needed product !!
Great job on NutritionAI! Quite a nice work on making nutrition tracking easy!!!
Wow, Ritesh, this is incredible! NutritionAI sounds like a game-changer for anyone looking to make smarter food choices. I love how it brings the power of AI to personal nutrition, making it easier to understand and apply good habits in everyday life. Looking forward to seeing how this develops and helps people build healthier lifestyles—keep up the amazing work
Impressive work! Developing an app for smart eating habits is so relevant today – making healthy choices easier is something many people need. I’m actually working on a similar concept for my college project, and I’d love to collaborate with you on building this further!
This is such an amazing tool, can’t wait to try it! This would help so many people to understand their diet better!
Well done!! 👏
Superb concept! Its a Much needed initiative. Great job on making diet tracking easier.