Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import cv2
- import time
- IM_SIZE = 224
- print("LOADING....")
- net = cv2.dnn.readNetFromCaffe('channel_pruning_VGG-16_3C4x.prototxt', 'channel_pruning_VGG-16_3C4x.caffemodel')
- print("LOADED")
- sum_t = 0
- num_runs = 10
- for i in range(num_runs):
- x_image = np.asarray(np.random.rand(IM_SIZE, IM_SIZE, 3), dtype=np.float32)
- t = time.time()
- inputBlob = cv2.dnn.blobFromImage(x_image)
- net.setInput(inputBlob)
- result = net.forward()
- sum_t += time.time()-t
- print("Inference done in {}s".format(sum_t/num_runs))
Add Comment
Please, Sign In to add comment