This repository contains the code and notebooks for the Landmark Classification project, where we build a Convolutional Neural Network (CNN) to classify landmarks from images. The project involves three major steps: building a CNN from scratch, applying transfer learning, and deploying the model in a simple app.
Photo sharing and storage services often rely on location metadata to organize and tag images. However, not all images contain this metadata. This project aims to solve this problem by creating a machine learning model that can predict the location of an image based on the landmarks depicted in it.
The project is divided into three main stages:
-
Create a CNN from Scratch:
- Visualize and preprocess the dataset.
- Build a CNN from scratch to classify the landmarks.
- Export the best model using Torch Script.
-
Create a CNN using Transfer Learning:
- Explore different pre-trained models.
- Use transfer learning to train and test a network for this classification task.
- Export the best transfer learning model using Torch Script.
-
Deploy the Model in an App:
- Use the best model to create a simple app.
- Test the app for identifying landmarks in images.
- Generate an archive file for submission.
The repository contains the following key files and directories:
- cnn_from_scratch.ipynb: Notebook for creating a CNN from scratch.
- transfer_learning.ipynb: Notebook for applying transfer learning.
- app.ipynb: Notebook for deploying the model in a simple app.
- data/: Directory containing the dataset (note: dataset files are not included in the repository).
- models/: Directory for saving trained models and exported Torch Script models.
- README.md: This file.
To run the notebooks, you need the following software installed:
- Python 3.x
- Jupyter Notebook
- PyTorch
- Torchvision
- Other Python dependencies listed in
requirements.txt
Clone this repository to your local machine:
git clone https://github.com/your-username/landmark-classification.git
cd landmark-classification
Install the required Python packages:
pip install -r requirements.txt
-
CNN from Scratch: Open
cnn_from_scratch.ipynb
in Jupyter Notebook and run the cells to build and train a CNN from scratch. -
Transfer Learning: Open
transfer_learning.ipynb
in Jupyter Notebook and run the cells to explore pre-trained models and apply transfer learning. -
Deploying the Model: Open
app.ipynb
in Jupyter Notebook and run the cells to deploy your model in a simple app.
- CNN from Scratch: Achieved 62% accuracy on the test set.
- Transfer Learning: Achieved 75% accuracy on the test set using ResNet18.
The app created in app.ipynb
allows users to upload an image and get predictions for the most likely landmarks depicted in the image.
This project is licensed under the MIT License - see the LICENSE file for details.
- This project was completed as part of the advanced Machine Learning Nanodegree Program by Udacity and AWS.