PyTorchCV
raw JSON → 0.0.74 verified Fri May 01 auth: no python
PyTorchCV provides a collection of computer vision models (classification, segmentation, detection, etc.) for PyTorch, with pretrained weights. Current version 0.0.74, release cadence is irregular. Requires Python >=3.10.
pip install pytorchcv Common errors
error ModuleNotFoundError: No module named 'pytorchcv' ↓
cause Package not installed or installed in wrong environment.
fix
Run: pip install pytorchcv
error KeyError: 'resnet18' ↓
cause Using incorrect model name (case or spelling).
fix
Check list of models: from pytorchcv.model_provider import get_model_list; print(get_model_list())
error AttributeError: 'NoneType' object has no attribute 'shape' ↓
cause Model returned None because pretrained weights failed to load (network issue).
fix
Ensure internet connection or set pretrained=False to load architecture without weights.
Warnings
gotcha Model names are case-sensitive and must match exactly the keys in model_provider (e.g., 'resnet18' works, 'ResNet18' does not). ↓
fix Use lowercase names; check available models via pytorchcv.model_provider.get_model_list().
deprecated Some older model APIs (e.g., direct import of model classes from pytorchcv.models) may be deprecated in future releases. Use get_model() for future compatibility. ↓
fix Replace direct class imports with get_model('model_name').
gotcha Pretrained weights download from a remote server; if the server is down or slow, model loading may fail or hang. There is no fallback or mirror. ↓
fix Set environment variable PYTORCHCV_CACHE_DIR to customize cache location; consider pre-downloading weights.
Imports
- get_model
from pytorchcv.model_provider import get_model
Quickstart
import torch
from pytorchcv.model_provider import get_model
model = get_model('resnet18', pretrained=True)
model.eval()
x = torch.randn(1, 3, 224, 224)
with torch.no_grad():
out = model(x)
print(out.shape)