-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Error with transfroms.Scale when feeding iterable size #200
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
Comments
By the way here's the version of torchvision I use |
I have the same issue. I also use 0.1.8, which seems to be the latest version. The problem is easy to solve, apparently they forgot to add the option of size being a tuple (even if it specified this way). In I believe something like this would solve it:
|
I see, I just avoid using the function and directly call resize() for now.
|
Uh oh!
There was an error while loading. Please reload this page.
I'm having a problem with transforms.Scale function, which complains
TypeError: unsupported operand type(s) for /: 'tuple' and 'int'
when feeding an iterable size.
It persists even after installed latest packages.
I don't see any problem in a source code, but seems like the if statement gets True for
isinstance(self.size, int)
Here's how it fails.
>>> import torch
>>> import collections
>>> from torchvision.transforms import Scale
>>> from PIL import Image
>>> im = Image.open('pos19.jpg')
>>> Scale(size=(512,256))(im)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/ntomita/pytorch-env/lib/python2.7/site-packages/torchvision-0.1.8-py2.7.egg/torchvision/transforms.py", line 139, in __call__
TypeError: unsupported operand type(s) for /: 'tuple' and 'int'
Now checking each portion in a source.
>>> transform = Scale(size=(512, 224))
>>> isinstance(transform.size, int)
False
>>> (isinstance(transform.size, collections.Iterable) and len(transform.size) == 2)
True
Condition terms look fine, but when calling,
>>> transform(im)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/ntomita/pytorch-env/lib/python2.7/site-packages/torchvision-0.1.8-py2.7.egg/torchvision/transforms.py", line 139, in __call__
TypeError: unsupported operand type(s) for /: 'tuple' and 'int'
It fails. If I call resize directly,
>>> im.resize(transform.size, transform.interpolation)
<PIL.Image.Image image mode=L size=512x224 at 0x7F7F8C6D4F50>
works.
The text was updated successfully, but these errors were encountered: