April 2020
Intermediate to advanced
438 pages
12h 2m
English
Run the following steps to implement image colorization using the pre-trained deep learning Caffe model with the opencv-python functions:
proto_file = "models/colorization_deploy_v2.prototxt"weights_file = "models/colorization_release_v2.caffemodel"net = cv2.dnn.readNetFromCaffe(proto_file, weights_file)
pts_in_hull = np.load('models/pts_in_hull.npy') pts_in_hull = pts_in_hull.transpose().reshape(2, 313, 1, 1)net.getLayer(net.getLayerId('class8_ab')).blobs = [pts_in_hull.astype(np.float32)]net.getLayer(net.getLayerId('conv8_313_rh')).blobs ...Read now
Unlock full access