caffe检测代码中加入batchsize,实现更快测试


imgs = np.zeros((batch_size, 3, height, width))#创建多维度数组
image_last = cv2.imread(image_path)

image = cv2.resize(image_last, (width, height))
#####尽量不要用caffe封装的transform模块,这样跟c++工程实现会有不同。
image= image.astype(np.float32)
emptyImage = cv2.resize(image, (width, height), interpolation=cv2.INTER_CUBIC)
emptyImage[:, :, 0] = mu[0] * scale
emptyImage[:, :, 1] = mu[1] * scale
emptyImage[:, :, 2] = mu[2] * scale
transformed_image = image -emptyImage

transformed_image = transformed_image.transpose((2, 0, 1))
#################################################################################
imgs[a] = np.array(transformed_image)

你可能感兴趣的:(caffe)