2ee8ac1546400645908b61ef015cdf5d71aa34cc,utils/datasets.py,,pad_to_square,#,20

Before Change


    h, w = image_np.shape[:2]
    dim_diff = np.abs(h - w)
    pad1, pad2 = dim_diff // 2, dim_diff - dim_diff // 2
    new_shape = (max([h, w]), max([h, w]), 3)
    padded_image = np.full(new_shape, constant_value, dtype=np.float32)
    if h < w:
        padded_image[pad1 : pad1 + h, :] = image_np
        padding = (0, pad1, 0, pad2)
    else:
        padded_image[:, pad1 : pad1 + w] = image_np
        padding = (pad1, 0, pad2, 0)
    return padded_image, padding


class ImageFolder(Dataset):
    def __init__(self, folder_path, img_size=416):

After Change




def pad_to_square(img, pad_value):
    h, w, _ = img.shape
    dim_diff = np.abs(h - w)
    // Upper (left) and lower (right) padding
    pad1, pad2 = dim_diff // 2, dim_diff - dim_diff // 2
    // Determine padding
    pad = ((pad1, pad2), (0, 0), (0, 0)) if h <= w else ((0, 0), (pad1, pad2), (0, 0))
    // Add padding
    img = np.pad(img, pad, "constant", constant_values=127.5)
    return img, pad


class ImageFolder(Dataset):
    def __init__(self, folder_path, img_size=416):
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 6

Instances


Project Name: eriklindernoren/PyTorch-YOLOv3
Commit Name: 2ee8ac1546400645908b61ef015cdf5d71aa34cc
Time: 2019-04-22
Author: eriklindernoren@live.se
File Name: utils/datasets.py
Class Name:
Method Name: pad_to_square


Project Name: librosa/librosa
Commit Name: 489494cdbbd3bf9f75b37c58e15ffbbbc1dd0188
Time: 2015-01-03
Author: brian.mcfee@nyu.edu
File Name: librosa/util.py
Class Name:
Method Name: fix_length


Project Name: eriklindernoren/PyTorch-YOLOv3
Commit Name: 2ee8ac1546400645908b61ef015cdf5d71aa34cc
Time: 2019-04-22
Author: eriklindernoren@live.se
File Name: utils/datasets.py
Class Name:
Method Name: pad_to_square


Project Name: librosa/librosa
Commit Name: 8acf04da9110e1fdb5846c4bf511c8d9f29a6565
Time: 2014-11-06
Author: brian.mcfee@nyu.edu
File Name: librosa/util.py
Class Name:
Method Name: pad_center