Skip to content

Commit

Permalink
WIP for if Stability-AI/stablediffusion#269 gets merged
Browse files Browse the repository at this point in the history
  • Loading branch information
akx committed May 30, 2023
1 parent b957dcf commit ddeadc8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
18 changes: 4 additions & 14 deletions modules/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,12 @@
# data_path = cmd_opts_pre.data
sys.path.insert(0, script_path)

# search for directory of stable diffusion in following places
sd_path = None
possible_sd_paths = [os.path.join(script_path, 'repositories/stable-diffusion-stability-ai'), '.', os.path.dirname(script_path)]
for possible_sd_path in possible_sd_paths:
if os.path.exists(os.path.join(possible_sd_path, 'ldm/models/diffusion/ddpm.py')):
sd_path = os.path.abspath(possible_sd_path)
break

assert sd_path is not None, f"Couldn't find Stable Diffusion in any of: {possible_sd_paths}"
repositories_path = os.path.join(script_path, "repositories")

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, '../k-diffusion'), 'k_diffusion/sampling.py', 'k_diffusion', ["atstart"]),
(os.path.join(repositories_path, 'CodeFormer'), 'inference_codeformer.py', 'CodeFormer', []),
(os.path.join(repositories_path, 'BLIP'), 'models/blip.py', 'BLIP', []),
(os.path.join(repositories_path, 'k-diffusion'), 'k_diffusion/sampling.py', 'k_diffusion', ["atstart"]),
]

paths = {}
Expand Down
8 changes: 6 additions & 2 deletions modules/sd_models_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
from modules import shared, paths, sd_disable_initialization

sd_configs_path = shared.sd_configs_path
sd_repo_configs_path = os.path.join(paths.paths['Stable Diffusion'], "configs", "stable-diffusion")

try:
from ldm import get_configs_path
sd_repo_configs_path = os.path.join(get_configs_path(), "stable-diffusion")
except ImportError:
sd_repo_configs_path = os.path.join(paths.paths['Stable Diffusion'], "configs", "stable-diffusion")


config_default = shared.sd_default_config
Expand Down Expand Up @@ -115,4 +120,3 @@ def find_checkpoint_config_near_filename(info):
return config

return None

0 comments on commit ddeadc8

Please sign in to comment.