fix the sys not found error when importing sd_samplers that appeared after PR

This commit is contained in:
AUTOMATIC 2022-09-30 08:21:05 +03:00
parent f295d90971
commit f80c3696f6
2 changed files with 11 additions and 10 deletions

View file

@ -15,21 +15,24 @@ for possible_sd_path in possible_sd_paths:
assert sd_path is not None, "Couldn't find Stable Diffusion in any of: " + str(possible_sd_paths)
path_dirs = [
(sd_path, 'ldm', 'Stable Diffusion'),
(os.path.join(sd_path, '../taming-transformers'), 'taming', 'Taming Transformers'),
(os.path.join(sd_path, '../CodeFormer'), 'inference_codeformer.py', 'CodeFormer'),
(os.path.join(sd_path, '../BLIP'), 'models/blip.py', 'BLIP'),
(os.path.join(sd_path, '../latent-diffusion'), 'LDSR.py', 'LDSR'),
(os.path.join(sd_path, '../k-diffusion'), 'k_diffusion/sampling.py', 'k_diffusion'),
(sd_path, 'ldm', 'Stable Diffusion', []),
(os.path.join(sd_path, '../taming-transformers'), 'taming', 'Taming Transformers', []),
(os.path.join(sd_path, '../CodeFormer'), 'inference_codeformer.py', 'CodeFormer', []),
(os.path.join(sd_path, '../BLIP'), 'models/blip.py', 'BLIP', []),
(os.path.join(sd_path, '../latent-diffusion'), 'LDSR.py', 'LDSR', []),
(os.path.join(sd_path, '../k-diffusion'), 'k_diffusion/sampling.py', 'k_diffusion', ["atstart"]),
]
paths = {}
for d, must_exist, what in path_dirs:
for d, must_exist, what, options in path_dirs:
must_exist_path = os.path.abspath(os.path.join(script_path, d, must_exist))
if not os.path.exists(must_exist_path):
print(f"Warning: {what} not found at path {must_exist_path}", file=sys.stderr)
else:
d = os.path.abspath(d)
sys.path.append(d)
if "atstart" in options:
sys.path.insert(0, d)
else:
sys.path.append(d)
paths[what] = d

View file

@ -4,8 +4,6 @@ import torch
import tqdm
from PIL import Image
import inspect
from modules.paths import paths
sys.path.insert(0, paths["k_diffusion"])
import k_diffusion.sampling
import ldm.models.diffusion.ddim
import ldm.models.diffusion.plms