aboutsummaryrefslogtreecommitdiffstats
path: root/modules/textual_inversion/preprocess.py
diff options
context:
space:
mode:
authoralg-wiki <alg.4chan@gmail.com>2022-10-11 08:32:46 +0000
committeralg-wiki <alg.4chan@gmail.com>2022-10-11 08:32:46 +0000
commitb2368a3bce663f19a7209d9cb38617e635ca6e3c (patch)
treef6d65553a2903fbd5c7ee93f10182c8a3280db4e /modules/textual_inversion/preprocess.py
parent907a88b2d0be320575c2129d8d6a1d4f3a68f9eb (diff)
downloadstable-diffusion-webui-gfx803-b2368a3bce663f19a7209d9cb38617e635ca6e3c.tar.gz
stable-diffusion-webui-gfx803-b2368a3bce663f19a7209d9cb38617e635ca6e3c.tar.bz2
stable-diffusion-webui-gfx803-b2368a3bce663f19a7209d9cb38617e635ca6e3c.zip
Switched to exception handling
Diffstat (limited to 'modules/textual_inversion/preprocess.py')
-rw-r--r--modules/textual_inversion/preprocess.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/modules/textual_inversion/preprocess.py b/modules/textual_inversion/preprocess.py
index 8290abe8..1a672725 100644
--- a/modules/textual_inversion/preprocess.py
+++ b/modules/textual_inversion/preprocess.py
@@ -12,13 +12,12 @@ def preprocess(process_src, process_dst, process_width, process_height, process_
height = process_height
src = os.path.abspath(process_src)
dst = os.path.abspath(process_dst)
- extns = [".jpg",".jpeg",".png",".webp",".bmp"]
assert src != dst, 'same directory specified as source and destination'
os.makedirs(dst, exist_ok=True)
- files = [i for i in os.listdir(src) if os.path.splitext(i.casefold())[1] in extns]
+ files = os.listdir(src)
shared.state.textinfo = "Preprocessing..."
shared.state.job_count = len(files)
@@ -47,7 +46,10 @@ def preprocess(process_src, process_dst, process_width, process_height, process_
for index, imagefile in enumerate(tqdm.tqdm(files)):
subindex = [0]
filename = os.path.join(src, imagefile)
- img = Image.open(filename).convert("RGB")
+ try:
+ img = Image.open(filename).convert("RGB")
+ except Exception:
+ continue
if shared.state.interrupted:
break