SHARE
TWEET

Untitled

a guest Jun 25th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import caffe
  2. import cv2
  3. import sys
  4. def deploy(img_path):
  5.     caffe.set_mode_gpu()
  6.  
  7. # Initialize the Caffe model using the model trained in DIGITS. Which two files constitute your trained model?
  8. net = caffe.Classifier('../deploy.prototxt', '../snapshot_iter_31000.caffemodel',
  9.                        channel_swap=(2,1,0),
  10.                        raw_scale=255,
  11.                        image_dims=(256, 256))
  12.  
  13. # Create an input that the network expects. This is different for each project, so don't worry about the exact steps, but find the dataset job directory to show you know that whatever preprocessing is done during training must also be done during deployment.
  14. input_image= caffe.io.load_image(img_path)
  15. input_image = cv2.resize(input_image, (256,256))
  16. mean_image = caffe.io.load_image('../mean.jpg')
  17. input_image = input_image-mean_image
  18.  
  19. # Make prediction. What is the function and the input to the function needed to make a prediction?
  20. prediction = net.predict([input_image])##REPLACE WITH THE FUNCTION THAT RETURNS THE OUTPUT OF THE NETWORK##([##REPLACE WITH THE INPUT TO THE FUNCTION##])
  21. print(prediction)
  22. if prediction.argmax()==0: ...
  23.      
  24. snapshot_500.ckpt.data-00000-of-00001
  25. snapshot_500.ckpt.index
  26. snapshot_500.ckpt.meta
  27. info.json
  28. labels.txt
  29. mean.binaryproto
  30. network.py
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top