spandrel
Give your project support for a variety of PyTorch model architectures, including auto-detecting model architecture from just .pth files. spandrel gives you arch support.
Decision gist · record as of 2026-08-14
Yes, if you work with pre-trained PyTorch models and want to avoid architecture-specific loading boilerplate. The library is actively maintained, has low install friction, uses a permissive license, and supports a wide range of image models. Start with the base package; add spandrel_extra_arches only if you need non-commercial or restrictive-license architectures. Note that you must handle tensor preparation yourself—this is not an end-to-end inference library.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.10+.
- Torch and torchvision must be installed; they are not bundled.
- The model descriptor does not automatically convert images to tensors—you must handle tensor preparation yourself.
License · maintenance · safety
MIT (permissive) — MIT license (permissive) means you can use this freely in commercial and private projects without restriction or attribution requirement.
last release 2026-02-21 (174 days)
0 known vulnerabilities (OSV.dev, 2026-08-14) · 1,553,115 downloads/mo, #3,772 on PyPI
Alternatives
Verify before relying
pip install spandrel
from spandrel import ImageModelDescriptor, ModelLoader
import torch
model = ModelLoader().load_from_file("path/to/model.pth")
assert isinstance(model, ImageModelDescriptor)
model.cuda().eval()
with torch.no_grad():
output = model(input_tensor)- Whether the package has comprehensive documentation beyond the GitHub README for all supported architectures.
- Performance characteristics when loading very large model files or running inference on CPU vs GPU.
- Whether spandrel_extra_arches is required for your specific model architecture or if the base package suffices.
What it is and what it does
Spandrel is a PyTorch model loading library that automatically detects model architecture and hyperparameters from saved model files, then wraps them in a unified interface for inference. It originated from the chaiNNer project and now serves as a central package for architecture support across the community. The library focuses on image models (super-resolution, restoration) but is designed to be extensible for other architectures.
You provide a path to a model file (.pth, .pt, .ckpt, or .safetensors), and Spandrel identifies the architecture, returns a ModelDescriptor object with metadata, and lets you call the model directly. It does not handle image-to-tensor conversion or other preprocessing—you manage that yourself. The base package includes only permissive-license architectures (MIT, Apache 2.0, public domain); restrictive-license models require the optional spandrel_extra_arches package.
Use it for
- Load and run ESRGAN, SwinIR, HAT, or other super-resolution models without manually implementing architecture detection.
- Build an image processing pipeline that supports multiple model formats and architectures through a single interface.
- Integrate community-trained PyTorch models into an application without hardcoding architecture-specific loading logic.
- Extend model support by contributing new architectures to a shared, centralized package rather than maintaining per-project implementations.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you work with pre-trained PyTorch models and want to avoid architecture-specific loading boilerplate.
The library is actively maintained, has low install friction, uses a permissive license, and supports a wide range of image models. Start with the base package; add spandrel_extra_arches only if you need non-commercial or restrictive-license architectures. Note that you must handle tensor preparation yourself—this is not an end-to-end inference library.
Install
spandrel on PyPI
Before you install
Low install friction with a pure-Python wheel. Maintenance is active with a recent release (174 days ago). Requires Python 3.10 or later and depends on torch, torchvision, and several other standard ML libraries.
Requires Python 3.10+. Torch and torchvision must be installed; they are not bundled. The model descriptor does not automatically convert images to tensors—you must handle tensor preparation yourself.
License in practice
MIT license (permissive) means you can use this freely in commercial and private projects without restriction or attribution requirement.
Quickstart
pip install spandrel
from spandrel import ImageModelDescriptor, ModelLoader
import torch
model = ModelLoader().load_from_file("path/to/model.pth")
assert isinstance(model, ImageModelDescriptor)
model.cuda().eval()
with torch.no_grad():
output = model(input_tensor)
Verify before relying
- Whether the package has comprehensive documentation beyond the GitHub README for all supported architectures.
- Performance characteristics when loading very large model files or running inference on CPU vs GPU.
- Whether spandrel_extra_arches is required for your specific model architecture or if the base package suffices.
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.10 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 6 packagestorchtorchvisionsafetensorsnumpyeinopstyping_extensions |
| Maintenance | Actively maintained 174 days since the last release |
| First released | |
| Downloads | 1,553,115 / month, #3,772 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 2 - Pre-AlphaIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Topic :: Software Development :: Libraries |
Evidence: spandrel-0.4.2-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “auto-detect model architecture”
- spandrelSpandrel loads and runs pre-trained PyTorch models by automatically…
- loadimgLoads and converts images between multiple formats—numpy arrays, PIL…
- archspecArchspec provides APIs to detect, query, and compare CPU…
Give your agent the search over MCP, or paste the wish link into any chat.
More Libraries packages
urllib3 is an HTTP client library that provides thread-safe connection pooling, SSL/TLS verification, multipart file uploads, request retries, compression support, and proxy handling for Python applications.
Requests is a Python HTTP library that simplifies sending HTTP/1.1 requests with automatic handling of headers, authentication, cookies, and response parsing.
Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.
Install it if you're building an extensible application or framework.
Provides parsing, arithmetic, and recurrence rule computation for dates and times, with timezone support and iCalendar RFC compliance.
Install it if you need to parse flexible date strings, compute relative dates, handle timezones, or work with recurrence rules—it's the de facto choice for these tasks.
Six provides utility functions to write Python code that runs on both Python 2.7 and Python 3.3+, smoothing over language differences between the two versions.
pytest is a testing framework that lets you write test functions using plain assert statements and automatically discovers and runs them, with detailed failure reporting.
See also spandrel-extra-arches · torchvision · torchtext · torchsr · facenet-pytorch · ncnn · pytorch · torch · efficientnet-pytorch · torch-model-archiver