Skip to content

Strip redundant model. prefix from TorchScript .pt state dicts (Adds support for big-lama.pt)#132

Open
benstaniford wants to merge 1 commit into
Acly:mainfrom
benstaniford:fix/torchscript-model-prefix-stripping
Open

Strip redundant model. prefix from TorchScript .pt state dicts (Adds support for big-lama.pt)#132
benstaniford wants to merge 1 commit into
Acly:mainfrom
benstaniford:fix/torchscript-model-prefix-stripping

Conversation

@benstaniford

@benstaniford benstaniford commented Jun 21, 2026

Copy link
Copy Markdown

Summary

  • Some TorchScript inpaint models (e.g. big-lama.pt) are saved with weights nested under an extra model. prefix (e.g. model.generator.model.1.bn_l.running_mean) that spandrel does not recognise, causing load failures.
  • When this prefix pattern is detected, strip it from all keys before passing the state dict to spandrel.
  • The fix is conditional so it has no effect on models that do not exhibit this layout.

Some TorchScript inpaint models (e.g. big-lama.pt) wrap their weights
under an extra 'model.' prefix (e.g. 'model.generator.model.1.bn_l…'),
which spandrel does not recognise. Strip the prefix when it is present
so spandrel can load these models correctly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@benstaniford benstaniford changed the title Strip redundant model. prefix from TorchScript .pt state dicts Strip redundant model. prefix from TorchScript .pt state dicts (Adds support for big-lama.pt) Jun 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant