Spaces:
Runtime error
Runtime error
changed ckpt to download from hf
Browse files- .gitignore +0 -1
- app.py +1 -0
- sd.py +7 -5
.gitignore
CHANGED
@@ -2,7 +2,6 @@ venv/
|
|
2 |
AdaBins/
|
3 |
k-diffusion/
|
4 |
MiDaS/
|
5 |
-
models/*
|
6 |
pytorch3d-lite/
|
7 |
stable-diffusion/
|
8 |
.idea
|
|
|
2 |
AdaBins/
|
3 |
k-diffusion/
|
4 |
MiDaS/
|
|
|
5 |
pytorch3d-lite/
|
6 |
stable-diffusion/
|
7 |
.idea
|
app.py
CHANGED
@@ -12,6 +12,7 @@ from types import SimpleNamespace
|
|
12 |
import sd
|
13 |
|
14 |
import warnings
|
|
|
15 |
warnings.filterwarnings("ignore")
|
16 |
|
17 |
#3. Set args
|
|
|
12 |
import sd
|
13 |
|
14 |
import warnings
|
15 |
+
|
16 |
warnings.filterwarnings("ignore")
|
17 |
|
18 |
#3. Set args
|
sd.py
CHANGED
@@ -18,8 +18,8 @@ from PIL import Image
|
|
18 |
import os
|
19 |
import requests
|
20 |
|
21 |
-
#from huggingface_hub import snapshot_download
|
22 |
from omegaconf import OmegaConf
|
|
|
23 |
|
24 |
# 1. Download stable diffusion repository and set path
|
25 |
os.system("git clone https://github.com/deforum/stable-diffusion")
|
@@ -72,12 +72,11 @@ def load_model_from_config(config, ckpt, verbose=False, device='cuda', half_prec
|
|
72 |
|
73 |
print('Model loading...')
|
74 |
|
|
|
75 |
models_path = "models"
|
76 |
model_checkpoint = "sd-v1-4.ckpt"
|
77 |
ckpt_path = os.path.join(models_path, model_checkpoint)
|
78 |
-
|
79 |
-
|
80 |
-
ckpt_config_path = "./stable-diffusion/configs/stable-diffusion/v1-inference.yaml"
|
81 |
|
82 |
if os.path.exists(ckpt_path):
|
83 |
print(f"{ckpt_path} exists")
|
@@ -88,7 +87,10 @@ else:
|
|
88 |
|
89 |
print('Model downloaded.')
|
90 |
with open(os.path.join(models_path, model_checkpoint), 'wb') as model_file:
|
91 |
-
model_file.write(ckpt_request.content)
|
|
|
|
|
|
|
92 |
|
93 |
local_config = OmegaConf.load(f"{ckpt_config_path}")
|
94 |
model = load_model_from_config(local_config, f"{ckpt_path}")
|
|
|
18 |
import os
|
19 |
import requests
|
20 |
|
|
|
21 |
from omegaconf import OmegaConf
|
22 |
+
from huggingface_hub import hf_hub_download
|
23 |
|
24 |
# 1. Download stable diffusion repository and set path
|
25 |
os.system("git clone https://github.com/deforum/stable-diffusion")
|
|
|
72 |
|
73 |
print('Model loading...')
|
74 |
|
75 |
+
'''
|
76 |
models_path = "models"
|
77 |
model_checkpoint = "sd-v1-4.ckpt"
|
78 |
ckpt_path = os.path.join(models_path, model_checkpoint)
|
79 |
+
ckpt_path = snapshot_download(repo_id="CompVis/stable-diffusion-v-1-4-original", filename="sd-v1-4.ckpt")
|
|
|
|
|
80 |
|
81 |
if os.path.exists(ckpt_path):
|
82 |
print(f"{ckpt_path} exists")
|
|
|
87 |
|
88 |
print('Model downloaded.')
|
89 |
with open(os.path.join(models_path, model_checkpoint), 'wb') as model_file:
|
90 |
+
model_file.write(ckpt_request.content)'''
|
91 |
+
|
92 |
+
ckpt_path = hf_hub_download(repo_id="CompVis/stable-diffusion-v-1-4-original", filename="sd-v1-4.ckpt")
|
93 |
+
ckpt_config_path = "./stable-diffusion/configs/stable-diffusion/v1-inference.yaml"
|
94 |
|
95 |
local_config = OmegaConf.load(f"{ckpt_config_path}")
|
96 |
model = load_model_from_config(local_config, f"{ckpt_path}")
|