From 73ed887e58114230fca0eb724e6925207b5663f8 Mon Sep 17 00:00:00 2001 From: toshiaki1729 <116595002+toshiaki1729@users.noreply.github.com> Date: Fri, 11 Nov 2022 21:48:37 +0900 Subject: [PATCH] Update dataset_tag_editor.py it will be better than previous --- dataset_tag_editor.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/dataset_tag_editor.py b/dataset_tag_editor.py index 765a394..759562d 100644 --- a/dataset_tag_editor.py +++ b/dataset_tag_editor.py @@ -155,12 +155,8 @@ class DatasetTagEditor: for img_path in filepath_set: img_dir = os.path.dirname(img_path) img_filename, img_ext = os.path.splitext(os.path.basename(img_path)) - if img_ext == '.txt': - continue - try: - img = Image.open(img_path) - except: - img.close() + ext_supported = {e for e, str in Image.registered_extensions().items() if str in Image.OPEN} + if img_ext not in ext_supported: continue text_filename = os.path.join(img_dir, img_filename+'.txt')