diff --git a/.release b/.release index e7088bda7..ddcd4c6f5 100644 --- a/.release +++ b/.release @@ -1 +1 @@ -v24.0.8 \ No newline at end of file +v24.0.9 \ No newline at end of file diff --git a/README.md b/README.md index 00f977eb2..73f256244 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ The GUI allows you to set the training parameters and generate and run the requi - [SDXL training](#sdxl-training) - [Masked loss](#masked-loss) - [Change History](#change-history) + - [2024/04/28 (v24.0.9)](#20240428-v2409) - [2024/04/26 (v24.0.8)](#20240426-v2408) - [2024/04/25 (v24.0.7)](#20240425-v2407) - [2024/04/22 (v24.0.6)](#20240422-v2406) @@ -454,6 +455,11 @@ ControlNet dataset is used to specify the mask. The mask images should be the RG ## Change History +### 2024/04/28 (v24.0.9) + +- Updated the temporary configuration file to include date and time information in the file name. This will allow for easier batching of multiple training commands, particularly useful for users who want to automate their training sessions. +- Fixed an issue with wd14 captioning where the captioning process was not functioning correctly when the recursive option was set to true. Prefixes and postfixes are now applied to all caption files in the folder. + ### 2024/04/26 (v24.0.8) - Set `max_train_steps` to 0 if not specified in older `.json` config files. diff --git a/kohya_gui/class_basic_training.py b/kohya_gui/class_basic_training.py index 91b1f258f..ee22d552b 100644 --- a/kohya_gui/class_basic_training.py +++ b/kohya_gui/class_basic_training.py @@ -323,7 +323,7 @@ def init_scheduler_controls(self) -> None: # Initialize the learning rate scheduler power textbox self.lr_scheduler_power = gr.Number( label="LR power", - minimum=1.0, + minimum=0.0, step=0.01, info="Polynomial power for polynomial scheduler", value=self.config.get("basic.lr_scheduler_power", 1.0), diff --git a/kohya_gui/common_gui.py b/kohya_gui/common_gui.py index 12947b0a8..52d4faa94 100644 --- a/kohya_gui/common_gui.py +++ b/kohya_gui/common_gui.py @@ -739,6 +739,8 @@ def add_pre_postfix( prefix: str = "", postfix: str = "", caption_file_ext: str = ".caption", + recursive: bool = False, + ) -> None: """ Add prefix and/or postfix to the content of caption files within a folder. @@ -762,10 +764,18 @@ def add_pre_postfix( # Define the image file extensions to filter image_extensions = (".jpg", ".jpeg", ".png", ".webp") - # List all image files in the folder - image_files = [ - f for f in os.listdir(folder) if f.lower().endswith(image_extensions) - ] + # If recursive is true, list all image files in the folder and its subfolders + if recursive: + image_files = [] + for root, dirs, files in os.walk(folder): + for file in files: + if file.lower().endswith(image_extensions): + image_files.append(os.path.join(root, file)) + else: + # List all image files in the folder + image_files = [ + f for f in os.listdir(folder) if f.lower().endswith(image_extensions) + ] # Iterate over the list of image files for image_file in image_files: diff --git a/kohya_gui/dreambooth_gui.py b/kohya_gui/dreambooth_gui.py index 591fe310c..8b8d8ded7 100644 --- a/kohya_gui/dreambooth_gui.py +++ b/kohya_gui/dreambooth_gui.py @@ -823,7 +823,10 @@ def train_model( # Sort the dictionary by keys config_toml_data = dict(sorted(config_toml_data.items())) - tmpfilename = "./outputs/tmpfiledbooth.toml" + current_datetime = datetime.now() + formatted_datetime = current_datetime.strftime("%Y%m%d-%H%M%S") + tmpfilename = f"./outputs/config_dreambooth-{formatted_datetime}.toml" + # Save the updated TOML data back to the file with open(tmpfilename, "w", encoding="utf-8") as toml_file: toml.dump(config_toml_data, toml_file) diff --git a/kohya_gui/finetune_gui.py b/kohya_gui/finetune_gui.py index 7f0a317c9..ef384f23e 100644 --- a/kohya_gui/finetune_gui.py +++ b/kohya_gui/finetune_gui.py @@ -894,7 +894,9 @@ def train_model( # Sort the dictionary by keys config_toml_data = dict(sorted(config_toml_data.items())) - tmpfilename = "./outputs/tmpfilefinetune.toml" + current_datetime = datetime.now() + formatted_datetime = current_datetime.strftime("%Y%m%d-%H%M%S") + tmpfilename = f"./outputs/config_finetune-{formatted_datetime}.toml" # Save the updated TOML data back to the file with open(tmpfilename, "w", encoding="utf-8") as toml_file: toml.dump(config_toml_data, toml_file) diff --git a/kohya_gui/lora_gui.py b/kohya_gui/lora_gui.py index 1b823396a..02e98cd9d 100644 --- a/kohya_gui/lora_gui.py +++ b/kohya_gui/lora_gui.py @@ -1187,7 +1187,10 @@ def train_model( # Sort the dictionary by keys config_toml_data = dict(sorted(config_toml_data.items())) - tmpfilename = "./outputs/tmpfilelora.toml" + current_datetime = datetime.now() + formatted_datetime = current_datetime.strftime("%Y%m%d-%H%M%S") + tmpfilename = f"./outputs/config_lora-{formatted_datetime}.toml" + # Save the updated TOML data back to the file with open(tmpfilename, "w", encoding="utf-8") as toml_file: toml.dump(config_toml_data, toml_file) diff --git a/kohya_gui/textual_inversion_gui.py b/kohya_gui/textual_inversion_gui.py index bc4f0b3c2..b897a855a 100644 --- a/kohya_gui/textual_inversion_gui.py +++ b/kohya_gui/textual_inversion_gui.py @@ -842,7 +842,10 @@ def train_model( # Sort the dictionary by keys config_toml_data = dict(sorted(config_toml_data.items())) - tmpfilename = "./outputs/tmpfileti.toml" + current_datetime = datetime.now() + formatted_datetime = current_datetime.strftime("%Y%m%d-%H%M%S") + tmpfilename = f"./outputs/config_textual_inversion-{formatted_datetime}.toml" + # Save the updated TOML data back to the file with open(tmpfilename, "w", encoding="utf-8") as toml_file: toml.dump(config_toml_data, toml_file) diff --git a/kohya_gui/wd14_caption_gui.py b/kohya_gui/wd14_caption_gui.py index 32153e5b0..f34dbdee2 100644 --- a/kohya_gui/wd14_caption_gui.py +++ b/kohya_gui/wd14_caption_gui.py @@ -63,7 +63,7 @@ def caption_images( ] # Uncomment and modify if needed - # if always_first_tags: + # if always_first_tags != "": # run_cmd.append('--always_first_tags') # run_cmd.append(always_first_tags) @@ -138,6 +138,7 @@ def caption_images( folder=train_data_dir, caption_file_ext=caption_extension, prefix=always_first_tags, + recursive=recursive, ) log.info("...captioning done") @@ -267,7 +268,7 @@ def list_train_dirs(path): with gr.Row(): always_first_tags = gr.Textbox( label="Prefix to add to WD14 caption", - info="comma-separated list of tags to always put at the beginning, e.g. 1girl, 1boy, ", + info="comma-separated list of tags to always put at the beginning, e.g.: 1girl, 1boy, ", placeholder="(Optional)", interactive=True, value=config.get("wd14_caption.always_first_tags", ""),