Internship Report
On
AI POWERED NUTRITION ANALYSIS FOR FITNESS-
PYTHON ML
In
Altruist Technologies
From 21/10/2024 to 21/12/2024
Submitted by
DHANUSH KUMAR R
i
CERTIFICATE
This is to certify that Dhanush kumar R has successfully completed a 2-month
internship at Altruist Technologies, from 21th October 2024 to 21st December 2024,
in the domain of Artificial Intelligence and Machine Learning (AI & ML).
During the internship, Dhanush kumar R worked on the project titled “AI POWERED
NUTRITION ANALYSIS FOR FITNESS-PYTHON ML” under the AI & ML
Development team.
Charan has demonstrated exceptional growth and development, gaining valuable
experience and insights into the field of AI and ML. Their commitment to learning
and adapting to challenges reflects Altruist Technologies’ core values of excellence
and innovation.
We acknowledge Dhanush Kumar R's outstanding performance and dedication
throughout the internship tenure.
Signature of the Guide
ii
ACKNOWLEDGEMENT
I am sincerely grateful to Altruist Technologies, Chennai, for providing me with the
opportunity to undertake this project and for extending their guidance and support
throughout its course.
First and foremost, I would like to express my deepest gratitude to M. Siva Venkata
Satya Narayana, for their valuable insights, constant encouragement, and constructive
feedback, which greatly contributed to the successful completion of this project.
I also extend my thanks to the entire team at Altruist Technologies for their
collaboration and willingness to share knowledge, creating a positive and supportive
environment that enriched my learning experience.
Finally, I would like to thank my family and friends for their constant motivation and
encouragement throughout this journey.
This project has been a tremendous learning experience, and I am confident that the
skills and knowledge I have gained during this period will contribute significantly to
my professional growth.
iii
TABLE OF CONTENTS
CHAPTER NO. TITLE PAGE NO.
ABSTRACT v
LIST OF FIGURES vi
LIST OF ABBREVIATIONS vii
1. INTRODUCTION 1
1.1 INTRODUCTION 1
1.2 OBJECTIVE 1
1.3 EXISTING SYSTEM 2
1.4 PROPOSED SYSTEM 2
2. REQUIREMENT SPECIFICATION 3
2.1 FUNCTIONAL REQUIREMENTS 3
2.2 NON-FUNCTIONAL REQUIREMENTS 3
3. DESIGN 4
3.1 ARCHITECTURE DIAGRAM 4
3.2 SEQUENCE DIAGRAM 4
4. IMPLEMENTATION 5
4.1 SDXL 1.0 5
4.2 PIL PACKAGE 5
4.3 ENVIRONMENT SETUP 6
4.3.1 Google Colab Setup 6
4.3.2 Hugging Face Transformers 6
4.3.3 PIL Installation 6
4.4 CODING 7
5. TESTING 9
6. OUTPUT SCREENSHOTS 10
7. CONCLUSION 12
8. FUTURE WORK 13
REFERENCES 14
iv
ABSTRACT
In recent years, there has been a growing interest in leveraging artificial intelligence (AI)
and machine learning (ML) to enhance health and fitness outcomes. This project aims to
develop an AI-powered nutrition analysis system using Python, designed to assist
individuals in optimizing their dietary intake for fitness and health goals. The system
employs machine learning algorithms to analyze nutritional data, providing personalized
recommendations based on user-specific parameters such as age, gender, weight, height,
activity level, and fitness objectives. The core components of the system include data
collection, preprocessing, feature extraction, model training, and recommendation
generation. Data is sourced from extensive nutritional databases and user inputs, ensuring a
comprehensive understanding of dietary habits. Preprocessing involves cleaning and
normalizing the data to facilitate accurate analysis. Feature extraction focuses on identifying
key nutritional metrics relevant to fitness outcomes, such as macronutrient distribution.
v
LIST OF FIGURES
Figure No Figure Name Page No.
3.1 Architecture Diagram 4
3.2 Sequence Diagram 4
vi
LIST OF ABBREVIATIONS
ABBREVIATION ACCRONYM
AI Artificial Intelligence
NLP Natural Language Processing
API Application Program Interface
ML Machine Learning
vii
CHAPTER 1
1.1 INTRODUCTION
The integration of artificial intelligence (AI) into the fitness industry,
particularly through AI-powered nutrition analysis, has revolutionized personalized
dietary recommendations, helping individuals optimize performance, recovery, and
overall health. Leveraging machine learning (ML), a subset of AI, these systems
analyze vast datasets to identify patterns in food consumption, nutritional values, and
dietary habits, enabling precise predictions of individual nutritional needs based on
factors like age, weight, activity level, and goals. Python, with its rich ecosystem of
libraries such as TensorFlow, Keras, and Scikit-learn, plays a pivotal role in
developing these ML models, which undergo processes like data collection,
preprocessing, and training to deliver tailored meal plans and nutritional advice.
These AI-driven systems dynamically adapt to users' evolving needs, providing data-
driven insights and personalized guidance that enhance long-term adherence and
success, marking a new era of precision in fitness and health optimization.
1.2 OBJECTIVE
The Aim Of The "Ai-powered Nutrition Analysis For Fitness" Project Is To
Leverage Machine Learning Techniques To Develop A Personalized Nutrition
Assessment Tool That Aids Fitness Enthusiasts In Optimizing Their Dietary
Intake. This Project Seeks To Create An Intelligent System Capable Of Analyzing
Individual Dietary Habits And Fitness Goals, Offering Tailored Nutrition Advice
To Enhance Performance, Recovery, And Overall Health.
1
1.3 EXISTING SYSTEM
The existing systems for nutrition analysis primarily rely on manual input and
generalized dietary guidelines, such as calorie calculators, food tracking apps, and
predefined meal plans. While these tools provide basic insights, they often lack
personalization and fail to adapt dynamically to individual goals or changes in
lifestyle. Most existing solutions depend on static databases and user-driven
logging, which can be tedious and prone to inaccuracies. Moreover, they typically
offer one-size-fits-all advice, overlooking unique nutritional requirements based
on specific health conditions, fitness levels, and dietary preferences. This gap
underscores the need for more sophisticated, AI-powered solutions to deliver
precise, adaptive, and user-centered nutrition analysis.
1.4 PROPOSED SYSTEM
The proposed system leverages AI and machine learning to deliver a dynamic,
personalized nutrition analysis tailored to individual fitness goals, health
conditions, and dietary preferences. By utilizing large datasets and advanced ML
algorithms, it predicts nutritional needs with high accuracy, automates meal
planning, and adapts recommendations in real-time as users’ goals or conditions
change. Built with Python and its robust libraries like TensorFlow and Scikit-learn,
the system integrates user data from various sources, such as fitness trackers and
food databases, ensuring precise and adaptive guidance. This AI-driven approach
enhances user engagement, simplifies dietary management, and optimizes health
outcomes effectively.
2
CHAPTER 2
REQUIREMENTS SPECIFICATION
2.1. FUNCTIONAL REQUIREMENTS
The functional requirements of The AI-powered nutrition analysis system will
allow users to create and manage personalized profiles by inputting details such as age, weight,
activity level, fitness goals, and dietary preferences. It will integrate data from external sources
like food databases and fitness trackers while also enabling manual logging of meals and
activities. The system will analyze nutritional intake, calculate caloric needs, and use machine
learning models to provide personalized meal plans and dietary recommendations. It will
dynamically adapt these suggestions based on users’ progress, goals, and changing lifestyle
factors, ensuring continuous optimization and effective dietary management.
2.2. NON - FUNCTIONAL REQUIREMENTS
The AI-powered nutrition analysis system will prioritize performance by
delivering recommendations within 2 seconds and handling large datasets
efficiently. It will be scalable to accommodate a growing user base and integrate
additional data sources seamlessly. Usability will be ensured through an intuitive
interface and clear visualizations, while 99.9% uptime and robust failover
mechanisms will guarantee availability. Security measures, including encryption
and compliance with privacy standards like GDPR and HIPAA, will safeguard
sensitive user data. The system will be maintainable with modular, well-
documented code and regular updates to ML models. Additionally, it will support
compatibility across web, iOS, and Android platforms.
3
CHAPTER 3
DESIGN
3.1 ARCHITECTURE DIAGRAM:
Fig 3.1 Architecture Diagram
4
3.2 SEQUENCE DIAGRAM:
Fig 3.2 Sequence Diagram
5
CHAPTER 4
CODING
4.1 Stable Diffusion XL 1.0 (SDXL 1.0) Model:
Stability AI's Stable Diffusion XL 1.0 (SDXL 1.0) foundation model is a
powerful text-to-image generative model. It is currently considered to be the most
advanced model in Stability AI's Stable Diffusion suite. Some of the key points are:
• Generates high-quality images in various art styles, excelling at photorealism.
• Requires minimal text prompts to create complex, detailed, and aesthetically
pleasing images.
• Tuned for vibrant and accurate colors, with improved contrast, lighting, and
shadows compared to its predecessor SDXL 0.8
• Generates images in a native resolution of 1024x1024
4.2 PIL Package:
PIL, or the Python Imaging Library, is a powerful library for working with
images in Python. It provides extensive capabilities for image manipulation,
processing, and annotation. One notable feature is its ability to annotate images,
allowing users to add text, shapes, and other elements to images programmatically.
Another useful functionality of PIL is its ability to compile images into a PDF
document. This feature allows users to easily create PDF documents containing
multiple images, which can be useful for tasks such as creating image-based reports or
presentations.
Overall, PIL is a versatile tool for working with images in Python, offering a
wide range of capabilities for both image manipulation and document creation.
6
4.3 ENVIRONMENT SETUP:
4.3.1. Google Colab Setup
Google Colab provides a free cloud-based platform with GPU
support that is ideal for running machine learning experiments. This allows us to
run our code with all the necessary resources.
4.3.2. Hugging Face Transformers
Hugging Face Transformers is an open-source library that provides
easy-to-use interfaces to work with pre-trained language models.
• Installing the transformers library: !pip install transformers
4.3.3. PIL Setup
PIL, or the Python Imaging Library, is a powerful library for
working with images in Python.
• Installing the PIL package: !pip install PIL
7
4.3.4 CODING:
import streamlit as st
import requests
from PIL import Image
from keras_preprocessing.image import img_to_array
import numpy as np
from [Link] import load_model
# Load the model
model = load_model('FV.h5')
# Define labels
labels = {0: 'apple', 1: 'banana', 2: 'beetroot', 3: 'bell pepper', 4: 'cabbage', 5: 'capsicum', 6: 'carrot',
7: 'cauliflower', 8: 'chilli pepper', 9: 'corn', 10: 'cucumber', 11: 'eggplant', 12: 'garlic', 13:
'ginger',
14: 'grapes', 15: 'jalepeno', 16: 'kiwi', 17: 'lemon', 18: 'lettuce',
19: 'mango', 20: 'onion', 21: 'orange', 22: 'paprika', 23: 'pear', 24: 'peas', 25: 'pineapple',
26: 'pomegranate', 27: 'potato', 28: 'raddish', 29: 'soy beans', 30: 'spinach', 31: 'sweetcorn',
32: 'sweetpotato', 33: 'tomato', 34: 'turnip', 35: 'watermelon'}
vegetables = ['Beetroot', 'Cabbage', 'Capsicum', 'Carrot', 'Cauliflower', 'Corn', 'Cucumber', 'Eggplant',
'Ginger',
'Lettuce', 'Onion', 'Peas', 'Potato', 'Raddish', 'Soy Beans', 'Spinach', 'Sweetcorn',
'Sweetpotato',
'Tomato', 'Turnip']
nutritious_alternatives = {
'apple': 'banana',
'banana': 'mango',
'carrot': 'sweetpotato',
'lettuce': 'spinach',
'cucumber': 'tomato',
'bell pepper': 'paprika',
'grapes': 'pomegranate'
}
API_KEY = 'FgafNBR8VPucQBKyp3xbJqLLbrXLAaMd6ZvKV9yL'
def fetch_nutrition(prediction):
try:
url = f'[Link]
response = [Link](url)
8
data = [Link]()
if 'foods' in data and len(data['foods']) > 0:
food = data['foods'][0]
calories = [Link]('foodNutrients', [])[3]['value']
nutrition_info = {
'Calories': calories,
'Protein': [Link]('foodNutrients', [])[0]['value'],
'Fat': [Link]('foodNutrients', [])[1]['value'],
'Carbohydrate': [Link]('foodNutrients', [])[2]['value']
}
return calories, nutrition_info
else:
return None, {}
except Exception as e:
print("Can't fetch the nutrition information")
print(e)
return None, {}
def processed_img(uploaded_file):
img = [Link](uploaded_file).resize((224, 224))
img = img_to_array(img)
img = img / 255.0
img = np.expand_dims(img, axis=0)
answer = [Link](img)
y_class = [Link](axis=-1)[0]
res = labels[y_class]
return [Link]()
def check_nutrition(nutrition_info):
nutrition_thresholds = {
'Calories': 50,
'Protein': 1.0,
'Fat': 0.5,
'Carbohydrate': 10.0
}
for key, threshold in nutrition_thresholds.items():
if key in nutrition_info:
if nutrition_info[key] < threshold:
return False
return True
9
def main():
[Link]("Fruit and Vegetable Classifier and Nutrition Checker")
uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
if uploaded_file is not None:
img = [Link](uploaded_file)
[Link](img, caption='Uploaded Image.', use_column_width=True)
[Link]("")
[Link]("Classifying...")
result = processed_img(uploaded_file)
[Link](f"Predicted: {result}")
if [Link]() in [[Link]() for v in vegetables]:
[Link]('Category: Vegetables')
else:
[Link]('Category: Fruit')
calories, nutrition_info = fetch_nutrition(result)
if calories:
[Link](f'Calories: {calories} kcal (100 grams)')
if nutrition_info:
for key, value in nutrition_info.items():
[Link](f'{key}: {value} g')
if not check_nutrition(nutrition_info):
if [Link]() in nutritious_alternatives:
alternative = nutritious_alternatives[[Link]()]
[Link](f'The {result} is low in nutritional value. Consider eating {[Link]()}
for better nutrition.')
if __name__ == "__main__":
main()
10
CHAPTER 5
TESTING
In the testing phase of the project, rigorous evaluations were conducted to assess
the system’s performance across a variety of user scenarios, including different fitness
goals, dietary preferences, and health conditions. The primary objective was to ensure
the system delivered accurate, personalized, and actionable nutritional
recommendations while maintaining usability and adaptability.
To achieve this, several key metrics were considered:
Prediction Accuracy: The machine learning models were tested to ensure accurate
calorie, macronutrient, and micronutrient predictions based on user inputs and fitness
goals.
Personalization Effectiveness: The system's ability to generate tailored meal plans
and dietary advice was evaluated for different user profiles, such as weight loss, muscle
gain, and special dietary needs (e.g., vegan, diabetic).
Data Processing Efficiency: The speed and efficiency of the data preprocessing
pipeline were assessed to ensure smooth handling of large datasets without delays.
User Experience: The user interface was tested for ease of navigation, clarity of
recommendations, and responsiveness across platforms (web, iOS, Android).
System Adaptability: The system’s ability to dynamically adjust recommendations
based on updated user data (e.g., progress logs, changing fitness goals) was thoroughly
tested. Integration Accuracy: The integration with external APIs (e.g., food databases,
fitness trackers) was verified to ensure accurate and seamless data retrieval
11
CHAPTER 6
OUTPUT SCREENSHOTS
12
13
CHAPTER 7
CONCLUSION
The AI-powered nutrition analysis system represents a significant advancement
in the intersection of technology and health, delivering tailored dietary
recommendations to meet the diverse needs of users. By utilizing machine learning and
Python's powerful libraries, the system offers accurate and adaptive insights, enabling
users to achieve their fitness goals more effectively. Its integration with external APIs
and databases enhances the depth of nutritional analysis, while its user-friendly
interface ensures accessibility for individuals with varying technical skills and dietary
needs.
Through Extensive testing has demonstrated the system's ability to provide
precise nutritional predictions, dynamic meal plans, and seamless user experiences.
The system adapts in real-time to changes in user data, such as progress logs or shifting
goals, ensuring continuous relevance and engagement. Its robust architecture and
adherence to security and privacy standards further establish its reliability and
suitability for widespread use in the fitness and health industry. This project
underscores the transformative potential of AI in empowering individuals to take
control of their health and fitness journeys. By delivering actionable insights and
simplifying complex nutritional planning, the system bridges the gap between
technology and personalized healthcare, paving the way for smarter, more efficient
solutions in the evolving landscape of health and wellness.
14
CHAPTER 8
FUTURE WORK
The project has laid In the future, the AI-powered nutrition analysis system can
be enhanced by incorporating more advanced machine learning models, such as deep
learning techniques, to improve the precision and adaptability of its predictions.
Integrating natural language processing (NLP) could allow users to interact with the
system more intuitively, enabling voice or text-based queries for meal recommendations
and nutritional advice.
Expanding the database to include region-specific foods and cultural dietary
practices will further increase the system's global applicability, making it more inclusive
and relevant for diverse user groups. Another area of future work involves integrating
wearable devices and IoT sensors to provide real-time health metrics, such as blood
glucose levels, hydration status, and metabolic rates. This would allow the system to
deliver highly personalized and dynamic recommendations based on immediate
physiological data.
Additionally, the system can explore gamification strategies, such as rewards for
meeting fitness milestones, to enhance user engagement and motivation. Finally, the
system could evolve into a holistic health management platform by incorporating
features such as mental health assessments, sleep tracking, and stress management.
Collaborations with healthcare providers could enable the system to support medical
nutrition therapy, catering to users with chronic conditions such as diabetes or heart
disease. By continually evolving and embracing multidisciplinary innovations, the
system can establish itself as a comprehensive tool for health and wellness in the AI-
driven future.
15
REFERENCES
1. PIL Docs:
[Link]
2. Stable Diffusion Model:
[Link]
diffusion-xl-base-1.0
3. Google Colab:
[Link]
kevdp/PythonDataScienceHandbook/blob/
master/notebooks/01.01-Help-And-
[Link]
16