There is clearly a torchvision.transforms.Resize documented here:
http://pytorch.org/docs/master/torchvision/transforms.html#torchvision.transforms.Resize
but when I use it
transforms.Compose([
transforms.Resize(size=(224, 224)),
transforms.ToTensor(),
transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
])
I get the following error:
AttributeError: ‘module’ object has no attribute ‘Resize’
As soon as I change transforms.Resize(size=(224, 224)), to something else like transforms.CenterCrop(224), it starts working.
What is the reason for this problem and how can it be solved?
Thanks.
2 Likes
jpeg729
(jpeg729)
January 8, 2018, 9:52pm
2
Are you sure your version of torchvision is up to date?
If you have an old version of torchvision transforms.Scale might work.
yes, the problem was resolved after upgrading torchvision.
jpeg729
(jpeg729)
January 9, 2018, 1:06am
4
The link to the docs that you provided is for the current version of the source code.
If you replace “master” with “0.3.0” you get the docs for pytorch version 0.3.0 (which is currently the latest release) …
http://pytorch.org/docs/0.3.0/torchvision/transforms.html#torchvision.transforms.Resize
… which doesn’t make that much sense when you consider that the latest release of torchvision is version 0.2.0.
yes, I should mention that I actually upgraded both pytorch and torchvision to the latest version, and the problem was fixed.
1 Like
I’m facing the same issue with PyTorch version 1.0.1 (the latest stable release). I have installed torchvision via pip.
When I try to check the version of torchvision, I do not see the version class attribute. How do I make sure that mhy torchvision is up-to-date?
shahadatku
(Md. Shahadat Hossain)
June 7, 2020, 12:48pm
9
I am facing the same problem. How can I upgrade the torchvision?
Thanks in advance for your cooperation.
You can use this command
pip install torchvision==0.5.0+cpu -f https://download.pytorch.org/whl/torch_stable.html