我是Digits和TensorFlow的新手。
使用caffe训练后的模型已使用上面的代码进行了测试:
<app-button (click)="functioncall($event)">Your Label Here</app-button>
但是,下载的TensorFlow模型包含以下文件:
import caffe
import cv2
import sys
def deploy(img_path):
caffe.set_mode_gpu()
# 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',
channel_swap=(2,1,0),
raw_scale=255,
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##])
print(prediction)
if prediction.argmax()==0: ...
如何像使用Caffe一样用图像测试这样的模型?