Unverified Commit 87cf88ed authored by Abhishek Varma's avatar Abhishek Varma Committed by GitHub
Browse files

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: default avatarAbhishek Varma <abhishek@nod-labs.com>
Co-authored-by: default avatarAbhishek Varma <abhishek@nod-labs.com>
parent 60d915fb
...@@ -20,6 +20,7 @@ import tempfile ...@@ -20,6 +20,7 @@ import tempfile
import torch import torch
import requests
from diffusers import ( from diffusers import (
AutoencoderKL, AutoencoderKL,
DDIMScheduler, DDIMScheduler,
...@@ -860,11 +861,10 @@ def load_pipeline_from_original_stable_diffusion_ckpt( ...@@ -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 key_name in checkpoint and checkpoint[key_name].shape[-1] == 1024:
if not os.path.isfile("v2-inference-v.yaml"): if not os.path.isfile("v2-inference-v.yaml"):
# model_type = "v2" # model_type = "v2"
os.system( r = requests.get(
"wget -P"
" https://raw.githubusercontent.com/Stability-AI/stablediffusion/main/configs/stable-diffusion/v2-inference-v.yaml" " 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: if global_step == 110000:
# v2.1 needs to upcast attention # v2.1 needs to upcast attention
...@@ -872,11 +872,10 @@ def load_pipeline_from_original_stable_diffusion_ckpt( ...@@ -872,11 +872,10 @@ def load_pipeline_from_original_stable_diffusion_ckpt(
else: else:
if not os.path.isfile("v1-inference.yaml"): if not os.path.isfile("v1-inference.yaml"):
# model_type = "v1" # model_type = "v1"
os.system( r = requests.get(
"wget"
" https://raw.githubusercontent.com/CompVis/stable-diffusion/main/configs/stable-diffusion/v1-inference.yaml" " 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) original_config = OmegaConf.load(original_config_file)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment