This code creates and trains an image detector to recognize pandas in images. By changing the directory paths and getting different training data you can classify any type of image you like.
The image detector operates using SIFT (Scale-Invariant Feature Transform) features, with a Visual Bag of Words model. For a detailed description see my blog posts:
- Part 1: What are SIFT features and how to generate them in OpenCV with Python
- Part 2: The Visual Bag of Words Model
My slide deck for this project is available to view. The slides are from a 5-minute lightning presentation at Metis.
Panda images for training the classifier used in the Flask app are from the Caltech101 dataset and from several hundred additional photos and drawings ripped from Google Images. The negative non-panda images used to train the classifier are also from the Caltech101 dataset.
To scrape images from Google Images yourself, check out my selenium_google_img_rip.py
script in this repo.
-
Check out the Flask app: http://54.210.9.61/panda_app/
-
Use the simple API. Eg with
curl
:curl -X POST -F "file=@path/to/cat.jpg" 'http://54.210.9.61/panda_app/'
-
Upload webcam images to the flask server, eg using
webcam-upload.py
on the command line orpanda-webcam-test.ipynb
in Jupyter Notebook. Both require OpenCV 3.1.0 with nonfree packages included -- install instructions here (scroll down a bit)