144c6c7c2a60531ed72afe07cc575c261be9ec2f,petastorm/codecs.py,CompressedImageCodec,decode,#CompressedImageCodec#Any#Any#,69

Before Change


    def decode(self, unischema_field, value):
        Decode the image using OpenCV
        numpy_image = cv2.imdecode(np.frombuffer(value, dtype=np.uint8), cv2.IMREAD_UNCHANGED)
        return numpy_image

    def spark_dtype(self):
        return BinaryType()

After Change



        // cv returns a BGR or grayscale image. Convert to RGB (unless a grayscale image).
        image_bgr_or_gray = cv2.imdecode(np.frombuffer(value, dtype=np.uint8), cv2.IMREAD_UNCHANGED)
        if len(image_bgr_or_gray.shape) == 2:
            // Greyscale image
            return image_bgr_or_gray
        elif len(image_bgr_or_gray.shape) == 3 and image_bgr_or_gray.shape[2] == 3:
            // Convert BGR to RGB (opencv assumes BGR)
            image_rgb = image_bgr_or_gray[:, :, (2, 1, 0)]
            return image_rgb
        else:
            raise ValueError("Unexpected image dimensions. Supported dimensions are (H, W) or (H, W, 3). "
                               "Got {}".format(image_bgr_or_gray.shape))

    def spark_dtype(self):
        return BinaryType()

Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 11

Instances


Project Name: uber/petastorm
Commit Name: 144c6c7c2a60531ed72afe07cc575c261be9ec2f
Time: 2018-08-16
Author: yevgeni@uber.com
File Name: petastorm/codecs.py
Class Name: CompressedImageCodec
Method Name: decode


Project Name: google/deepvariant
Commit Name: 37651fcb98ae564f95c28fbbe3401f48731f7a0d
Time: 2018-07-30
Author: no-reply@google.com
File Name: deepvariant/realigner/window_selector.py
Class Name:
Method Name: _candidates_from_reads


Project Name: datascienceinc/Skater
Commit Name: 5f3e7ef013b7cecda55d9dd7fcc8f55cb01eee1b
Time: 2017-04-21
Author: aikramer2@gmail.com
File Name: pyinterpret/data/dataset.py
Class Name: DataManager
Method Name: __getitem__