3a25edce742db97d936ffb645185b520878d0c6d,dataset/resize.py,ImagenetResizer,resize_img,#ImagenetResizer#Any#Any#,23

Before Change


        width, height = img.size
        aspect_ratio = width / height
        if width <= height & width < size[0]:
            cover = img.resize((size[0], math.floor(size[0] / aspect_ratio)))
        elif width >= height & height < size[1]:
            cover = img.resize((size[1], math.floor(size[1] * aspect_ratio)))
        else:
            cover = resizeimage.resize_contain(img, size)

After Change


        wanted_width, wanted_height = size
        ratio_w, ratio_h = wanted_width / width, wanted_height / height

        if np.alltrue(ratios > 1):
            // Both sides of the image are shorter than the desired dimension,
            // so take the side that"s closer in size and enlarge the image
            // in both directions to make that one fit
            factor = min(ratio_h, ratio_w)
            img = img.resize((int(width * factor), int(height * factor)))

        // Now we have an image that"s either larger than the desired shape
        // or at least one side matches the desired shape and we can resize
        // with contain
        cover = resizeimage.resize_contain(img, size)
        cover.save(join(self.dest_dir, filename), "JPEG")

    def resize_all(self, size=(299, 299)):
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 5

Instances


Project Name: baldassarreFe/deep-koalarization
Commit Name: 3a25edce742db97d936ffb645185b520878d0c6d
Time: 2017-05-06
Author: baldassarre.fe@gmail.com
File Name: dataset/resize.py
Class Name: ImagenetResizer
Method Name: resize_img


Project Name: CellProfiler/CellProfiler
Commit Name: 09b2b1a7cab804077ad3bdaee2d86e6994ec8126
Time: 2017-09-02
Author: allen.goodman@icloud.com
File Name: cellprofiler/modules/watershed.py
Class Name: Watershed
Method Name: run


Project Name: streamlit/streamlit
Commit Name: dfe171249a251094498f4f17902f2486eb2fa941
Time: 2019-08-28
Author: arraydude@gmail.com
File Name: lib/streamlit/elements/image_proto.py
Class Name:
Method Name: _bytes_to_b64