Skip to content

Commit

Permalink
Merge pull request #2491 from bmaltais/dev
Browse files Browse the repository at this point in the history
v24.1.4
  • Loading branch information
bmaltais committed May 11, 2024
2 parents 8316941 + 3b771f5 commit 5ed5623
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .release
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v24.1.3
v24.1.4
5 changes: 2 additions & 3 deletions kohya_gui/common_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -1424,12 +1424,11 @@ def validate_model_path(pretrained_model_name_or_path: str) -> bool:
log.info(f"{msg} SUCCESS")
else:
# If not one of the default models, check if it's a valid local path
if not validate_file_path(pretrained_model_name_or_path):
if not validate_file_path(pretrained_model_name_or_path) and not validate_folder_path(pretrained_model_name_or_path):
log.info(f"{msg} FAILURE: not a valid file or folder")
return False

return True


def is_file_writable(file_path: str) -> bool:
"""
Checks if a file is writable.
Expand Down
2 changes: 1 addition & 1 deletion kohya_gui/dreambooth_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ def train_model(
if not validate_folder_path(reg_data_dir):
return TRAIN_BUTTON_VISIBLE

if not validate_file_path(resume):
if not validate_folder_path(resume):
return TRAIN_BUTTON_VISIBLE

if not validate_folder_path(train_data_dir):
Expand Down
18 changes: 11 additions & 7 deletions kohya_gui/finetune_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ def train_model(
if not validate_model_path(pretrained_model_name_or_path):
return TRAIN_BUTTON_VISIBLE

if not validate_file_path(resume):
if not validate_folder_path(resume):
return TRAIN_BUTTON_VISIBLE

#
Expand Down Expand Up @@ -628,8 +628,8 @@ def train_model(
run_cmd.append(caption_extension)

# Add paths for the image folder and the caption metadata file
run_cmd.append(image_folder)
run_cmd.append(os.path.join(train_dir, caption_metadata_filename))
run_cmd.append(rf"{image_folder}")
run_cmd.append(rf"{os.path.join(train_dir, caption_metadata_filename)}")

# Include the full path flag if specified
if full_path:
Expand All @@ -641,16 +641,20 @@ def train_model(
# Prepare environment variables
env = setup_environment()

# Execute the command if not just for printing
if not print_only:
subprocess.run(run_cmd, env=env)

# create images buckets
if generate_image_buckets:
# Build the command to run the preparation script
run_cmd = [
PYTHON,
rf"{scriptdir}/sd-scripts/finetune/prepare_buckets_latents.py",
image_folder,
os.path.join(train_dir, caption_metadata_filename),
os.path.join(train_dir, latent_metadata_filename),
pretrained_model_name_or_path,
rf"{image_folder}",
rf"{os.path.join(train_dir, caption_metadata_filename)}",
rf"{os.path.join(train_dir, latent_metadata_filename)}",
rf"{pretrained_model_name_or_path}",
"--batch_size",
str(batch_size),
"--max_resolution",
Expand Down
2 changes: 1 addition & 1 deletion kohya_gui/lora_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ def train_model(
if not validate_folder_path(reg_data_dir):
return TRAIN_BUTTON_VISIBLE

if not validate_file_path(resume):
if not validate_folder_path(resume):
return TRAIN_BUTTON_VISIBLE

if not validate_folder_path(train_data_dir):
Expand Down
2 changes: 1 addition & 1 deletion kohya_gui/textual_inversion_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ def train_model(
if not validate_folder_path(reg_data_dir):
return TRAIN_BUTTON_VISIBLE

if not validate_file_path(resume):
if not validate_folder_path(resume):
return TRAIN_BUTTON_VISIBLE

if not validate_folder_path(train_data_dir):
Expand Down

0 comments on commit 5ed5623

Please sign in to comment.