class documentation

class Architecture(ABC, Generic[T]): (source)

Known subclasses: spandrel.architectures.ATD.ATDArch, spandrel.architectures.Compact.CompactArch, spandrel.architectures.CRAFT.CRAFTArch, spandrel.architectures.DAT.DATArch, spandrel.architectures.DCTLSA.DCTLSAArch, spandrel.architectures.DITN.DITNArch, spandrel.architectures.DnCNN.DnCNNArch, spandrel.architectures.DRCT.DRCTArch, spandrel.architectures.DRUNet.DRUNetArch, spandrel.architectures.ESRGAN.ESRGANArch, spandrel.architectures.FBCNN.FBCNNArch, spandrel.architectures.FFTformer.FFTformerArch, spandrel.architectures.GFPGAN.GFPGANArch, spandrel.architectures.GRL.GRLArch, spandrel.architectures.HAT.HATArch, spandrel.architectures.HVICIDNet.HVICIDNetArch, spandrel.architectures.IPT.IPTArch, spandrel.architectures.KBNet.KBNetArch, spandrel.architectures.LaMa.LaMaArch, spandrel.architectures.MixDehazeNet.MixDehazeNetArch, spandrel.architectures.MMRealSR.MMRealSRArch, spandrel.architectures.MoSR.MoSRArch, spandrel.architectures.NAFNet.NAFNetArch, spandrel.architectures.OmniSR.OmniSRArch, spandrel.architectures.PLKSR.PLKSRArch, spandrel.architectures.RealCUGAN.RealCUGANArch, spandrel.architectures.RestoreFormer.RestoreFormerArch, spandrel.architectures.RetinexFormer.RetinexFormerArch, spandrel.architectures.RGT.RGTArch, spandrel.architectures.SAFMN.SAFMNArch, spandrel.architectures.SAFMNBCIE.SAFMNBCIEArch, spandrel.architectures.SCUNet.SCUNetArch, spandrel.architectures.SeemoRe.SeemoReArch, spandrel.architectures.SPAN.SPANArch, spandrel.architectures.SwiftSRGAN.SwiftSRGANArch, spandrel.architectures.Swin2SR.Swin2SRArch, spandrel.architectures.SwinIR.SwinIRArch, spandrel.architectures.Uformer.UformerArch, spandrel_extra_arches.architectures.AdaCode.AdaCodeArch, spandrel_extra_arches.architectures.CodeFormer.CodeFormerArch, spandrel_extra_arches.architectures.DDColor.DDColorArch, spandrel_extra_arches.architectures.FeMaSR.FeMaSRArch, spandrel_extra_arches.architectures.M3SNet.M3SNetArch, spandrel_extra_arches.architectures.MAT.MATArch, spandrel_extra_arches.architectures.MIRNet2.MIRNet2Arch, spandrel_extra_arches.architectures.MPRNet.MPRNetArch, spandrel_extra_arches.architectures.Restormer.RestormerArch, spandrel_extra_arches.architectures.SRFormer.SRFormerArch

Constructor: Architecture(id, detect, name)

View In Hierarchy

The abstract base class for all architectures.

Method __init__ Undocumented
Method detect Inspects the given state dict and returns True if it is a state dict of this architecture.
Method load Loads the given state dict into a model. The hyperparameters will automatically be deduced.
Property id The unique ID of the architecture.
Property name The name of the architecture.
Instance Variable _detect Undocumented
Instance Variable _id Undocumented
Instance Variable _name Undocumented
def __init__(self, *, id: ArchId|str, detect: Callable[[StateDict], bool], name: str|None = None): (source)
overridden in spandrel.architectures.ATD.ATDArch, spandrel.architectures.Compact.CompactArch, spandrel.architectures.CRAFT.CRAFTArch, spandrel.architectures.DAT.DATArch, spandrel.architectures.DCTLSA.DCTLSAArch, spandrel.architectures.DITN.DITNArch, spandrel.architectures.DnCNN.DnCNNArch, spandrel.architectures.DRCT.DRCTArch, spandrel.architectures.DRUNet.DRUNetArch, spandrel.architectures.ESRGAN.ESRGANArch, spandrel.architectures.FBCNN.FBCNNArch, spandrel.architectures.FFTformer.FFTformerArch, spandrel.architectures.GFPGAN.GFPGANArch, spandrel.architectures.GRL.GRLArch, spandrel.architectures.HAT.HATArch, spandrel.architectures.HVICIDNet.HVICIDNetArch, spandrel.architectures.IPT.IPTArch, spandrel.architectures.KBNet.KBNetArch, spandrel.architectures.LaMa.LaMaArch, spandrel.architectures.MixDehazeNet.MixDehazeNetArch, spandrel.architectures.MMRealSR.MMRealSRArch, spandrel.architectures.MoSR.MoSRArch, spandrel.architectures.NAFNet.NAFNetArch, spandrel.architectures.OmniSR.OmniSRArch, spandrel.architectures.PLKSR.PLKSRArch, spandrel.architectures.RealCUGAN.RealCUGANArch, spandrel.architectures.RestoreFormer.RestoreFormerArch, spandrel.architectures.RetinexFormer.RetinexFormerArch, spandrel.architectures.RGT.RGTArch, spandrel.architectures.SAFMN.SAFMNArch, spandrel.architectures.SAFMNBCIE.SAFMNBCIEArch, spandrel.architectures.SCUNet.SCUNetArch, spandrel.architectures.SeemoRe.SeemoReArch, spandrel.architectures.SPAN.SPANArch, spandrel.architectures.SwiftSRGAN.SwiftSRGANArch, spandrel.architectures.Swin2SR.Swin2SRArch, spandrel.architectures.SwinIR.SwinIRArch, spandrel.architectures.Uformer.UformerArch, spandrel_extra_arches.architectures.AdaCode.AdaCodeArch, spandrel_extra_arches.architectures.CodeFormer.CodeFormerArch, spandrel_extra_arches.architectures.DDColor.DDColorArch, spandrel_extra_arches.architectures.FeMaSR.FeMaSRArch, spandrel_extra_arches.architectures.M3SNet.M3SNetArch, spandrel_extra_arches.architectures.MAT.MATArch, spandrel_extra_arches.architectures.MIRNet2.MIRNet2Arch, spandrel_extra_arches.architectures.MPRNet.MPRNetArch, spandrel_extra_arches.architectures.Restormer.RestormerArch, spandrel_extra_arches.architectures.SRFormer.SRFormerArch

Undocumented

def detect(self, state_dict: StateDict) -> bool: (source)

Inspects the given state dict and returns True if it is a state dict of this architecture.

This guarantees that there are no false negatives, but there might be false positives. This is important to remember when ordering architectures in a registry.

(Note: while false positives are allowed, they are supposed to be rare. So we do accept bug reports for false positives.)

@abstractmethod
def load(self, state_dict: StateDict) -> ImageModelDescriptor[T]|MaskedImageModelDescriptor[T]: (source)
overridden in spandrel.architectures.ATD.ATDArch, spandrel.architectures.Compact.CompactArch, spandrel.architectures.CRAFT.CRAFTArch, spandrel.architectures.DAT.DATArch, spandrel.architectures.DCTLSA.DCTLSAArch, spandrel.architectures.DITN.DITNArch, spandrel.architectures.DnCNN.DnCNNArch, spandrel.architectures.DRCT.DRCTArch, spandrel.architectures.DRUNet.DRUNetArch, spandrel.architectures.ESRGAN.ESRGANArch, spandrel.architectures.FBCNN.FBCNNArch, spandrel.architectures.FFTformer.FFTformerArch, spandrel.architectures.GFPGAN.GFPGANArch, spandrel.architectures.GRL.GRLArch, spandrel.architectures.HAT.HATArch, spandrel.architectures.HVICIDNet.HVICIDNetArch, spandrel.architectures.IPT.IPTArch, spandrel.architectures.KBNet.KBNetArch, spandrel.architectures.LaMa.LaMaArch, spandrel.architectures.MixDehazeNet.MixDehazeNetArch, spandrel.architectures.MMRealSR.MMRealSRArch, spandrel.architectures.MoSR.MoSRArch, spandrel.architectures.NAFNet.NAFNetArch, spandrel.architectures.OmniSR.OmniSRArch, spandrel.architectures.PLKSR.PLKSRArch, spandrel.architectures.RealCUGAN.RealCUGANArch, spandrel.architectures.RestoreFormer.RestoreFormerArch, spandrel.architectures.RetinexFormer.RetinexFormerArch, spandrel.architectures.RGT.RGTArch, spandrel.architectures.SAFMN.SAFMNArch, spandrel.architectures.SAFMNBCIE.SAFMNBCIEArch, spandrel.architectures.SCUNet.SCUNetArch, spandrel.architectures.SeemoRe.SeemoReArch, spandrel.architectures.SPAN.SPANArch, spandrel.architectures.SwiftSRGAN.SwiftSRGANArch, spandrel.architectures.Swin2SR.Swin2SRArch, spandrel.architectures.SwinIR.SwinIRArch, spandrel.architectures.Uformer.UformerArch, spandrel_extra_arches.architectures.AdaCode.AdaCodeArch, spandrel_extra_arches.architectures.CodeFormer.CodeFormerArch, spandrel_extra_arches.architectures.DDColor.DDColorArch, spandrel_extra_arches.architectures.FeMaSR.FeMaSRArch, spandrel_extra_arches.architectures.M3SNet.M3SNetArch, spandrel_extra_arches.architectures.MAT.MATArch, spandrel_extra_arches.architectures.MIRNet2.MIRNet2Arch, spandrel_extra_arches.architectures.MPRNet.MPRNetArch, spandrel_extra_arches.architectures.Restormer.RestormerArch, spandrel_extra_arches.architectures.SRFormer.SRFormerArch

Loads the given state dict into a model. The hyperparameters will automatically be deduced.

The state dict is assumed to be a state dict of this architecture, meaning that detect returned True for the state dict. If this is not the case, then the behavior of this function is unspecified (the model may be loaded incorrect or an error is thrown).

@property
id: ArchId = (source)

The unique ID of the architecture.

For built-in architectures, this is the same as the module name. E.g. spandrel.architectures.RestoreFormer has the ID RestoreFormer.

@property
name: str = (source)

The name of the architecture.

This is often the same as id.

Undocumented

_id: Final[ArchId] = (source)

Undocumented

_name: Final[str] = (source)

Undocumented