Several examples of how to perform image classification using different pre-trained models will be covered in this section. Note that you can get the inference time by using the net.getPerfProfile() method as follows:
# Feed the input blob to the network, perform inference and get the output:
net.setInput(blob)
preds = net.forward()
# Get inference time:
t, _ = net.getPerfProfile()
print('Inference time: %.2f ms' % (t * 1000.0 / cv2.getTickFrequency()))
As you can see, the net.getPerfProfile() method is called after performing the inference.
The net.getPerfProfile() method returns overall time for inference and timings (in ticks) for the layers. This way, you can compare the inference time using different deep learning architectures.
We will see the main deep learning classification architectures, starting from the AlexNet architecture, which is shown in the next subsection.