How it works...

To load pre-trained models from the frameworks, you need to use the readNetFromCaffe, readNetFromTorch, or readNetFromTensorflow functions for the Caffe, Torch, and TensorFlow networks respectively. All these functions return the cv2.dnn_Net object, which is the parsed version of the graph from the model's file.

It's worth mentioning that you may face issues while loading models with complicated architectures or models not having widely spread layers (for example, models with new types of layers, recently added or developed and implemented by you). OpenCV's dnn module is still developing and may not include the latest features from Deep Learning frameworks. But despite that fact, the dnn module has a lot of supported layer ...

Get OpenCV 3 Computer Vision with Python Cookbook 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.