]> khamidou — GitHub mirrors - safetensors.git/commit
Fix `convert.py` to handle diffusers, and its transformers part (#105)
authorNicolas Patry <patry.nicolas@protonmail.com>
Wed, 23 Nov 2022 14:41:15 +0000 (15:41 +0100)
committerGitHub <noreply@github.com>
Wed, 23 Nov 2022 14:41:15 +0000 (15:41 +0100)
commitf9b4a932d57a60dfdf4aa149c8fe7763c64172c4
treea95372257fa36e9b6ba7e86af6f6fbc921cb1f51
parent27cb200d5c4871cd040da63051cedaa90b435ae4
Fix `convert.py` to handle diffusers, and its transformers part (#105)

Turns out `diffusers` does rely on `transformers`:

`pytorch_model.safetensors` was not a recognized filename by
`transformers` which expects it to be named `model.safetensors`.

The convert_generic works by simply creating the new files and changing
the extension, which broke this.

Current proposed fix is to handle specially files named
`pytorch_model.bin` since they are more likely to be `transformers`
files.

This is however not necessarily true, we might want to protect with
checking against `model_info.library_name` though I feel like this is
better to just check against the name, since it's still likely to be a
transformers/diffusers/sentence-transformers thing.
bindings/python/convert.py