Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about utils.joint_transforms.Scale() #55

Open
RXZ1452132 opened this issue Sep 29, 2019 · 0 comments
Open

Question about utils.joint_transforms.Scale() #55

RXZ1452132 opened this issue Sep 29, 2019 · 0 comments

Comments

@RXZ1452132
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant