a guest Jun 25th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- import caffe
- import cv2
- import sys
- def deploy(img_path):
- # Initialize the Caffe model using the model trained in DIGITS. Which two files constitute your trained model?
- net = caffe.Classifier('../deploy.prototxt', '../snapshot_iter_31000.caffemodel',
- image_dims=(256, 256))
- # 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.
- input_image= caffe.io.load_image(img_path)
- input_image = cv2.resize(input_image, (256,256))
- mean_image = caffe.io.load_image('../mean.jpg')
- input_image = input_image-mean_image
- # Make prediction. What is the function and the input to the function needed to make a prediction?
- prediction = net.predict([input_image])##REPLACE WITH THE FUNCTION THAT RETURNS THE OUTPUT OF THE NETWORK##([##REPLACE WITH THE INPUT TO THE FUNCTION##])
- if prediction.argmax()==0: ...
RAW Paste Data