Add linux support
This commit is contained in:
parent
f903753989
commit
3beeef4414
@ -176,6 +176,9 @@ This will store your a backup file with your current locally installed pip packa
|
||||
|
||||
## Change History
|
||||
|
||||
* 2023/03/04 (v21.1.3):
|
||||
- Fix progress bar being displayed when not required.
|
||||
- Add support for linux, thank you @devNegative-asm
|
||||
* 2023/03/03 (v21.1.2):
|
||||
- Fix issue https://github.com/bmaltais/kohya_ss/issues/277
|
||||
- Fix issue https://github.com/bmaltais/kohya_ss/issues/278 introduce by LoCon project switching to pip module. Make sure to run upgrade.ps1 to install the latest pip requirements for LoCon support.
|
||||
|
@ -25,7 +25,7 @@ from library.common_gui import (
|
||||
gradio_config,
|
||||
gradio_source_model,
|
||||
set_legacy_8bitadam,
|
||||
my_data,
|
||||
update_my_data,
|
||||
)
|
||||
from library.tensorboard_gui import (
|
||||
gradio_tensorboard,
|
||||
@ -214,7 +214,7 @@ def open_configuration(
|
||||
my_data = json.load(f)
|
||||
print('Loading config...')
|
||||
# Update values to fix deprecated use_8bit_adam checkbox and set appropriate optimizer if it is set to True
|
||||
my_data = my_data(my_data)
|
||||
my_data = update_my_data(my_data)
|
||||
else:
|
||||
file_path = original_file_path # In case a file_path was provided and the user decide to cancel the open action
|
||||
my_data = {}
|
||||
@ -500,7 +500,9 @@ def dreambooth_tab(
|
||||
'📂', elem_id='open_folder_small'
|
||||
)
|
||||
train_data_dir_input_folder.click(
|
||||
get_folder_path, outputs=train_data_dir
|
||||
get_folder_path,
|
||||
outputs=train_data_dir,
|
||||
show_progress=False,
|
||||
)
|
||||
reg_data_dir = gr.Textbox(
|
||||
label='Regularisation folder',
|
||||
@ -510,7 +512,9 @@ def dreambooth_tab(
|
||||
'📂', elem_id='open_folder_small'
|
||||
)
|
||||
reg_data_dir_input_folder.click(
|
||||
get_folder_path, outputs=reg_data_dir
|
||||
get_folder_path,
|
||||
outputs=reg_data_dir,
|
||||
show_progress=False,
|
||||
)
|
||||
with gr.Row():
|
||||
output_dir = gr.Textbox(
|
||||
@ -529,7 +533,9 @@ def dreambooth_tab(
|
||||
'📂', elem_id='open_folder_small'
|
||||
)
|
||||
logging_dir_input_folder.click(
|
||||
get_folder_path, outputs=logging_dir
|
||||
get_folder_path,
|
||||
outputs=logging_dir,
|
||||
show_progress=False,
|
||||
)
|
||||
with gr.Row():
|
||||
output_name = gr.Textbox(
|
||||
@ -610,7 +616,11 @@ def dreambooth_tab(
|
||||
placeholder='(Optiona) path to checkpoint of vae to replace for training',
|
||||
)
|
||||
vae_button = gr.Button('📂', elem_id='open_folder_small')
|
||||
vae_button.click(get_any_file_path, outputs=vae)
|
||||
vae_button.click(
|
||||
get_any_file_path,
|
||||
outputs=vae,
|
||||
show_progress=False,
|
||||
)
|
||||
(
|
||||
use_8bit_adam,
|
||||
xformers,
|
||||
@ -664,10 +674,12 @@ def dreambooth_tab(
|
||||
button_start_tensorboard.click(
|
||||
start_tensorboard,
|
||||
inputs=logging_dir,
|
||||
show_progress=False,
|
||||
)
|
||||
|
||||
button_stop_tensorboard.click(
|
||||
stop_tensorboard,
|
||||
show_progress=False,
|
||||
)
|
||||
|
||||
settings_list = [
|
||||
@ -730,23 +742,27 @@ def dreambooth_tab(
|
||||
open_configuration,
|
||||
inputs=[config_file_name] + settings_list,
|
||||
outputs=[config_file_name] + settings_list,
|
||||
show_progress=False,
|
||||
)
|
||||
|
||||
button_save_config.click(
|
||||
save_configuration,
|
||||
inputs=[dummy_db_false, config_file_name] + settings_list,
|
||||
outputs=[config_file_name],
|
||||
show_progress=False,
|
||||
)
|
||||
|
||||
button_save_as_config.click(
|
||||
save_configuration,
|
||||
inputs=[dummy_db_true, config_file_name] + settings_list,
|
||||
outputs=[config_file_name],
|
||||
show_progress=False,
|
||||
)
|
||||
|
||||
button_run.click(
|
||||
train_model,
|
||||
inputs=settings_list,
|
||||
show_progress=False,
|
||||
)
|
||||
|
||||
return (
|
||||
|
@ -19,7 +19,7 @@ from library.common_gui import (
|
||||
color_aug_changed,
|
||||
run_cmd_training,
|
||||
set_legacy_8bitadam,
|
||||
my_data,
|
||||
update_my_data,
|
||||
)
|
||||
from library.tensorboard_gui import (
|
||||
gradio_tensorboard,
|
||||
@ -33,7 +33,8 @@ refresh_symbol = '\U0001f504' # 🔄
|
||||
save_style_symbol = '\U0001f4be' # 💾
|
||||
document_symbol = '\U0001F4C4' # 📄
|
||||
|
||||
PYTHON = "python3" if os.name == 'posix' else './venv/Scripts/python.exe'
|
||||
PYTHON = 'python3' if os.name == 'posix' else './venv/Scripts/python.exe'
|
||||
|
||||
|
||||
def save_configuration(
|
||||
save_as,
|
||||
@ -217,7 +218,7 @@ def open_config_file(
|
||||
my_data_db = json.load(f)
|
||||
print('Loading config...')
|
||||
# Update values to fix deprecated use_8bit_adam checkbox and set appropriate optimizer if it is set to True
|
||||
my_data = my_data(my_data)
|
||||
my_data = update_my_data(my_data)
|
||||
else:
|
||||
file_path = original_file_path # In case a file_path was provided and the user decide to cancel the open action
|
||||
my_data_db = {}
|
||||
@ -296,9 +297,7 @@ def train_model(
|
||||
if not os.path.exists(train_dir):
|
||||
os.mkdir(train_dir)
|
||||
|
||||
run_cmd = (
|
||||
f'{PYTHON} finetune/merge_captions_to_metadata.py'
|
||||
)
|
||||
run_cmd = f'{PYTHON} finetune/merge_captions_to_metadata.py'
|
||||
if caption_extension == '':
|
||||
run_cmd += f' --caption_extension=".caption"'
|
||||
else:
|
||||
@ -315,9 +314,7 @@ def train_model(
|
||||
|
||||
# create images buckets
|
||||
if generate_image_buckets:
|
||||
run_cmd = (
|
||||
f'{PYTHON} finetune/prepare_buckets_latents.py'
|
||||
)
|
||||
run_cmd = f'{PYTHON} finetune/prepare_buckets_latents.py'
|
||||
run_cmd += f' "{image_folder}"'
|
||||
run_cmd += f' "{train_dir}/{caption_metadata_filename}"'
|
||||
run_cmd += f' "{train_dir}/{latent_metadata_filename}"'
|
||||
@ -491,7 +488,11 @@ def finetune_tab():
|
||||
train_dir_folder = gr.Button(
|
||||
folder_symbol, elem_id='open_folder_small'
|
||||
)
|
||||
train_dir_folder.click(get_folder_path, outputs=train_dir)
|
||||
train_dir_folder.click(
|
||||
get_folder_path,
|
||||
outputs=train_dir,
|
||||
show_progress=False,
|
||||
)
|
||||
|
||||
image_folder = gr.Textbox(
|
||||
label='Training Image folder',
|
||||
@ -501,7 +502,9 @@ def finetune_tab():
|
||||
folder_symbol, elem_id='open_folder_small'
|
||||
)
|
||||
image_folder_input_folder.click(
|
||||
get_folder_path, outputs=image_folder
|
||||
get_folder_path,
|
||||
outputs=image_folder,
|
||||
show_progress=False,
|
||||
)
|
||||
with gr.Row():
|
||||
output_dir = gr.Textbox(
|
||||
@ -511,7 +514,11 @@ def finetune_tab():
|
||||
output_dir_input_folder = gr.Button(
|
||||
folder_symbol, elem_id='open_folder_small'
|
||||
)
|
||||
output_dir_input_folder.click(get_folder_path, outputs=output_dir)
|
||||
output_dir_input_folder.click(
|
||||
get_folder_path,
|
||||
outputs=output_dir,
|
||||
show_progress=False,
|
||||
)
|
||||
|
||||
logging_dir = gr.Textbox(
|
||||
label='Logging folder',
|
||||
@ -521,7 +528,9 @@ def finetune_tab():
|
||||
folder_symbol, elem_id='open_folder_small'
|
||||
)
|
||||
logging_dir_input_folder.click(
|
||||
get_folder_path, outputs=logging_dir
|
||||
get_folder_path,
|
||||
outputs=logging_dir,
|
||||
show_progress=False,
|
||||
)
|
||||
with gr.Row():
|
||||
output_name = gr.Textbox(
|
||||
@ -655,6 +664,7 @@ def finetune_tab():
|
||||
|
||||
button_stop_tensorboard.click(
|
||||
stop_tensorboard,
|
||||
show_progress=False,
|
||||
)
|
||||
|
||||
settings_list = [
|
||||
@ -725,18 +735,21 @@ def finetune_tab():
|
||||
open_config_file,
|
||||
inputs=[config_file_name] + settings_list,
|
||||
outputs=[config_file_name] + settings_list,
|
||||
show_progress=False,
|
||||
)
|
||||
|
||||
button_save_config.click(
|
||||
save_configuration,
|
||||
inputs=[dummy_ft_false, config_file_name] + settings_list,
|
||||
outputs=[config_file_name],
|
||||
show_progress=False,
|
||||
)
|
||||
|
||||
button_save_as_config.click(
|
||||
save_configuration,
|
||||
inputs=[dummy_ft_true, config_file_name] + settings_list,
|
||||
outputs=[config_file_name],
|
||||
show_progress=False,
|
||||
)
|
||||
|
||||
|
||||
|
@ -4,6 +4,7 @@ import subprocess
|
||||
from .common_gui import get_folder_path, add_pre_postfix, find_replace
|
||||
import os
|
||||
|
||||
|
||||
def caption_images(
|
||||
caption_text_input,
|
||||
images_dir_input,
|
||||
@ -85,7 +86,9 @@ def gradio_basic_caption_gui_tab():
|
||||
'📂', elem_id='open_folder_small'
|
||||
)
|
||||
button_images_dir_input.click(
|
||||
get_folder_path, outputs=images_dir_input
|
||||
get_folder_path,
|
||||
outputs=images_dir_input,
|
||||
show_progress=False,
|
||||
)
|
||||
caption_file_ext = gr.Textbox(
|
||||
label='Caption file extension',
|
||||
@ -139,4 +142,5 @@ def gradio_basic_caption_gui_tab():
|
||||
find,
|
||||
replace,
|
||||
],
|
||||
show_progress=False,
|
||||
)
|
||||
|
@ -3,7 +3,9 @@ from easygui import msgbox
|
||||
import subprocess
|
||||
import os
|
||||
from .common_gui import get_folder_path, add_pre_postfix
|
||||
PYTHON = "python3" if os.name == 'posix' else './venv/Scripts/python.exe'
|
||||
|
||||
PYTHON = 'python3' if os.name == 'posix' else './venv/Scripts/python.exe'
|
||||
|
||||
|
||||
def caption_images(
|
||||
train_data_dir,
|
||||
@ -81,7 +83,9 @@ def gradio_blip_caption_gui_tab():
|
||||
'📂', elem_id='open_folder_small'
|
||||
)
|
||||
button_train_data_dir_input.click(
|
||||
get_folder_path, outputs=train_data_dir
|
||||
get_folder_path,
|
||||
outputs=train_data_dir,
|
||||
show_progress=False,
|
||||
)
|
||||
with gr.Row():
|
||||
caption_file_ext = gr.Textbox(
|
||||
@ -138,4 +142,5 @@ def gradio_blip_caption_gui_tab():
|
||||
prefix,
|
||||
postfix,
|
||||
],
|
||||
show_progress=False,
|
||||
)
|
||||
|
@ -10,11 +10,11 @@ save_style_symbol = '\U0001f4be' # 💾
|
||||
document_symbol = '\U0001F4C4' # 📄
|
||||
|
||||
|
||||
def my_data(my_data):
|
||||
def update_my_data(my_data):
|
||||
if my_data.get('use_8bit_adam', False):
|
||||
my_data['optimizer'] = 'AdamW8bit'
|
||||
my_data['use_8bit_adam'] = False
|
||||
|
||||
|
||||
if my_data.get('model_list', 'custom') == []:
|
||||
print('Old config with empty model list. Setting to custom...')
|
||||
my_data['model_list'] = 'custom'
|
||||
@ -276,7 +276,9 @@ def save_inference_file(output_dir, v2, v_parameterization, output_name):
|
||||
)
|
||||
|
||||
|
||||
def set_pretrained_model_name_or_path_input(model_list, pretrained_model_name_or_path, v2, v_parameterization):
|
||||
def set_pretrained_model_name_or_path_input(
|
||||
model_list, pretrained_model_name_or_path, v2, v_parameterization
|
||||
):
|
||||
# define a list of substrings to search for
|
||||
substrings_v2 = [
|
||||
'stabilityai/stable-diffusion-2-1-base',
|
||||
@ -320,7 +322,12 @@ def set_pretrained_model_name_or_path_input(model_list, pretrained_model_name_or
|
||||
return model_list, v2, v_parameterization
|
||||
|
||||
if model_list == 'custom':
|
||||
if str(pretrained_model_name_or_path) in substrings_v1_model or str(pretrained_model_name_or_path) in substrings_v2 or str(pretrained_model_name_or_path) in substrings_v_parameterization:
|
||||
if (
|
||||
str(pretrained_model_name_or_path) in substrings_v1_model
|
||||
or str(pretrained_model_name_or_path) in substrings_v2
|
||||
or str(pretrained_model_name_or_path)
|
||||
in substrings_v_parameterization
|
||||
):
|
||||
pretrained_model_name_or_path = ''
|
||||
v2 = False
|
||||
v_parameterization = False
|
||||
@ -359,7 +366,7 @@ def gradio_source_model():
|
||||
pretrained_model_name_or_path = gr.Textbox(
|
||||
label='Pretrained model name or path',
|
||||
placeholder='enter the path to custom model or name of pretrained model',
|
||||
value='runwayml/stable-diffusion-v1-5'
|
||||
value='runwayml/stable-diffusion-v1-5',
|
||||
)
|
||||
pretrained_model_name_or_path_file = gr.Button(
|
||||
document_symbol, elem_id='open_folder_small'
|
||||
@ -368,6 +375,7 @@ def gradio_source_model():
|
||||
get_any_file_path,
|
||||
inputs=pretrained_model_name_or_path,
|
||||
outputs=pretrained_model_name_or_path,
|
||||
show_progress=False,
|
||||
)
|
||||
pretrained_model_name_or_path_folder = gr.Button(
|
||||
folder_symbol, elem_id='open_folder_small'
|
||||
@ -376,6 +384,7 @@ def gradio_source_model():
|
||||
get_folder_path,
|
||||
inputs=pretrained_model_name_or_path,
|
||||
outputs=pretrained_model_name_or_path,
|
||||
show_progress=False,
|
||||
)
|
||||
model_list = gr.Dropdown(
|
||||
label='Model Quick Pick',
|
||||
@ -388,7 +397,7 @@ def gradio_source_model():
|
||||
'runwayml/stable-diffusion-v1-5',
|
||||
'CompVis/stable-diffusion-v1-4',
|
||||
],
|
||||
value='runwayml/stable-diffusion-v1-5'
|
||||
value='runwayml/stable-diffusion-v1-5',
|
||||
)
|
||||
save_model_as = gr.Dropdown(
|
||||
label='Save trained model as',
|
||||
@ -409,7 +418,12 @@ def gradio_source_model():
|
||||
)
|
||||
model_list.change(
|
||||
set_pretrained_model_name_or_path_input,
|
||||
inputs=[model_list, pretrained_model_name_or_path, v2, v_parameterization],
|
||||
inputs=[
|
||||
model_list,
|
||||
pretrained_model_name_or_path,
|
||||
v2,
|
||||
v_parameterization,
|
||||
],
|
||||
outputs=[
|
||||
pretrained_model_name_or_path,
|
||||
v2,
|
||||
@ -661,7 +675,11 @@ def gradio_advanced_training():
|
||||
placeholder='path to "last-state" state folder to resume from',
|
||||
)
|
||||
resume_button = gr.Button('📂', elem_id='open_folder_small')
|
||||
resume_button.click(get_folder_path, outputs=resume)
|
||||
resume_button.click(
|
||||
get_folder_path,
|
||||
outputs=resume,
|
||||
show_progress=False,
|
||||
)
|
||||
max_train_epochs = gr.Textbox(
|
||||
label='Max train epoch',
|
||||
placeholder='(Optional) Override number of epoch',
|
||||
|
@ -9,7 +9,8 @@ folder_symbol = '\U0001f4c2' # 📂
|
||||
refresh_symbol = '\U0001f504' # 🔄
|
||||
save_style_symbol = '\U0001f4be' # 💾
|
||||
document_symbol = '\U0001F4C4' # 📄
|
||||
PYTHON = "python3" if os.name == 'posix' else './venv/Scripts/python.exe'
|
||||
PYTHON = 'python3' if os.name == 'posix' else './venv/Scripts/python.exe'
|
||||
|
||||
|
||||
def convert_model(
|
||||
source_model_input,
|
||||
@ -166,7 +167,9 @@ def gradio_convert_model_tab():
|
||||
folder_symbol, elem_id='open_folder_small'
|
||||
)
|
||||
button_source_model_dir.click(
|
||||
get_folder_path, outputs=source_model_input
|
||||
get_folder_path,
|
||||
outputs=source_model_input,
|
||||
show_progress=False,
|
||||
)
|
||||
|
||||
button_source_model_file = gr.Button(
|
||||
@ -176,6 +179,7 @@ def gradio_convert_model_tab():
|
||||
get_file_path,
|
||||
inputs=[source_model_input],
|
||||
outputs=source_model_input,
|
||||
show_progress=False,
|
||||
)
|
||||
|
||||
source_model_type = gr.Dropdown(
|
||||
@ -199,7 +203,9 @@ def gradio_convert_model_tab():
|
||||
folder_symbol, elem_id='open_folder_small'
|
||||
)
|
||||
button_target_model_folder.click(
|
||||
get_folder_path, outputs=target_model_folder_input
|
||||
get_folder_path,
|
||||
outputs=target_model_folder_input,
|
||||
show_progress=False,
|
||||
)
|
||||
|
||||
target_model_name_input = gr.Textbox(
|
||||
@ -234,4 +240,5 @@ def gradio_convert_model_tab():
|
||||
target_model_type,
|
||||
target_save_precision_type,
|
||||
],
|
||||
show_progress=False,
|
||||
)
|
||||
|
@ -118,7 +118,9 @@ def gradio_dataset_balancing_tab():
|
||||
'📂', elem_id='open_folder_small'
|
||||
)
|
||||
select_dataset_folder_button.click(
|
||||
get_folder_path, outputs=select_dataset_folder_input
|
||||
get_folder_path,
|
||||
outputs=select_dataset_folder_input,
|
||||
show_progress=False,
|
||||
)
|
||||
|
||||
total_repeats_number = gr.Number(
|
||||
@ -140,4 +142,5 @@ def gradio_dataset_balancing_tab():
|
||||
select_dataset_folder_input,
|
||||
insecure,
|
||||
],
|
||||
show_progress=False,
|
||||
)
|
||||
|
@ -140,7 +140,9 @@ def gradio_dreambooth_folder_creation_tab(
|
||||
'📂', elem_id='open_folder_small'
|
||||
)
|
||||
button_util_training_images_dir_input.click(
|
||||
get_folder_path, outputs=util_training_images_dir_input
|
||||
get_folder_path,
|
||||
outputs=util_training_images_dir_input,
|
||||
show_progress=False,
|
||||
)
|
||||
util_training_images_repeat_input = gr.Number(
|
||||
label='Repeats',
|
||||
@ -158,7 +160,9 @@ def gradio_dreambooth_folder_creation_tab(
|
||||
'📂', elem_id='open_folder_small'
|
||||
)
|
||||
button_util_regularization_images_dir_input.click(
|
||||
get_folder_path, outputs=util_regularization_images_dir_input
|
||||
get_folder_path,
|
||||
outputs=util_regularization_images_dir_input,
|
||||
show_progress=False,
|
||||
)
|
||||
util_regularization_images_repeat_input = gr.Number(
|
||||
label='Repeats',
|
||||
@ -190,6 +194,7 @@ def gradio_dreambooth_folder_creation_tab(
|
||||
util_class_prompt_input,
|
||||
util_training_dir_output,
|
||||
],
|
||||
show_progress=False,
|
||||
)
|
||||
button_copy_info_to_Folders_tab = gr.Button('Copy info to Folders Tab')
|
||||
button_copy_info_to_Folders_tab.click(
|
||||
@ -201,4 +206,5 @@ def gradio_dreambooth_folder_creation_tab(
|
||||
output_dir_input,
|
||||
logging_dir_input,
|
||||
],
|
||||
show_progress=False,
|
||||
)
|
||||
|
@ -12,7 +12,8 @@ folder_symbol = '\U0001f4c2' # 📂
|
||||
refresh_symbol = '\U0001f504' # 🔄
|
||||
save_style_symbol = '\U0001f4be' # 💾
|
||||
document_symbol = '\U0001F4C4' # 📄
|
||||
PYTHON = "python3" if os.name == 'posix' else './venv/Scripts/python.exe'
|
||||
PYTHON = 'python3' if os.name == 'posix' else './venv/Scripts/python.exe'
|
||||
|
||||
|
||||
def extract_lora(
|
||||
model_tuned,
|
||||
@ -85,6 +86,7 @@ def gradio_extract_lora_tab():
|
||||
get_file_path,
|
||||
inputs=[model_tuned, model_ext, model_ext_name],
|
||||
outputs=model_tuned,
|
||||
show_progress=False,
|
||||
)
|
||||
|
||||
model_org = gr.Textbox(
|
||||
@ -99,6 +101,7 @@ def gradio_extract_lora_tab():
|
||||
get_file_path,
|
||||
inputs=[model_org, model_ext, model_ext_name],
|
||||
outputs=model_org,
|
||||
show_progress=False,
|
||||
)
|
||||
with gr.Row():
|
||||
save_to = gr.Textbox(
|
||||
@ -113,6 +116,7 @@ def gradio_extract_lora_tab():
|
||||
get_saveasfilename_path,
|
||||
inputs=[save_to, lora_ext, lora_ext_name],
|
||||
outputs=save_to,
|
||||
show_progress=False,
|
||||
)
|
||||
save_precision = gr.Dropdown(
|
||||
label='Save precision',
|
||||
@ -136,4 +140,5 @@ def gradio_extract_lora_tab():
|
||||
extract_button.click(
|
||||
extract_lora,
|
||||
inputs=[model_tuned, model_org, save_to, save_precision, dim, v2],
|
||||
show_progress=False,
|
||||
)
|
||||
|
@ -3,7 +3,9 @@ from easygui import msgbox
|
||||
import subprocess
|
||||
import os
|
||||
from .common_gui import get_folder_path, add_pre_postfix
|
||||
PYTHON = "python3" if os.name == 'posix' else './venv/Scripts/python.exe'
|
||||
|
||||
PYTHON = 'python3' if os.name == 'posix' else './venv/Scripts/python.exe'
|
||||
|
||||
|
||||
def caption_images(
|
||||
train_data_dir,
|
||||
@ -73,7 +75,9 @@ def gradio_git_caption_gui_tab():
|
||||
'📂', elem_id='open_folder_small'
|
||||
)
|
||||
button_train_data_dir_input.click(
|
||||
get_folder_path, outputs=train_data_dir
|
||||
get_folder_path,
|
||||
outputs=train_data_dir,
|
||||
show_progress=False,
|
||||
)
|
||||
with gr.Row():
|
||||
caption_ext = gr.Textbox(
|
||||
@ -126,4 +130,5 @@ def gradio_git_caption_gui_tab():
|
||||
prefix,
|
||||
postfix,
|
||||
],
|
||||
show_progress=False,
|
||||
)
|
||||
|
@ -12,7 +12,8 @@ folder_symbol = '\U0001f4c2' # 📂
|
||||
refresh_symbol = '\U0001f504' # 🔄
|
||||
save_style_symbol = '\U0001f4be' # 💾
|
||||
document_symbol = '\U0001F4C4' # 📄
|
||||
PYTHON = "python3" if os.name == 'posix' else './venv/Scripts/python.exe'
|
||||
PYTHON = 'python3' if os.name == 'posix' else './venv/Scripts/python.exe'
|
||||
|
||||
|
||||
def merge_lora(
|
||||
lora_a_model,
|
||||
@ -81,6 +82,7 @@ def gradio_merge_lora_tab():
|
||||
get_file_path,
|
||||
inputs=[lora_a_model, lora_ext, lora_ext_name],
|
||||
outputs=lora_a_model,
|
||||
show_progress=False,
|
||||
)
|
||||
|
||||
lora_b_model = gr.Textbox(
|
||||
@ -95,6 +97,7 @@ def gradio_merge_lora_tab():
|
||||
get_file_path,
|
||||
inputs=[lora_b_model, lora_ext, lora_ext_name],
|
||||
outputs=lora_b_model,
|
||||
show_progress=False,
|
||||
)
|
||||
with gr.Row():
|
||||
ratio = gr.Slider(
|
||||
@ -119,6 +122,7 @@ def gradio_merge_lora_tab():
|
||||
get_saveasfilename_path,
|
||||
inputs=[save_to, lora_ext, lora_ext_name],
|
||||
outputs=save_to,
|
||||
show_progress=False,
|
||||
)
|
||||
precision = gr.Dropdown(
|
||||
label='Merge precision',
|
||||
@ -145,4 +149,5 @@ def gradio_merge_lora_tab():
|
||||
precision,
|
||||
save_precision,
|
||||
],
|
||||
show_progress=False,
|
||||
)
|
||||
|
@ -3,7 +3,8 @@ from easygui import msgbox
|
||||
import subprocess
|
||||
import os
|
||||
from .common_gui import get_saveasfilename_path, get_file_path
|
||||
PYTHON = "python3" if os.name == 'posix' else './venv/Scripts/python.exe'
|
||||
|
||||
PYTHON = 'python3' if os.name == 'posix' else './venv/Scripts/python.exe'
|
||||
folder_symbol = '\U0001f4c2' # 📂
|
||||
refresh_symbol = '\U0001f504' # 🔄
|
||||
save_style_symbol = '\U0001f4be' # 💾
|
||||
@ -68,6 +69,7 @@ def gradio_resize_lora_tab():
|
||||
get_file_path,
|
||||
inputs=[model, lora_ext, lora_ext_name],
|
||||
outputs=model,
|
||||
show_progress=False,
|
||||
)
|
||||
with gr.Row():
|
||||
new_rank = gr.Slider(
|
||||
@ -92,6 +94,7 @@ def gradio_resize_lora_tab():
|
||||
get_saveasfilename_path,
|
||||
inputs=[save_to, lora_ext, lora_ext_name],
|
||||
outputs=save_to,
|
||||
show_progress=False,
|
||||
)
|
||||
save_precision = gr.Dropdown(
|
||||
label='Save precision',
|
||||
@ -116,4 +119,5 @@ def gradio_resize_lora_tab():
|
||||
save_precision,
|
||||
device,
|
||||
],
|
||||
show_progress=False,
|
||||
)
|
||||
|
@ -5,7 +5,8 @@ import subprocess
|
||||
import time
|
||||
|
||||
tensorboard_proc = None # I know... bad but heh
|
||||
TENSORBOARD = "tensorboard" if os.name == 'posix' else 'tensorboard.exe'
|
||||
TENSORBOARD = 'tensorboard' if os.name == 'posix' else 'tensorboard.exe'
|
||||
|
||||
|
||||
def start_tensorboard(logging_dir):
|
||||
global tensorboard_proc
|
||||
|
@ -7,7 +7,8 @@ from .common_gui import (
|
||||
get_any_file_path,
|
||||
get_file_path,
|
||||
)
|
||||
PYTHON = "python3" if os.name == 'posix' else './venv/Scripts/python.exe'
|
||||
|
||||
PYTHON = 'python3' if os.name == 'posix' else './venv/Scripts/python.exe'
|
||||
folder_symbol = '\U0001f4c2' # 📂
|
||||
refresh_symbol = '\U0001f504' # 🔄
|
||||
save_style_symbol = '\U0001f4be' # 💾
|
||||
@ -29,11 +30,11 @@ def verify_lora(
|
||||
|
||||
run_cmd = [
|
||||
PYTHON,
|
||||
os.path.join("networks","check_lora_weights.py"),
|
||||
f'{lora_model}'
|
||||
os.path.join('networks', 'check_lora_weights.py'),
|
||||
f'{lora_model}',
|
||||
]
|
||||
|
||||
print(" ".join(run_cmd))
|
||||
print(' '.join(run_cmd))
|
||||
|
||||
# Run the command
|
||||
process = subprocess.Popen(
|
||||
@ -71,6 +72,7 @@ def gradio_verify_lora_tab():
|
||||
get_file_path,
|
||||
inputs=[lora_model, lora_ext, lora_ext_name],
|
||||
outputs=lora_model,
|
||||
show_progress=False,
|
||||
)
|
||||
verify_button = gr.Button('Verify', variant='primary')
|
||||
|
||||
@ -96,4 +98,5 @@ def gradio_verify_lora_tab():
|
||||
lora_model,
|
||||
],
|
||||
outputs=[lora_model_verif_output, lora_model_verif_error],
|
||||
show_progress=False,
|
||||
)
|
||||
|
@ -56,7 +56,9 @@ def gradio_wd14_caption_gui_tab():
|
||||
'📂', elem_id='open_folder_small'
|
||||
)
|
||||
button_train_data_dir_input.click(
|
||||
get_folder_path, outputs=train_data_dir
|
||||
get_folder_path,
|
||||
outputs=train_data_dir,
|
||||
show_progress=False,
|
||||
)
|
||||
|
||||
caption_extension = gr.Textbox(
|
||||
@ -76,4 +78,5 @@ def gradio_wd14_caption_gui_tab():
|
||||
caption_button.click(
|
||||
caption_images,
|
||||
inputs=[train_data_dir, caption_extension, batch_size, thresh],
|
||||
show_progress=False,
|
||||
)
|
||||
|
39
lora_gui.py
39
lora_gui.py
@ -25,7 +25,7 @@ from library.common_gui import (
|
||||
gradio_source_model,
|
||||
run_cmd_training,
|
||||
set_legacy_8bitadam,
|
||||
my_data,
|
||||
update_my_data,
|
||||
)
|
||||
from library.dreambooth_folder_creation_gui import (
|
||||
gradio_dreambooth_folder_creation_tab,
|
||||
@ -239,7 +239,7 @@ def open_configuration(
|
||||
my_data = json.load(f)
|
||||
print('Loading config...')
|
||||
# Update values to fix deprecated use_8bit_adam checkbox and set appropriate optimizer if it is set to True
|
||||
my_data = my_data(my_data)
|
||||
my_data = update_my_data(my_data)
|
||||
else:
|
||||
file_path = original_file_path # In case a file_path was provided and the user decide to cancel the open action
|
||||
my_data = {}
|
||||
@ -462,7 +462,9 @@ def train_model(
|
||||
try:
|
||||
import locon.locon_kohya
|
||||
except ModuleNotFoundError:
|
||||
print("\033[1;31mError:\033[0m The required module 'locon' is not installed. Please install by running \033[33mupgrade.ps1\033[0m before running this program.")
|
||||
print(
|
||||
"\033[1;31mError:\033[0m The required module 'locon' is not installed. Please install by running \033[33mupgrade.ps1\033[0m before running this program."
|
||||
)
|
||||
return
|
||||
run_cmd += f' --network_module=locon.locon_kohya'
|
||||
run_cmd += (
|
||||
@ -588,27 +590,41 @@ def lora_tab(
|
||||
)
|
||||
train_data_dir_folder = gr.Button('📂', elem_id='open_folder_small')
|
||||
train_data_dir_folder.click(
|
||||
get_folder_path, outputs=train_data_dir
|
||||
get_folder_path,
|
||||
outputs=train_data_dir,
|
||||
show_progress=False,
|
||||
)
|
||||
reg_data_dir = gr.Textbox(
|
||||
label='Regularisation folder',
|
||||
placeholder='(Optional) Folder where where the regularization folders containing the images are located',
|
||||
)
|
||||
reg_data_dir_folder = gr.Button('📂', elem_id='open_folder_small')
|
||||
reg_data_dir_folder.click(get_folder_path, outputs=reg_data_dir)
|
||||
reg_data_dir_folder.click(
|
||||
get_folder_path,
|
||||
outputs=reg_data_dir,
|
||||
show_progress=False,
|
||||
)
|
||||
with gr.Row():
|
||||
output_dir = gr.Textbox(
|
||||
label='Output folder',
|
||||
placeholder='Folder to output trained model',
|
||||
)
|
||||
output_dir_folder = gr.Button('📂', elem_id='open_folder_small')
|
||||
output_dir_folder.click(get_folder_path, outputs=output_dir)
|
||||
output_dir_folder.click(
|
||||
get_folder_path,
|
||||
outputs=output_dir,
|
||||
show_progress=False,
|
||||
)
|
||||
logging_dir = gr.Textbox(
|
||||
label='Logging folder',
|
||||
placeholder='Optional: enable logging and output TensorBoard log to this folder',
|
||||
)
|
||||
logging_dir_folder = gr.Button('📂', elem_id='open_folder_small')
|
||||
logging_dir_folder.click(get_folder_path, outputs=logging_dir)
|
||||
logging_dir_folder.click(
|
||||
get_folder_path,
|
||||
outputs=logging_dir,
|
||||
show_progress=False,
|
||||
)
|
||||
with gr.Row():
|
||||
output_name = gr.Textbox(
|
||||
label='Model output name',
|
||||
@ -662,6 +678,7 @@ def lora_tab(
|
||||
get_any_file_path,
|
||||
inputs=[lora_network_weights],
|
||||
outputs=lora_network_weights,
|
||||
show_progress=False,
|
||||
)
|
||||
(
|
||||
learning_rate,
|
||||
@ -736,7 +753,7 @@ def lora_tab(
|
||||
return gr.Group.update(visible=True)
|
||||
else:
|
||||
return gr.Group.update(visible=False)
|
||||
|
||||
|
||||
LoRA_type.change(
|
||||
LoRA_type_change, inputs=[LoRA_type], outputs=[LoCon_row]
|
||||
)
|
||||
@ -834,10 +851,12 @@ def lora_tab(
|
||||
button_start_tensorboard.click(
|
||||
start_tensorboard,
|
||||
inputs=logging_dir,
|
||||
show_progress=False,
|
||||
)
|
||||
|
||||
button_stop_tensorboard.click(
|
||||
stop_tensorboard,
|
||||
show_progress=False,
|
||||
)
|
||||
|
||||
settings_list = [
|
||||
@ -910,23 +929,27 @@ def lora_tab(
|
||||
open_configuration,
|
||||
inputs=[config_file_name] + settings_list,
|
||||
outputs=[config_file_name] + settings_list + [LoCon_row],
|
||||
show_progress=False,
|
||||
)
|
||||
|
||||
button_save_config.click(
|
||||
save_configuration,
|
||||
inputs=[dummy_db_false, config_file_name] + settings_list,
|
||||
outputs=[config_file_name],
|
||||
show_progress=False,
|
||||
)
|
||||
|
||||
button_save_as_config.click(
|
||||
save_configuration,
|
||||
inputs=[dummy_db_true, config_file_name] + settings_list,
|
||||
outputs=[config_file_name],
|
||||
show_progress=False,
|
||||
)
|
||||
|
||||
button_run.click(
|
||||
train_model,
|
||||
inputs=settings_list,
|
||||
show_progress=False,
|
||||
)
|
||||
|
||||
return (
|
||||
|
@ -25,7 +25,7 @@ from library.common_gui import (
|
||||
gradio_config,
|
||||
gradio_source_model,
|
||||
set_legacy_8bitadam,
|
||||
my_data,
|
||||
update_my_data,
|
||||
)
|
||||
from library.tensorboard_gui import (
|
||||
gradio_tensorboard,
|
||||
@ -226,7 +226,7 @@ def open_configuration(
|
||||
my_data_db = json.load(f)
|
||||
print('Loading config...')
|
||||
# Update values to fix deprecated use_8bit_adam checkbox and set appropriate optimizer if it is set to True
|
||||
my_data = my_data(my_data)
|
||||
my_data = update_my_data(my_data)
|
||||
else:
|
||||
file_path = original_file_path # In case a file_path was provided and the user decide to cancel the open action
|
||||
my_data_db = {}
|
||||
@ -542,7 +542,9 @@ def ti_tab(
|
||||
'📂', elem_id='open_folder_small'
|
||||
)
|
||||
train_data_dir_input_folder.click(
|
||||
get_folder_path, outputs=train_data_dir
|
||||
get_folder_path,
|
||||
outputs=train_data_dir,
|
||||
show_progress=False,
|
||||
)
|
||||
reg_data_dir = gr.Textbox(
|
||||
label='Regularisation folder',
|
||||
@ -552,7 +554,9 @@ def ti_tab(
|
||||
'📂', elem_id='open_folder_small'
|
||||
)
|
||||
reg_data_dir_input_folder.click(
|
||||
get_folder_path, outputs=reg_data_dir
|
||||
get_folder_path,
|
||||
outputs=reg_data_dir,
|
||||
show_progress=False,
|
||||
)
|
||||
with gr.Row():
|
||||
output_dir = gr.Textbox(
|
||||
@ -562,7 +566,11 @@ def ti_tab(
|
||||
output_dir_input_folder = gr.Button(
|
||||
'📂', elem_id='open_folder_small'
|
||||
)
|
||||
output_dir_input_folder.click(get_folder_path, outputs=output_dir)
|
||||
output_dir_input_folder.click(
|
||||
get_folder_path,
|
||||
outputs=output_dir,
|
||||
show_progress=False,
|
||||
)
|
||||
logging_dir = gr.Textbox(
|
||||
label='Logging folder',
|
||||
placeholder='Optional: enable logging and output TensorBoard log to this folder',
|
||||
@ -571,7 +579,9 @@ def ti_tab(
|
||||
'📂', elem_id='open_folder_small'
|
||||
)
|
||||
logging_dir_input_folder.click(
|
||||
get_folder_path, outputs=logging_dir
|
||||
get_folder_path,
|
||||
outputs=logging_dir,
|
||||
show_progress=False,
|
||||
)
|
||||
with gr.Row():
|
||||
output_name = gr.Textbox(
|
||||
@ -607,7 +617,11 @@ def ti_tab(
|
||||
placeholder='(Optional) Path to existing TI embeding file to keep training',
|
||||
)
|
||||
weights_file_input = gr.Button('📂', elem_id='open_folder_small')
|
||||
weights_file_input.click(get_file_path, outputs=weights)
|
||||
weights_file_input.click(
|
||||
get_file_path,
|
||||
outputs=weights,
|
||||
show_progress=False,
|
||||
)
|
||||
with gr.Row():
|
||||
token_string = gr.Textbox(
|
||||
label='Token string',
|
||||
@ -688,7 +702,11 @@ def ti_tab(
|
||||
placeholder='(Optiona) path to checkpoint of vae to replace for training',
|
||||
)
|
||||
vae_button = gr.Button('📂', elem_id='open_folder_small')
|
||||
vae_button.click(get_any_file_path, outputs=vae)
|
||||
vae_button.click(
|
||||
get_any_file_path,
|
||||
outputs=vae,
|
||||
show_progress=False,
|
||||
)
|
||||
(
|
||||
use_8bit_adam,
|
||||
xformers,
|
||||
@ -742,10 +760,12 @@ def ti_tab(
|
||||
button_start_tensorboard.click(
|
||||
start_tensorboard,
|
||||
inputs=logging_dir,
|
||||
show_progress=False,
|
||||
)
|
||||
|
||||
button_stop_tensorboard.click(
|
||||
stop_tensorboard,
|
||||
show_progress=False,
|
||||
)
|
||||
|
||||
settings_list = [
|
||||
@ -814,23 +834,27 @@ def ti_tab(
|
||||
open_configuration,
|
||||
inputs=[config_file_name] + settings_list,
|
||||
outputs=[config_file_name] + settings_list,
|
||||
show_progress=False,
|
||||
)
|
||||
|
||||
button_save_config.click(
|
||||
save_configuration,
|
||||
inputs=[dummy_db_false, config_file_name] + settings_list,
|
||||
outputs=[config_file_name],
|
||||
show_progress=False,
|
||||
)
|
||||
|
||||
button_save_as_config.click(
|
||||
save_configuration,
|
||||
inputs=[dummy_db_true, config_file_name] + settings_list,
|
||||
outputs=[config_file_name],
|
||||
show_progress=False,
|
||||
)
|
||||
|
||||
button_run.click(
|
||||
train_model,
|
||||
inputs=settings_list,
|
||||
show_progress=False,
|
||||
)
|
||||
|
||||
return (
|
||||
|
Loading…
Reference in New Issue
Block a user