Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc559bf3

Browse files
authored
Add a sanity check to root directory finding algorithm (invoke-ai#2772)
Root directory finding algorithm is:2) use --root argument2) use INVOKEAI_ROOT environment variable3) use VIRTUAL_ENV environment variable4) use ~/invokeaiSince developers are liable to put virtual environments in theirfavorite places, not necessarily in the invokeai root directory, this PRadds a sanity check that looks for the existence of`VIRTUAL_ENV/invokeai.init`, and moves on to (4) if not found.
2 parents2c9b297 +a485515 commitc559bf3

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

‎ldm/invoke/globals.py‎

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,28 @@
1919

2020
Globals=Namespace()
2121

22-
# This is usually overwritten by the command line and/or environment variables
23-
ifos.environ.get('INVOKEAI_ROOT'):
24-
Globals.root=osp.abspath(os.environ.get('INVOKEAI_ROOT'))
25-
elifos.environ.get('VIRTUAL_ENV'):
26-
Globals.root=osp.abspath(osp.join(os.environ.get('VIRTUAL_ENV'),'..'))
27-
else:
28-
Globals.root=osp.abspath(osp.expanduser('~/invokeai'))
29-
30-
# Where to look for the initialization file
22+
# Where to look for the initialization file and other key components
3123
Globals.initfile='invokeai.init'
3224
Globals.models_file='models.yaml'
3325
Globals.models_dir='models'
3426
Globals.config_dir='configs'
3527
Globals.autoscan_dir='weights'
3628
Globals.converted_ckpts_dir='converted_ckpts'
3729

30+
# Set the default root directory. This can be overwritten by explicitly
31+
# passing the `--root <directory>` argument on the command line.
32+
# logic is:
33+
# 1) use INVOKEAI_ROOT environment variable (no check for this being a valid directory)
34+
# 2) use VIRTUAL_ENV environment variable, with a check for initfile being there
35+
# 3) use ~/invokeai
36+
37+
ifos.environ.get('INVOKEAI_ROOT'):
38+
Globals.root=osp.abspath(os.environ.get('INVOKEAI_ROOT'))
39+
elifos.environ.get('VIRTUAL_ENV')andPath(os.environ.get('VIRTUAL_ENV'),'..',Globals.initfile).exists():
40+
Globals.root=osp.abspath(osp.join(os.environ.get('VIRTUAL_ENV'),'..'))
41+
else:
42+
Globals.root=osp.abspath(osp.expanduser('~/invokeai'))
43+
3844
# Try loading patchmatch
3945
Globals.try_patchmatch=True
4046

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp