UserWarning: The parameter ‘pretrained’ is deprecated since 0.13 and will be removed in 0.15, please use ‘weights’ instead is a warning that is seen whenever you are coding in python using torchvisions package. Given below is the snippet of the warning:
UserWarning: The parameter 'pretrained' is deprecated since 0.13 and will be removed in 0.15, please use 'weights' instead.
I would like to share why “UserWarning The parameter ‘pretrained’ is deprecated since 0.13 and will be removed in 0.15, please use ‘weights’ instead warning is seen in your python.
Why UserWarning The parameter ‘pretrained’ is deprecated since 0.13 and will be removed in 0.15, please use ‘weights’ instead Warning is seen?
UserWarning: The parameter ‘pretrained’ is deprecated since 0.13 and will be removed in 0.15, please use ‘weights’ instead Warning is seen because “pretrained=True parameter” is soon going to be deprecated in the 0.15 version of torchvisions package in python. You have to replace it with the weights parameter instead in newer version.
The detailed solution to fix the warning “UserWarning The parameter ‘pretrained’ is deprecated since 0.13 and will be removed in 0.15, please use ‘weights’ instead”, is given below:
How to fix UserWarning: The parameter ‘pretrained’ is deprecated since 0.13 and will be removed in 0.15, please use ‘weights’ instead Warning?
To fix the “UserWarning: The parameter ‘pretrained’ is deprecated since 0.13 and will be removed in 0.15, please use ‘weights’ instead” warning, you have to use weights parameter instead of “pretrained=True parameter” parameter as “pretrained=True parameter” is soon going to be deprecated in the torchvisions package version 0.15 in python.
To fix the warning, UserWarning: The parameter ‘pretrained’ is deprecated since 0.13 and will be removed in 0.15, please use ‘weights’ instead'”, you have to follow the below mentioned steps:
The primary reason why your warning is being seen is because pretrained=True parameter is soon going to be deprecated in the new version of torchvisions package in python. You would want to replace it with the weights instead and you will have to follow the below mentioned code to achieve this:
import torchvision.models.detection as detection
weights= detection.MaskRCNN_ResNet50_FPN_Weights.DEFAULT
model = detection.maskrcnn_resnet50_fpn(weights=weights)
This should fix the warning, UserWarning: The parameter ‘pretrained’ is deprecated since 0.13 and will be removed in 0.15, please use ‘weights’ instead.
Conclusion
To fix the warning “UserWarning: The parameter ‘pretrained’ is deprecated since 0.13 and will be removed in 0.15, please use ‘weights’ instead”, you have to use weights parameter instead of “pretrained=True parameter” in the torchvisions package version 0.15 in python.