--- id: spandrel version: "0.4.2" license: MIT license_treatment: permissive maintenance: active --- # 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. License: permissive · Maintenance: active · Downloads: 1.6M/mo ## 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 above — verify before relying. Spandrel loads and runs pre-trained PyTorch models by automatically detecting their architecture from model files and providing a unified interface for inference. 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 pip install spandrel uv add spandrel poetry add spandrel ## Installing spandrel 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. 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) 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. 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_current - Install friction: low - Maintenance: active - Downloads: 1.6M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags pytorch model loader, auto-detect model architecture, load pth files, pytorch model inference, model architecture detection, unified pytorch interface, pre-trained model support, pytorch-models, model-loading, image-restoration [View on SkillFed](https://skillfed.io/packages/spandrel) · [View on PyPI](https://pypi.org/project/spandrel/)