fix the sys not found error when importing sd_samplers that appeared after PR
This commit is contained in:
parent
f295d90971
commit
f80c3696f6
2 changed files with 11 additions and 10 deletions
|
@ -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)
|
assert sd_path is not None, "Couldn't find Stable Diffusion in any of: " + str(possible_sd_paths)
|
||||||
|
|
||||||
path_dirs = [
|
path_dirs = [
|
||||||
(sd_path, 'ldm', 'Stable Diffusion'),
|
(sd_path, 'ldm', 'Stable Diffusion', []),
|
||||||
(os.path.join(sd_path, '../taming-transformers'), 'taming', 'Taming Transformers'),
|
(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, '../CodeFormer'), 'inference_codeformer.py', 'CodeFormer', []),
|
||||||
(os.path.join(sd_path, '../BLIP'), 'models/blip.py', 'BLIP'),
|
(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, '../latent-diffusion'), 'LDSR.py', 'LDSR', []),
|
||||||
(os.path.join(sd_path, '../k-diffusion'), 'k_diffusion/sampling.py', 'k_diffusion'),
|
(os.path.join(sd_path, '../k-diffusion'), 'k_diffusion/sampling.py', 'k_diffusion', ["atstart"]),
|
||||||
]
|
]
|
||||||
|
|
||||||
paths = {}
|
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))
|
must_exist_path = os.path.abspath(os.path.join(script_path, d, must_exist))
|
||||||
if not os.path.exists(must_exist_path):
|
if not os.path.exists(must_exist_path):
|
||||||
print(f"Warning: {what} not found at path {must_exist_path}", file=sys.stderr)
|
print(f"Warning: {what} not found at path {must_exist_path}", file=sys.stderr)
|
||||||
else:
|
else:
|
||||||
d = os.path.abspath(d)
|
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
|
paths[what] = d
|
||||||
|
|
|
@ -4,8 +4,6 @@ import torch
|
||||||
import tqdm
|
import tqdm
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
import inspect
|
import inspect
|
||||||
from modules.paths import paths
|
|
||||||
sys.path.insert(0, paths["k_diffusion"])
|
|
||||||
import k_diffusion.sampling
|
import k_diffusion.sampling
|
||||||
import ldm.models.diffusion.ddim
|
import ldm.models.diffusion.ddim
|
||||||
import ldm.models.diffusion.plms
|
import ldm.models.diffusion.plms
|
||||||
|
|
Loading…
Reference in a new issue