Skip to content

Commit

Permalink
Use requests instead of wget in convert_from_ckpt.py (huggingfa…
Browse files Browse the repository at this point in the history
…ce#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]>
  • Loading branch information
Abhishek-Varma and Abhishek Varma authored Jan 31, 2023
1 parent 60d915f commit 87cf88e
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/diffusers/pipelines/stable_diffusion/convert_from_ckpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import torch

import requests
from diffusers import (
AutoencoderKL,
DDIMScheduler,
Expand Down Expand Up @@ -860,23 +861,21 @@ 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
upcast_attention = True
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)

Expand Down

0 comments on commit 87cf88e

Please sign in to comment.