yangxy / GPEN

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

UserWarning: The parameter 'pretrained' is deprecated since 0.13

elen07zz opened this issue · comments

commented

I am getting this error/warning every time I run the script.
Some help please?

C:\Users\xxxxx\anaconda3\envs\GPEN\lib\site-packages\torchvision\models_utils.py:208: UserWarning: The parameter 'pretrained' is deprecated since 0.13 and will be removed in 0.15, please use 'weights' instead.
warnings.warn(
C:\Users\xxxx\anaconda3\envs\GPEN\lib\site-packages\torchvision\models_utils.py:223: UserWarning: Arguments other than a weight enum or None for 'weights' are deprecated since 0.13 and will be removed in 0.15. The current behavior is equivalent to passing weights=None.
warnings.warn(msg)

commented

pip install --upgrade torchvision==0.12
dowgrading torchvision from 0.13 to 012 fixes that warning

That's because the new version torchvision(from 0.13) offer a "Multi-weight support API".
And the parameter to load the pretrained model function was changed from "pretrained=True" to "weights=pretrained model parameter version".
If you don't know the version to use,try"weights=models.ResNet50_Weights.DEFAULT" to load the newest version.
e.g.:
model_new = models.resnet50(weights=models.ResNet50_Weights.DEFAULT)
Also,you can downgrade the version of torchvison to 0.12,but I don't recommend it because the old version code "pretrained=True" will be Deprecated in a future torchvision 0.15 release.

reference1
reference2