aboutsummaryrefslogtreecommitdiff
path: root/modules/postprocessing.py
diff options
context:
space:
mode:
authorAUTOMATIC1111 <16777216c@gmail.com>2024-01-04 11:15:56 +0300
committerGitHub <noreply@github.com>2024-01-04 11:15:56 +0300
commit397251ba0cc1a1df2c558c28c416b64eef73a051 (patch)
treec5bd1c25eae4d890b7f5f79d938ca5e04802bafc /modules/postprocessing.py
parent149c9d223463c8fc34f53f26ca06e02be4c8835b (diff)
parentdf62ffbd2525792c115adefdbaeb7799699624b1 (diff)
Merge pull request #14527 from akx/avoid-isfiles
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: