GithubHelp home page GithubHelp logo

ipinmi / landmark-classifier-and-tagger Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 713 KB

Convolutional Neural Network architectures for classifying landmark images.

HTML 65.81% Jupyter Notebook 32.89% Python 1.30%

landmark-classifier-and-tagger's Introduction

Landmark Classification & Tagging for Social Media

Two Convolutional Neural Network architectures for classifying landmark images. One built from the scratch and the other utilizes transfer learning.

Project Steps

  1. Creating a CNN architecture from Scratch to Classify Landmarks
    • Data Loading and Preprocessing
      • The data_transforms dictionary contains train, valid and test keys. The values are instances of transforms.Compose.
      • At the minimum, the 3 set of transforms contains a Resize(256) step, a crop step (RandomCrop for train and CenterCrop for valid and test), a ColorJitter step, a ToTensor step and finally a Normalize step (which uses the mean and std of the dataset).
      • The ImageFolder instances for train, valid and test use the appropriate transform from the data_transforms dictionary (using the “transform” keyword of ImageFolder)
      • The data loaders for train, valid and test use the right ImageFolder instance and use the batch_size, sampler, and num_workers that are given in input to the function.
    • Model Architecture
      • The model architecture is a CNN with 5 convolutional layers and 2 linear layers. The output of the model is a logit for each class. The model uses dropout and batch normalization to reduce overfitting.
    • Training and Testing the Model
      • The model is trained first for 70 epochs with a learning rate of 0.001 and achieves a test accuracy of 42%
      • The model is reloaded from its checkpoint and trained for second time for 30 epochs with a learning rate of 0.0005 and achieves a test accuracy of 51%
    • Saving and Loading the Model
      • The trained model is saved as a checkpoint along with associated hyperparameters and the class_to_idx dictionary.
      • There is a function that successfully loads a checkpoint and rebuilds the model.
    • Inference for Classification
      • There is a function that successfully makes a prediction for an image. The function returns the top 𝐾 most likely classes along with the probabilities. It takes a path to an image and a checkpoint, then returns the probabilities and classes.
    • Sanity Checking with matplotlib
      • There is a function that takes a path to an image and a model checkpoint, then plots the image and its predicted classes. The function uses matplotlib to plot the image and its 𝐾 most likely classes with actual flower names.

  1. Using Transfer Learning to Classify Landmarks
    • Model Architecture
      • The model architecture uses the ResNet18 pre-trained CNN model.
      • All parameters of the loaded architecture are frozen, and a linear layer at the end has been added using the appropriate input features (as returned by the backbone), and the appropriate output features, as specified by the n_classes parameter
    • Training and Testing the Model
      • The model is trained first for 50 epochs with a learning rate of 0.001 and achieves a test accuracy of 74%.
    • Saving and Loading the Model
      • The trained model is saved as a checkpoint along with associated hyperparameters and the class_to_idx dictionary.
      • There is a function that successfully loads a checkpoint and rebuilds the model.
    • Inference for Classification
      • There is a function that successfully makes a prediction for an image. The function returns the top 𝐾 most likely classes along with the probabilities. It takes a path to an image and a checkpoint, then returns the probabilities and classes.
    • Sanity Checking with matplotlib
      • There is a function that takes a path to an image and a model checkpoint, then plots the image and its predicted classes. The function uses matplotlib to plot the image and its 𝐾 most likely classes with actual flower names.

landmark-classifier-and-tagger's People

Contributors

ipinmi avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.