This repository contains code for training a Convolutional Neural Network (CNN) food classifier using Python. The classifier is trained using images from the Food-5K dataset and utilizes the VGG16 pre-trained network for feature extraction.
- Python 3.x
- TensorFlow
- scikit-learn
- NumPy
- imutils
train.py
: Script for training the logistic regression model using extracted features.build_dataset.py
: Script for organizing the dataset into training, testing, and validation splits.extract_features.py
: Script for extracting features from images using VGG16 and preparing data for training.config.py
: Configuration file containing paths and constants used throughout the project.
- Build Dataset: Run
build_dataset.py
to organize the dataset into the desired splits (training, testing, and validation).
python build_dataset.py
- Extract Features: Run
extract_features.py
to extract features from images using VGG16 and save them in CSV format along with labels.
python extract_features.py
- Train Model: Finally, run
train.py
to train the logistic regression model using the extracted features.
python train.py
config.py
contains paths and constants used in the project. Adjust these paths if necessary.
- Trained model will be saved as
model.cpickle
. - Label encoder will be saved as
le.cpickle
. - Extracted features will be saved as CSV files in the
output
directory.
- Ensure that the Food-5K dataset is downloaded and placed in the appropriate directory (
Food-5K
by default). - Modify the
config.py
file according to your dataset directory structure if different from the default. - Additional configuration options such as batch size can be adjusted in
config.py
.
This project utilizes the Food-5K dataset and the VGG16 pre-trained network. Credits to the authors of these resources.
This project is licensed under the MIT License - see the LICENSE file for details.