Skip to content

Commit

Permalink
Minor fixes (#2480)
Browse files Browse the repository at this point in the history
* Update common_gui.py

Little fix to the `validate_model_path` function to properly handle a folder path. Currently, it errors out when a folder path is selected for a training with diffusers. 😊

* Update lora_gui.py

Switching the validation type for the resume training state path from 'file' to 'folder'.
😊

* Update common_gui.py

format

* Update common_gui.py

My last fix was wrong and was returning errors when using a default model or when the VAE was not defined. This new fix works with all possibilities.
However, when a diffusers folder is used, `validate_file_path` will show a failed check, but the operation will still succeed because `validate_folder_path` will return successfully.
  • Loading branch information
sangoi-exe committed May 11, 2024
1 parent dd083f9 commit bfc2856
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
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/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

0 comments on commit bfc2856

Please sign in to comment.