mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
cca8d14c79
* defer patchmatch loading Because of the way that patchmatch was loaded early at import time, it was impossible to turn off the attempted loading with --no-patchmatch. In addition, the patchmatch loading messages appear early on during initialization, interfering with ability to print out the version cleanly when --version provided to invoke script. This commit creates a thin wrapper class for patch_match that is only loaded when needed, solving both problems. * create a singleton patchmatch object for use in inpainting This creates a thin wrapper to patchmatch which loads the module on demand, respecting the global "trypatchmatch" option. * address 2d round of issues in PR 2039 comments * Patchmatch->PatchMatch and misc cleanup
32 lines
1.0 KiB
Python
32 lines
1.0 KiB
Python
'''
|
|
ldm.invoke.globals defines a small number of global variables that would
|
|
otherwise have to be passed through long and complex call chains.
|
|
|
|
It defines a Namespace object named "Globals" that contains
|
|
the attributes:
|
|
|
|
- root - the root directory under which "models" and "outputs" can be found
|
|
- initfile - path to the initialization file
|
|
- try_patchmatch - option to globally disable loading of 'patchmatch' module
|
|
'''
|
|
|
|
import os
|
|
import os.path as osp
|
|
from argparse import Namespace
|
|
|
|
Globals = Namespace()
|
|
|
|
# This is usually overwritten by the command line and/or environment variables
|
|
if os.environ.get('INVOKEAI_ROOT'):
|
|
Globals.root = osp.abspath(os.environ.get('INVOKEAI_ROOT'))
|
|
elif os.environ.get('VIRTUAL_ENV'):
|
|
Globals.root = osp.abspath(osp.join(os.environ.get('VIRTUAL_ENV'), '..'))
|
|
else:
|
|
Globals.root = osp.abspath(osp.expanduser('~/invokeai'))
|
|
|
|
# Where to look for the initialization file
|
|
Globals.initfile = 'invokeai.init'
|
|
|
|
# Try loading patchmatch
|
|
Globals.try_patchmatch = True
|