diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2023-07-27 06:02:22 +0000 |
---|---|---|
committer | AUTOMATIC1111 <16777216c@gmail.com> | 2023-07-27 06:02:22 +0000 |
commit | 68f336bd994bed5442ad95bad6b6ad5564a5409a (patch) | |
tree | c49a1dabb84c89d2c5dbac61ea67042ea01d0e76 /modules/api | |
parent | a3ddf464a2ed24c999f67ddfef7969f8291567be (diff) | |
parent | 50973ec77c297edc3b3c581e871b970dde1af8ba (diff) | |
download | stable-diffusion-webui-gfx803-68f336bd994bed5442ad95bad6b6ad5564a5409a.tar.gz stable-diffusion-webui-gfx803-68f336bd994bed5442ad95bad6b6ad5564a5409a.tar.bz2 stable-diffusion-webui-gfx803-68f336bd994bed5442ad95bad6b6ad5564a5409a.zip |
Merge branch 'release_candidate'
Diffstat (limited to 'modules/api')
-rw-r--r-- | modules/api/api.py | 40 | ||||
-rw-r--r-- | modules/api/models.py | 6 |
2 files changed, 24 insertions, 22 deletions
diff --git a/modules/api/api.py b/modules/api/api.py index 2a4cd8a2..606db179 100644 --- a/modules/api/api.py +++ b/modules/api/api.py @@ -333,14 +333,16 @@ class Api: p.outpath_grids = opts.outdir_txt2img_grids p.outpath_samples = opts.outdir_txt2img_samples - shared.state.begin(job="scripts_txt2img") - if selectable_scripts is not None: - p.script_args = script_args - processed = scripts.scripts_txt2img.run(p, *p.script_args) # Need to pass args as list here - else: - p.script_args = tuple(script_args) # Need to pass args as tuple here - processed = process_images(p) - shared.state.end() + try: + shared.state.begin(job="scripts_txt2img") + if selectable_scripts is not None: + p.script_args = script_args + processed = scripts.scripts_txt2img.run(p, *p.script_args) # Need to pass args as list here + else: + p.script_args = tuple(script_args) # Need to pass args as tuple here + processed = process_images(p) + finally: + shared.state.end() b64images = list(map(encode_pil_to_base64, processed.images)) if send_images else [] @@ -390,14 +392,16 @@ class Api: p.outpath_grids = opts.outdir_img2img_grids p.outpath_samples = opts.outdir_img2img_samples - shared.state.begin(job="scripts_img2img") - if selectable_scripts is not None: - p.script_args = script_args - processed = scripts.scripts_img2img.run(p, *p.script_args) # Need to pass args as list here - else: - p.script_args = tuple(script_args) # Need to pass args as tuple here - processed = process_images(p) - shared.state.end() + try: + shared.state.begin(job="scripts_img2img") + if selectable_scripts is not None: + p.script_args = script_args + processed = scripts.scripts_img2img.run(p, *p.script_args) # Need to pass args as list here + else: + p.script_args = tuple(script_args) # Need to pass args as tuple here + processed = process_images(p) + finally: + shared.state.end() b64images = list(map(encode_pil_to_base64, processed.images)) if send_images else [] @@ -720,9 +724,9 @@ class Api: cuda = {'error': f'{err}'} return models.MemoryResponse(ram=ram, cuda=cuda) - def launch(self, server_name, port): + def launch(self, server_name, port, root_path): self.app.include_router(self.router) - uvicorn.run(self.app, host=server_name, port=port, timeout_keep_alive=shared.cmd_opts.timeout_keep_alive) + uvicorn.run(self.app, host=server_name, port=port, timeout_keep_alive=shared.cmd_opts.timeout_keep_alive, root_path=root_path) def kill_webui(self): restart.stop_program() diff --git a/modules/api/models.py b/modules/api/models.py index bf97b1a3..800c9b93 100644 --- a/modules/api/models.py +++ b/modules/api/models.py @@ -208,11 +208,9 @@ class PreprocessResponse(BaseModel): fields = {} for key, metadata in opts.data_labels.items(): value = opts.data.get(key) - optType = opts.typemap.get(type(metadata.default), type(metadata.default)) + optType = opts.typemap.get(type(metadata.default), type(metadata.default)) if metadata.default else Any - if metadata.default is None: - pass - elif metadata is not None: + if metadata is not None: fields.update({key: (Optional[optType], Field(default=metadata.default, description=metadata.label))}) else: fields.update({key: (Optional[optType], Field())}) |