1
0
mirror of https://github.com/opencv/opencv_contrib.git synced 2025-10-23 18:09:25 +08:00

Extended and generalized CropLayer implementation

Also, small fix inside inside Python types conversion was added
This commit is contained in:
Vitaliy Lyudvichenko
2016-08-18 20:00:29 +03:00
parent 8b4b7f6c93
commit dcf425256c
7 changed files with 81 additions and 69 deletions

View File

@@ -10,7 +10,7 @@ def prepare_image(img):
blob = np.moveaxis(img, 2, 0)
blob = np.reshape(blob.astype(np.float32), (-1, 3, 224, 224))
return blob
def timeit_forward(net):
print("OpenCL:", cv2.ocl.useOpenCL())
print("Runtime:", timeit.timeit(lambda: net.forward(), number=10))
@@ -26,7 +26,7 @@ cv2.ocl.setUseOpenCL(True) #Disable OCL if you want
net = dnn.readNetFromCaffe('bvlc_googlenet.prototxt', 'bvlc_googlenet.caffemodel')
net.setBlob(".data", blob)
net.forward()
timeit_forward(net) #Uncomment to check performance
#timeit_forward(net) #Uncomment to check performance
prob = net.getBlob("prob")
print("Output:", prob.shape, prob.dtype)