Deprecated 'pretrained' parameter in PyTorch torchvision models - Seeking generalized solution

Hi PyTorch community,

I’ve been using the torchvision library to work with pre-trained models, and I noticed that the pretrained parameter is deprecated in recent versions. I am looking for a generalized solution that works for every model, as my model_name is dynamically configured.

In my code, I have been using the following line to instantiate the model:

model = models.__ dict __ [model_name] (pretrained=True)

I want to make sure I’m using the recommended generalized approach for loading pre-trained weights that accommodates dynamic model configurations. Could someone please guide me on the valid alternative to the deprecated pretrained parameter for dynamically configured model names?

Thank you in advance for your help!

@ptrblck and @J_Johnson please take a look at this question. Thanks!