XiaLiPKU / EMANet

The code for Expectation-Maximization Attention Networks for Semantic Segmentation (ICCV'2019 Oral)

Home Page:https://xialipku.github.io/publication/expectation-maximization-attention-networks-for-semantic-segmentation/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Why use padding for ValDataset?

rulixiang opened this issue · comments

Hey, I found the ValDataset used padding for both image and label.

#image, label = pad_inf(image, label)

def pad_inf(image, label=None):
    h, w = image.size()[-2:] 
    stride = settings.STRIDE
    pad_h = (stride + 1 - h % stride) % stride
    pad_w = (stride + 1 - w % stride) % stride
    if pad_h > 0 or pad_w > 0:
        image = F.pad(image, (0, pad_w, 0, pad_h), mode='constant', value=0.)
        if label is not None:
            label = F.pad(label, (0, pad_w, 0, pad_h), mode='constant', 
                          value=settings.IGNORE_LABEL)
    return image, label

Can you show the reasons for doing so?