From 95821f0132f5437ef30b0dbcac7c51e55818c18f Mon Sep 17 00:00:00 2001 From: AUTOMATIC1111 <16777216c@gmail.com> Date: Wed, 9 Aug 2023 18:11:13 +0300 Subject: split webui.py's initialization and utility functions into separate files --- modules/ui_tempdir.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'modules/ui_tempdir.py') diff --git a/modules/ui_tempdir.py b/modules/ui_tempdir.py index fb75137e..506017e5 100644 --- a/modules/ui_tempdir.py +++ b/modules/ui_tempdir.py @@ -57,8 +57,9 @@ def save_pil_to_file(self, pil_image, dir=None, format="png"): return file_obj.name -# override save to file function so that it also writes PNG info -gradio.components.IOComponent.pil_to_temp_file = save_pil_to_file +def install_ui_tempdir_override(): + """override save to file function so that it also writes PNG info""" + gradio.components.IOComponent.pil_to_temp_file = save_pil_to_file def on_tmpdir_changed(): -- cgit v1.2.1 From 299b8096bc19c8a619fbeef735cb90544350243c Mon Sep 17 00:00:00 2001 From: brkirch Date: Mon, 21 Aug 2023 17:36:17 -0400 Subject: Make Gradio temp directory if it doesn't exist Gradio normally creates the temp directory in `pil_to_temp_file()` (https://github.com/gradio-app/gradio/blob/861d752a83da0f95e9f79173069b69eababeed39/gradio/components/base.py#L313) but since the Gradio implementation of `pil_to_temp_file()` is replaced with `save_pil_to_file()`, the Gradio temp directory should also be created by `save_pil_to_file()` when necessary. --- modules/ui_tempdir.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'modules/ui_tempdir.py') diff --git a/modules/ui_tempdir.py b/modules/ui_tempdir.py index 506017e5..85015db5 100644 --- a/modules/ui_tempdir.py +++ b/modules/ui_tempdir.py @@ -44,6 +44,8 @@ def save_pil_to_file(self, pil_image, dir=None, format="png"): if shared.opts.temp_dir != "": dir = shared.opts.temp_dir + else: + os.makedirs(dir, exist_ok=True) use_metadata = False metadata = PngImagePlugin.PngInfo() -- cgit v1.2.1