Guest User

Untitled

a guest
Dec 5th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. mean_file='../models/pretrained/imagenet_mean.binaryproto'
  2. if not os.path.isfile('imagenet_mean.pkl'):
  3.  
  4. import sys
  5. sys.path.append('/work/04340/tushar_n/packages/caffe/python')
  6. import caffe
  7. caffe.set_device(0)
  8.  
  9. blob = caffe.proto.caffe_pb2.BlobProto()
  10. data = open(mean_file,'rb').read()
  11. blob.ParseFromString(data)
  12. mean_val = np.array(caffe.io.blobproto_to_array(blob))[0] #BGR
  13. mean_val = mean_val[::-1,:,:] #RGB
  14. pickle.dump(mean_val, open('imagenet_mean.pkl','wb')) #(3,256,256)
  15. print 'imagenet mean np file generated'
Add Comment
Please, Sign In to add comment