Instructions for Running the Code for Eatalyze: Using Machine Learning to Classify and Analyze Food Nutrition
Eatalyze is a machine learning project that classifies foods and analyzes their nutritional properties using traditional machine learning models and deep learning techniques. It includes:
- Nutritional analysis using Linear Regression and XGBoost
- A custom-trained image classifier using the Food-101 dataset
- A live webcam-based food classifier that predicts food categories in real time
-
pip install numpy -
pip install pandas -
pip install matplotlib -
pip install scikit-learn -
pip install statsmodels -
pip install xgboost
Ensure the food.xlsx data is installed and in the same folder as your jupyter notebooks for this line to run
food = pd.read_excel("food.xlsx", sheet_name="food"). From there, just run all cells and the graphs and tables should appear!
Below are instructions to run the training script, which will train the model and save the parameters to a file on your computer. This section will guide you on how to download the food-101 images and install the required packages.
-
pip install numpy -
pip install pandas -
pip install matplotlib -
pip install scikit-learn -
pip install tensorflow
import kagglehub
path = kagglehub.dataset_download("kmader/food41")
print("Path to dataset files:", path)
- Update the dataset path in the program to the path on your specific computer
- Run this updated script and ensure that the Epochs are incrementing
- Watch grass grow : )
The ML_Image_Classifier.py script opens a new window and uses the computer camera to classify objects in front of it. This uses the model that was previously trained with ML_Custom_Classifier.py. This will also require a few packages to run.
-
pip install numpy -
pip install pandas -
pip install matplotlib -
pip install scikit-learn -
pip install tensorflow -
pip install opencv-python
model = tf.keras.models.load_model("food_cnn_model_custom.h5")
- A new window will open using the built-in laptop camera
- When the desired food is within this frame, press the "s" key to capture an image
- This image will then be passed through the classifier to predict the image's label
- The resulting prediction will output to the terminal with an associated confidence level
- Press the "q" key to quit the program and exit