From 83e0eb094f6f3e504fc264ae9044ae2fbaa747cc Mon Sep 17 00:00:00 2001 From: missionfloyd Date: Thu, 28 Dec 2023 18:10:58 -0700 Subject: [PATCH] Fix displaying images that haven't already been saved Still copies already_saved_as images to temp. --- modules/ui_tempdir.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/ui_tempdir.py b/modules/ui_tempdir.py index 3a5ca8b8c..3e9f53f59 100644 --- a/modules/ui_tempdir.py +++ b/modules/ui_tempdir.py @@ -31,7 +31,7 @@ def check_tmp_file(gradio, filename): return False -def save_pil_to_file(pil_image, dir=None, format="png", cache_dir=None): +def save_pil_to_file(pil_image, cache_dir=None, format="png"): already_saved_as = getattr(pil_image, 'already_saved_as', None) if already_saved_as and os.path.isfile(already_saved_as): register_tmp_file(shared.demo, already_saved_as) @@ -42,9 +42,10 @@ def save_pil_to_file(pil_image, dir=None, format="png", cache_dir=None): return filename - if shared.opts.temp_dir != "": + if shared.opts.temp_dir: dir = shared.opts.temp_dir else: + dir = cache_dir os.makedirs(dir, exist_ok=True) use_metadata = False