Skip to content

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

@wendlerc

Description

@wendlerc

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions