Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python wrapper: classifier.py does not initialize mean if no mean file is provided #671

Closed
wendlerc opened this issue Jul 11, 2014 · 3 comments
Labels

Comments

@wendlerc
Copy link

Hello,

I just tried to switch off the mean normalization like it is proposed in http://nbviewer.ipython.org/github/BVLC/caffe/blob/master/examples/imagenet_classification.ipynb . When doing so I ran into an AttributeError since when not giving a meanfile to the classifier constructor, it won't initialize self.mean which is needed in the later _Net_preprocess function in pycaffe. For now I fixed it by initializing it in the Classifier constructor.

class Classifier(caffe.Net):
    """
    Classifier extends Net for image class prediction
    by scaling, center cropping, or oversampling.
    """
    def __init__(self, model_file, pretrained_file, image_dims=None,
                 gpu=False, mean_file=None, input_scale=None, channel_swap=None):

I skip some stuff there.

       if mean_file:
           self.set_mean(self.inputs[0], mean_file)
       #Chris Wendler
       if mean_file == None:
           self.mean = {}

Correct me if I understood something wrong.

Best regards,

Chris

@kubiakb
Copy link

kubiakb commented Jul 15, 2014

Can anyone explain why mean file is necessary for classification?
Model was trained with images centered with means, but while classification process we are showing new image. In this case we need to calculated and use mean for that new image image.
What is the reason of reading training set means file?

Regards,
Blazej

@wendlerc
Copy link
Author

longjon added a commit to longjon/caffe that referenced this issue Jul 19, 2014
@shelhamer
Copy link
Member

Fixed by #733.

@shelhamer shelhamer added the bug label Jul 28, 2014
mitmul pushed a commit to mitmul/caffe that referenced this issue Sep 30, 2014
RazvanRanca pushed a commit to RazvanRanca/caffe that referenced this issue Nov 4, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants