From b1b9dec980a0056f4d2b57ef10b00af7e4d98681 Mon Sep 17 00:00:00 2001 From: Kohya S <52813779+kohya-ss@users.noreply.github.com> Date: Wed, 3 Sep 2025 22:13:40 +0900 Subject: [PATCH] fix: add return type annotation for process_tag_replacement function and ensure tags are returned --- finetune/tag_images_by_wd14_tagger.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/finetune/tag_images_by_wd14_tagger.py b/finetune/tag_images_by_wd14_tagger.py index 38d8449b..5c426c56 100644 --- a/finetune/tag_images_by_wd14_tagger.py +++ b/finetune/tag_images_by_wd14_tagger.py @@ -239,7 +239,7 @@ def main(args): def remove_underscore(tags): return [tag.replace("_", " ") if len(tag) > 3 else tag for tag in tags] - def process_tag_replacement(tags: list[str], tag_replacements_arg: str): + def process_tag_replacement(tags: list[str], tag_replacements_arg: str) -> list[str]: # escape , and ; in tag_replacement: wd14 tag names may contain , and ;, # so user must be specified them like `aa\,bb,AA\,BB;cc\;dd,CC\;DD` which means # `aa,bb` is replaced with `AA,BB` and `cc;dd` is replaced with `CC;DD` @@ -258,6 +258,8 @@ def main(args): if source in tags: tags[tags.index(source)] = target + return tags + if default_format: with open(os.path.join(model_location, CSV_FILE), "r", encoding="utf-8") as f: reader = csv.reader(f)