{"id":7736,"library":"spandrel-extra-arches","title":"spandrel-extra-arches","description":"spandrel-extra-arches is a Python library that implements various PyTorch model architectures with restrictive licenses, designed to extend the capabilities of the core `spandrel` package. It enables `spandrel` to automatically detect and load models that might have non-commercial or other specific license requirements, segregating them from `spandrel`'s permissively licensed architectures. The current version is 0.2.0, released on September 15, 2024, and it is actively maintained and developed in conjunction with `spandrel`.","status":"active","version":"0.2.0","language":"en","source_language":"en","source_url":"https://github.com/chaiNNer-org/spandrel","tags":["spandrel","pytorch architecture","pytorch","model architecture","deep learning","image restoration"],"install":[{"cmd":"pip install spandrel-extra-arches","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"This library extends spandrel with additional model architectures.","package":"spandrel","optional":false},{"reason":"Provides PyTorch functionalities for the model architectures.","package":"torch","optional":false}],"imports":[{"note":"While direct import is possible for specific architectures, typical usage involves `spandrel`'s auto-detection mechanism after installation. This example demonstrates a direct architectural class import if needed.","symbol":"RCAN","correct":"from spandrel_extra_arches.architectures.rcan.__arch.rcan import RCAN"}],"quickstart":{"code":"import torch\nfrom spandrel import Spandrel\n\n# Ensure spandrel-extra-arches is installed (pip install spandrel-extra-arches)\n# spandrel will automatically discover architectures provided by spandrel-extra-arches\n\n# Example: Assuming you have a .pth model file for an architecture in spandrel-extra-arches\n# For demonstration, let's pretend 'my_extra_arch_model.pth' is an RCAN model.\n# In a real scenario, `spandrel.Spandrel()` would detect the architecture type.\n\ntry:\n    # This path would be to an actual model file\n    model_path = 'my_extra_arch_model.pth'\n    # Create a dummy model file for demonstration if it doesn't exist\n    if not torch.exists(model_path):\n        # This is a placeholder. A real model would be loaded from a file.\n        # In practice, you'd download a .pth file for an extra arch model.\n        print(f\"[INFO] No model file found at {model_path}. Skipping model loading example.\")\n        print(\"[INFO] Please provide a valid .pth model file for an architecture supported by spandrel-extra-arches to run this part.\")\n    else:\n        # Load the model using spandrel\n        spandrel_model = Spandrel(model_path)\n        print(f\"Model loaded successfully: {spandrel_model.name} - {spandrel_model.arch_name}\")\n        \n        # Example of getting the underlying PyTorch module\n        pytorch_module = spandrel_model.model\n        print(f\"PyTorch module type: {type(pytorch_module)}\")\n\nexcept Exception as e:\n    print(f\"An error occurred during model loading: {e}\")","lang":"python","description":"This quickstart demonstrates how to use the `spandrel` library to load a model file, which would implicitly utilize the architectures provided by `spandrel-extra-arches` if one of its models is detected. The `spandrel` library handles the automatic detection and instantiation of the correct architecture."},"warnings":[{"fix":"Always check the license of specific architectures before use, especially for commercial or closed-source applications.","message":"Many architectures within `spandrel-extra-arches` are subject to restrictive licenses (e.g., non-commercial use only). Users engaging in commercial or closed-source projects MUST carefully review the individual licenses of each architecture they intend to use.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Update model instantiation calls to use keyword arguments exclusively, e.g., `MyArch(scale=2, channels=3)` instead of `MyArch(2, 3)`.","message":"Starting with `spandrel` v0.4.0 (released alongside `spandrel-extra-arches` v0.2.0), all architectures now require keyword arguments for instantiation. Code that previously used positional arguments for initializing models might break.","severity":"breaking","affected_versions":"spandrel-extra-arches >=0.2.0 (when used with spandrel >=0.4.0)"},{"fix":"Ensure your Python environment is version 3.10 or newer when using `spandrel-extra-arches` with the latest `spandrel` package.","message":"While `spandrel-extra-arches` itself specifies `requires_python: >=3.8`, the core `spandrel` library, which is a dependency and the primary interface, has recently dropped support for Python 3.8 and 3.9, now requiring Python >=3.10. Using `spandrel-extra-arches` with older Python versions (3.8, 3.9) might lead to incompatibility issues with `spandrel`.","severity":"gotcha","affected_versions":"spandrel-extra-arches <0.2.0 (if spandrel is updated), spandrel-extra-arches >=0.2.0 (if used with spandrel <0.4.0)"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"First, ensure `spandrel-extra-arches` is installed via `pip install spandrel-extra-arches`. If directly importing, double-check the exact import path and architecture name against the library's source code or documentation.","cause":"The `spandrel-extra-arches` package is either not installed, or the specified architecture path is incorrect or does not exist. This can happen if attempting a direct import before installation or if an unsupported architecture name is used.","error":"ModuleNotFoundError: No module named 'spandrel_extra_arches.architectures.<some_arch>'"},{"fix":"Modify the instantiation call to use keyword arguments for all parameters, e.g., change `RCAN(2, 64, 16)` to `RCAN(scale=2, num_feat=64, num_rcab=16)`.","cause":"This error occurs when attempting to instantiate an architecture class with positional arguments. A recent update in `spandrel` and `spandrel-extra-arches` requires all architecture parameters to be passed as keyword arguments.","error":"TypeError: <ArchitectureClass>() takes no positional arguments"}]}