Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions modules/ui/AdditionalEmbeddingsTab.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from pathlib import Path

from modules.ui.ConfigList import ConfigList
from modules.util.config.TrainConfig import TrainConfig, TrainEmbeddingConfig
Expand Down Expand Up @@ -89,9 +88,9 @@ def __init__(self, master, element, i, open_command, remove_command, clone_comma
# embedding model names
components.label(top_frame, 0, 2, "base embedding:",
tooltip="The base embedding to train on. Leave empty to create a new embedding")
components.file_entry(
components.path_entry(
top_frame, 0, 3, self.ui_state, "model_name",
path_modifier=lambda x: Path(x).parent.absolute() if x.endswith(".json") else x
mode="file", path_modifier=components.json_path_modifier
)

# placeholder
Expand Down
2 changes: 1 addition & 1 deletion modules/ui/CloudTab.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def __init__(self, master, train_config: TrainConfig, ui_state: UIState, parent)

components.label(self.frame, 7, 0, "SSH keyfile path",
tooltip="Absolute path to the private key file used for SSH connections. Leave empty to rely on your system SSH configuration.")
components.file_entry(self.frame, 7, 1, self.ui_state, "secrets.cloud.key_file") #TODO Replace with path_entry in a future PR
components.path_entry(self.frame, 7, 1, self.ui_state, "secrets.cloud.key_file", mode="file")

components.label(self.frame, 8, 0, "SSH password",
tooltip="SSH password for password-based authentication. If you try to use native SCP requires sshpass to be installed. Leave empty to use key-based authentication.")
Expand Down
2 changes: 1 addition & 1 deletion modules/ui/ConceptTab.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
from modules.util.enum.ConceptType import ConceptType
from modules.util.image_util import load_image
from modules.util.ui import components
from modules.util.ui.ui_utils import DebounceTimer
from modules.util.ui.UIState import UIState
from modules.util.ui.validation import DebounceTimer

import customtkinter as ctk
from PIL import Image
Expand Down
4 changes: 2 additions & 2 deletions modules/ui/ConceptWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,14 @@ def __general_tab(self, master, concept: ConceptConfig):
# path
components.label(frame, 3, 0, "Path",
tooltip="Path where the training data is located")
components.dir_entry(frame, 3, 1, self.ui_state, "path")
components.path_entry(frame, 3, 1, self.ui_state, "path", mode="dir")
components.button(frame, 3, 2, text="download now", command=self.__download_dataset_threaded,
tooltip="Download dataset from Huggingface now, for the purpose of previewing and statistics. Otherwise, it will be downloaded when you start training. Path must be a Huggingface repository.")

# prompt source
components.label(frame, 4, 0, "Prompt Source",
tooltip="The source for prompts used during training. When selecting \"From single text file\", select a text file that contains a list of prompts")
prompt_path_entry = components.file_entry(frame, 4, 2, self.text_ui_state, "prompt_path")
prompt_path_entry = components.path_entry(frame, 4, 2, self.text_ui_state, "prompt_path", mode="file")

def set_prompt_path_entry_enabled(option: str):
if option == 'concept':
Expand Down
12 changes: 8 additions & 4 deletions modules/ui/ConvertModelUI.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import traceback
from pathlib import Path
from uuid import uuid4

from modules.util import create
Expand All @@ -8,6 +7,7 @@
from modules.util.enum.DataType import DataType
from modules.util.enum.ModelFormat import ModelFormat
from modules.util.enum.ModelType import ModelType
from modules.util.enum.PathIOType import PathIOType
from modules.util.enum.TrainingMethod import TrainingMethod
from modules.util.ModelNames import EmbeddingName, ModelNames
from modules.util.torch_util import torch_gc
Expand Down Expand Up @@ -85,9 +85,9 @@ def main_frame(self, master):
# input name
components.label(master, 2, 0, "Input name",
tooltip="Filename, directory or hugging face repository of the base model")
components.file_entry(
components.path_entry(
master, 2, 1, self.ui_state, "input_name",
path_modifier=lambda x: Path(x).parent.absolute() if x.endswith(".json") else x
mode="file", path_modifier=components.json_path_modifier
)

# output data type
Expand All @@ -110,7 +110,11 @@ def main_frame(self, master):
# output model destination
components.label(master, 5, 0, "Model Output Destination",
tooltip="Filename or directory where the output model is saved")
components.file_entry(master, 5, 1, self.ui_state, "output_model_destination", is_output=True)
components.path_entry(
master, 5, 1, self.ui_state, "output_model_destination",
mode="file",
io_type=PathIOType.MODEL,
)

self.button = components.button(master, 6, 1, "Convert", self.convert_model)

Expand Down
12 changes: 6 additions & 6 deletions modules/ui/LoraTab.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from pathlib import Path

from modules.util.config.TrainConfig import TrainConfig
from modules.util.enum.DataType import DataType
from modules.util.enum.ModelType import PeftType
from modules.util.ui import components
from modules.util.ui.UIState import UIState
from modules.util.ui.validation_helpers import check_range

import customtkinter as ctk

Expand Down Expand Up @@ -64,9 +64,9 @@ def setup_lora(self, peft_type: PeftType):
# lora model name
components.label(master, 0, 0, f"{name} base model",
tooltip=f"The base {name} to train on. Leave empty to create a new {name}")
entry = components.file_entry(
entry = components.path_entry(
master, 0, 1, self.ui_state, "lora_model_name",
path_modifier=lambda x: Path(x).parent.absolute() if x.endswith(".json") else x
mode="file", path_modifier=components.json_path_modifier
)
entry.grid(row=0, column=1, columnspan=4)

Expand All @@ -89,12 +89,12 @@ def setup_lora(self, peft_type: PeftType):
# rank
components.label(master, 1, 0, f"{name} rank",
tooltip=f"The rank parameter used when creating a new {name}")
components.entry(master, 1, 1, self.ui_state, "lora_rank")
components.entry(master, 1, 1, self.ui_state, "lora_rank", required=True, extra_validate=check_range(lower=1, message="Rank must be at least 1"))

# alpha
components.label(master, 2, 0, f"{name} alpha",
tooltip=f"The alpha parameter used when creating a new {name}")
components.entry(master, 2, 1, self.ui_state, "lora_alpha")
components.entry(master, 2, 1, self.ui_state, "lora_alpha", required=True)

# Dropout Percentage
components.label(master, 3, 0, "Dropout Probability",
Expand All @@ -119,7 +119,7 @@ def setup_lora(self, peft_type: PeftType):
# Block Size
components.label(master, 1, 0, f"{name} Block Size",
tooltip=f"The block size parameter used when creating a new {name}")
components.entry(master, 1, 1, self.ui_state, "oft_block_size")
components.entry(master, 1, 1, self.ui_state, "oft_block_size", required=True)

# COFT
components.label(master, 1, 3, "Constrained OFT (COFT)",
Expand Down
36 changes: 20 additions & 16 deletions modules/ui/ModelTab.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from pathlib import Path

from modules.util import create
from modules.util.config.TrainConfig import TrainConfig
from modules.util.enum.ConfigPart import ConfigPart
from modules.util.enum.DataType import DataType
from modules.util.enum.ModelFormat import ModelFormat
from modules.util.enum.PathIOType import PathIOType
from modules.util.enum.TrainingMethod import TrainingMethod
from modules.util.ui import components
from modules.util.ui.UIState import UIState
Expand Down Expand Up @@ -365,9 +365,9 @@ def __create_base_dtype_components(self, frame, row: int) -> int:
# base model
components.label(frame, row, 0, "Base Model",
tooltip="Filename, directory or Hugging Face repository of the base model")
components.file_entry(
components.path_entry(
frame, row, 1, self.ui_state, "base_model_name",
path_modifier=lambda x: Path(x).parent.absolute() if x.endswith(".json") else x
mode="file", path_modifier=components.json_path_modifier
)

# compile
Expand Down Expand Up @@ -410,9 +410,9 @@ def __create_base_components(
# prior model
components.label(frame, row, 0, "Prior Model",
tooltip="Filename, directory or Hugging Face repository of the prior model")
components.file_entry(
components.path_entry(
frame, row, 1, self.ui_state, "prior.model_name",
path_modifier=lambda x: Path(x).parent.absolute() if x.endswith(".json") else x
mode="file", path_modifier=components.json_path_modifier
)

# prior weight dtype
Expand All @@ -428,9 +428,9 @@ def __create_base_components(
# transformer model
components.label(frame, row, 0, "Override Transformer / GGUF",
tooltip="Can be used to override the transformer in the base model. Safetensors and GGUF files are supported, local and on Huggingface. If a GGUF file is used, the DataType must also be set to GGUF")
components.file_entry(
components.path_entry(
frame, row, 1, self.ui_state, "transformer.model_name",
path_modifier=lambda x: Path(x).parent.absolute() if x.endswith(".json") else x
mode="file", path_modifier=components.json_path_modifier
)

# transformer weight dtype
Expand Down Expand Up @@ -512,9 +512,9 @@ def __create_base_components(
# text encoder 4 weight dtype
components.label(frame, row, 0, "Text Encoder 4 Override",
tooltip="Filename, directory or Hugging Face repository of the text encoder 4 model")
components.file_entry(
components.path_entry(
frame, row, 1, self.ui_state, "text_encoder_4.model_name",
path_modifier=lambda x: Path(x).parent.absolute() if x.endswith(".json") else x
mode="file", path_modifier=components.json_path_modifier
)

# text encoder 4 weight dtype
Expand All @@ -529,9 +529,9 @@ def __create_base_components(
# base model
components.label(frame, row, 0, "VAE Override",
tooltip="Directory or Hugging Face repository of a VAE model in diffusers format. Can be used to override the VAE included in the base model. Using a safetensor VAE file will cause an error that the model cannot be loaded.")
components.file_entry(
components.path_entry(
frame, row, 1, self.ui_state, "vae.model_name",
path_modifier=lambda x: Path(x).parent.absolute() if x.endswith(".json") else x
mode="file", path_modifier=components.json_path_modifier
)

# vae weight dtype
Expand All @@ -548,9 +548,9 @@ def __create_effnet_encoder_components(self, frame, row: int):
# effnet encoder model
components.label(frame, row, 0, "Effnet Encoder Model",
tooltip="Filename, directory or Hugging Face repository of the effnet encoder model")
components.file_entry(
components.path_entry(
frame, row, 1, self.ui_state, "effnet_encoder.model_name",
path_modifier=lambda x: Path(x).parent.absolute() if x.endswith(".json") else x
mode="file", path_modifier=components.json_path_modifier
)

# effnet encoder weight dtype
Expand All @@ -572,9 +572,9 @@ def __create_decoder_components(
# decoder model
components.label(frame, row, 0, "Decoder Model",
tooltip="Filename, directory or Hugging Face repository of the decoder model")
components.file_entry(
components.path_entry(
frame, row, 1, self.ui_state, "decoder.model_name",
path_modifier=lambda x: Path(x).parent.absolute() if x.endswith(".json") else x
mode="file", path_modifier=components.json_path_modifier
)

# decoder weight dtype
Expand Down Expand Up @@ -616,7 +616,11 @@ def __create_output_components(
# output model destination
components.label(frame, row, 0, "Model Output Destination",
tooltip="Filename or directory where the output model is saved")
components.file_entry(frame, row, 1, self.ui_state, "output_model_destination", is_output=True)
components.path_entry(
frame, row, 1, self.ui_state, "output_model_destination",
mode="file",
io_type=PathIOType.MODEL,
)

# output data type
components.label(frame, row, 3, "Output Data Type",
Expand Down
8 changes: 4 additions & 4 deletions modules/ui/SampleFrame.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@ def __init__(
# base image path
components.label(bottom_frame, 6, 0, "base image path:",
tooltip="The base image used when inpainting.")
components.file_entry(bottom_frame, 6, 1, self.ui_state, "base_image_path",
allow_model_files=False,
components.path_entry(bottom_frame, 6, 1, self.ui_state, "base_image_path",
mode="file", allow_model_files=False,
allow_image_files=True,
)

# mask image path
components.label(bottom_frame, 6, 2, "mask image path:",
tooltip="The mask used when inpainting.")
components.file_entry(bottom_frame, 6, 3, self.ui_state, "mask_image_path",
allow_model_files=False,
components.path_entry(bottom_frame, 6, 3, self.ui_state, "mask_image_path",
mode="file", allow_model_files=False,
allow_image_files=True,
)
Loading