0db94786a7a463fed49825811fac903f1f1fc3c8,python/caffe/classifier.py,Classifier,predict,#Classifier#,49

Before Change


                     for N images and C classes.
        
        // Scale to standardize input dimensions.
        inputs = np.asarray([caffe.io.resize_image(im, self.image_dims)
                             for im in inputs])

        if oversample:
            // Generate center, corner, and mirrored crops.
            inputs = caffe.io.oversample(inputs, self.crop_dims)
        else:
            // Take center crop.
            center = np.array(self.image_dims) / 2.0
            crop = np.tile(center, (1, 2))[0] + np.concatenate([
                -self.crop_dims / 2.0,
                self.crop_dims / 2.0
            ])
            inputs = inputs[:, crop[0]:crop[2], crop[1]:crop[3], :]

        // Classify
        caffe_in = np.asarray([self.preprocess(self.inputs[0], in_)
                    for in_ in inputs])
        out = self.forward_all(**{self.inputs[0]: caffe_in})
        predictions = out[self.outputs[0]].squeeze(axis=(2,3))

After Change


        input_ = np.zeros((len(inputs),
            self.image_dims[0], self.image_dims[1], inputs[0].shape[2]),
            dtype=np.float32)
        for ix, in_ in enumerate(inputs):
            input_[ix] = caffe.io.resize_image(in_, self.image_dims)

        if oversample:
            // Generate center, corner, and mirrored crops.
            input_ = caffe.io.oversample(input_, self.crop_dims)
        else:
            // Take center crop.
            center = np.array(self.image_dims) / 2.0
            crop = np.tile(center, (1, 2))[0] + np.concatenate([
                -self.crop_dims / 2.0,
                self.crop_dims / 2.0
            ])
            input_ = input_[:, crop[0]:crop[2], crop[1]:crop[3], :]

        // Classify
        caffe_in = np.zeros(np.array(input_.shape)[[0,3,1,2]],
                            dtype=np.float32)
        for ix, in_ in enumerate(input_):
            caffe_in[ix] = self.preprocess(self.inputs[0], in_)
        out = self.forward_all(**{self.inputs[0]: caffe_in})
        predictions = out[self.outputs[0]].squeeze(axis=(2,3))
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 7

Instances


Project Name: BVLC/caffe
Commit Name: 0db94786a7a463fed49825811fac903f1f1fc3c8
Time: 2014-08-05
Author: shelhamer@imaginarynumber.net
File Name: python/caffe/classifier.py
Class Name: Classifier
Method Name: predict


Project Name: scikit-learn/scikit-learn
Commit Name: 0b0afd2d644c65554c907f8e8320e507f8caaefc
Time: 2020-07-17
Author: noelanorodriguez@gmail.com
File Name: sklearn/feature_selection/_mutual_info.py
Class Name:
Method Name: _compute_mi_cc


Project Name: scikit-learn/scikit-learn
Commit Name: 0b0afd2d644c65554c907f8e8320e507f8caaefc
Time: 2020-07-17
Author: noelanorodriguez@gmail.com
File Name: sklearn/feature_selection/_mutual_info.py
Class Name:
Method Name: _compute_mi_cd