mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
install frontend/dist into package directory
- When invokeai installed with `pip install .`, the frontend will be in the venv directory under invokeai. - When invokeai installed with `pip install -e .`, the frontend will be in the source repo. -invoke_ai_web_sever.py will look in both places using relative addressing.
This commit is contained in:
parent
b23c471cf0
commit
d079445943
@ -65,8 +65,9 @@ class InvokeAIWebServer:
|
|||||||
if opt.cors:
|
if opt.cors:
|
||||||
socketio_args["cors_allowed_origins"] = opt.cors
|
socketio_args["cors_allowed_origins"] = opt.cors
|
||||||
|
|
||||||
|
frontend_path = self.find_frontend()
|
||||||
self.app = Flask(
|
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)
|
self.socketio = SocketIO(self.app, **socketio_args)
|
||||||
@ -129,6 +130,16 @@ class InvokeAIWebServer:
|
|||||||
print(f">> Point your browser at http://{self.host}:{self.port}")
|
print(f">> Point your browser at http://{self.host}:{self.port}")
|
||||||
self.socketio.run(app=self.app, host=self.host, port=self.port)
|
self.socketio.run(app=self.app, host=self.host, port=self.port)
|
||||||
|
|
||||||
|
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):
|
def setup_app(self):
|
||||||
self.result_url = "outputs/"
|
self.result_url = "outputs/"
|
||||||
self.init_image_url = "outputs/init-images/"
|
self.init_image_url = "outputs/init-images/"
|
||||||
|
@ -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'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'\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')
|
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)
|
os.makedirs(os.path.join(root,name), exist_ok=True)
|
||||||
for src in ['configs']:
|
for src in ['configs']:
|
||||||
dest = os.path.join(root,src)
|
dest = os.path.join(root,src)
|
||||||
|
20
setup.py
20
setup.py
@ -3,13 +3,8 @@ import re
|
|||||||
|
|
||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
|
|
||||||
def frontend_files(directory):
|
def list_files(directory):
|
||||||
paths = []
|
return [os.path.join(directory,x) for x in os.listdir(directory) if os.path.isfile(os.path.join(directory,x))]
|
||||||
for (path, directories, filenames) in os.walk(directory):
|
|
||||||
for filename in filenames:
|
|
||||||
paths.append(os.path.join(path, filename))
|
|
||||||
return paths
|
|
||||||
|
|
||||||
|
|
||||||
def _get_requirements(path):
|
def _get_requirements(path):
|
||||||
try:
|
try:
|
||||||
@ -24,9 +19,6 @@ def _get_requirements(path):
|
|||||||
return packages
|
return packages
|
||||||
|
|
||||||
|
|
||||||
frontend_files = frontend_files('frontend/dist')
|
|
||||||
print(f'DEBUG: {frontend_files}')
|
|
||||||
|
|
||||||
VERSION = '2.1.4'
|
VERSION = '2.1.4'
|
||||||
DESCRIPTION = ('An implementation of Stable Diffusion which provides various new features'
|
DESCRIPTION = ('An implementation of Stable Diffusion which provides various new features'
|
||||||
' and options to aid the image generation process')
|
' and options to aid the image generation process')
|
||||||
@ -70,7 +62,11 @@ setup(
|
|||||||
'Topic :: Scientific/Engineering :: Artificial Intelligence',
|
'Topic :: Scientific/Engineering :: Artificial Intelligence',
|
||||||
'Topic :: Scientific/Engineering :: Image Processing',
|
'Topic :: Scientific/Engineering :: Image Processing',
|
||||||
],
|
],
|
||||||
scripts = ['scripts/invoke.py','scripts/configure_invokeai.py', 'scripts/sd-metadata.py'],
|
scripts = ['scripts/invoke.py','scripts/configure_invokeai.py', 'scripts/sd-metadata.py',
|
||||||
data_files=[('frontend',frontend_files)],
|
'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'))
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user