This repository contains a Convolutional Neural Network (CNN) model for food classification using the Food101 dataset. The model leverages transfer learning with EfficientNetV2B0 as the base model. The goal of this project is to surpass the accuracy reported in the reference experiment paper.
- Introduction
- Dataset
- Model Architecture
- Training and Fine-Tuning
- Results
- Tools Used
- References
- Contributing
- License
- Fine-Tuned Model Access
- Loading Fine-Tuned Model
Food classification is a challenging task due to the large variety of food types and the visual similarity between certain classes. This project uses transfer learning with EfficientNetV2B0 to build a high-accuracy food classification model. The goal is to achieve and surpass the accuracy reported in the experiment paper link to paper.
The Food101 dataset consists of 101,000 images of food divided into 101 categories, with 750 training images and 250 test images per class. The dataset can be directly loaded from TensorFlow Datasets.
The base model used is EfficientNetV2B0, a state-of-the-art CNN architecture known for its efficiency and performance. The pre-trained weights on ImageNet are used for transfer learning. The model architecture is modified by adding a few fully connected layers on top of the base model for the food classification task.
1. Transfer Learning: The EfficientNetV2B0 base model is used with pre-trained weights, and only the top layers are trained initially.
2. Fine-Tuning: After achieving a satisfactory baseline accuracy, the entire model is fine-tuned by unfreezing the base model and training with a lower learning rate.
- Load the Food101 dataset.
- Preprocess the images and labels.
- Build the model using EfficientNetV2B0 as the base.
- Compile the model with appropriate loss function and optimizer.
- Train the top layers.
- Fine-tune the entire model.
- Evaluate the model on the test set.
The model achieved an accuracy of 81% on the Food101 dataset, surpassing the accuracy reported in the reference experiment paper.
- Google Colab
- TensorFlow
- NumPy
- Pandas
- Matplotlib
- EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks
- Food101 Dataset
- Experiment Paper
Contributions are welcome! Please submit a pull request or open an issue to discuss your ideas.
This project is licensed under the MIT License. See the LICENSE file for details.
The fine-tuned model weights can be accessed and downloaded from the following link:
To load the fine-tuned model in your Python code, you can use the tf.keras.models.load_model
function. First, make sure TensorFlow is installed:
pip install tensorflow
Then, use the following code snippet to load the model:
import tensorflow as tf
Replace 'path_to_your_model_weights' with the actual path where you saved the model weights model = tf.keras.models.load_model('path_to_your_model_weights')
Now you can use the model
object for inference on new images.