gladwinyjh / harambAI

PyTorch Ape classifier with visualisations

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Header


Why have a model learn 1000 classes when it can learn just 5? Are we really just 'a notch above chimps'?

harambAI is a pre-trained PyTorch Resnet50 model that was re-trained for the sole purpose of classifying the Apes:

  • Gibbon
  • Orangutan
  • Gorilla
  • Chimpanzee/Bonobo (yes I know they aren't exactly the same)
  • Human

It is trained on a very modest number of images (~2000) for each Ape, so do not to have too high expectations. The purpose of this repo is to implement some visualisation techniques for ConvNets.

harambAI is easy to use. Just give an image link of one of the Apes and choose any of the visualisations below:

  • Saliency
  • Guided Backpropagation
  • Grad-CAM

Getting Started

Requirements

  • Python 3.+
  • Create virtual env (optional)
git clone git@github.com:gladwinyjh/harambAI.git
cd harambAI
pip install -r requirements.txt
cd src
  • For gpu usage, install the appropriate version for your cuda if not already set up. Running on gpu is not necessary at all.

Command Line Arguments

-u or --url: Image address of image
    - Accepts most images by 'Copy image address' (Chrome) or 'Copy image link (Firefox)
    - type=str, required=True


-s or --saliency: Option to produce saliency map, defaults to False
    - action='store_true', default=False


-gbp or --guided_backprop: Option to produce guided backpropagation visualisation, defaults to False
    - action='store_true', default=False


-gc or --grad_cam: Option to produce Grad-CAM superimposed image, defaults to False
    - action='store_true', default=False


-cuda or --cuda: Option to use cuda is available, defaults to False (use cpu)
    - action='store_true', default=False

Examples

python main.py -u "https://upload.wikimedia.org/wikipedia/commons/thumb/0/03/Hylobates_lar_-_Kaeng_Krachan_WB.jpg/800px-Hylobates_lar_-_Kaeng_Krachan_WB.jpg" -s -gbp -gc

Gibbon


python main.py -u "https://upload.wikimedia.org/wikipedia/commons/thumb/7/72/Chimp_Serengeti_Park_2015_%28215379799%29.jpeg/800px-Chimp_Serengeti_Park_2015_%28215379799%29.jpeg" -s -gbp -gc

Chimp


python main.py -u "https://upload.wikimedia.org/wikipedia/commons/f/f5/Gorilla_gorilla06.jpg" -s -gbp -gc

Gorilla


python main.py -u "https://upload.wikimedia.org/wikipedia/commons/thumb/a/a0/Tapanuli_Orangutan_Amid_Threat_of_Extinction.jpg/800px-Tapanuli_Orangutan_Amid_Threat_of_Extinction.jpg" -s -gbp -gc

Orangutan


python main.py -u "https://upload.wikimedia.org/wikipedia/commons/thumb/7/70/Man_in_forest_working.jpg/800px-Man_in_forest_working.jpg" -s -gbp -gc

Human


References

[1] Utku Ozbulak. (2019). PyTorch CNN Visualizations. https://github.com/utkuozbulak/pytorch-cnn-visualizations.

Header and Demo images:

About

PyTorch Ape classifier with visualisations

License:MIT License


Languages

Language:Python 100.0%