Caffe - 使用来自贝壳的训练有效的caffemodel的前馈图像

时间:2016-05-25 14:33:28

标签: shell neural-network deep-learning caffe

假设我有一个训练有素的caffe模型(.caffemodel权重文件和.prototxt文件以及网络描述)和一个我想用这个网络分类的图像(一个简单的前馈,然后得到最后一层的输出值,假设图像具有网络第一层的正确尺寸。

我见过教程用Matlab或Python做这个。

有没有办法用Caffe本身从shell中做到这一点? (不使用其他语言的绑定)

由于

2 个答案:

答案 0 :(得分:1)

您可以通过以下方式执行此操作:

./build/tools/extract_features.bin
models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel
examples/_temp/imagenet_val.prototxt fc7 examples/_temp/features 10 leveldb

而不是" fc7"您可以指定要从中输出的图层的名称甚至多个名称。另请查看这些链接以获取更多详细信息:https://github.com/BVLC/caffe/blob/master/tools/extract_features.cpp#L36-L45http://caffe.berkeleyvision.org/gathered/examples/feature_extraction.html

答案 1 :(得分:0)

您可以从shell调用$CAFFE_ROOT/python/classify.py来对图像进行分类:

~$ python $CAFFE_ROOT/python/classify.py \
      --model_def /path/to/deploy.prototxt \
      --pretrained_model /path/to/weights.caffemodel \
      --gpu \
      /path/to/image.jpg /path/to/output

此python脚本还有一些可选参数,您可能需要设置其中一些参数。