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

allow loading of sd models from safetensors without online lookups using local config files #5019

Merged
merged 1 commit into from
Sep 14, 2023

Conversation

vladmandic
Copy link
Contributor

What does this PR do?

Fixes outstanding critical request that diffusers can use from_single_file method to load safetensors file
without needing to download yaml config file from github

This allows loading of safetensors to be done while offline.

Without this, any attempt to load safetensors model requires connection to github
(e.g. https://raw.githubusercontent.com/CompVis/stable-diffusion/main/configs/stable-diffusion/v1-inference.yaml)

Note that download_from_original_stable_diffusion_ckpt already has defined model_files param and its fully documented,
but it was never actually implemented. this PR completes the implementation in existing code.

Tested in SD.Next:

diffusers_load_config['config_files'] = {
    'v1': 'configs/v1-inference.yaml',
    'v2': 'configs/v2-inference-768-v.yaml',
    'xl': 'configs/sd_xl_base.yaml',
    'xl_refiner': 'configs/sd_xl_refiner.yaml',
}
if hasattr(pipeline, 'from_single_file'):
    diffusers_load_config['use_safetensors'] = True
    sd_model = pipeline.from_single_file(checkpoint_info.path, **diffusers_load_config)

Before submitting

Who can review?

@patrickvonplaten and @sayakpaul

@Nuullll
Copy link

Nuullll commented Sep 14, 2023

- Note that download_from_original_stable_diffusion_ckpt already has defined model_files param and its fully documented,
+ Note that download_from_original_stable_diffusion_ckpt already has defined config_files param and its fully documented,

Minor typo :-P

@patrickvonplaten
Copy link
Contributor

That works! Thanks

@patrickvonplaten patrickvonplaten merged commit ef29b24 into huggingface:main Sep 14, 2023
patrickvonplaten pushed a commit that referenced this pull request Sep 14, 2023
…ing local config files (#5019)

finish config_files implementation
@Louis24
Copy link

Louis24 commented Oct 9, 2023

still not fixed

yoonseokjin pushed a commit to yoonseokjin/diffusers that referenced this pull request Dec 25, 2023
…ing local config files (huggingface#5019)

finish config_files implementation
AmericanPresidentJimmyCarter pushed a commit to AmericanPresidentJimmyCarter/diffusers that referenced this pull request Apr 26, 2024
…ing local config files (huggingface#5019)

finish config_files implementation
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.

4 participants