Spandrel is a library for loading and running pre-trained PyTorch models. It automatically detects the model architecture and hyper parameters from model files, and provides a unified interface for running models.
Package | architectures |
The package containing the implementations of all supported architectures. Not necessary for most user code. |
Package | util |
A module containing commonly-used functionality to implement architectures. |
From __init__.py
:
Class |
|
The abstract base class for all architectures. |
Class |
|
A registry of architectures. |
Class |
|
An entry in an ArchRegistry that describes how to detect and load a model architecture. |
Class |
|
A model that takes an image as input and returns an image. See __call__ for more information. |
Class |
|
A model that takes an image and a mask for that image as input and returns an image. See __call__ for more information. |
Class |
|
The base class of all model descriptors. |
Class |
|
Class for automatically loading a pth file into any architecture |
Class |
|
Describes whether and how a model supports tiling. |
Class |
|
A set of requirements for the size of an input image. |
Exception |
|
An error that will be thrown by ArchRegistry if the same architecture is added twice. |
Exception |
|
An error that will be thrown by .to if the model does not support the given dtype. |
Exception |
|
An error that will be thrown by ArchRegistry and ModelLoader if a model architecture is not supported. |
Constant | MAIN |
The main architecture registry of spandrel. |
Type Alias |
|
A model descriptor is a loaded model with metadata. Metadata includes the architecture, purpose, tags, and other information about the model. |
Type Alias |
|
A short string describing the purpose of the model. |
Type Alias |
|
Spandrel's type alias for PyTorch state dicts. |
Variable |
|
A unique identifier for an Architecture . |
Function | canonicalize |
Canonicalize a state dict. |
Canonicalize a state dict.
This function is used to canonicalize a state dict, so that it can be used for architecture detection and loading.
This function is not intended to be used in production code.
The main architecture registry of spandrel.
Modifying this registry will affect all ModelLoader
instances without a custom registry.
Value |
|
A model descriptor is a loaded model with metadata. Metadata includes the architecture, purpose, tags, and other information about the model.
The API of a model is described by the type of the model descriptor. E.g.
a SISR model will have a descriptor of type ImageModelDescriptor
.
Value |
|
A short string describing the purpose of the model.
SR
: Super resolutionFaceSR
: Face super resolutionInpainting
: Image inpaintingRestoration
: Image restoration (denoising, deblurring, JPEG, etc.)
Value |
|
Spandrel's type alias for PyTorch state dicts.
See https://pytorch.org/tutorials/recipes/recipes/what_is_state_dict.html
Value |
|