Skip to content

Commit

Permalink
Merge pull request #2416 from bmaltais/dev
Browse files Browse the repository at this point in the history
v24.0.9
  • Loading branch information
bmaltais committed Apr 29, 2024
2 parents f66a238 + fbd0d1a commit 415d7b2
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .release
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v24.0.8
v24.0.9
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion kohya_gui/class_basic_training.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
18 changes: 14 additions & 4 deletions kohya_gui/common_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion kohya_gui/dreambooth_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion kohya_gui/finetune_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion kohya_gui/lora_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion kohya_gui/textual_inversion_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions kohya_gui/wd14_caption_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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", ""),
Expand Down

0 comments on commit 415d7b2

Please sign in to comment.