Advertisement
Guest User

Untitled

a guest
Oct 24th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. input_image = caffe.io.load_image(IMAGE_FILE)
  2. input_image = input_image
  3. label_index = int(label_index) - 1
  4. caffeLabel = np.zeros((1, 1000, 1, 1))
  5. caffeLabel[0, label_index, 0, 0] = 1;
  6.  
  7. net = caffe.Classifier(imagenetModelFile, imagenetTrainedModel, mean=np.load(imagenetMeanFile).mean(1).mean(1),
  8. channel_swap=(2, 1, 0),
  9. raw_scale=255,
  10. image_dims=(256, 256))
  11.  
  12. pred = net.predict([input_image])
  13. bw = net.backward(**{net.outputs[0]: caffeLabel})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement