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

Adding fix to Size method #234

Closed
antspy opened this issue Aug 30, 2017 · 2 comments
Closed

Adding fix to Size method #234

antspy opened this issue Aug 30, 2017 · 2 comments

Comments

@antspy
Copy link

antspy commented Aug 30, 2017

Hi,

There is an issue with the Size method failing when a tuple is passed as argument; it was also open here: #200

The issue itself appears easy to solve, you just have to check whether the size in input is a tuple or not. Maybe something like this:

    #call method of transforms.Scale
    def __call__(self, img):
        w, h = img.size
        if (w <= h and w == self.size) or (h <= w and h == self.size):
            return img
        if w < h:
            ow = self.size 
            oh = int(self.size * h / w) <-- issue here if self.size is a tuple
            return img.resize((ow, oh), self.interpolation)
        else:
            if isinstance(self.size, tuple): #<--- check if tuple, in which case just use it
                 return img.resize(self.size, self.interpolation)
            oh = self.size
            ow = int(self.size * w / h)
            return img.resize((ow, oh), self.interpolation)
@alykhantejani
Copy link
Contributor

Hi @antspy this has been fixed in this PR. However, a new version of torchvision has not been released. If you install from source you will have this fix.

@fmassa I think we can close this issue and #200 - perhaps we should cut a release soon too as it's been quite a few months since the last one.

@fmassa fmassa closed this as completed Sep 3, 2017
@fmassa
Copy link
Member

fmassa commented Sep 3, 2017

Thanks Aly! Yes, let's cut a release soon, maybe after #230 is implemented? Let's discuss about that tomorrow.

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

3 participants