697e7fa4f4a6e45566843adc24b126165b817ac0,src/misc_functions.py,,save_image,#,101

Before Change


    
    if isinstance(im, np.ndarray):
        if len(im.shape) == 2:
            im = np.expand_dims(im, axis=0)
        if im.shape[0] == 1:
            // Converting an image with depth = 1 to depth = 3, repeating the same values
            // For some reason PIL complains when I want to save channel image as jpg without
            // additional format in the .save()
            im = np.repeat(im, 3, axis=0)
            // Convert to values to range 1-255 and W,H, D
        // A bandaid fix to an issue with gradcam
        if im.shape[0] == 3 and np.max(im) == 1:
            im = im.transpose(1, 2, 0) * 255
        elif im.shape[0] == 3 and np.max(im) > 1:
            im = im.transpose(1, 2, 0)
        im = Image.fromarray(im.astype(np.uint8))
    im.save(path)


def preprocess_image(pil_im, resize_im=True):

After Change


        im_as_arr (Numpy array): Matrix of shape DxWxH
        path (str): Path to the image
    
    if isinstance(im, (np.ndarray, np.generic)):
        im = format_np_output(im)
        im = Image.fromarray(im)
    im.save(path)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 3

Instances


Project Name: utkuozbulak/pytorch-cnn-visualizations
Commit Name: 697e7fa4f4a6e45566843adc24b126165b817ac0
Time: 2019-05-03
Author: utku.ozbulak@gmail.com
File Name: src/misc_functions.py
Class Name:
Method Name: save_image


Project Name: xinntao/BasicSR
Commit Name: 6917d8a3dbf6617f02b1247fd50fbc20d3cb6fd4
Time: 2018-06-10
Author: wxt1994@126.com
File Name: codes/data/LR_dataset.py
Class Name: LRDataset
Method Name: __getitem__


Project Name: kundajelab/dragonn
Commit Name: 530367b89414bf6570a2e1a70bc9fa71035274bc
Time: 2019-07-10
Author: annashcherbina@gmail.com
File Name: dragonn/interpret/ism.py
Class Name:
Method Name: in_silico_mutagenesis