From 98719c16725339ceb5ad93f895de622ab53d58ce Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Wed, 7 Jun 2023 14:49:44 -0400 Subject: [PATCH] bugfixes --- CHANGELOG.md | 10 ++++++++++ cli/train.py | 9 ++++++--- launch.py | 2 +- modules/cmd_args.py | 1 + webui.py | 31 ++++++++++++++++++------------- 5 files changed, 36 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b5eadde2..afc7a8fcf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Change Log for SD.Next +## Update for 06/07/2023 + +- reworked **installer** sequence + as some extensions are loading packages directly from their preload sequence + which was preventing some optimizations to take effect + i hope this does not cause regressions, but if it does, please report +- experimental `sd_model_dict` setting which allows you to load model dictionary + from one model and apply weights from another model specified in `sd_model_checkpoint` + results? who am i to judge :) + ## Update for 06/05/2023 Few new features and extra handling for broken extensions diff --git a/cli/train.py b/cli/train.py index 2f68bbb40..919295a77 100755 --- a/cli/train.py +++ b/cli/train.py @@ -95,7 +95,7 @@ def parse_args(): group_data = parser.add_argument_group('Dataset') group_data.add_argument('--input', type=str, default=None, required=True, help='input folder with training images') - group_data.add_argument('--output', type=str, default='', required=False, help='where to store processed images, default is system temp/train') + group_data.add_argument('--interim', type=str, default='', required=False, help='where to store processed images, default is system temp/train') group_data.add_argument('--process', type=str, default='original,interrogate,resize,square', required=False, help=f'list of possible processing steps: {valid_steps}, default: %(default)s') group_train = parser.add_argument_group('Train') @@ -176,8 +176,8 @@ def verify_args(): if not os.path.exists(args.lyco_dir) or not os.path.isdir(args.lyco_dir): log.error(f'cannot find lyco folder: {args.lyco_dir}') exit(1) - if args.output != '': - args.process_dir = args.output + if args.interim != '': + args.process_dir = args.interim else: args.process_dir = os.path.join(tempfile.gettempdir(), 'train', args.name) log.debug(f'args: {vars(args)}') @@ -375,6 +375,9 @@ def process_inputs(): if __name__ == '__main__': log.info('SD.Next train script') + server_options = util.Map(sdapi.options()) + from rich import print + print(server_options) parse_args() setup_logging() prepare_server() diff --git a/launch.py b/launch.py index 56ee77a0e..4b931e8e5 100644 --- a/launch.py +++ b/launch.py @@ -142,6 +142,7 @@ if __name__ == "__main__": installer.args = args installer.setup_logging(False) installer.log.info('Starting SD.Next') + installer.read_options() installer.check_python() installer.check_version() installer.set_environment() @@ -150,7 +151,6 @@ if __name__ == "__main__": installer.install_packages() installer.extensions_preload(parser) # adds additional args from extensions args = installer.parse_args(parser) - installer.read_options() installer.run_setup() installer.log.info(f"Server arguments: {sys.argv[1:]}") logging.disable(logging.NOTSET if args.debug else logging.DEBUG) diff --git a/modules/cmd_args.py b/modules/cmd_args.py index 7d854702c..b385961d7 100644 --- a/modules/cmd_args.py +++ b/modules/cmd_args.py @@ -25,6 +25,7 @@ group.add_argument("--freeze", action='store_true', help="Disable editing settin group.add_argument("--auth", type=str, help='Set access authentication like "user:pwd,user:pwd""', default=None) group.add_argument("--auth-file", type=str, help='Set access authentication using file, default: %(default)s', default=None) group.add_argument("--autolaunch", action='store_true', help="Open the UI URL in the system's default browser upon launch", default=False) +group.add_argument('--docs', default = False, action='store_true', help = "Mount Gradio docs at /docs, default: %(default)s") group.add_argument('--api-only', default = False, action='store_true', help = "Run in API only mode without starting UI") group.add_argument("--api-log", default=False, action='store_true', help="Enable logging of all API requests, default: %(default)s") group.add_argument("--device-id", type=str, help="Select the default CUDA device to use, default: %(default)s", default=None) diff --git a/webui.py b/webui.py index 84f4aefc9..4f34b62af 100644 --- a/webui.py +++ b/webui.py @@ -225,6 +225,21 @@ def start_ui(): import installer global local_url # pylint: disable=global-statement + gradio_kwargs = { + "version": f'0.0.{installer.git_commit}', + "title": "SD.Next", + "description": "SD.Next", + } + if cmd_opts.docs: + gradio_kwargs.update({ + "docs_url": "/docs", + "redocs_url": "/redocs", + "swagger_ui_parameters": { + "displayOperationId": True, + "showCommonExtensions": True, + "deepLinking": False, + } + }) app, local_url, share_url = shared.demo.launch( share=cmd_opts.share, server_name=server_name, @@ -239,21 +254,11 @@ def start_ui(): max_threads=64, show_api=True, favicon_path='html/logo.ico', - app_kwargs={ - "version": f'0.0.{installer.git_commit}', - "title": "SD.Next", - "description": "SD.Next", - # "docs_url": "/docs", - # "redocs_url": "/redocs", - "swagger_ui_parameters": { - "displayOperationId": True, - "showCommonExtensions": True, - "deepLinking": False, - }, - } + app_kwargs=gradio_kwargs, ) shared.log.info(f'Local URL: {local_url}') - shared.log.info(f'API Docs: {local_url[:-1]}/docs') # {local_url[:-1]}?view=api + if cmd_opts.docs: + shared.log.info(f'API Docs: {local_url[:-1]}/docs') # {local_url[:-1]}?view=api if share_url is not None: shared.log.info(f'Share URL: {share_url}') shared.log.debug(f'Gradio registered functions: {len(shared.demo.fns)}')