From 40aad268acaea0c7ea8bb8df0535b5b39b2e72f7 Mon Sep 17 00:00:00 2001 From: saltacc Date: Sun, 5 Mar 2023 13:10:39 -0800 Subject: [PATCH] add replace underscores option --- library/wd14_caption_gui.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/library/wd14_caption_gui.py b/library/wd14_caption_gui.py index 89de66d..99d22d8 100644 --- a/library/wd14_caption_gui.py +++ b/library/wd14_caption_gui.py @@ -5,7 +5,7 @@ from .common_gui import get_folder_path import os -def caption_images(train_data_dir, caption_extension, batch_size, thresh): +def caption_images(train_data_dir, caption_extension, batch_size, thresh, replace_underscores): # Check for caption_text_input # if caption_text_input == "": # msgbox("Caption text is missing...") @@ -24,6 +24,7 @@ def caption_images(train_data_dir, caption_extension, batch_size, thresh): run_cmd = f'accelerate launch "./finetune/tag_images_by_wd14_tagger.py"' run_cmd += f' --batch_size="{int(batch_size)}"' run_cmd += f' --thresh="{thresh}"' + run_cmd += f' --replace_underscores' if replace_underscores else '' if caption_extension != '': run_cmd += f' --caption_extension="{caption_extension}"' run_cmd += f' "{train_data_dir}"' @@ -75,11 +76,17 @@ def gradio_wd14_caption_gui_tab(): batch_size = gr.Number( value=1, label='Batch size', interactive=True ) + + replace_underscores = gr.Checkbox( + label='Replace underscores in filenames with spaces', + value=False, + interactive=True, + ) caption_button = gr.Button('Caption images') caption_button.click( caption_images, - inputs=[train_data_dir, caption_extension, batch_size, thresh], + inputs=[train_data_dir, caption_extension, batch_size, thresh, replace_underscores], show_progress=False, )