chaiNNer-org / spandrel

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.
MIT License
138 stars 12 forks source link

Detect archictecture in `assert_loads_correctly` #225

Closed RunDevelopment closed 6 months ago

RunDevelopment commented 6 months ago

Since some architectures can have highly varying state dicts depending on their hyperparameters, I added an optional detect: bool = True argument to assert_loads_correctly. If enabled, assert_loads_correctly will check that the detect method of the architecture correctly identifies a model of its architecture. This means that our detect methods aren't just tested by example model files, but also by the diverse set of models used to test parameter detection.

RunDevelopment commented 6 months ago

Nice, it already found some bugs.

RunDevelopment commented 6 months ago

Error messages now look like this:

AssertionError: Failed to detect lambda: RGT(resi_connection="3conv"),
15/16 keys accepted.
1 missing key(s):
  - conv_after_body.weight
RunDevelopment commented 6 months ago

Changes to fix the 5 errors: