Skip to content

Question about utils.joint_transforms.Scale() #55

@RXZ1452132

Description

@RXZ1452132

Hi~
I find one question in train/cityscapes-fcn/train.py:
short_size = int(min(args['input_size']) / 0.875)
train_joint_transform = joint_transforms.Compose([
joint_transforms.Scale(short_size),
joint_transforms.RandomCrop(args['input_size']),
joint_transforms.RandomHorizontallyFlip()
])
And this is the code of function joint_transforms.Scale(short_size):

class Scale(object):
def init(self, size):
self.size = size

def __call__(self, img, mask):
    assert img.size == mask.size
    w, h = img.size
    if (w >= h and w == self.size) or (h >= w and h == self.size):
        return img, mask
    if w > h:
        ow = self.size
        oh = int(self.size * h / w)
        return img.resize((ow, oh), Image.BILINEAR), mask.resize((ow, oh), Image.NEAREST)
    else:
        oh = self.size
        ow = int(self.size * w / h)
        return img.resize((ow, oh), Image.BILINEAR), mask.resize((ow, oh), Image.NEAREST)

for example: the image size is 512256, and args['input_size'] =(256,512)
Dose that mean resize the image to 292
146(2568/7=292, 256292/512=146)? And after that function joint_transforms.RandomCrop resize it back to 256*512.
Why should we do such thing?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions