Spandrel gives your project support for various PyTorch architectures meant for AI Super-Resolution, restoration, and inpainting. Based on the model support implemented in chaiNNer.
This a huge PR, because I fundamentally changed how we define architectures. Instead of having a single load function per architecture, each architecture now defines a <Name>Arch class that extends the new Architecture class. The basic idea is that an architecture (class) knows its ID, its name, a way to tell whether a state dict is of its own architecture (a detect method), and a way to load a state dict.
For users, this means that they can no longer just import a load function. E.g. to load a state dict manually, they now have to do this:
from spandrel.architectures.DAT import DATArch
model = DATArch().load(state_dict)
Other changes:
In preparation for splitting spandrel into multiple packages, I added a spandrel.util package with the functions that were previously in spandrel.architectures.__arch_helpers.state (things like get_seq_len).
Added a KeyCondition class to aid in the detection of the architecture based on which keys are in the state dict.
Moved SizeRequirements into its own file.
Note: the number of lines changed is overblown. I had to add one level of indentation to all load functions, so hide whitespace changes to see the actual diff.
I haven't updated the contributing docs yet, because I plan to add licensing information and an API for hyperparameters next. Docs will updated after that.
This a huge PR, because I fundamentally changed how we define architectures. Instead of having a single
load
function per architecture, each architecture now defines a<Name>Arch
class that extends the newArchitecture
class. The basic idea is that an architecture (class) knows its ID, its name, a way to tell whether a state dict is of its own architecture (adetect
method), and a way to load a state dict.For users, this means that they can no longer just import a load function. E.g. to load a state dict manually, they now have to do this:
Other changes:
spandrel.util
package with the functions that were previously inspandrel.architectures.__arch_helpers.state
(things likeget_seq_len
).KeyCondition
class to aid in the detection of the architecture based on which keys are in the state dict.SizeRequirements
into its own file.Note: the number of lines changed is overblown. I had to add one level of indentation to all
load
functions, so hide whitespace changes to see the actual diff.I haven't updated the contributing docs yet, because I plan to add licensing information and an API for hyperparameters next. Docs will updated after that.