(config) moving the 'configs' dir into the 'config' module

This allows reliable distribution of the initial 'configs' directory
with the Python package, and enables the configuration script to be running
from anywhere, as long as the virtual environment is available on the sys.path
This commit is contained in:
Eugene Brodsky 2023-01-14 02:13:01 -05:00
parent 9e22ed5c12
commit 9997fde144
13 changed files with 114 additions and 12 deletions

1
MANIFEST.in Normal file
View File

@ -0,0 +1 @@
recursive-include ldm/invoke/config/configs *

View File

@ -574,7 +574,7 @@ def import_model(model_path:str, gen, opt, completer):
if model_path.startswith(('http:','https:','ftp:')):
model_name = import_ckpt_model(model_path, gen, opt, completer)
elif os.path.exists(model_path) and model_path.endswith(('.ckpt','.safetensors')) and os.path.isfile(model_path):
model_name = import_ckpt_model(model_path, gen, opt, completer)
model_name = import_ckpt_model(model_path, gen, opt, completer)
elif re.match('^[\w.+-]+/[\w.+-]+$',model_path):
model_name = import_diffuser_model(model_path, gen, opt, completer)
elif os.path.isdir(model_path):
@ -743,7 +743,7 @@ def del_config(model_name:str, gen, opt, completer):
if input(f'Remove {model_name} from the list of models known to InvokeAI? [y] ').strip().startswith(('n','N')):
return
delete_completely = input('Completely remove the model file or directory from disk? [n] ').startswith(('y','Y'))
gen.model_manager.del_model(model_name,delete_files=delete_completely)
gen.model_manager.commit(opt.conf)
@ -1118,7 +1118,7 @@ def report_model_error(opt:Namespace, e:Exception):
if yes_to_all is not None:
sys.argv.append(yes_to_all)
import ldm.invoke.configure_invokeai as configure_invokeai
from ldm.invoke.config import configure_invokeai
configure_invokeai.main()
print('** InvokeAI will now restart')
sys.argv = previous_args

View File

@ -48,9 +48,11 @@ except ImportError:
#--------------------------globals-----------------------
Model_dir = 'models'
Weights_dir = 'ldm/stable-diffusion-v1/'
Dataset_path = './configs/INITIAL_MODELS.yaml'
Default_config_file = './configs/models.yaml'
SD_Configs = './configs/stable-diffusion'
# the initial "configs" dir is now bundled with the `config` package
Dataset_path = Path(__file__).parent / "configs" / 'INITIAL_MODELS.yaml'
Default_config_file = Path(__file__).parent / "configs" / 'models.yaml'
SD_Configs = Path(__file__).parent / "configs" / 'stable-diffusion'
assert os.path.exists(Dataset_path),"The configs directory cannot be found. Please run this script from within the invokeai runtime directory."
@ -690,7 +692,6 @@ def select_outputs(root:str,yes_to_all:bool=False):
#-------------------------------------
def initialize_rootdir(root:str,yes_to_all:bool=False):
assert os.path.exists('./configs'),'Run this script from within the InvokeAI source code directory, "InvokeAI" or the runtime directory "invokeai".'
print(f'** INITIALIZING INVOKEAI RUNTIME DIRECTORY **')
root_selected = False
@ -720,11 +721,11 @@ def initialize_rootdir(root:str,yes_to_all:bool=False):
for name in ('models','configs','embeddings','text-inversion-data','text-inversion-training-data'):
os.makedirs(os.path.join(root,name), exist_ok=True)
for src in (['configs']):
dest = os.path.join(root,src)
if not os.path.samefile(src,dest):
shutil.copytree(src,dest,dirs_exist_ok=True)
os.makedirs(outputs, exist_ok=True)
configs_src = Path(__file__).parent / "configs"
configs_dest = Path(root) / "configs"
if not os.path.samefile(configs_src, configs_dest):
shutil.copytree(configs_src, configs_dest, dirs_exist_ok=True)
init_file = os.path.join(Globals.root,Globals.initfile)

100
setup.py Normal file
View File

@ -0,0 +1,100 @@
import sys
import os
import re
from setuptools import setup, find_packages
def list_files(directory):
listing = list()
for root, dirs, files in os.walk(directory,topdown=False):
pair = (root,[os.path.join(root,f) for f in files])
listing.append(pair)
return listing
def get_version()->str:
from ldm.invoke import __version__ as version
return version
# The canonical version number is stored in the file ldm/invoke/_version.py
VERSION = get_version()
DESCRIPTION = ('An implementation of Stable Diffusion which provides various new features'
' and options to aid the image generation process')
LONG_DESCRIPTION = ('This version of Stable Diffusion features a slick WebGUI, an'
' interactive command-line script that combines text2img and img2img'
' functionality in a "dream bot" style interface, and multiple features'
' and other enhancements.')
HOMEPAGE = 'https://github.com/invoke-ai/InvokeAI'
FRONTEND_FILES = list_files('frontend/dist')
FRONTEND_FILES.append(('assets',['assets/caution.png']))
print(FRONTEND_FILES)
REQUIREMENTS=[
'accelerate',
'albumentations',
'diffusers',
'eventlet',
'flask_cors',
'flask_socketio',
'flaskwebgui',
'getpass_asterisk',
'imageio-ffmpeg',
'pyreadline3',
'realesrgan',
'send2trash',
'streamlit',
'taming-transformers-rom1504',
'test-tube',
'torch-fidelity',
'torch',
'torchvision',
'transformers',
'picklescan',
'clip',
'clipseg',
'gfpgan',
'k-diffusion',
'pypatchmatch',
]
setup(
name='InvokeAI',
version=VERSION,
description=DESCRIPTION,
long_description=LONG_DESCRIPTION,
author='The InvokeAI Project',
author_email='lincoln.stein@gmail.com',
url=HOMEPAGE,
license='MIT',
packages=find_packages(exclude=['tests.*']),
install_requires=REQUIREMENTS,
dependency_links=['https://download.pytorch.org/whl/torch_stable.html'],
python_requires='>=3.9, <3.11',
classifiers=[
'Development Status :: 4 - Beta',
'Environment :: GPU',
'Environment :: GPU :: NVIDIA CUDA',
'Environment :: MacOS X',
'Intended Audience :: End Users/Desktop',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: POSIX :: Linux',
'Operating System :: MacOS',
'Operating System :: Microsoft :: Windows',
'Programming Language :: Python :: 3 :: Only,'
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Topic :: Artistic Software',
'Topic :: Internet :: WWW/HTTP :: WSGI :: Application',
'Topic :: Internet :: WWW/HTTP :: WSGI :: Server',
'Topic :: Multimedia :: Graphics',
'Topic :: Scientific/Engineering :: Artificial Intelligence',
'Topic :: Scientific/Engineering :: Image Processing',
],
scripts = ['scripts/invoke.py','scripts/configure_invokeai.py', 'scripts/sd-metadata.py',
'scripts/images2prompt.py','scripts/merge_embeddings.py',
'scripts/textual_inversion_fe.py','scripts/textual_inversion.py'
],
data_files=FRONTEND_FILES,
include_package_data=True,
)