Make Predictions using the model
Now that we have our input ready, we have to explicitly set it as input using the setInput() method and then pass it to our model and use the forward method to generate predictions.
#——setting input—–#
net.setInput(blob)
#—–using the model to make predictions
results = net.forward()
The forward method returns us a 4-dimensional list:
The 3rd dimension has our predictions, and each prediction is a list of 7 floating values. At the 1 index we have the class_id, at 2nd index we have the confidence/probability and from 3rd to 6th index we have the coordinates of the object detected.
Let’s directly see how they are used in our final implementation.
Deep Learning with Python OpenCV
Opencv 3.3 brought with a very improved and efficient (dnn) module which makes it very for you to use deep learning with OpenCV. You still cannot train models in OpenCV, and they probably don’t have any intention of doing anything like that, but now you can very easily use image processing and use the pre-trained models to make predictions using the dnn module.
This new version supports a number of large frameworks which include :
- Tensorflow
- Torch
- Caffe
Contact Us