From 87cf88ed3d351cc4e2b7cdd462ddf7a4ebf2109e Mon Sep 17 00:00:00 2001 From: Abhishek Varma Date: Tue, 31 Jan 2023 19:05:45 +0530 Subject: [PATCH] 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 Co-authored-by: Abhishek Varma --- .../pipelines/stable_diffusion/convert_from_ckpt.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/diffusers/pipelines/stable_diffusion/convert_from_ckpt.py b/src/diffusers/pipelines/stable_diffusion/convert_from_ckpt.py index 0ea318bc3b..45788a8e29 100644 --- a/src/diffusers/pipelines/stable_diffusion/convert_from_ckpt.py +++ b/src/diffusers/pipelines/stable_diffusion/convert_from_ckpt.py @@ -20,6 +20,7 @@ import tempfile import torch +import requests from diffusers import ( AutoencoderKL, DDIMScheduler, @@ -860,11 +861,10 @@ def load_pipeline_from_original_stable_diffusion_ckpt( if key_name in checkpoint and checkpoint[key_name].shape[-1] == 1024: if not os.path.isfile("v2-inference-v.yaml"): # model_type = "v2" - os.system( - "wget -P" + r = requests.get( " https://raw.githubusercontent.com/Stability-AI/stablediffusion/main/configs/stable-diffusion/v2-inference-v.yaml" - f" -O {original_config_file}" ) + open(original_config_file, "wb").write(r.content) if global_step == 110000: # v2.1 needs to upcast attention @@ -872,11 +872,10 @@ def load_pipeline_from_original_stable_diffusion_ckpt( else: if not os.path.isfile("v1-inference.yaml"): # model_type = "v1" - os.system( - "wget" + r = requests.get( " https://raw.githubusercontent.com/CompVis/stable-diffusion/main/configs/stable-diffusion/v1-inference.yaml" - f" -O {original_config_file}" ) + open(original_config_file, "wb").write(r.content) original_config = OmegaConf.load(original_config_file)