Skip to content

Commit 87cf88e

Browse files
Abhishek-VarmaAbhishek Varma
andauthored
Use requests instead of wget in convert_from_ckpt.py (#2168)
-- This commit adopts `requests` in place of `wget` to fetch config `.yaml` files as part of `load_pipeline_from_original_stable_diffusion_ckpt` API. -- This was done because in Windows PowerShell one needs to explicitly ensure that `wget` binary is part of the PATH variable. If not present, this leads to the code not being able to download the `.yaml` config file. Signed-off-by: Abhishek Varma <[email protected]> Co-authored-by: Abhishek Varma <[email protected]>
1 parent 60d915f commit 87cf88e

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/diffusers/pipelines/stable_diffusion/convert_from_ckpt.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import torch
2222

23+
import requests
2324
from diffusers import (
2425
AutoencoderKL,
2526
DDIMScheduler,
@@ -860,23 +861,21 @@ def load_pipeline_from_original_stable_diffusion_ckpt(
860861
if key_name in checkpoint and checkpoint[key_name].shape[-1] == 1024:
861862
if not os.path.isfile("v2-inference-v.yaml"):
862863
# model_type = "v2"
863-
os.system(
864-
"wget -P"
864+
r = requests.get(
865865
" https://raw.githubusercontent.com/Stability-AI/stablediffusion/main/configs/stable-diffusion/v2-inference-v.yaml"
866-
f" -O {original_config_file}"
867866
)
867+
open(original_config_file, "wb").write(r.content)
868868

869869
if global_step == 110000:
870870
# v2.1 needs to upcast attention
871871
upcast_attention = True
872872
else:
873873
if not os.path.isfile("v1-inference.yaml"):
874874
# model_type = "v1"
875-
os.system(
876-
"wget"
875+
r = requests.get(
877876
" https://raw.githubusercontent.com/CompVis/stable-diffusion/main/configs/stable-diffusion/v1-inference.yaml"
878-
f" -O {original_config_file}"
879877
)
878+
open(original_config_file, "wb").write(r.content)
880879

881880
original_config = OmegaConf.load(original_config_file)
882881

0 commit comments

Comments
 (0)