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:
- 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.
- Let's also use a sample image of a giraffe for image classification: