Prevent online access when desired when using download_from_original_stable_diffusion_ckpt by w4ffl35 · Pull Request #4271 · huggingface/diffusers · GitHub
Skip to content

Prevent online access when desired when using download_from_original_stable_diffusion_ckpt - #4271

Merged
patrickvonplaten merged 1 commit into
huggingface:mainfrom
w4ffl35:convert_from_ckpt_fix
Aug 3, 2023
Merged

patrickvonplaten merged 1 commit into
huggingface:mainfrom
w4ffl35:convert_from_ckpt_fix

Conversation

@w4ffl35

@w4ffl35 w4ffl35 commented Jul 25, 2023

Copy link
Copy Markdown
Contributor
  • Bypass requests with config files option added to download_from_original_stable_diffusion_ckpt
  • Adds local_files_only flags to all from_pretrained requests

What does this PR do?

Adds local_files_only flag to all from_pretrained calls within download_from_original_stable_diffusion_ckpt function and allows config files to be passed to the function in order to prevent online access via requests when no config file is provided.

This allows developers to take advantage of logic within the function which sorts what model type is being loaded and choose the appropriate config file without requiring online access via requests call.

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@patrickvonplaten

@w4ffl35 w4ffl35 changed the title Prevent online access when desired Prevent online access when desired when using download_from_original_stable_diffusion_ckpt Jul 25, 2023
@w4ffl35
w4ffl35 marked this pull request as draft July 25, 2023 21:15
@HuggingFaceDocBuilderDev

HuggingFaceDocBuilderDev commented Jul 25, 2023 •

Copy link
Copy Markdown

- Bypass requests with config files option added to download_from_original_stable_diffusion_ckpt
- Adds local_files_only flags to all from_pretrained requests
@w4ffl35
w4ffl35 force-pushed the convert_from_ckpt_fix branch from cc1f025 to ac4ec43 Compare July 25, 2023 21:28
@w4ffl35
w4ffl35 marked this pull request as ready for review July 25, 2023 21:29
@w4ffl35

w4ffl35 commented Jul 26, 2023 •

Copy link
Copy Markdown
Contributor Author

To see why this is needed -

  1. use the latest version of diffusers or run from main
  2. acquire a ckpt / safetensors file
  3. disable your internet access
  4. load the ckpt / safetensors file with download_from_original_stable_diffusion_ckpt using the local_files_only flag set to True

your script will hang while it attempts to acquire the missing config files using requests.

On the front-end side there is virtually no way of identifying what version of Stable Diffusion a ckpt / safetensors file is (if there is, I have been unable to find documentation stating how to do so and I haven't been able to hack my own solution together).

I could perform the same checks that download_from_original_stable_diffusion_ckpt do in order to determine version, but that would require loading the ckpt / safetensors file with torch and examining the state dict prior to loading the model - inefficient.

@patrickvonplaten

Copy link
Copy Markdown
Contributor

@patrickvonplaten
patrickvonplaten merged commit 4517117 into huggingface:main Aug 3, 2023
yoonseokjin pushed a commit to yoonseokjin/diffusers that referenced this pull request Dec 25, 2023
…stable_diffusion_ckpt (huggingface#4271)

Prevent online access when desired

- Bypass requests with config files option added to download_from_original_stable_diffusion_ckpt
- Adds local_files_only flags to all from_pretrained requests
AmericanPresidentJimmyCarter pushed a commit to AmericanPresidentJimmyCarter/diffusers that referenced this pull request Apr 26, 2024
…stable_diffusion_ckpt (huggingface#4271)

Prevent online access when desired

- Bypass requests with config files option added to download_from_original_stable_diffusion_ckpt
- Adds local_files_only flags to all from_pretrained requests
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