Add authentication support
This commit is contained in:
parent
1bc5089db8
commit
aa5d13f9a7
@ -10,4 +10,9 @@ You can find the dreambooth solution spercific [Dreambooth README](README_dreamb
|
|||||||
|
|
||||||
## Finetune
|
## Finetune
|
||||||
|
|
||||||
You can find the finetune solution spercific [Finetune README](README_finetune.md)
|
You can find the finetune solution spercific [Finetune README](README_finetune.md)
|
||||||
|
|
||||||
|
## Change history
|
||||||
|
|
||||||
|
* 12/21 (v9.7) update:
|
||||||
|
- add optional GUI authentication support via: `python fine_tune.py --username=<name> --password=<password>`
|
@ -10,6 +10,7 @@ import os
|
|||||||
import subprocess
|
import subprocess
|
||||||
import pathlib
|
import pathlib
|
||||||
import shutil
|
import shutil
|
||||||
|
import argparse
|
||||||
from library.dreambooth_folder_creation_gui import (
|
from library.dreambooth_folder_creation_gui import (
|
||||||
gradio_dreambooth_folder_creation_tab,
|
gradio_dreambooth_folder_creation_tab,
|
||||||
)
|
)
|
||||||
@ -472,491 +473,505 @@ def set_pretrained_model_name_or_path_input(value, v2, v_parameterization):
|
|||||||
|
|
||||||
return value, v2, v_parameterization
|
return value, v2, v_parameterization
|
||||||
|
|
||||||
|
def UI(username, password):
|
||||||
|
css = ''
|
||||||
|
|
||||||
css = ''
|
if os.path.exists('./style.css'):
|
||||||
|
with open(os.path.join('./style.css'), 'r', encoding='utf8') as file:
|
||||||
|
print('Load CSS...')
|
||||||
|
css += file.read() + '\n'
|
||||||
|
|
||||||
if os.path.exists('./style.css'):
|
interface = gr.Blocks(css=css)
|
||||||
with open(os.path.join('./style.css'), 'r', encoding='utf8') as file:
|
|
||||||
print('Load CSS...')
|
|
||||||
css += file.read() + '\n'
|
|
||||||
|
|
||||||
interface = gr.Blocks(css=css)
|
with interface:
|
||||||
|
dummy_true = gr.Label(value=True, visible=False)
|
||||||
with interface:
|
dummy_false = gr.Label(value=False, visible=False)
|
||||||
dummy_true = gr.Label(value=True, visible=False)
|
with gr.Tab('Dreambooth'):
|
||||||
dummy_false = gr.Label(value=False, visible=False)
|
gr.Markdown('Enter kohya finetuner parameter using this interface.')
|
||||||
with gr.Tab('Dreambooth'):
|
with gr.Accordion('Configuration file', open=False):
|
||||||
gr.Markdown('Enter kohya finetuner parameter using this interface.')
|
with gr.Row():
|
||||||
with gr.Accordion('Configuration file', open=False):
|
button_open_config = gr.Button('Open 📂', elem_id='open_folder')
|
||||||
with gr.Row():
|
button_save_config = gr.Button('Save 💾', elem_id='open_folder')
|
||||||
button_open_config = gr.Button('Open 📂', elem_id='open_folder')
|
button_save_as_config = gr.Button(
|
||||||
button_save_config = gr.Button('Save 💾', elem_id='open_folder')
|
'Save as... 💾', elem_id='open_folder'
|
||||||
button_save_as_config = gr.Button(
|
)
|
||||||
'Save as... 💾', elem_id='open_folder'
|
config_file_name = gr.Textbox(
|
||||||
)
|
label='',
|
||||||
config_file_name = gr.Textbox(
|
placeholder="type the configuration file path or use the 'Open' button above to select it...",
|
||||||
label='',
|
interactive=True,
|
||||||
placeholder="type the configuration file path or use the 'Open' button above to select it...",
|
)
|
||||||
interactive=True,
|
# config_file_name.change(
|
||||||
)
|
# remove_doublequote,
|
||||||
# config_file_name.change(
|
# inputs=[config_file_name],
|
||||||
# remove_doublequote,
|
# outputs=[config_file_name],
|
||||||
# inputs=[config_file_name],
|
# )
|
||||||
# outputs=[config_file_name],
|
with gr.Tab('Source model'):
|
||||||
# )
|
# Define the input elements
|
||||||
with gr.Tab('Source model'):
|
with gr.Row():
|
||||||
# Define the input elements
|
pretrained_model_name_or_path_input = gr.Textbox(
|
||||||
with gr.Row():
|
label='Pretrained model name or path',
|
||||||
pretrained_model_name_or_path_input = gr.Textbox(
|
placeholder='enter the path to custom model or name of pretrained model',
|
||||||
label='Pretrained model name or path',
|
)
|
||||||
placeholder='enter the path to custom model or name of pretrained model',
|
pretrained_model_name_or_path_fille = gr.Button(
|
||||||
)
|
document_symbol, elem_id='open_folder_small'
|
||||||
pretrained_model_name_or_path_fille = gr.Button(
|
)
|
||||||
document_symbol, elem_id='open_folder_small'
|
pretrained_model_name_or_path_fille.click(
|
||||||
)
|
get_file_path,
|
||||||
pretrained_model_name_or_path_fille.click(
|
inputs=[pretrained_model_name_or_path_input],
|
||||||
get_file_path,
|
outputs=pretrained_model_name_or_path_input,
|
||||||
|
)
|
||||||
|
pretrained_model_name_or_path_folder = gr.Button(
|
||||||
|
folder_symbol, elem_id='open_folder_small'
|
||||||
|
)
|
||||||
|
pretrained_model_name_or_path_folder.click(
|
||||||
|
get_folder_path,
|
||||||
|
outputs=pretrained_model_name_or_path_input,
|
||||||
|
)
|
||||||
|
model_list = gr.Dropdown(
|
||||||
|
label='(Optional) Model Quick Pick',
|
||||||
|
choices=[
|
||||||
|
'custom',
|
||||||
|
'stabilityai/stable-diffusion-2-1-base',
|
||||||
|
'stabilityai/stable-diffusion-2-base',
|
||||||
|
'stabilityai/stable-diffusion-2-1',
|
||||||
|
'stabilityai/stable-diffusion-2',
|
||||||
|
'runwayml/stable-diffusion-v1-5',
|
||||||
|
'CompVis/stable-diffusion-v1-4',
|
||||||
|
],
|
||||||
|
)
|
||||||
|
save_model_as_dropdown = gr.Dropdown(
|
||||||
|
label='Save trained model as',
|
||||||
|
choices=[
|
||||||
|
'same as source model',
|
||||||
|
'ckpt',
|
||||||
|
'diffusers',
|
||||||
|
'diffusers_safetensors',
|
||||||
|
'safetensors',
|
||||||
|
],
|
||||||
|
value='same as source model',
|
||||||
|
)
|
||||||
|
with gr.Row():
|
||||||
|
v2_input = gr.Checkbox(label='v2', value=True)
|
||||||
|
v_parameterization_input = gr.Checkbox(
|
||||||
|
label='v_parameterization', value=False
|
||||||
|
)
|
||||||
|
pretrained_model_name_or_path_input.change(
|
||||||
|
remove_doublequote,
|
||||||
inputs=[pretrained_model_name_or_path_input],
|
inputs=[pretrained_model_name_or_path_input],
|
||||||
outputs=pretrained_model_name_or_path_input,
|
outputs=[pretrained_model_name_or_path_input],
|
||||||
)
|
)
|
||||||
pretrained_model_name_or_path_folder = gr.Button(
|
model_list.change(
|
||||||
folder_symbol, elem_id='open_folder_small'
|
set_pretrained_model_name_or_path_input,
|
||||||
)
|
inputs=[model_list, v2_input, v_parameterization_input],
|
||||||
pretrained_model_name_or_path_folder.click(
|
outputs=[
|
||||||
get_folder_path,
|
pretrained_model_name_or_path_input,
|
||||||
outputs=pretrained_model_name_or_path_input,
|
v2_input,
|
||||||
)
|
v_parameterization_input,
|
||||||
model_list = gr.Dropdown(
|
|
||||||
label='(Optional) Model Quick Pick',
|
|
||||||
choices=[
|
|
||||||
'custom',
|
|
||||||
'stabilityai/stable-diffusion-2-1-base',
|
|
||||||
'stabilityai/stable-diffusion-2-base',
|
|
||||||
'stabilityai/stable-diffusion-2-1',
|
|
||||||
'stabilityai/stable-diffusion-2',
|
|
||||||
'runwayml/stable-diffusion-v1-5',
|
|
||||||
'CompVis/stable-diffusion-v1-4',
|
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
save_model_as_dropdown = gr.Dropdown(
|
|
||||||
label='Save trained model as',
|
|
||||||
choices=[
|
|
||||||
'same as source model',
|
|
||||||
'ckpt',
|
|
||||||
'diffusers',
|
|
||||||
'diffusers_safetensors',
|
|
||||||
'safetensors',
|
|
||||||
],
|
|
||||||
value='same as source model',
|
|
||||||
)
|
|
||||||
with gr.Row():
|
|
||||||
v2_input = gr.Checkbox(label='v2', value=True)
|
|
||||||
v_parameterization_input = gr.Checkbox(
|
|
||||||
label='v_parameterization', value=False
|
|
||||||
)
|
|
||||||
pretrained_model_name_or_path_input.change(
|
|
||||||
remove_doublequote,
|
|
||||||
inputs=[pretrained_model_name_or_path_input],
|
|
||||||
outputs=[pretrained_model_name_or_path_input],
|
|
||||||
)
|
|
||||||
model_list.change(
|
|
||||||
set_pretrained_model_name_or_path_input,
|
|
||||||
inputs=[model_list, v2_input, v_parameterization_input],
|
|
||||||
outputs=[
|
|
||||||
pretrained_model_name_or_path_input,
|
|
||||||
v2_input,
|
|
||||||
v_parameterization_input,
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
with gr.Tab('Directories'):
|
with gr.Tab('Directories'):
|
||||||
with gr.Row():
|
|
||||||
train_data_dir_input = gr.Textbox(
|
|
||||||
label='Image folder',
|
|
||||||
placeholder='Folder where the training folders containing the images are located',
|
|
||||||
)
|
|
||||||
train_data_dir_input_folder = gr.Button(
|
|
||||||
'📂', elem_id='open_folder_small'
|
|
||||||
)
|
|
||||||
train_data_dir_input_folder.click(
|
|
||||||
get_folder_path, outputs=train_data_dir_input
|
|
||||||
)
|
|
||||||
reg_data_dir_input = gr.Textbox(
|
|
||||||
label='Regularisation folder',
|
|
||||||
placeholder='(Optional) Folder where where the regularization folders containing the images are located',
|
|
||||||
)
|
|
||||||
reg_data_dir_input_folder = gr.Button(
|
|
||||||
'📂', elem_id='open_folder_small'
|
|
||||||
)
|
|
||||||
reg_data_dir_input_folder.click(
|
|
||||||
get_folder_path, outputs=reg_data_dir_input
|
|
||||||
)
|
|
||||||
with gr.Row():
|
|
||||||
output_dir_input = gr.Textbox(
|
|
||||||
label='Output folder',
|
|
||||||
placeholder='Folder to output trained model',
|
|
||||||
)
|
|
||||||
output_dir_input_folder = gr.Button(
|
|
||||||
'📂', elem_id='open_folder_small'
|
|
||||||
)
|
|
||||||
output_dir_input_folder.click(
|
|
||||||
get_folder_path, outputs=output_dir_input
|
|
||||||
)
|
|
||||||
logging_dir_input = gr.Textbox(
|
|
||||||
label='Logging folder',
|
|
||||||
placeholder='Optional: enable logging and output TensorBoard log to this folder',
|
|
||||||
)
|
|
||||||
logging_dir_input_folder = gr.Button(
|
|
||||||
'📂', elem_id='open_folder_small'
|
|
||||||
)
|
|
||||||
logging_dir_input_folder.click(
|
|
||||||
get_folder_path, outputs=logging_dir_input
|
|
||||||
)
|
|
||||||
train_data_dir_input.change(
|
|
||||||
remove_doublequote,
|
|
||||||
inputs=[train_data_dir_input],
|
|
||||||
outputs=[train_data_dir_input],
|
|
||||||
)
|
|
||||||
reg_data_dir_input.change(
|
|
||||||
remove_doublequote,
|
|
||||||
inputs=[reg_data_dir_input],
|
|
||||||
outputs=[reg_data_dir_input],
|
|
||||||
)
|
|
||||||
output_dir_input.change(
|
|
||||||
remove_doublequote,
|
|
||||||
inputs=[output_dir_input],
|
|
||||||
outputs=[output_dir_input],
|
|
||||||
)
|
|
||||||
logging_dir_input.change(
|
|
||||||
remove_doublequote,
|
|
||||||
inputs=[logging_dir_input],
|
|
||||||
outputs=[logging_dir_input],
|
|
||||||
)
|
|
||||||
with gr.Tab('Training parameters'):
|
|
||||||
with gr.Row():
|
|
||||||
learning_rate_input = gr.Textbox(
|
|
||||||
label='Learning rate', value=1e-6
|
|
||||||
)
|
|
||||||
lr_scheduler_input = gr.Dropdown(
|
|
||||||
label='LR Scheduler',
|
|
||||||
choices=[
|
|
||||||
'constant',
|
|
||||||
'constant_with_warmup',
|
|
||||||
'cosine',
|
|
||||||
'cosine_with_restarts',
|
|
||||||
'linear',
|
|
||||||
'polynomial',
|
|
||||||
],
|
|
||||||
value='constant',
|
|
||||||
)
|
|
||||||
lr_warmup_input = gr.Textbox(label='LR warmup', value=0)
|
|
||||||
with gr.Row():
|
|
||||||
train_batch_size_input = gr.Slider(
|
|
||||||
minimum=1,
|
|
||||||
maximum=32,
|
|
||||||
label='Train batch size',
|
|
||||||
value=1,
|
|
||||||
step=1,
|
|
||||||
)
|
|
||||||
epoch_input = gr.Textbox(label='Epoch', value=1)
|
|
||||||
save_every_n_epochs_input = gr.Textbox(
|
|
||||||
label='Save every N epochs', value=1
|
|
||||||
)
|
|
||||||
with gr.Row():
|
|
||||||
mixed_precision_input = gr.Dropdown(
|
|
||||||
label='Mixed precision',
|
|
||||||
choices=[
|
|
||||||
'no',
|
|
||||||
'fp16',
|
|
||||||
'bf16',
|
|
||||||
],
|
|
||||||
value='fp16',
|
|
||||||
)
|
|
||||||
save_precision_input = gr.Dropdown(
|
|
||||||
label='Save precision',
|
|
||||||
choices=[
|
|
||||||
'float',
|
|
||||||
'fp16',
|
|
||||||
'bf16',
|
|
||||||
],
|
|
||||||
value='fp16',
|
|
||||||
)
|
|
||||||
num_cpu_threads_per_process_input = gr.Slider(
|
|
||||||
minimum=1,
|
|
||||||
maximum=os.cpu_count(),
|
|
||||||
step=1,
|
|
||||||
label='Number of CPU threads per process',
|
|
||||||
value=os.cpu_count(),
|
|
||||||
)
|
|
||||||
with gr.Row():
|
|
||||||
seed_input = gr.Textbox(label='Seed', value=1234)
|
|
||||||
max_resolution_input = gr.Textbox(
|
|
||||||
label='Max resolution',
|
|
||||||
value='512,512',
|
|
||||||
placeholder='512,512',
|
|
||||||
)
|
|
||||||
with gr.Row():
|
|
||||||
caption_extention_input = gr.Textbox(
|
|
||||||
label='Caption Extension',
|
|
||||||
placeholder='(Optional) Extension for caption files. default: .caption',
|
|
||||||
)
|
|
||||||
stop_text_encoder_training_input = gr.Slider(
|
|
||||||
minimum=0,
|
|
||||||
maximum=100,
|
|
||||||
value=0,
|
|
||||||
step=1,
|
|
||||||
label='Stop text encoder training',
|
|
||||||
)
|
|
||||||
with gr.Row():
|
|
||||||
enable_bucket_input = gr.Checkbox(
|
|
||||||
label='Enable buckets', value=True
|
|
||||||
)
|
|
||||||
cache_latent_input = gr.Checkbox(
|
|
||||||
label='Cache latent', value=True
|
|
||||||
)
|
|
||||||
use_8bit_adam_input = gr.Checkbox(
|
|
||||||
label='Use 8bit adam', value=True
|
|
||||||
)
|
|
||||||
xformers_input = gr.Checkbox(label='Use xformers', value=True)
|
|
||||||
with gr.Accordion('Advanced Configuration', open=False):
|
|
||||||
with gr.Row():
|
with gr.Row():
|
||||||
full_fp16_input = gr.Checkbox(
|
train_data_dir_input = gr.Textbox(
|
||||||
label='Full fp16 training (experimental)', value=False
|
label='Image folder',
|
||||||
|
placeholder='Folder where the training folders containing the images are located',
|
||||||
)
|
)
|
||||||
no_token_padding_input = gr.Checkbox(
|
train_data_dir_input_folder = gr.Button(
|
||||||
label='No token padding', value=False
|
'📂', elem_id='open_folder_small'
|
||||||
)
|
)
|
||||||
|
train_data_dir_input_folder.click(
|
||||||
gradient_checkpointing_input = gr.Checkbox(
|
get_folder_path, outputs=train_data_dir_input
|
||||||
label='Gradient checkpointing', value=False
|
|
||||||
)
|
)
|
||||||
|
reg_data_dir_input = gr.Textbox(
|
||||||
shuffle_caption = gr.Checkbox(
|
label='Regularisation folder',
|
||||||
label='Shuffle caption', value=False
|
placeholder='(Optional) Folder where where the regularization folders containing the images are located',
|
||||||
|
)
|
||||||
|
reg_data_dir_input_folder = gr.Button(
|
||||||
|
'📂', elem_id='open_folder_small'
|
||||||
|
)
|
||||||
|
reg_data_dir_input_folder.click(
|
||||||
|
get_folder_path, outputs=reg_data_dir_input
|
||||||
)
|
)
|
||||||
save_state = gr.Checkbox(label='Save training state', value=False)
|
|
||||||
with gr.Row():
|
with gr.Row():
|
||||||
resume = gr.Textbox(
|
output_dir_input = gr.Textbox(
|
||||||
label='Resume from saved training state',
|
label='Output folder',
|
||||||
placeholder='path to "last-state" state folder to resume from',
|
placeholder='Folder to output trained model',
|
||||||
)
|
)
|
||||||
resume_button = gr.Button('📂', elem_id='open_folder_small')
|
output_dir_input_folder = gr.Button(
|
||||||
resume_button.click(get_folder_path, outputs=resume)
|
'📂', elem_id='open_folder_small'
|
||||||
prior_loss_weight = gr.Number(
|
|
||||||
label='Prior loss weight', value=1.0
|
|
||||||
)
|
)
|
||||||
|
output_dir_input_folder.click(
|
||||||
|
get_folder_path, outputs=output_dir_input
|
||||||
|
)
|
||||||
|
logging_dir_input = gr.Textbox(
|
||||||
|
label='Logging folder',
|
||||||
|
placeholder='Optional: enable logging and output TensorBoard log to this folder',
|
||||||
|
)
|
||||||
|
logging_dir_input_folder = gr.Button(
|
||||||
|
'📂', elem_id='open_folder_small'
|
||||||
|
)
|
||||||
|
logging_dir_input_folder.click(
|
||||||
|
get_folder_path, outputs=logging_dir_input
|
||||||
|
)
|
||||||
|
train_data_dir_input.change(
|
||||||
|
remove_doublequote,
|
||||||
|
inputs=[train_data_dir_input],
|
||||||
|
outputs=[train_data_dir_input],
|
||||||
|
)
|
||||||
|
reg_data_dir_input.change(
|
||||||
|
remove_doublequote,
|
||||||
|
inputs=[reg_data_dir_input],
|
||||||
|
outputs=[reg_data_dir_input],
|
||||||
|
)
|
||||||
|
output_dir_input.change(
|
||||||
|
remove_doublequote,
|
||||||
|
inputs=[output_dir_input],
|
||||||
|
outputs=[output_dir_input],
|
||||||
|
)
|
||||||
|
logging_dir_input.change(
|
||||||
|
remove_doublequote,
|
||||||
|
inputs=[logging_dir_input],
|
||||||
|
outputs=[logging_dir_input],
|
||||||
|
)
|
||||||
|
with gr.Tab('Training parameters'):
|
||||||
|
with gr.Row():
|
||||||
|
learning_rate_input = gr.Textbox(
|
||||||
|
label='Learning rate', value=1e-6
|
||||||
|
)
|
||||||
|
lr_scheduler_input = gr.Dropdown(
|
||||||
|
label='LR Scheduler',
|
||||||
|
choices=[
|
||||||
|
'constant',
|
||||||
|
'constant_with_warmup',
|
||||||
|
'cosine',
|
||||||
|
'cosine_with_restarts',
|
||||||
|
'linear',
|
||||||
|
'polynomial',
|
||||||
|
],
|
||||||
|
value='constant',
|
||||||
|
)
|
||||||
|
lr_warmup_input = gr.Textbox(label='LR warmup', value=0)
|
||||||
|
with gr.Row():
|
||||||
|
train_batch_size_input = gr.Slider(
|
||||||
|
minimum=1,
|
||||||
|
maximum=32,
|
||||||
|
label='Train batch size',
|
||||||
|
value=1,
|
||||||
|
step=1,
|
||||||
|
)
|
||||||
|
epoch_input = gr.Textbox(label='Epoch', value=1)
|
||||||
|
save_every_n_epochs_input = gr.Textbox(
|
||||||
|
label='Save every N epochs', value=1
|
||||||
|
)
|
||||||
|
with gr.Row():
|
||||||
|
mixed_precision_input = gr.Dropdown(
|
||||||
|
label='Mixed precision',
|
||||||
|
choices=[
|
||||||
|
'no',
|
||||||
|
'fp16',
|
||||||
|
'bf16',
|
||||||
|
],
|
||||||
|
value='fp16',
|
||||||
|
)
|
||||||
|
save_precision_input = gr.Dropdown(
|
||||||
|
label='Save precision',
|
||||||
|
choices=[
|
||||||
|
'float',
|
||||||
|
'fp16',
|
||||||
|
'bf16',
|
||||||
|
],
|
||||||
|
value='fp16',
|
||||||
|
)
|
||||||
|
num_cpu_threads_per_process_input = gr.Slider(
|
||||||
|
minimum=1,
|
||||||
|
maximum=os.cpu_count(),
|
||||||
|
step=1,
|
||||||
|
label='Number of CPU threads per process',
|
||||||
|
value=os.cpu_count(),
|
||||||
|
)
|
||||||
|
with gr.Row():
|
||||||
|
seed_input = gr.Textbox(label='Seed', value=1234)
|
||||||
|
max_resolution_input = gr.Textbox(
|
||||||
|
label='Max resolution',
|
||||||
|
value='512,512',
|
||||||
|
placeholder='512,512',
|
||||||
|
)
|
||||||
|
with gr.Row():
|
||||||
|
caption_extention_input = gr.Textbox(
|
||||||
|
label='Caption Extension',
|
||||||
|
placeholder='(Optional) Extension for caption files. default: .caption',
|
||||||
|
)
|
||||||
|
stop_text_encoder_training_input = gr.Slider(
|
||||||
|
minimum=0,
|
||||||
|
maximum=100,
|
||||||
|
value=0,
|
||||||
|
step=1,
|
||||||
|
label='Stop text encoder training',
|
||||||
|
)
|
||||||
|
with gr.Row():
|
||||||
|
enable_bucket_input = gr.Checkbox(
|
||||||
|
label='Enable buckets', value=True
|
||||||
|
)
|
||||||
|
cache_latent_input = gr.Checkbox(
|
||||||
|
label='Cache latent', value=True
|
||||||
|
)
|
||||||
|
use_8bit_adam_input = gr.Checkbox(
|
||||||
|
label='Use 8bit adam', value=True
|
||||||
|
)
|
||||||
|
xformers_input = gr.Checkbox(label='Use xformers', value=True)
|
||||||
|
with gr.Accordion('Advanced Configuration', open=False):
|
||||||
|
with gr.Row():
|
||||||
|
full_fp16_input = gr.Checkbox(
|
||||||
|
label='Full fp16 training (experimental)', value=False
|
||||||
|
)
|
||||||
|
no_token_padding_input = gr.Checkbox(
|
||||||
|
label='No token padding', value=False
|
||||||
|
)
|
||||||
|
|
||||||
button_run = gr.Button('Train model')
|
gradient_checkpointing_input = gr.Checkbox(
|
||||||
|
label='Gradient checkpointing', value=False
|
||||||
|
)
|
||||||
|
|
||||||
with gr.Tab('Utilities'):
|
shuffle_caption = gr.Checkbox(
|
||||||
with gr.Tab('Captioning'):
|
label='Shuffle caption', value=False
|
||||||
gradio_basic_caption_gui_tab()
|
)
|
||||||
gradio_blip_caption_gui_tab()
|
save_state = gr.Checkbox(label='Save training state', value=False)
|
||||||
gradio_wd14_caption_gui_tab()
|
with gr.Row():
|
||||||
gradio_dreambooth_folder_creation_tab(
|
resume = gr.Textbox(
|
||||||
train_data_dir_input,
|
label='Resume from saved training state',
|
||||||
reg_data_dir_input,
|
placeholder='path to "last-state" state folder to resume from',
|
||||||
output_dir_input,
|
)
|
||||||
logging_dir_input,
|
resume_button = gr.Button('📂', elem_id='open_folder_small')
|
||||||
|
resume_button.click(get_folder_path, outputs=resume)
|
||||||
|
prior_loss_weight = gr.Number(
|
||||||
|
label='Prior loss weight', value=1.0
|
||||||
|
)
|
||||||
|
|
||||||
|
button_run = gr.Button('Train model')
|
||||||
|
|
||||||
|
with gr.Tab('Utilities'):
|
||||||
|
with gr.Tab('Captioning'):
|
||||||
|
gradio_basic_caption_gui_tab()
|
||||||
|
gradio_blip_caption_gui_tab()
|
||||||
|
gradio_wd14_caption_gui_tab()
|
||||||
|
gradio_dreambooth_folder_creation_tab(
|
||||||
|
train_data_dir_input,
|
||||||
|
reg_data_dir_input,
|
||||||
|
output_dir_input,
|
||||||
|
logging_dir_input,
|
||||||
|
)
|
||||||
|
gradio_dataset_balancing_tab()
|
||||||
|
gradio_convert_model_tab()
|
||||||
|
|
||||||
|
button_open_config.click(
|
||||||
|
open_configuration,
|
||||||
|
inputs=[
|
||||||
|
config_file_name,
|
||||||
|
pretrained_model_name_or_path_input,
|
||||||
|
v2_input,
|
||||||
|
v_parameterization_input,
|
||||||
|
logging_dir_input,
|
||||||
|
train_data_dir_input,
|
||||||
|
reg_data_dir_input,
|
||||||
|
output_dir_input,
|
||||||
|
max_resolution_input,
|
||||||
|
learning_rate_input,
|
||||||
|
lr_scheduler_input,
|
||||||
|
lr_warmup_input,
|
||||||
|
train_batch_size_input,
|
||||||
|
epoch_input,
|
||||||
|
save_every_n_epochs_input,
|
||||||
|
mixed_precision_input,
|
||||||
|
save_precision_input,
|
||||||
|
seed_input,
|
||||||
|
num_cpu_threads_per_process_input,
|
||||||
|
cache_latent_input,
|
||||||
|
caption_extention_input,
|
||||||
|
enable_bucket_input,
|
||||||
|
gradient_checkpointing_input,
|
||||||
|
full_fp16_input,
|
||||||
|
no_token_padding_input,
|
||||||
|
stop_text_encoder_training_input,
|
||||||
|
use_8bit_adam_input,
|
||||||
|
xformers_input,
|
||||||
|
save_model_as_dropdown,
|
||||||
|
shuffle_caption,
|
||||||
|
save_state,
|
||||||
|
resume,
|
||||||
|
prior_loss_weight,
|
||||||
|
],
|
||||||
|
outputs=[
|
||||||
|
config_file_name,
|
||||||
|
pretrained_model_name_or_path_input,
|
||||||
|
v2_input,
|
||||||
|
v_parameterization_input,
|
||||||
|
logging_dir_input,
|
||||||
|
train_data_dir_input,
|
||||||
|
reg_data_dir_input,
|
||||||
|
output_dir_input,
|
||||||
|
max_resolution_input,
|
||||||
|
learning_rate_input,
|
||||||
|
lr_scheduler_input,
|
||||||
|
lr_warmup_input,
|
||||||
|
train_batch_size_input,
|
||||||
|
epoch_input,
|
||||||
|
save_every_n_epochs_input,
|
||||||
|
mixed_precision_input,
|
||||||
|
save_precision_input,
|
||||||
|
seed_input,
|
||||||
|
num_cpu_threads_per_process_input,
|
||||||
|
cache_latent_input,
|
||||||
|
caption_extention_input,
|
||||||
|
enable_bucket_input,
|
||||||
|
gradient_checkpointing_input,
|
||||||
|
full_fp16_input,
|
||||||
|
no_token_padding_input,
|
||||||
|
stop_text_encoder_training_input,
|
||||||
|
use_8bit_adam_input,
|
||||||
|
xformers_input,
|
||||||
|
save_model_as_dropdown,
|
||||||
|
shuffle_caption,
|
||||||
|
save_state,
|
||||||
|
resume,
|
||||||
|
prior_loss_weight,
|
||||||
|
],
|
||||||
)
|
)
|
||||||
gradio_dataset_balancing_tab()
|
|
||||||
gradio_convert_model_tab()
|
|
||||||
|
|
||||||
button_open_config.click(
|
save_as = True
|
||||||
open_configuration,
|
not_save_as = False
|
||||||
inputs=[
|
button_save_config.click(
|
||||||
config_file_name,
|
save_configuration,
|
||||||
pretrained_model_name_or_path_input,
|
inputs=[
|
||||||
v2_input,
|
dummy_false,
|
||||||
v_parameterization_input,
|
config_file_name,
|
||||||
logging_dir_input,
|
pretrained_model_name_or_path_input,
|
||||||
train_data_dir_input,
|
v2_input,
|
||||||
reg_data_dir_input,
|
v_parameterization_input,
|
||||||
output_dir_input,
|
logging_dir_input,
|
||||||
max_resolution_input,
|
train_data_dir_input,
|
||||||
learning_rate_input,
|
reg_data_dir_input,
|
||||||
lr_scheduler_input,
|
output_dir_input,
|
||||||
lr_warmup_input,
|
max_resolution_input,
|
||||||
train_batch_size_input,
|
learning_rate_input,
|
||||||
epoch_input,
|
lr_scheduler_input,
|
||||||
save_every_n_epochs_input,
|
lr_warmup_input,
|
||||||
mixed_precision_input,
|
train_batch_size_input,
|
||||||
save_precision_input,
|
epoch_input,
|
||||||
seed_input,
|
save_every_n_epochs_input,
|
||||||
num_cpu_threads_per_process_input,
|
mixed_precision_input,
|
||||||
cache_latent_input,
|
save_precision_input,
|
||||||
caption_extention_input,
|
seed_input,
|
||||||
enable_bucket_input,
|
num_cpu_threads_per_process_input,
|
||||||
gradient_checkpointing_input,
|
cache_latent_input,
|
||||||
full_fp16_input,
|
caption_extention_input,
|
||||||
no_token_padding_input,
|
enable_bucket_input,
|
||||||
stop_text_encoder_training_input,
|
gradient_checkpointing_input,
|
||||||
use_8bit_adam_input,
|
full_fp16_input,
|
||||||
xformers_input,
|
no_token_padding_input,
|
||||||
save_model_as_dropdown,
|
stop_text_encoder_training_input,
|
||||||
shuffle_caption,
|
use_8bit_adam_input,
|
||||||
save_state,
|
xformers_input,
|
||||||
resume,
|
save_model_as_dropdown,
|
||||||
prior_loss_weight,
|
shuffle_caption,
|
||||||
],
|
save_state,
|
||||||
outputs=[
|
resume,
|
||||||
config_file_name,
|
prior_loss_weight,
|
||||||
pretrained_model_name_or_path_input,
|
],
|
||||||
v2_input,
|
outputs=[config_file_name],
|
||||||
v_parameterization_input,
|
)
|
||||||
logging_dir_input,
|
|
||||||
train_data_dir_input,
|
|
||||||
reg_data_dir_input,
|
|
||||||
output_dir_input,
|
|
||||||
max_resolution_input,
|
|
||||||
learning_rate_input,
|
|
||||||
lr_scheduler_input,
|
|
||||||
lr_warmup_input,
|
|
||||||
train_batch_size_input,
|
|
||||||
epoch_input,
|
|
||||||
save_every_n_epochs_input,
|
|
||||||
mixed_precision_input,
|
|
||||||
save_precision_input,
|
|
||||||
seed_input,
|
|
||||||
num_cpu_threads_per_process_input,
|
|
||||||
cache_latent_input,
|
|
||||||
caption_extention_input,
|
|
||||||
enable_bucket_input,
|
|
||||||
gradient_checkpointing_input,
|
|
||||||
full_fp16_input,
|
|
||||||
no_token_padding_input,
|
|
||||||
stop_text_encoder_training_input,
|
|
||||||
use_8bit_adam_input,
|
|
||||||
xformers_input,
|
|
||||||
save_model_as_dropdown,
|
|
||||||
shuffle_caption,
|
|
||||||
save_state,
|
|
||||||
resume,
|
|
||||||
prior_loss_weight,
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
save_as = True
|
button_save_as_config.click(
|
||||||
not_save_as = False
|
save_configuration,
|
||||||
button_save_config.click(
|
inputs=[
|
||||||
save_configuration,
|
dummy_true,
|
||||||
inputs=[
|
config_file_name,
|
||||||
dummy_false,
|
pretrained_model_name_or_path_input,
|
||||||
config_file_name,
|
v2_input,
|
||||||
pretrained_model_name_or_path_input,
|
v_parameterization_input,
|
||||||
v2_input,
|
logging_dir_input,
|
||||||
v_parameterization_input,
|
train_data_dir_input,
|
||||||
logging_dir_input,
|
reg_data_dir_input,
|
||||||
train_data_dir_input,
|
output_dir_input,
|
||||||
reg_data_dir_input,
|
max_resolution_input,
|
||||||
output_dir_input,
|
learning_rate_input,
|
||||||
max_resolution_input,
|
lr_scheduler_input,
|
||||||
learning_rate_input,
|
lr_warmup_input,
|
||||||
lr_scheduler_input,
|
train_batch_size_input,
|
||||||
lr_warmup_input,
|
epoch_input,
|
||||||
train_batch_size_input,
|
save_every_n_epochs_input,
|
||||||
epoch_input,
|
mixed_precision_input,
|
||||||
save_every_n_epochs_input,
|
save_precision_input,
|
||||||
mixed_precision_input,
|
seed_input,
|
||||||
save_precision_input,
|
num_cpu_threads_per_process_input,
|
||||||
seed_input,
|
cache_latent_input,
|
||||||
num_cpu_threads_per_process_input,
|
caption_extention_input,
|
||||||
cache_latent_input,
|
enable_bucket_input,
|
||||||
caption_extention_input,
|
gradient_checkpointing_input,
|
||||||
enable_bucket_input,
|
full_fp16_input,
|
||||||
gradient_checkpointing_input,
|
no_token_padding_input,
|
||||||
full_fp16_input,
|
stop_text_encoder_training_input,
|
||||||
no_token_padding_input,
|
use_8bit_adam_input,
|
||||||
stop_text_encoder_training_input,
|
xformers_input,
|
||||||
use_8bit_adam_input,
|
save_model_as_dropdown,
|
||||||
xformers_input,
|
shuffle_caption,
|
||||||
save_model_as_dropdown,
|
save_state,
|
||||||
shuffle_caption,
|
resume,
|
||||||
save_state,
|
prior_loss_weight,
|
||||||
resume,
|
],
|
||||||
prior_loss_weight,
|
outputs=[config_file_name],
|
||||||
],
|
)
|
||||||
outputs=[config_file_name],
|
|
||||||
)
|
|
||||||
|
|
||||||
button_save_as_config.click(
|
button_run.click(
|
||||||
save_configuration,
|
train_model,
|
||||||
inputs=[
|
inputs=[
|
||||||
dummy_true,
|
pretrained_model_name_or_path_input,
|
||||||
config_file_name,
|
v2_input,
|
||||||
pretrained_model_name_or_path_input,
|
v_parameterization_input,
|
||||||
v2_input,
|
logging_dir_input,
|
||||||
v_parameterization_input,
|
train_data_dir_input,
|
||||||
logging_dir_input,
|
reg_data_dir_input,
|
||||||
train_data_dir_input,
|
output_dir_input,
|
||||||
reg_data_dir_input,
|
max_resolution_input,
|
||||||
output_dir_input,
|
learning_rate_input,
|
||||||
max_resolution_input,
|
lr_scheduler_input,
|
||||||
learning_rate_input,
|
lr_warmup_input,
|
||||||
lr_scheduler_input,
|
train_batch_size_input,
|
||||||
lr_warmup_input,
|
epoch_input,
|
||||||
train_batch_size_input,
|
save_every_n_epochs_input,
|
||||||
epoch_input,
|
mixed_precision_input,
|
||||||
save_every_n_epochs_input,
|
save_precision_input,
|
||||||
mixed_precision_input,
|
seed_input,
|
||||||
save_precision_input,
|
num_cpu_threads_per_process_input,
|
||||||
seed_input,
|
cache_latent_input,
|
||||||
num_cpu_threads_per_process_input,
|
caption_extention_input,
|
||||||
cache_latent_input,
|
enable_bucket_input,
|
||||||
caption_extention_input,
|
gradient_checkpointing_input,
|
||||||
enable_bucket_input,
|
full_fp16_input,
|
||||||
gradient_checkpointing_input,
|
no_token_padding_input,
|
||||||
full_fp16_input,
|
stop_text_encoder_training_input,
|
||||||
no_token_padding_input,
|
use_8bit_adam_input,
|
||||||
stop_text_encoder_training_input,
|
xformers_input,
|
||||||
use_8bit_adam_input,
|
save_model_as_dropdown,
|
||||||
xformers_input,
|
shuffle_caption,
|
||||||
save_model_as_dropdown,
|
save_state,
|
||||||
shuffle_caption,
|
resume,
|
||||||
save_state,
|
prior_loss_weight,
|
||||||
resume,
|
],
|
||||||
prior_loss_weight,
|
)
|
||||||
],
|
|
||||||
outputs=[config_file_name],
|
|
||||||
)
|
|
||||||
|
|
||||||
button_run.click(
|
# Show the interface
|
||||||
train_model,
|
if not username == '':
|
||||||
inputs=[
|
interface.launch(auth=(username, password))
|
||||||
pretrained_model_name_or_path_input,
|
else:
|
||||||
v2_input,
|
interface.launch()
|
||||||
v_parameterization_input,
|
|
||||||
logging_dir_input,
|
|
||||||
train_data_dir_input,
|
|
||||||
reg_data_dir_input,
|
|
||||||
output_dir_input,
|
|
||||||
max_resolution_input,
|
|
||||||
learning_rate_input,
|
|
||||||
lr_scheduler_input,
|
|
||||||
lr_warmup_input,
|
|
||||||
train_batch_size_input,
|
|
||||||
epoch_input,
|
|
||||||
save_every_n_epochs_input,
|
|
||||||
mixed_precision_input,
|
|
||||||
save_precision_input,
|
|
||||||
seed_input,
|
|
||||||
num_cpu_threads_per_process_input,
|
|
||||||
cache_latent_input,
|
|
||||||
caption_extention_input,
|
|
||||||
enable_bucket_input,
|
|
||||||
gradient_checkpointing_input,
|
|
||||||
full_fp16_input,
|
|
||||||
no_token_padding_input,
|
|
||||||
stop_text_encoder_training_input,
|
|
||||||
use_8bit_adam_input,
|
|
||||||
xformers_input,
|
|
||||||
save_model_as_dropdown,
|
|
||||||
shuffle_caption,
|
|
||||||
save_state,
|
|
||||||
resume,
|
|
||||||
prior_loss_weight,
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
# Show the interface
|
|
||||||
interface.launch()
|
if __name__ == '__main__':
|
||||||
|
# torch.cuda.set_per_process_memory_fraction(0.48)
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument("--username", type=str, default='', help="Username for authentication")
|
||||||
|
parser.add_argument("--password", type=str, default='', help="Password for authentication")
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
UI(username=args.username, password=args.password)
|
||||||
|
791
finetune_gui.py
791
finetune_gui.py
@ -5,6 +5,7 @@ import os
|
|||||||
import subprocess
|
import subprocess
|
||||||
import pathlib
|
import pathlib
|
||||||
import shutil
|
import shutil
|
||||||
|
import argparse
|
||||||
|
|
||||||
# from easygui import fileopenbox, filesavebox, diropenbox, msgbox
|
# from easygui import fileopenbox, filesavebox, diropenbox, msgbox
|
||||||
from library.basic_caption_gui import gradio_basic_caption_gui_tab
|
from library.basic_caption_gui import gradio_basic_caption_gui_tab
|
||||||
@ -99,9 +100,8 @@ def save_configuration(
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Save the data to the selected file
|
# Save the data to the selected file
|
||||||
# with open(file_path, 'w') as file:
|
with open(file_path, 'w') as file:
|
||||||
# json.dump(variables, file)
|
json.dump(variables, file)
|
||||||
# msgbox('File was saved...')
|
|
||||||
|
|
||||||
return file_path
|
return file_path
|
||||||
|
|
||||||
@ -386,410 +386,425 @@ def remove_doublequote(file_path):
|
|||||||
|
|
||||||
return file_path
|
return file_path
|
||||||
|
|
||||||
|
def UI(username, password):
|
||||||
|
|
||||||
css = ''
|
css = ''
|
||||||
|
|
||||||
if os.path.exists('./style.css'):
|
if os.path.exists('./style.css'):
|
||||||
with open(os.path.join('./style.css'), 'r', encoding='utf8') as file:
|
with open(os.path.join('./style.css'), 'r', encoding='utf8') as file:
|
||||||
print('Load CSS...')
|
print('Load CSS...')
|
||||||
css += file.read() + '\n'
|
css += file.read() + '\n'
|
||||||
|
|
||||||
interface = gr.Blocks(css=css)
|
interface = gr.Blocks(css=css)
|
||||||
|
|
||||||
with interface:
|
with interface:
|
||||||
dummy_true = gr.Label(value=True, visible=False)
|
dummy_true = gr.Label(value=True, visible=False)
|
||||||
dummy_false = gr.Label(value=False, visible=False)
|
dummy_false = gr.Label(value=False, visible=False)
|
||||||
with gr.Tab('Finetuning'):
|
with gr.Tab('Finetuning'):
|
||||||
gr.Markdown('Enter kohya finetuner parameter using this interface.')
|
gr.Markdown('Enter kohya finetuner parameter using this interface.')
|
||||||
with gr.Accordion('Configuration File Load/Save', open=False):
|
with gr.Accordion('Configuration File Load/Save', open=False):
|
||||||
with gr.Row():
|
with gr.Row():
|
||||||
button_open_config = gr.Button(
|
button_open_config = gr.Button(
|
||||||
f'Open {folder_symbol}', elem_id='open_folder'
|
f'Open {folder_symbol}', elem_id='open_folder'
|
||||||
|
)
|
||||||
|
button_save_config = gr.Button(
|
||||||
|
f'Save {save_style_symbol}', elem_id='open_folder'
|
||||||
|
)
|
||||||
|
button_save_as_config = gr.Button(
|
||||||
|
f'Save as... {save_style_symbol}', elem_id='open_folder'
|
||||||
|
)
|
||||||
|
config_file_name = gr.Textbox(
|
||||||
|
label='', placeholder='type file path or use buttons...'
|
||||||
)
|
)
|
||||||
button_save_config = gr.Button(
|
config_file_name.change(
|
||||||
f'Save {save_style_symbol}', elem_id='open_folder'
|
remove_doublequote,
|
||||||
|
inputs=[config_file_name],
|
||||||
|
outputs=[config_file_name],
|
||||||
)
|
)
|
||||||
button_save_as_config = gr.Button(
|
with gr.Tab('Source model'):
|
||||||
f'Save as... {save_style_symbol}', elem_id='open_folder'
|
# Define the input elements
|
||||||
)
|
with gr.Row():
|
||||||
config_file_name = gr.Textbox(
|
pretrained_model_name_or_path_input = gr.Textbox(
|
||||||
label='', placeholder='type file path or use buttons...'
|
label='Pretrained model name or path',
|
||||||
)
|
placeholder='enter the path to custom model or name of pretrained model',
|
||||||
config_file_name.change(
|
)
|
||||||
remove_doublequote,
|
pretrained_model_name_or_path_file = gr.Button(
|
||||||
inputs=[config_file_name],
|
document_symbol, elem_id='open_folder_small'
|
||||||
outputs=[config_file_name],
|
)
|
||||||
)
|
pretrained_model_name_or_path_file.click(
|
||||||
with gr.Tab('Source model'):
|
get_file_path,
|
||||||
# Define the input elements
|
inputs=pretrained_model_name_or_path_input,
|
||||||
with gr.Row():
|
outputs=pretrained_model_name_or_path_input,
|
||||||
pretrained_model_name_or_path_input = gr.Textbox(
|
)
|
||||||
label='Pretrained model name or path',
|
pretrained_model_name_or_path_folder = gr.Button(
|
||||||
placeholder='enter the path to custom model or name of pretrained model',
|
folder_symbol, elem_id='open_folder_small'
|
||||||
)
|
)
|
||||||
pretrained_model_name_or_path_file = gr.Button(
|
pretrained_model_name_or_path_folder.click(
|
||||||
document_symbol, elem_id='open_folder_small'
|
get_folder_path,
|
||||||
)
|
inputs=pretrained_model_name_or_path_input,
|
||||||
pretrained_model_name_or_path_file.click(
|
outputs=pretrained_model_name_or_path_input,
|
||||||
get_file_path,
|
)
|
||||||
inputs=pretrained_model_name_or_path_input,
|
model_list = gr.Dropdown(
|
||||||
outputs=pretrained_model_name_or_path_input,
|
label='(Optional) Model Quick Pick',
|
||||||
)
|
choices=[
|
||||||
pretrained_model_name_or_path_folder = gr.Button(
|
'custom',
|
||||||
folder_symbol, elem_id='open_folder_small'
|
'stabilityai/stable-diffusion-2-1-base',
|
||||||
)
|
'stabilityai/stable-diffusion-2-base',
|
||||||
pretrained_model_name_or_path_folder.click(
|
'stabilityai/stable-diffusion-2-1',
|
||||||
get_folder_path,
|
'stabilityai/stable-diffusion-2',
|
||||||
inputs=pretrained_model_name_or_path_input,
|
'runwayml/stable-diffusion-v1-5',
|
||||||
outputs=pretrained_model_name_or_path_input,
|
'CompVis/stable-diffusion-v1-4',
|
||||||
)
|
],
|
||||||
model_list = gr.Dropdown(
|
)
|
||||||
label='(Optional) Model Quick Pick',
|
save_model_as_dropdown = gr.Dropdown(
|
||||||
choices=[
|
label='Save trained model as',
|
||||||
'custom',
|
choices=[
|
||||||
'stabilityai/stable-diffusion-2-1-base',
|
'same as source model',
|
||||||
'stabilityai/stable-diffusion-2-base',
|
'ckpt',
|
||||||
'stabilityai/stable-diffusion-2-1',
|
'diffusers',
|
||||||
'stabilityai/stable-diffusion-2',
|
'diffusers_safetensors',
|
||||||
'runwayml/stable-diffusion-v1-5',
|
'safetensors',
|
||||||
'CompVis/stable-diffusion-v1-4',
|
],
|
||||||
|
value='same as source model',
|
||||||
|
)
|
||||||
|
|
||||||
|
with gr.Row():
|
||||||
|
v2_input = gr.Checkbox(label='v2', value=True)
|
||||||
|
v_parameterization_input = gr.Checkbox(
|
||||||
|
label='v_parameterization', value=False
|
||||||
|
)
|
||||||
|
model_list.change(
|
||||||
|
set_pretrained_model_name_or_path_input,
|
||||||
|
inputs=[model_list, v2_input, v_parameterization_input],
|
||||||
|
outputs=[
|
||||||
|
pretrained_model_name_or_path_input,
|
||||||
|
v2_input,
|
||||||
|
v_parameterization_input,
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
save_model_as_dropdown = gr.Dropdown(
|
with gr.Tab('Directories'):
|
||||||
label='Save trained model as',
|
with gr.Row():
|
||||||
choices=[
|
train_dir_input = gr.Textbox(
|
||||||
'same as source model',
|
label='Training config folder',
|
||||||
'ckpt',
|
placeholder='folder where the training configuration files will be saved',
|
||||||
'diffusers',
|
)
|
||||||
'diffusers_safetensors',
|
train_dir_folder = gr.Button(
|
||||||
'safetensors',
|
folder_symbol, elem_id='open_folder_small'
|
||||||
],
|
)
|
||||||
value='same as source model',
|
train_dir_folder.click(
|
||||||
)
|
get_folder_path, outputs=train_dir_input
|
||||||
|
)
|
||||||
|
|
||||||
with gr.Row():
|
image_folder_input = gr.Textbox(
|
||||||
v2_input = gr.Checkbox(label='v2', value=True)
|
label='Training Image folder',
|
||||||
v_parameterization_input = gr.Checkbox(
|
placeholder='folder where the training images are located',
|
||||||
label='v_parameterization', value=False
|
)
|
||||||
|
image_folder_input_folder = gr.Button(
|
||||||
|
folder_symbol, elem_id='open_folder_small'
|
||||||
|
)
|
||||||
|
image_folder_input_folder.click(
|
||||||
|
get_folder_path, outputs=image_folder_input
|
||||||
|
)
|
||||||
|
with gr.Row():
|
||||||
|
output_dir_input = gr.Textbox(
|
||||||
|
label='Output folder',
|
||||||
|
placeholder='folder where the model will be saved',
|
||||||
|
)
|
||||||
|
output_dir_input_folder = gr.Button(
|
||||||
|
folder_symbol, elem_id='open_folder_small'
|
||||||
|
)
|
||||||
|
output_dir_input_folder.click(
|
||||||
|
get_folder_path, outputs=output_dir_input
|
||||||
|
)
|
||||||
|
|
||||||
|
logging_dir_input = gr.Textbox(
|
||||||
|
label='Logging folder',
|
||||||
|
placeholder='Optional: enable logging and output TensorBoard log to this folder',
|
||||||
|
)
|
||||||
|
logging_dir_input_folder = gr.Button(
|
||||||
|
folder_symbol, elem_id='open_folder_small'
|
||||||
|
)
|
||||||
|
logging_dir_input_folder.click(
|
||||||
|
get_folder_path, outputs=logging_dir_input
|
||||||
|
)
|
||||||
|
train_dir_input.change(
|
||||||
|
remove_doublequote,
|
||||||
|
inputs=[train_dir_input],
|
||||||
|
outputs=[train_dir_input],
|
||||||
)
|
)
|
||||||
model_list.change(
|
image_folder_input.change(
|
||||||
set_pretrained_model_name_or_path_input,
|
remove_doublequote,
|
||||||
inputs=[model_list, v2_input, v_parameterization_input],
|
inputs=[image_folder_input],
|
||||||
outputs=[
|
outputs=[image_folder_input],
|
||||||
|
)
|
||||||
|
output_dir_input.change(
|
||||||
|
remove_doublequote,
|
||||||
|
inputs=[output_dir_input],
|
||||||
|
outputs=[output_dir_input],
|
||||||
|
)
|
||||||
|
with gr.Tab('Training parameters'):
|
||||||
|
with gr.Row():
|
||||||
|
learning_rate_input = gr.Textbox(
|
||||||
|
label='Learning rate', value=1e-6
|
||||||
|
)
|
||||||
|
lr_scheduler_input = gr.Dropdown(
|
||||||
|
label='LR Scheduler',
|
||||||
|
choices=[
|
||||||
|
'constant',
|
||||||
|
'constant_with_warmup',
|
||||||
|
'cosine',
|
||||||
|
'cosine_with_restarts',
|
||||||
|
'linear',
|
||||||
|
'polynomial',
|
||||||
|
],
|
||||||
|
value='constant',
|
||||||
|
)
|
||||||
|
lr_warmup_input = gr.Textbox(label='LR warmup', value=0)
|
||||||
|
with gr.Row():
|
||||||
|
dataset_repeats_input = gr.Textbox(
|
||||||
|
label='Dataset repeats', value=40
|
||||||
|
)
|
||||||
|
train_batch_size_input = gr.Slider(
|
||||||
|
minimum=1,
|
||||||
|
maximum=32,
|
||||||
|
label='Train batch size',
|
||||||
|
value=1,
|
||||||
|
step=1,
|
||||||
|
)
|
||||||
|
epoch_input = gr.Textbox(label='Epoch', value=1)
|
||||||
|
save_every_n_epochs_input = gr.Textbox(
|
||||||
|
label='Save every N epochs', value=1
|
||||||
|
)
|
||||||
|
with gr.Row():
|
||||||
|
mixed_precision_input = gr.Dropdown(
|
||||||
|
label='Mixed precision',
|
||||||
|
choices=[
|
||||||
|
'no',
|
||||||
|
'fp16',
|
||||||
|
'bf16',
|
||||||
|
],
|
||||||
|
value='fp16',
|
||||||
|
)
|
||||||
|
save_precision_input = gr.Dropdown(
|
||||||
|
label='Save precision',
|
||||||
|
choices=[
|
||||||
|
'float',
|
||||||
|
'fp16',
|
||||||
|
'bf16',
|
||||||
|
],
|
||||||
|
value='fp16',
|
||||||
|
)
|
||||||
|
num_cpu_threads_per_process_input = gr.Slider(
|
||||||
|
minimum=1,
|
||||||
|
maximum=os.cpu_count(),
|
||||||
|
step=1,
|
||||||
|
label='Number of CPU threads per process',
|
||||||
|
value=os.cpu_count(),
|
||||||
|
)
|
||||||
|
with gr.Row():
|
||||||
|
seed_input = gr.Textbox(label='Seed', value=1234)
|
||||||
|
max_resolution_input = gr.Textbox(
|
||||||
|
label='Max resolution', value='512,512'
|
||||||
|
)
|
||||||
|
with gr.Row():
|
||||||
|
caption_extention_input = gr.Textbox(
|
||||||
|
label='Caption Extension',
|
||||||
|
placeholder='(Optional) Extension for caption files. default: .txt',
|
||||||
|
)
|
||||||
|
train_text_encoder_input = gr.Checkbox(
|
||||||
|
label='Train text encoder', value=True
|
||||||
|
)
|
||||||
|
with gr.Box():
|
||||||
|
with gr.Row():
|
||||||
|
create_caption = gr.Checkbox(
|
||||||
|
label='Generate caption database', value=True
|
||||||
|
)
|
||||||
|
create_buckets = gr.Checkbox(
|
||||||
|
label='Generate image buckets', value=True
|
||||||
|
)
|
||||||
|
train = gr.Checkbox(label='Train model', value=True)
|
||||||
|
|
||||||
|
button_run = gr.Button('Run')
|
||||||
|
|
||||||
|
button_run.click(
|
||||||
|
train_model,
|
||||||
|
inputs=[
|
||||||
|
create_caption,
|
||||||
|
create_buckets,
|
||||||
|
train,
|
||||||
pretrained_model_name_or_path_input,
|
pretrained_model_name_or_path_input,
|
||||||
v2_input,
|
v2_input,
|
||||||
v_parameterization_input,
|
v_parameterization_input,
|
||||||
|
train_dir_input,
|
||||||
|
image_folder_input,
|
||||||
|
output_dir_input,
|
||||||
|
logging_dir_input,
|
||||||
|
max_resolution_input,
|
||||||
|
learning_rate_input,
|
||||||
|
lr_scheduler_input,
|
||||||
|
lr_warmup_input,
|
||||||
|
dataset_repeats_input,
|
||||||
|
train_batch_size_input,
|
||||||
|
epoch_input,
|
||||||
|
save_every_n_epochs_input,
|
||||||
|
mixed_precision_input,
|
||||||
|
save_precision_input,
|
||||||
|
seed_input,
|
||||||
|
num_cpu_threads_per_process_input,
|
||||||
|
train_text_encoder_input,
|
||||||
|
save_model_as_dropdown,
|
||||||
|
caption_extention_input,
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
with gr.Tab('Directories'):
|
|
||||||
with gr.Row():
|
|
||||||
train_dir_input = gr.Textbox(
|
|
||||||
label='Training config folder',
|
|
||||||
placeholder='folder where the training configuration files will be saved',
|
|
||||||
)
|
|
||||||
train_dir_folder = gr.Button(
|
|
||||||
folder_symbol, elem_id='open_folder_small'
|
|
||||||
)
|
|
||||||
train_dir_folder.click(
|
|
||||||
get_folder_path, outputs=train_dir_input
|
|
||||||
)
|
|
||||||
|
|
||||||
image_folder_input = gr.Textbox(
|
button_open_config.click(
|
||||||
label='Training Image folder',
|
open_config_file,
|
||||||
placeholder='folder where the training images are located',
|
inputs=[
|
||||||
)
|
config_file_name,
|
||||||
image_folder_input_folder = gr.Button(
|
pretrained_model_name_or_path_input,
|
||||||
folder_symbol, elem_id='open_folder_small'
|
v2_input,
|
||||||
)
|
v_parameterization_input,
|
||||||
image_folder_input_folder.click(
|
train_dir_input,
|
||||||
get_folder_path, outputs=image_folder_input
|
image_folder_input,
|
||||||
)
|
output_dir_input,
|
||||||
with gr.Row():
|
logging_dir_input,
|
||||||
output_dir_input = gr.Textbox(
|
max_resolution_input,
|
||||||
label='Output folder',
|
learning_rate_input,
|
||||||
placeholder='folder where the model will be saved',
|
lr_scheduler_input,
|
||||||
)
|
lr_warmup_input,
|
||||||
output_dir_input_folder = gr.Button(
|
dataset_repeats_input,
|
||||||
folder_symbol, elem_id='open_folder_small'
|
train_batch_size_input,
|
||||||
)
|
epoch_input,
|
||||||
output_dir_input_folder.click(
|
save_every_n_epochs_input,
|
||||||
get_folder_path, outputs=output_dir_input
|
mixed_precision_input,
|
||||||
)
|
save_precision_input,
|
||||||
|
seed_input,
|
||||||
logging_dir_input = gr.Textbox(
|
num_cpu_threads_per_process_input,
|
||||||
label='Logging folder',
|
train_text_encoder_input,
|
||||||
placeholder='Optional: enable logging and output TensorBoard log to this folder',
|
create_buckets,
|
||||||
)
|
create_caption,
|
||||||
logging_dir_input_folder = gr.Button(
|
train,
|
||||||
folder_symbol, elem_id='open_folder_small'
|
save_model_as_dropdown,
|
||||||
)
|
caption_extention_input,
|
||||||
logging_dir_input_folder.click(
|
],
|
||||||
get_folder_path, outputs=logging_dir_input
|
outputs=[
|
||||||
)
|
config_file_name,
|
||||||
train_dir_input.change(
|
pretrained_model_name_or_path_input,
|
||||||
remove_doublequote,
|
v2_input,
|
||||||
inputs=[train_dir_input],
|
v_parameterization_input,
|
||||||
outputs=[train_dir_input],
|
train_dir_input,
|
||||||
|
image_folder_input,
|
||||||
|
output_dir_input,
|
||||||
|
logging_dir_input,
|
||||||
|
max_resolution_input,
|
||||||
|
learning_rate_input,
|
||||||
|
lr_scheduler_input,
|
||||||
|
lr_warmup_input,
|
||||||
|
dataset_repeats_input,
|
||||||
|
train_batch_size_input,
|
||||||
|
epoch_input,
|
||||||
|
save_every_n_epochs_input,
|
||||||
|
mixed_precision_input,
|
||||||
|
save_precision_input,
|
||||||
|
seed_input,
|
||||||
|
num_cpu_threads_per_process_input,
|
||||||
|
train_text_encoder_input,
|
||||||
|
create_buckets,
|
||||||
|
create_caption,
|
||||||
|
train,
|
||||||
|
save_model_as_dropdown,
|
||||||
|
caption_extention_input,
|
||||||
|
],
|
||||||
)
|
)
|
||||||
image_folder_input.change(
|
|
||||||
remove_doublequote,
|
button_save_config.click(
|
||||||
inputs=[image_folder_input],
|
save_configuration,
|
||||||
outputs=[image_folder_input],
|
inputs=[
|
||||||
|
dummy_false,
|
||||||
|
config_file_name,
|
||||||
|
pretrained_model_name_or_path_input,
|
||||||
|
v2_input,
|
||||||
|
v_parameterization_input,
|
||||||
|
train_dir_input,
|
||||||
|
image_folder_input,
|
||||||
|
output_dir_input,
|
||||||
|
logging_dir_input,
|
||||||
|
max_resolution_input,
|
||||||
|
learning_rate_input,
|
||||||
|
lr_scheduler_input,
|
||||||
|
lr_warmup_input,
|
||||||
|
dataset_repeats_input,
|
||||||
|
train_batch_size_input,
|
||||||
|
epoch_input,
|
||||||
|
save_every_n_epochs_input,
|
||||||
|
mixed_precision_input,
|
||||||
|
save_precision_input,
|
||||||
|
seed_input,
|
||||||
|
num_cpu_threads_per_process_input,
|
||||||
|
train_text_encoder_input,
|
||||||
|
create_buckets,
|
||||||
|
create_caption,
|
||||||
|
train,
|
||||||
|
save_model_as_dropdown,
|
||||||
|
caption_extention_input,
|
||||||
|
],
|
||||||
|
outputs=[config_file_name],
|
||||||
)
|
)
|
||||||
output_dir_input.change(
|
|
||||||
remove_doublequote,
|
button_save_as_config.click(
|
||||||
inputs=[output_dir_input],
|
save_configuration,
|
||||||
outputs=[output_dir_input],
|
inputs=[
|
||||||
|
dummy_true,
|
||||||
|
config_file_name,
|
||||||
|
pretrained_model_name_or_path_input,
|
||||||
|
v2_input,
|
||||||
|
v_parameterization_input,
|
||||||
|
train_dir_input,
|
||||||
|
image_folder_input,
|
||||||
|
output_dir_input,
|
||||||
|
logging_dir_input,
|
||||||
|
max_resolution_input,
|
||||||
|
learning_rate_input,
|
||||||
|
lr_scheduler_input,
|
||||||
|
lr_warmup_input,
|
||||||
|
dataset_repeats_input,
|
||||||
|
train_batch_size_input,
|
||||||
|
epoch_input,
|
||||||
|
save_every_n_epochs_input,
|
||||||
|
mixed_precision_input,
|
||||||
|
save_precision_input,
|
||||||
|
seed_input,
|
||||||
|
num_cpu_threads_per_process_input,
|
||||||
|
train_text_encoder_input,
|
||||||
|
create_buckets,
|
||||||
|
create_caption,
|
||||||
|
train,
|
||||||
|
save_model_as_dropdown,
|
||||||
|
caption_extention_input,
|
||||||
|
],
|
||||||
|
outputs=[config_file_name],
|
||||||
)
|
)
|
||||||
with gr.Tab('Training parameters'):
|
|
||||||
with gr.Row():
|
|
||||||
learning_rate_input = gr.Textbox(
|
|
||||||
label='Learning rate', value=1e-6
|
|
||||||
)
|
|
||||||
lr_scheduler_input = gr.Dropdown(
|
|
||||||
label='LR Scheduler',
|
|
||||||
choices=[
|
|
||||||
'constant',
|
|
||||||
'constant_with_warmup',
|
|
||||||
'cosine',
|
|
||||||
'cosine_with_restarts',
|
|
||||||
'linear',
|
|
||||||
'polynomial',
|
|
||||||
],
|
|
||||||
value='constant',
|
|
||||||
)
|
|
||||||
lr_warmup_input = gr.Textbox(label='LR warmup', value=0)
|
|
||||||
with gr.Row():
|
|
||||||
dataset_repeats_input = gr.Textbox(
|
|
||||||
label='Dataset repeats', value=40
|
|
||||||
)
|
|
||||||
train_batch_size_input = gr.Slider(
|
|
||||||
minimum=1,
|
|
||||||
maximum=32,
|
|
||||||
label='Train batch size',
|
|
||||||
value=1,
|
|
||||||
step=1,
|
|
||||||
)
|
|
||||||
epoch_input = gr.Textbox(label='Epoch', value=1)
|
|
||||||
save_every_n_epochs_input = gr.Textbox(
|
|
||||||
label='Save every N epochs', value=1
|
|
||||||
)
|
|
||||||
with gr.Row():
|
|
||||||
mixed_precision_input = gr.Dropdown(
|
|
||||||
label='Mixed precision',
|
|
||||||
choices=[
|
|
||||||
'no',
|
|
||||||
'fp16',
|
|
||||||
'bf16',
|
|
||||||
],
|
|
||||||
value='fp16',
|
|
||||||
)
|
|
||||||
save_precision_input = gr.Dropdown(
|
|
||||||
label='Save precision',
|
|
||||||
choices=[
|
|
||||||
'float',
|
|
||||||
'fp16',
|
|
||||||
'bf16',
|
|
||||||
],
|
|
||||||
value='fp16',
|
|
||||||
)
|
|
||||||
num_cpu_threads_per_process_input = gr.Slider(
|
|
||||||
minimum=1,
|
|
||||||
maximum=os.cpu_count(),
|
|
||||||
step=1,
|
|
||||||
label='Number of CPU threads per process',
|
|
||||||
value=os.cpu_count(),
|
|
||||||
)
|
|
||||||
with gr.Row():
|
|
||||||
seed_input = gr.Textbox(label='Seed', value=1234)
|
|
||||||
max_resolution_input = gr.Textbox(
|
|
||||||
label='Max resolution', value='512,512'
|
|
||||||
)
|
|
||||||
with gr.Row():
|
|
||||||
caption_extention_input = gr.Textbox(
|
|
||||||
label='Caption Extension',
|
|
||||||
placeholder='(Optional) Extension for caption files. default: .txt',
|
|
||||||
)
|
|
||||||
train_text_encoder_input = gr.Checkbox(
|
|
||||||
label='Train text encoder', value=True
|
|
||||||
)
|
|
||||||
with gr.Box():
|
|
||||||
with gr.Row():
|
|
||||||
create_caption = gr.Checkbox(
|
|
||||||
label='Generate caption database', value=True
|
|
||||||
)
|
|
||||||
create_buckets = gr.Checkbox(
|
|
||||||
label='Generate image buckets', value=True
|
|
||||||
)
|
|
||||||
train = gr.Checkbox(label='Train model', value=True)
|
|
||||||
|
|
||||||
button_run = gr.Button('Run')
|
with gr.Tab('Utilities'):
|
||||||
|
gradio_basic_caption_gui_tab()
|
||||||
button_run.click(
|
gradio_blip_caption_gui_tab()
|
||||||
train_model,
|
gradio_wd14_caption_gui_tab()
|
||||||
inputs=[
|
gradio_convert_model_tab()
|
||||||
create_caption,
|
|
||||||
create_buckets,
|
|
||||||
train,
|
|
||||||
pretrained_model_name_or_path_input,
|
|
||||||
v2_input,
|
|
||||||
v_parameterization_input,
|
|
||||||
train_dir_input,
|
|
||||||
image_folder_input,
|
|
||||||
output_dir_input,
|
|
||||||
logging_dir_input,
|
|
||||||
max_resolution_input,
|
|
||||||
learning_rate_input,
|
|
||||||
lr_scheduler_input,
|
|
||||||
lr_warmup_input,
|
|
||||||
dataset_repeats_input,
|
|
||||||
train_batch_size_input,
|
|
||||||
epoch_input,
|
|
||||||
save_every_n_epochs_input,
|
|
||||||
mixed_precision_input,
|
|
||||||
save_precision_input,
|
|
||||||
seed_input,
|
|
||||||
num_cpu_threads_per_process_input,
|
|
||||||
train_text_encoder_input,
|
|
||||||
save_model_as_dropdown,
|
|
||||||
caption_extention_input,
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
button_open_config.click(
|
|
||||||
open_config_file,
|
|
||||||
inputs=[
|
|
||||||
config_file_name,
|
|
||||||
pretrained_model_name_or_path_input,
|
|
||||||
v2_input,
|
|
||||||
v_parameterization_input,
|
|
||||||
train_dir_input,
|
|
||||||
image_folder_input,
|
|
||||||
output_dir_input,
|
|
||||||
logging_dir_input,
|
|
||||||
max_resolution_input,
|
|
||||||
learning_rate_input,
|
|
||||||
lr_scheduler_input,
|
|
||||||
lr_warmup_input,
|
|
||||||
dataset_repeats_input,
|
|
||||||
train_batch_size_input,
|
|
||||||
epoch_input,
|
|
||||||
save_every_n_epochs_input,
|
|
||||||
mixed_precision_input,
|
|
||||||
save_precision_input,
|
|
||||||
seed_input,
|
|
||||||
num_cpu_threads_per_process_input,
|
|
||||||
train_text_encoder_input,
|
|
||||||
create_buckets,
|
|
||||||
create_caption,
|
|
||||||
train,
|
|
||||||
save_model_as_dropdown,
|
|
||||||
caption_extention_input,
|
|
||||||
],
|
|
||||||
outputs=[
|
|
||||||
config_file_name,
|
|
||||||
pretrained_model_name_or_path_input,
|
|
||||||
v2_input,
|
|
||||||
v_parameterization_input,
|
|
||||||
train_dir_input,
|
|
||||||
image_folder_input,
|
|
||||||
output_dir_input,
|
|
||||||
logging_dir_input,
|
|
||||||
max_resolution_input,
|
|
||||||
learning_rate_input,
|
|
||||||
lr_scheduler_input,
|
|
||||||
lr_warmup_input,
|
|
||||||
dataset_repeats_input,
|
|
||||||
train_batch_size_input,
|
|
||||||
epoch_input,
|
|
||||||
save_every_n_epochs_input,
|
|
||||||
mixed_precision_input,
|
|
||||||
save_precision_input,
|
|
||||||
seed_input,
|
|
||||||
num_cpu_threads_per_process_input,
|
|
||||||
train_text_encoder_input,
|
|
||||||
create_buckets,
|
|
||||||
create_caption,
|
|
||||||
train,
|
|
||||||
save_model_as_dropdown,
|
|
||||||
caption_extention_input,
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
button_save_config.click(
|
|
||||||
save_configuration,
|
|
||||||
inputs=[
|
|
||||||
dummy_false,
|
|
||||||
config_file_name,
|
|
||||||
pretrained_model_name_or_path_input,
|
|
||||||
v2_input,
|
|
||||||
v_parameterization_input,
|
|
||||||
train_dir_input,
|
|
||||||
image_folder_input,
|
|
||||||
output_dir_input,
|
|
||||||
logging_dir_input,
|
|
||||||
max_resolution_input,
|
|
||||||
learning_rate_input,
|
|
||||||
lr_scheduler_input,
|
|
||||||
lr_warmup_input,
|
|
||||||
dataset_repeats_input,
|
|
||||||
train_batch_size_input,
|
|
||||||
epoch_input,
|
|
||||||
save_every_n_epochs_input,
|
|
||||||
mixed_precision_input,
|
|
||||||
save_precision_input,
|
|
||||||
seed_input,
|
|
||||||
num_cpu_threads_per_process_input,
|
|
||||||
train_text_encoder_input,
|
|
||||||
create_buckets,
|
|
||||||
create_caption,
|
|
||||||
train,
|
|
||||||
save_model_as_dropdown,
|
|
||||||
caption_extention_input,
|
|
||||||
],
|
|
||||||
outputs=[config_file_name],
|
|
||||||
)
|
|
||||||
|
|
||||||
button_save_as_config.click(
|
|
||||||
save_configuration,
|
|
||||||
inputs=[
|
|
||||||
dummy_true,
|
|
||||||
config_file_name,
|
|
||||||
pretrained_model_name_or_path_input,
|
|
||||||
v2_input,
|
|
||||||
v_parameterization_input,
|
|
||||||
train_dir_input,
|
|
||||||
image_folder_input,
|
|
||||||
output_dir_input,
|
|
||||||
logging_dir_input,
|
|
||||||
max_resolution_input,
|
|
||||||
learning_rate_input,
|
|
||||||
lr_scheduler_input,
|
|
||||||
lr_warmup_input,
|
|
||||||
dataset_repeats_input,
|
|
||||||
train_batch_size_input,
|
|
||||||
epoch_input,
|
|
||||||
save_every_n_epochs_input,
|
|
||||||
mixed_precision_input,
|
|
||||||
save_precision_input,
|
|
||||||
seed_input,
|
|
||||||
num_cpu_threads_per_process_input,
|
|
||||||
train_text_encoder_input,
|
|
||||||
create_buckets,
|
|
||||||
create_caption,
|
|
||||||
train,
|
|
||||||
save_model_as_dropdown,
|
|
||||||
caption_extention_input,
|
|
||||||
],
|
|
||||||
outputs=[config_file_name],
|
|
||||||
)
|
|
||||||
|
|
||||||
with gr.Tab('Utilities'):
|
|
||||||
gradio_basic_caption_gui_tab()
|
|
||||||
gradio_blip_caption_gui_tab()
|
|
||||||
gradio_wd14_caption_gui_tab()
|
|
||||||
gradio_convert_model_tab()
|
|
||||||
|
|
||||||
|
|
||||||
# Show the interface
|
# Show the interface
|
||||||
interface.launch()
|
if not username == '':
|
||||||
|
interface.launch(auth=(username, password))
|
||||||
|
else:
|
||||||
|
interface.launch()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
# torch.cuda.set_per_process_memory_fraction(0.48)
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument("--username", type=str, default='', help="Username for authentication")
|
||||||
|
parser.add_argument("--password", type=str, default='', help="Password for authentication")
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
UI(username=args.username, password=args.password)
|
||||||
|
Loading…
Reference in New Issue
Block a user