caffe.Classifier() and caffe.Net() have different class predictions for same image?

455 views
Skip to first unread message

Mohit Jain

unread,
Feb 12, 2016, 12:26:04 PM2/12/16
to Caffe Users
Hi,
    Is there a difference in the way the predictions work in the case of caffe.Classifier() and caffe.Net()? I have an image (linked below) that when run in the caffe-example (classification.ipynb) gives a prediction of class 287 (net.predict([img]).argmax()). However, if I use this image in the another example (filter_visualization.ipynb) the class probabilites (net.blobs['prob'].argmax()) comes out to be 2! Is there something trivial that I am missing or this really shouldn't be happening? Which of these is the correct classification if at all one is correct?

Regards,
Mohit

Alex Orloff

unread,
Feb 12, 2016, 12:33:20 PM2/12/16
to Caffe Users
do you use same imagemean?

Mohit Jain

unread,
Feb 12, 2016, 12:37:15 PM2/12/16
to Alex Orloff, Caffe Users
Yes I do. The one that comes as standard with the ILSVRC12 (python/caffe/imagenet/ilsvrc_2012_mean.npy).

--
You received this message because you are subscribed to a topic in the Google Groups "Caffe Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/caffe-users/ApD180RMDy8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to caffe-users...@googlegroups.com.
To post to this group, send email to caffe...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/caffe-users/a1378bf5-2e31-45a5-aba8-85550b304245%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alex Orloff

unread,
Feb 12, 2016, 12:55:21 PM2/12/16
to Caffe Users, gadgy....@gmail.com
It's not so easy to find a reason.
Exmple, Classifier() uses mean of 10 crops. Net() - dunno.

Mohit Jain

unread,
Feb 13, 2016, 12:38:02 PM2/13/16
to Alex Orloff, Caffe Users
Posting solution :

Thanks to Sean for the reply on Github :
Yes, the two are very different, and you should expect different answers. Look at the code -- Classifier.predict does oversampling and callsNet.forward_allhttps://github.com/BVLC/caffe/blob/master/python/caffe/classifier.py#L47

Jan C Peters

unread,
Feb 15, 2016, 3:27:18 AM2/15/16
to Caffe Users, gadgy....@gmail.com
For the record: caffe.Net does nothing extra, just the bare feedforward pass of the input data. There is no oversampling or other additions, just using the network as given in the train_val.prototxt or net_deploy.prototxt (and possibly using weights from a *.caffemodel, depending on the parameters given to the caffe.Net contructor).

Jan

Sidharth Singla

unread,
Nov 19, 2019, 2:15:06 PM11/19/19
to Caffe Users
@Mohit I still didn't get the difference in caffe.net and caffe.predict. Shouldn't both five same output probs and classes ?
What should be used to evaluate a model?

Regards
Sidharth Singla


On Saturday, February 13, 2016 at 12:38:02 PM UTC-5, Mohit Jain wrote:
Posting solution :

Thanks to Sean for the reply on Github :
Yes, the two are very different, and you should expect different answers. Look at the code -- Classifier.predict does oversampling and callsNet.forward_allhttps://github.com/BVLC/caffe/blob/master/python/caffe/classifier.py#L47

On Fri, Feb 12, 2016 at 11:25 PM Alex Orloff <gadgy...@gmail.com> wrote:
It's not so easy to find a reason.
Exmple, Classifier() uses mean of 10 crops. Net() - dunno.


On Friday, February 12, 2016 at 8:37:15 PM UTC+3, Mohit Jain wrote:
Yes I do. The one that comes as standard with the ILSVRC12 (python/caffe/imagenet/ilsvrc_2012_mean.npy).

On Fri, Feb 12, 2016 at 11:03 PM Alex Orloff <gadgy....@gmail.com> wrote:
do you use same imagemean?


On Friday, February 12, 2016 at 8:26:04 PM UTC+3, Mohit Jain wrote:
Hi,
    Is there a difference in the way the predictions work in the case of caffe.Classifier() and caffe.Net()? I have an image (linked below) that when run in the caffe-example (classification.ipynb) gives a prediction of class 287 (net.predict([img]).argmax()). However, if I use this image in the another example (filter_visualization.ipynb) the class probabilites (net.blobs['prob'].argmax()) comes out to be 2! Is there something trivial that I am missing or this really shouldn't be happening? Which of these is the correct classification if at all one is correct?

Regards,
Mohit

--
You received this message because you are subscribed to a topic in the Google Groups "Caffe Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/caffe-users/ApD180RMDy8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to caffe-users...@googlegroups.com.
To post to this group, send email to caffe...@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Caffe Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/caffe-users/ApD180RMDy8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to caffe...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages