aboutsummaryrefslogtreecommitdiffstats
path: root/modules/postprocessing.py
diff options
context:
space:
mode:
authorAarni Koskela <akx@iki.fi>2024-01-03 22:16:58 +0000
committerAarni Koskela <akx@iki.fi>2024-01-03 22:26:30 +0000
commitd9034b48a526f0a0c3e8f0dbf7c171bf4f0597fd (patch)
treeb01be238a08893afe6c5e5ebb58715c3860a2299 /modules/postprocessing.py
parente4dcdcc9554d7ff56993f5019eb90fe4ddf1e2e7 (diff)
downloadstable-diffusion-webui-gfx803-d9034b48a526f0a0c3e8f0dbf7c171bf4f0597fd.tar.gz
stable-diffusion-webui-gfx803-d9034b48a526f0a0c3e8f0dbf7c171bf4f0597fd.tar.bz2
stable-diffusion-webui-gfx803-d9034b48a526f0a0c3e8f0dbf7c171bf4f0597fd.zip
Avoid unnecessary `isfile`/`exists` calls
Diffstat (limited to 'modules/postprocessing.py')
-rw-r--r--modules/postprocessing.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/modules/postprocessing.py b/modules/postprocessing.py
index 7850328f..7449b0dc 100644
--- a/modules/postprocessing.py
+++ b/modules/postprocessing.py
@@ -97,11 +97,12 @@ def run_postprocessing(extras_mode, image, image_folder, input_dir, output_dir,
if pp.caption:
caption_filename = os.path.splitext(fullfn)[0] + ".txt"
- if os.path.isfile(caption_filename):
+ existing_caption = ""
+ try:
with open(caption_filename, encoding="utf8") as file:
existing_caption = file.read().strip()
- else:
- existing_caption = ""
+ except FileNotFoundError:
+ pass
action = shared.opts.postprocessing_existing_caption_action
if action == 'Prepend' and existing_caption: