diff options
author | AUTOMATIC <16777216c@gmail.com> | 2022-10-21 15:46:02 +0000 |
---|---|---|
committer | AUTOMATIC <16777216c@gmail.com> | 2022-10-21 15:46:02 +0000 |
commit | f49c08ea566385db339c6628f65c3a121033f67c (patch) | |
tree | 257b9112b81c5cf0f5e53393e0a00b6b38c363d2 /modules/textual_inversion | |
parent | 7464f367c31761d57e8fd46604a468e7839ff085 (diff) | |
download | stable-diffusion-webui-gfx803-f49c08ea566385db339c6628f65c3a121033f67c.tar.gz stable-diffusion-webui-gfx803-f49c08ea566385db339c6628f65c3a121033f67c.tar.bz2 stable-diffusion-webui-gfx803-f49c08ea566385db339c6628f65c3a121033f67c.zip |
prevent error spam when processing images without txt files for captions
Diffstat (limited to 'modules/textual_inversion')
-rw-r--r-- | modules/textual_inversion/preprocess.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/modules/textual_inversion/preprocess.py b/modules/textual_inversion/preprocess.py index 17e4ddc1..33eaddb6 100644 --- a/modules/textual_inversion/preprocess.py +++ b/modules/textual_inversion/preprocess.py @@ -122,11 +122,10 @@ def preprocess_work(process_src, process_dst, process_width, process_height, pre continue
existing_caption = None
-
- try:
- existing_caption = open(os.path.splitext(filename)[0] + '.txt', 'r').read()
- except Exception as e:
- print(e)
+ existing_caption_filename = os.path.splitext(filename)[0] + '.txt'
+ if os.path.exists(existing_caption_filename):
+ with open(existing_caption_filename, 'r', encoding="utf8") as file:
+ existing_caption = file.read()
if shared.state.interrupted:
break
|