caffe icon indicating copy to clipboard operation
caffe copied to clipboard

Predict one image, based on a trained model, from command prompt.

Open polySolo opened this issue 11 years ago • 4 comments

Hello,

As a new user of caffe, there are a couple burning questions that have accumulated and this is one of them.

One thing I am wondering, is, given a particular .caffemodel file, and ONE image, how exactly do I go about predicting the result of the model on this image, from the command prompt? Am I to understand that the only way to do this is via Python and/or MATLAB?

Thanks.

polySolo avatar Apr 11 '15 16:04 polySolo

Hello. U can use the "test" function of caffe by writing: caffe test -model my_model.prototxt - weights my_snapshot.caffemodel

As u only want to test on one image, give that image as input to your test data layer (you may want to give the mean_image as input too) in your my_model.prorotxt (test batch size is 1 in this case)

Add output layers in your model definition my_model.prorotxt, dependent on which output you want to have (loss, votes...)

userfou avatar Apr 13 '15 22:04 userfou

@userfou

Thanks, I couple questions:

  1. How exactly is a mean_image generated? I asked this as a previous question but never got an answer.
  2. I only want to predict one image. Does it also have to be in LMDB format? This is the biggest question.

Thanks.

polySolo avatar Apr 14 '15 17:04 polySolo

  1. you can use the caffe binary file therefore by writing in the terminal: CAFFE_ROOT/.build_release/tools/compute_image_mean.bin your_dataset_lmdb your_mean.binaryproto

  2. No it doesn't. See all the possibilities in the caffe layer catalogue in the "data layers" section http://caffe.berkeleyvision.org/tutorial/layers.html What I do is to change my data layer type to IMAGE_DATA and feed the data layer (source path) with a text file containing the path to the image and its label

I hope I could help :)

userfou avatar Apr 15 '15 12:04 userfou

Thanks for discussing this but please use caffe-users for this -- this issues tracker is primarily for Caffe development discussion. Thanks!

rohrbach avatar May 05 '15 13:05 rohrbach