Install & Compatibility
Where this runs
tested against v0.7.4 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
py 3.10
✕ build_error
✓ 82.9s
py 3.11
✕ build_error
✓ 76.7s
py 3.12
✕ build_error
✓ 63.4s
py 3.13
✕ build_error
✓ 59.9s
py 3.9
✕ build_error
✕ timeout
4890MB installed
● package 4890MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
pretrainedmodels
✓ import pretrainedmodels
✗ from pretrainedmodels import ...
Direct import is fine, but common mistake is to import submodules incorrectly; use pretrainedmodels.__dict__ to list models.
models
✓ from pretrainedmodels import models
To access model constructors like models.resnet101()
Load a pretrained ResNet-101 model and run inference.
import torch
import pretrainedmodels
model = pretrainedmodels.__dict__['resnet101'](pretrained='imagenet')
model.eval()
print(model)
# Example inference
from pretrainedmodels import utils
import torchvision.transforms as transforms
tf = utils.TransformImage(model)
input_tensor = torch.randn(1, 3, 224, 224)
out = model(input_tensor)
print(out.shape)
Debug
Known issues
deprecatedpretrainedmodels is in maintenance mode; many models are outdated and may not work with newer PyTorch versions. Prefer torchvision's model zoo or timm.fixSwitch to torchvision.models or the timm library.
affects: >=0.7.0
gotchaThe pretrained='imagenet' argument may fail silently if checkpoint not found. Always verify the model downloads correctly.fixCheck network connectivity or manually download pretrained weights from the official repository.
affects: all
gotchaModel input sizes vary; not all models accept 224x224 images. Use utils.TransformImage to get the correct preprocessing.fixAlways use pretrainedmodels.utils.TransformImage(model) to get the right transforms.
affects: all
breakingPyTorch 1.9+ may cause compatibility issues with older model definitions. You may see AttributeError: module 'torch' has no attribute 'irfft'.fixUse torchvision or timm instead. Or pin PyTorch to 1.8.x.
affects: 0.7.4 with PyTorch >=1.9
Upgrade
Version history
0.7.4latest on PyPI · released Oct 29, 2018
Audit
Dependencies
torchrequiredCore dependency for all models and operations
torchvisionoptionalRequired for some model definitions and transforms (e.g., pretrainedmodels.utils)