This project is a machine-learning application designed to classify dog breeds from images. Using a pre-trained MobileNetV2 model as the backbone, it fine-tunes the network on a dataset of labelled dog images to accurately predict the breed of a given dog. The project demonstrates end-to-end machine learning workflows, including data preprocessing, model training, and evaluation.
- Data Preprocessing: Efficiently processes and batches image data for training and validation.
- Model Architecture: Built on a fine-tuned MobileNetV2 model with custom output layers for multi-class classification.
- Training & Evaluation: Includes TensorBoard callbacks for real-time monitoring, early stopping for optimal training and various visualizations for model performance.
- Prediction: Converts model output probabilities into human-readable labels and visualizes the predictions with confidence levels.
The goal is to create an end-to-end multi-class image classifier capable of identifying a dog's breed from a given image. The task involves handling unstructured image data and predicting the correct breed out of 120 possible classes.
The data is downloaded from the Kaggle Bluebook for Bulldozers competition. There are three main datasets:
train.zip
is the training set, you are provided with the breed for these dogs.test.zip
the test set, you must predict the probability of each breed for each image.labels.csv
has the breeds for the images in the train set.
You must download a zip file here: https://www.kaggle.com/c/dog-breed-identification/data to run this project locally. Create a directory called
data
at the root of the project and place these folders and files into it. Setup the directory as such:
data/dog-breed-identification/labels.csv
data/dog-breed-identification/sample_submission.csv
data/dog-breed-identification/test/
data/dog-breed-identification/train/
The model's performance will be evaluated based on prediction probabilities for each dog breed for each test image.
- Data Type: Unstructured data (images).
- Number of Classes: 120 dog breeds, representing 120 distinct classes.
- Training Data: Approximately 10,000+ labelled images.
- Test Data: Approximately 10,000+ unlabeled images.
- Approach: Given the unstructured nature of the data, deep learning and transfer learning techniques are employed to build the image classifier.
The main steps we go through in this project are:
- Problem Definition
- Define the problem of identifying dog breeds from images and determine the scope of the project.
-
Data Collection and Exploration Gather the dataset from Kaggle's dog breed identification competition. Explore the data to understand its structure, including the number of classes, distribution of images, and data quality.
-
Data Preprocessing *Preprocess the images by resizing, normalizing, and augmenting to enhance model generalization. *Split the data into training, validation, and test sets.
-
Model Building
- Build a deep learning model using TensorFlow and Keras.
- Implement transfer learning by leveraging a pre-trained model to improve accuracy and reduce training time.
- Add custom layers to fine-tune the model according to the specific task of dog breed classification.
- Model Training
- Train the model on the processed data, utilizing techniques such as early stopping and learning rate scheduling.
- Monitor the training process using TensorBoard to track performance metrics and ensure model convergence.
-
Clone the repository:
git clone https://github.com/AdrianTomin/dog-vision.git cd dog-vision
-
Create and activate the Conda environment:
conda env create -f environment.yml conda activate dog-vision
-
Clone the repository:
git clone https://github.com/AdrianTomin/dog-vision.git cd dog-vision
-
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install the dependencies:
pip install -r requirements.txt
Choose one of these options to set up the environment, depending on your preference. `
-
Install Jupyter Notebook or JupyterLab:
conda install -c conda-forge notebook # or for JupyterLab conda install -c conda-forge jupyterlab
-
Start Jupyter Notebook or JupyterLab:
jupyter notebook # or for JupyterLab jupyter lab
-
Navigate to the project directory:
cd dog-vision
-
Start the Jupyter Notebook server:
jupyter notebook
-
Open the notebook:
In the Jupyter Notebook interface, open the
dog_vision.ipynb
notebook. -
Run the notebook cells:
Execute the cells in the notebook to train the model and make predictions. Ensure you have downloaded the dataset and placed it in the appropriate directory as mentioned in the notebook.
This README provides a comprehensive guide for setting up the environment, installing dependencies, and running the project locally. Adjust paths and repository links as needed to match your specific setup.