You need to complete the following steps:
- Import the modules:
import cv2import numpy as np
- Load a model from Caffe and print the information about the types of layers used in the model:
net = cv2.dnn.readNetFromCaffe('../data/bvlc_googlenet.prototxt', '../data/bvlc_googlenet.caffemodel')if not net.empty(): print('Net loaded successfully\n') print('Net contains:')for t in net.getLayerTypes(): print('\t%d layers of type %s' % (net.getLayersCount(t), t))
- Get the tensor shapes for the loaded model and specified input shape. Then print all of the information:
layers_ids, in_shapes, out_shapes = net.getLayersShapes([1, 3, 224, 224])layers_names = net.getLayerNames()print('Net layers shapes:')for l in range(len(layers_names)): ...