Guest User

Untitled

a guest
Mar 26th, 2018
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. import numpy as np
  2. import cv2
  3. import time
  4.  
  5. IM_SIZE = 224
  6.  
  7. print("LOADING....")
  8. net = cv2.dnn.readNetFromCaffe('channel_pruning_VGG-16_3C4x.prototxt', 'channel_pruning_VGG-16_3C4x.caffemodel')
  9. print("LOADED")
  10.  
  11. sum_t = 0
  12. num_runs = 10
  13. for i in range(num_runs):
  14.     x_image = np.asarray(np.random.rand(IM_SIZE, IM_SIZE, 3), dtype=np.float32)
  15.     t = time.time()
  16.     inputBlob = cv2.dnn.blobFromImage(x_image) 
  17.     net.setInput(inputBlob)
  18.     result = net.forward()
  19.     sum_t += time.time()-t
  20.  
  21. print("Inference done in {}s".format(sum_t/num_runs))
Add Comment
Please, Sign In to add comment