Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Safetensors loading in "convert_diffusers_to_original_stable_diffusion" #2054

Merged
merged 3 commits into from
Jan 23, 2023

Conversation

cafeai
Copy link
Contributor

@cafeai cafeai commented Jan 21, 2023

What does this PR do?

The convert_diffusers_to_original_stable_diffusion.py script currently only supports loading SD diffusers models in pytorch format. An update has been made to check to see if safetensors versions of the files exist before deserialization takes place. If safetensors versions exist, these are deserialized. If not, the pytorch version is attempted to be deserialized.

Usage Changes

No changes to the command line options are made. The detection happens behind the scenes.

Adds diffusers format saftetensors loading support
@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Jan 21, 2023

The documentation is not available anymore as the PR was closed or merged.

@patrickvonplaten
Copy link
Contributor

That is nice, it means the script automatically detects if the format is safetensors or not?

Note that we have an argument --from_safetensors should we maybe deprecate this one then?

@cafeai
Copy link
Contributor Author

cafeai commented Jan 22, 2023

Yes, the script automatically detects if the diffusers folders contain safetensors or not, and will load accordingly.

I suppose from a security point of view, you could make the argument that it may be useful to have a command line option that will force the script to fail if the version is not safetensors, instead of loading it automatically.

I can refactor so that it falls in line with --from_safetensors, as there is an added security benefit.

Another option is to add an argument like --only-allow-safe-loading where the script fails if and only if a safetensors format isn't detected to be loaded (or a potential future "safe" format). That way people who don't care can just have the script load any file type, without having to know what the original format is, or enforce safetensors if they so desire.

Thanks for your time!

Copy link
Contributor

@patrickvonplaten patrickvonplaten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually think this is very nice as is - let's merge it :-)

@patrickvonplaten patrickvonplaten merged commit d75ad93 into huggingface:main Jan 23, 2023
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.

3 participants