【发布时间】:2016-02-23 16:34:07
【问题描述】:
我有一个model,它接受过 CIFAR-10 的训练,但我不知道如何在 pycaffe 中进行预测。
我从 lmdb 获得了一张图片,但我不知道如何将其加载到网络中并获得预测的类。
我的代码:
net = caffe.Net('acc81/model.prototxt',
'acc81/cifar10_full_iter_70000.caffemodel.h5',
caffe.TEST)
lmdb_env = lmdb.open('cifar10_test_lmdb/')
lmdb_txn = lmdb_env.begin()
lmdb_cursor = lmdb_txn.cursor()
for key, value in lmdb_cursor:
datum = caffe.proto.caffe_pb2.Datum()
datum.ParseFromString(value)
image = caffe.io.datum_to_array(datum)
image = image.astype(np.uint8)
# What's next with the image variable?
# If i try:
# out = net.forward_all(data=np.asarray([image]))
# I get Exception: Input blob arguments do not match net inputs.
print("Image class is " + label)
【问题讨论】:
-
请参阅this answer 如何将您的训练 prototxt 转换为部署 prototxt。
标签: neural-network caffe