This repository contains a machine learning model for multi-class bird species classification. The model is implemented in a Jupyter Notebook, and it utilizes various deep learning techniques to train and evaluate the model's performance.
- Introduction
- Getting Started
- Dataset
- Preprocessing
- Model Training
- Evaluation
- Model Improvement
- Saving the Models
- Additional Resources
The goal of this project is to develop a machine learning model that can accurately classify bird species based on input images. The model is built using TensorFlow and Keras, and it leverages transfer learning with the InceptionV3 architecture. The model is trained and evaluated using a dataset of bird images.
To run the Jupyter Notebook and use the machine learning model, follow these steps:
- Clone the repository:
git clone https://github.com/fsantamaria1/Bird_Classification.git
- Install the required dependencies:
- matplotlib
- pandas
- numpy
- tensorflow
- tensorflow_hub
- fastai
-
Launch Jupyter Notebook and open the
Bird_Classification.ipynb
file. -
Run the cells in the notebook sequentially to execute the code and train the model.
The model uses a bird species dataset obtained from Kaggle. The dataset contains images of 525 different bird species. The images are divided into training, testing, and validation sets.
The dataset can be downloaded using the Kaggle API by following the instructions provided in the notebook. The downloaded dataset is stored in a zip file (100-bird-species.zip
), which is then extracted to the appropriate directories for training, testing, and validation.
Before training the model, the images are preprocessed using the following steps:
-
Rescaling: The pixel values of the images are rescaled to a range of 0 to 1.
-
Data Augmentation: Data augmentation techniques are applied to the training data to increase the diversity of the training set and improve the model's generalization.
The model training process involves the following steps:
-
Base Model Creation: The InceptionV3 architecture is used as the base model for transfer learning.
-
Freezing Base Model Layers: Initially, all layers of the base model are frozen to prevent their weights from being updated during training.
-
Model Compilation: The model is compiled with the categorical cross-entropy loss function, Adam optimizer, and accuracy metric.
-
Fit the Model: The model is trained on the training data for a specified number of epochs, with early stopping based on validation loss.
After training the model, it is evaluated on the test data to assess its performance. The accuracy metric is used to measure the model's ability to correctly classify bird species.
To further improve the model's performance, the top layers of the base model are unfrozen, and fine-tuning is applied. Only the last 10 layers of the base model are trainable, while the remaining layers are kept frozen.
The model is then recompiled and refit on the training data, with early stopping based on validation loss. The fine-tuning process aims to improve the model's ability to extract relevant features for bird species classification.
Two versions of the trained models are saved:
-
Base Model: The initial model before fine-tuning, saved as
base_bird_model.h5
. -
Tuned Model: The model after fine-tuning, saved as
tuned_bird_model.h5
.
These saved models can be used later without the need to retrain the models.
For more details on the implementation and analysis, please refer to the Jupyter Notebook in this repository.