{"id":21706,"library":"pretrainedmodels","title":"Pretrained models for Pytorch","description":"A library providing pretrained models for PyTorch, including architectures like ResNet, DenseNet, Inception, and more. Version 0.7.4 is the latest release, though the project is in maintenance mode with infrequent updates. It is commonly used for transfer learning and feature extraction, but users should prefer torchvision's model zoo for active support.","status":"maintenance","version":"0.7.4","language":"python","source_language":"en","source_url":"https://github.com/cadene/pretrained-models.pytorch","tags":["pretrained","models","pytorch","transfer-learning","deep-learning"],"install":[{"cmd":"pip install pretrainedmodels","lang":"bash","label":"Default install"}],"dependencies":[{"reason":"Core dependency for all models and operations","package":"torch","optional":false},{"reason":"Required for some model definitions and transforms (e.g., pretrainedmodels.utils)","package":"torchvision","optional":true}],"imports":[{"note":"Direct import is fine, but common mistake is to import submodules incorrectly; use pretrainedmodels.__dict__ to list models.","wrong":"from pretrainedmodels import ...","symbol":"pretrainedmodels","correct":"import pretrainedmodels"},{"note":"To access model constructors like models.resnet101()","symbol":"models","correct":"from pretrainedmodels import models"}],"quickstart":{"code":"import torch\nimport pretrainedmodels\n\nmodel = pretrainedmodels.__dict__['resnet101'](pretrained='imagenet')\nmodel.eval()\nprint(model)\n\n# Example inference\nfrom pretrainedmodels import utils\nimport torchvision.transforms as transforms\n\ntf = utils.TransformImage(model)\ninput_tensor = torch.randn(1, 3, 224, 224)\nout = model(input_tensor)\nprint(out.shape)","lang":"python","description":"Load a pretrained ResNet-101 model and run inference."},"warnings":[{"fix":"Switch to torchvision.models or the timm library.","message":"pretrainedmodels is in maintenance mode; many models are outdated and may not work with newer PyTorch versions. Prefer torchvision's model zoo or timm.","severity":"deprecated","affected_versions":">=0.7.0"},{"fix":"Check network connectivity or manually download pretrained weights from the official repository.","message":"The pretrained='imagenet' argument may fail silently if checkpoint not found. Always verify the model downloads correctly.","severity":"gotcha","affected_versions":"all"},{"fix":"Always use pretrainedmodels.utils.TransformImage(model) to get the right transforms.","message":"Model input sizes vary; not all models accept 224x224 images. Use utils.TransformImage to get the correct preprocessing.","severity":"gotcha","affected_versions":"all"},{"fix":"Use torchvision or timm instead. Or pin PyTorch to 1.8.x.","message":"PyTorch 1.9+ may cause compatibility issues with older model definitions. You may see AttributeError: module 'torch' has no attribute 'irfft'.","severity":"breaking","affected_versions":"0.7.4 with PyTorch >=1.9"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use an older PyTorch version (<=1.8) or avoid models that use irfft (e.g., pnasnet).","cause":"PyTorch 1.9 removed deprecated torch.irfft; used by some models.","error":"AttributeError: module 'torch' has no attribute 'irfft'"},{"fix":"Install torchvision: pip install torchvision, then from pretrainedmodels import utils.","cause":"Missing torchvision dependency or incorrect import path.","error":"ImportError: cannot import name 'TransformImage' from 'pretrainedmodels.utils'"},{"fix":"Reduce batch size, use model.half() for half precision, or switch to CPU.","cause":"Model too large for GPU memory or batch size too big.","error":"RuntimeError: CUDA error: out of memory"},{"fix":"Set environment variable CURL_CA_BUNDLE to a valid cert bundle or use pretrainedmodels.models.__dict__['model_name'](pretrained=False) to skip download.","cause":"SSL issues when downloading pretrained weights from the internet.","error":"SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}