Merge branch 'development' into model-import-fixes

This commit is contained in:
Lincoln Stein 2022-11-26 16:54:21 -05:00 committed by GitHub
commit 74487a95a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 34 deletions

View File

@ -81,10 +81,9 @@ class InvokeAIWebServer:
if opt.cors:
socketio_args["cors_allowed_origins"] = opt.cors
frontend_path = self.find_frontend()
self.app = Flask(
__name__,
static_url_path="",
static_folder=os.path.join(args.root_dir, "frontend/dist"),
__name__, static_url_path="", static_folder=frontend_path
)
self.socketio = SocketIO(self.app, **socketio_args)
@ -242,6 +241,16 @@ class InvokeAIWebServer:
keyfile=args.keyfile,
)
def find_frontend(self):
my_dir = os.path.dirname(__file__)
for candidate in (os.path.join(my_dir,'..','frontend','dist'), # pip install -e .
os.path.join(my_dir,'../../../../frontend','dist') # pip install .
):
if os.path.exists(candidate):
return candidate
assert "Frontend files cannot be found. Cannot continue"
def setup_app(self):
self.result_url = "outputs/"
self.init_image_url = "outputs/init-images/"

View File

@ -126,18 +126,15 @@ class ModelCache(object):
def list_models(self) -> dict:
'''
Return a dict of models in the format:
{
model_name1: {
'status': ('active'|'cached'|'not loaded'),
'description': description,
},
model_name2: { etc },
}
{ model_name1: {'status': ('active'|'cached'|'not loaded'),
'description': description,
},
model_name2: { etc }
'''
models = {}
for name, config in self.config.items():
result = dict()
for name in self.config:
try:
description = config.description
description = self.config[name].description
except ConfigAttributeError:
description = '<no description>'
@ -148,13 +145,11 @@ class ModelCache(object):
else:
status = 'not loaded'
models = models.update(
name = {
'status': status,
'description': description,
})
return models
result[name]={
'status' : status,
'description' : description
}
return result
def print_models(self) -> None:
'''

View File

@ -592,7 +592,7 @@ def initialize_rootdir(root:str,yes_to_all:bool=False):
print(f'InvokeAI models and configuration files will be placed into {root} and image outputs will be placed into {outputs}.')
print(f'\nYou may change these values at any time by editing the --root and --output_dir options in "{Globals.initfile}",')
print(f'You may also change the runtime directory by setting the environment variable INVOKEAI_ROOT.\n')
for name in ('models','configs','scripts','frontend/dist'):
for name in ('models','configs'):
os.makedirs(os.path.join(root,name), exist_ok=True)
for src in ['configs']:
dest = os.path.join(root,src)

View File

@ -3,14 +3,8 @@ import re
from setuptools import setup, find_packages
def frontend_files(directory):
paths = []
for (path, _, filenames) in os.walk(directory):
for filename in filenames:
paths.append(os.path.join(path, filename))
return paths
def list_files(directory):
return [os.path.join(directory,x) for x in os.listdir(directory) if os.path.isfile(os.path.join(directory,x))]
def _get_requirements(path):
try:
@ -25,9 +19,6 @@ def _get_requirements(path):
return packages
frontend_files = frontend_files('frontend/dist')
print(f'DEBUG: {frontend_files}')
VERSION = '2.1.4'
DESCRIPTION = ('An implementation of Stable Diffusion which provides various new features'
' and options to aid the image generation process')
@ -72,6 +63,10 @@ setup(
'Topic :: Scientific/Engineering :: Artificial Intelligence',
'Topic :: Scientific/Engineering :: Image Processing',
],
scripts = ['scripts/invoke.py','scripts/configure_invokeai.py', 'scripts/preload_models.py', 'scripts/sd-metadata.py'],
data_files=[('frontend',frontend_files)],
scripts = ['scripts/invoke.py','scripts/configure_invokeai.py', 'scripts/sd-metadata.py',
'scripts/preload_models.py', 'scripts/images2prompt.py','scripts/merge_embeddings.py'
],
data_files=[('frontend/dist',list_files('frontend/dist')),
('frontend/dist/assets',list_files('frontend/dist/assets'))
],
)