Image classification using OpenCV with OpenVINO

Let's first create an image classification inference code using OpenCV. Since we are only concerned with inference, we will use a pre-trained model:

  1. First, let's download the Caffe model files, deploy.prototxt and bvlc_reference_caffenet.caffemodel, which can be obtained from Berkley Visions' repository (https://github.com/BVLC/caffe/tree/master/models/bvlc_reference_caffenet). Make sure that you download both files in your current working directory. We will also need a text file with the class labels mentioned. You can get it from https://github.com/torch/tutorials/blob/master/7_imagenet_classification/synset_words.txt.
  2. Let's also use a sample image of a giraffe for image classification:

Get Machine Learning for OpenCV 4 - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.