import gradio as gr import os import argparse from kohya_gui.class_gui_config import KohyaSSGUIConfig from kohya_gui.dreambooth_gui import dreambooth_tab from kohya_gui.finetune_gui import finetune_tab from kohya_gui.textual_inversion_gui import ti_tab from kohya_gui.utilities import utilities_tab from kohya_gui.lora_gui import lora_tab from kohya_gui.class_lora_tab import LoRATools from kohya_gui.custom_logging import setup_logging from kohya_gui.localization_ext import add_javascript # Set up logging log = setup_logging() def UI(**kwargs): add_javascript(kwargs.get("language")) css = "" headless = kwargs.get("headless", False) log.info(f"headless: {headless}") if os.path.exists("./assets/style.css"): with open(os.path.join("./assets/style.css"), "r", encoding="utf8") as file: log.debug("Load CSS...") css += file.read() + "\n" if os.path.exists("./.release"): with open(os.path.join("./.release"), "r", encoding="utf8") as file: release = file.read() if os.path.exists("./README.md"): with open(os.path.join("./README.md"), "r", encoding="utf8") as file: README = file.read() interface = gr.Blocks( css=css, title=f"Kohya_ss GUI {release}", theme=gr.themes.Default() ) config = KohyaSSGUIConfig(config_file_path=kwargs.get("config_file_path")) with interface: with gr.Tab("Dreambooth"): ( train_data_dir_input, reg_data_dir_input, output_dir_input, logging_dir_input, ) = dreambooth_tab(headless=headless, config=config) with gr.Tab("LoRA"): lora_tab(headless=headless, config=config) with gr.Tab("Textual Inversion"): ti_tab(headless=headless, config=config) with gr.Tab("Finetuning"): finetune_tab(headless=headless, config=config) with gr.Tab("Utilities"): utilities_tab( train_data_dir_input=train_data_dir_input, reg_data_dir_input=reg_data_dir_input, output_dir_input=output_dir_input, logging_dir_input=logging_dir_input, enable_copy_info_button=True, headless=headless, ) with gr.Tab("LoRA"): _ = LoRATools(headless=headless) with gr.Tab("About"): gr.Markdown(f"kohya_ss GUI release {release}") with gr.Tab("README"): gr.Markdown(README) htmlStr = f"""