Merge dreambooth and Finetune is a common GUI
Merge dreambooth and Finetune is a common GUI
This commit is contained in:
commit
89d275dff7
@ -14,6 +14,9 @@ You can find the finetune solution spercific [Finetune README](README_finetune.m
|
||||
|
||||
## Change history
|
||||
|
||||
* 12/22 (v18.7) update:
|
||||
- Merge dreambooth and finetune is a common GUI
|
||||
- General bug fixes and code improvements
|
||||
* 12/21 (v18.6.1) update:
|
||||
- fix issue with dataset balancing when the number of detected images in the folder is 0
|
||||
|
||||
|
@ -71,7 +71,7 @@ When a new release comes out you can upgrade your repo with the following comman
|
||||
.\upgrade.bat
|
||||
```
|
||||
|
||||
or you can do it manually with
|
||||
alternatively you can do it manually with
|
||||
|
||||
```powershell
|
||||
cd kohya_ss
|
||||
@ -84,15 +84,27 @@ Once the commands have completed successfully you should be ready to use the new
|
||||
|
||||
## GUI
|
||||
|
||||
There is now support for GUI based training using gradio. You can start the GUI interface by running:
|
||||
There is now support for GUI based training using gradio. You can start the complete kohya training GUI interface by running:
|
||||
|
||||
```powershell
|
||||
.\dreambooth.bat
|
||||
.\kohya.cmd
|
||||
```
|
||||
|
||||
and select the Dreambooth tab.
|
||||
|
||||
Alternativelly you can use the Dreambooth focus GUI with
|
||||
|
||||
```powershell
|
||||
.\dreambooth.cmd
|
||||
```
|
||||
|
||||
## CLI
|
||||
|
||||
You can find various examples of how to leverage the fine_tune.py in this folder: https://github.com/bmaltais/kohya_ss/tree/master/examples
|
||||
You can find various examples of how to leverage the `train_db.py` in this folder: https://github.com/bmaltais/kohya_ss/tree/master/examples
|
||||
|
||||
## Support
|
||||
|
||||
Drop by the discord server for support: https://discord.com/channels/1041518562487058594/1041518563242020906
|
||||
|
||||
## Quickstart screencast
|
||||
|
||||
|
@ -107,15 +107,23 @@ You can also use the `Captioning` tool found under the `Utilities` tab in the GU
|
||||
|
||||
## GUI
|
||||
|
||||
Support for GUI based training using gradio. You can start the GUI interface by running:
|
||||
There is now support for GUI based training using gradio. You can start the complete kohya training GUI interface by running:
|
||||
|
||||
```powershell
|
||||
.\finetune.bat
|
||||
.\kohya.cmd
|
||||
```
|
||||
|
||||
and select the Finetune tab.
|
||||
|
||||
Alternativelly you can use the Finetune focus GUI with
|
||||
|
||||
```powershell
|
||||
.\finetune.cmd
|
||||
```
|
||||
|
||||
## CLI
|
||||
|
||||
You can find various examples of how to leverage the fine_tune.py in this folder: https://github.com/bmaltais/kohya_ss/tree/master/examples
|
||||
You can find various examples of how to leverage the `fine_tune.py` in this folder: https://github.com/bmaltais/kohya_ss/tree/master/examples
|
||||
|
||||
## Support
|
||||
|
||||
|
@ -11,20 +11,13 @@ import subprocess
|
||||
import pathlib
|
||||
import shutil
|
||||
import argparse
|
||||
from library.dreambooth_folder_creation_gui import (
|
||||
gradio_dreambooth_folder_creation_tab,
|
||||
)
|
||||
from library.basic_caption_gui import gradio_basic_caption_gui_tab
|
||||
from library.convert_model_gui import gradio_convert_model_tab
|
||||
from library.blip_caption_gui import gradio_blip_caption_gui_tab
|
||||
from library.wd14_caption_gui import gradio_wd14_caption_gui_tab
|
||||
from library.dataset_balancing_gui import gradio_dataset_balancing_tab
|
||||
from library.common_gui import (
|
||||
get_folder_path,
|
||||
remove_doublequote,
|
||||
get_file_path,
|
||||
get_saveasfile_path,
|
||||
)
|
||||
from library.utilities import utilities_tab
|
||||
from easygui import msgbox
|
||||
|
||||
folder_symbol = '\U0001f4c2' # 📂
|
||||
@ -473,6 +466,7 @@ def set_pretrained_model_name_or_path_input(value, v2, v_parameterization):
|
||||
|
||||
return value, v2, v_parameterization
|
||||
|
||||
|
||||
def UI(username, password):
|
||||
css = ''
|
||||
|
||||
@ -484,10 +478,38 @@ def UI(username, password):
|
||||
interface = gr.Blocks(css=css)
|
||||
|
||||
with interface:
|
||||
dummy_true = gr.Label(value=True, visible=False)
|
||||
dummy_false = gr.Label(value=False, visible=False)
|
||||
with gr.Tab('Dreambooth'):
|
||||
gr.Markdown('Enter kohya finetuner parameter using this interface.')
|
||||
(
|
||||
train_data_dir_input,
|
||||
reg_data_dir_input,
|
||||
output_dir_input,
|
||||
logging_dir_input,
|
||||
) = dreambooth_tab()
|
||||
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,
|
||||
)
|
||||
|
||||
# Show the interface
|
||||
if not username == '':
|
||||
interface.launch(auth=(username, password))
|
||||
else:
|
||||
interface.launch()
|
||||
|
||||
|
||||
def dreambooth_tab(
|
||||
train_data_dir_input=gr.Textbox(),
|
||||
reg_data_dir_input=gr.Textbox(),
|
||||
output_dir_input=gr.Textbox(),
|
||||
logging_dir_input=gr.Textbox(),
|
||||
):
|
||||
dummy_db_true = gr.Label(value=True, visible=False)
|
||||
dummy_db_false = gr.Label(value=False, visible=False)
|
||||
gr.Markdown('Enter kohya dreambooth training parameter using this interface.')
|
||||
with gr.Accordion('Configuration file', open=False):
|
||||
with gr.Row():
|
||||
button_open_config = gr.Button('Open 📂', elem_id='open_folder')
|
||||
@ -635,9 +657,7 @@ def UI(username, password):
|
||||
)
|
||||
with gr.Tab('Training parameters'):
|
||||
with gr.Row():
|
||||
learning_rate_input = gr.Textbox(
|
||||
label='Learning rate', value=1e-6
|
||||
)
|
||||
learning_rate_input = gr.Textbox(label='Learning rate', value=1e-6)
|
||||
lr_scheduler_input = gr.Dropdown(
|
||||
label='LR Scheduler',
|
||||
choices=[
|
||||
@ -712,9 +732,7 @@ def UI(username, password):
|
||||
enable_bucket_input = gr.Checkbox(
|
||||
label='Enable buckets', value=True
|
||||
)
|
||||
cache_latent_input = gr.Checkbox(
|
||||
label='Cache latent', value=True
|
||||
)
|
||||
cache_latent_input = gr.Checkbox(label='Cache latent', value=True)
|
||||
use_8bit_adam_input = gr.Checkbox(
|
||||
label='Use 8bit adam', value=True
|
||||
)
|
||||
@ -735,7 +753,9 @@ def UI(username, password):
|
||||
shuffle_caption = gr.Checkbox(
|
||||
label='Shuffle caption', value=False
|
||||
)
|
||||
save_state = gr.Checkbox(label='Save training state', value=False)
|
||||
save_state = gr.Checkbox(
|
||||
label='Save training state', value=False
|
||||
)
|
||||
with gr.Row():
|
||||
resume = gr.Textbox(
|
||||
label='Resume from saved training state',
|
||||
@ -749,20 +769,6 @@ def UI(username, password):
|
||||
|
||||
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=[
|
||||
@ -837,12 +843,10 @@ def UI(username, password):
|
||||
],
|
||||
)
|
||||
|
||||
save_as = True
|
||||
not_save_as = False
|
||||
button_save_config.click(
|
||||
save_configuration,
|
||||
inputs=[
|
||||
dummy_false,
|
||||
dummy_db_false,
|
||||
config_file_name,
|
||||
pretrained_model_name_or_path_input,
|
||||
v2_input,
|
||||
@ -883,7 +887,7 @@ def UI(username, password):
|
||||
button_save_as_config.click(
|
||||
save_configuration,
|
||||
inputs=[
|
||||
dummy_true,
|
||||
dummy_db_true,
|
||||
config_file_name,
|
||||
pretrained_model_name_or_path_input,
|
||||
v2_input,
|
||||
@ -959,18 +963,23 @@ def UI(username, password):
|
||||
],
|
||||
)
|
||||
|
||||
# Show the interface
|
||||
if not username == '':
|
||||
interface.launch(auth=(username, password))
|
||||
else:
|
||||
interface.launch()
|
||||
return (
|
||||
train_data_dir_input,
|
||||
reg_data_dir_input,
|
||||
output_dir_input,
|
||||
logging_dir_input,
|
||||
)
|
||||
|
||||
|
||||
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")
|
||||
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()
|
||||
|
||||
|
977
fine_tune.py
977
fine_tune.py
File diff suppressed because it is too large
Load Diff
@ -6,17 +6,12 @@ import subprocess
|
||||
import pathlib
|
||||
import shutil
|
||||
import argparse
|
||||
|
||||
# from easygui import fileopenbox, filesavebox, diropenbox, msgbox
|
||||
from library.basic_caption_gui import gradio_basic_caption_gui_tab
|
||||
from library.convert_model_gui import gradio_convert_model_tab
|
||||
from library.blip_caption_gui import gradio_blip_caption_gui_tab
|
||||
from library.wd14_caption_gui import gradio_wd14_caption_gui_tab
|
||||
from library.common_gui import (
|
||||
get_folder_path,
|
||||
get_file_path,
|
||||
get_saveasfile_path,
|
||||
)
|
||||
from library.utilities import utilities_tab
|
||||
|
||||
folder_symbol = '\U0001f4c2' # 📂
|
||||
refresh_symbol = '\U0001f504' # 🔄
|
||||
@ -49,7 +44,6 @@ def save_configuration(
|
||||
train_text_encoder,
|
||||
create_buckets,
|
||||
create_caption,
|
||||
train,
|
||||
save_model_as,
|
||||
caption_extension,
|
||||
):
|
||||
@ -94,7 +88,6 @@ def save_configuration(
|
||||
'train_text_encoder': train_text_encoder,
|
||||
'create_buckets': create_buckets,
|
||||
'create_caption': create_caption,
|
||||
'train': train,
|
||||
'save_model_as': save_model_as,
|
||||
'caption_extension': caption_extension,
|
||||
}
|
||||
@ -130,7 +123,6 @@ def open_config_file(
|
||||
train_text_encoder,
|
||||
create_buckets,
|
||||
create_caption,
|
||||
train,
|
||||
save_model_as,
|
||||
caption_extension,
|
||||
):
|
||||
@ -175,7 +167,6 @@ def open_config_file(
|
||||
my_data.get('train_text_encoder', train_text_encoder),
|
||||
my_data.get('create_buckets', create_buckets),
|
||||
my_data.get('create_caption', create_caption),
|
||||
my_data.get('train', train),
|
||||
my_data.get('save_model_as', save_model_as),
|
||||
my_data.get('caption_extension', caption_extension),
|
||||
)
|
||||
@ -184,7 +175,6 @@ def open_config_file(
|
||||
def train_model(
|
||||
generate_caption_database,
|
||||
generate_image_buckets,
|
||||
train,
|
||||
pretrained_model_name_or_path,
|
||||
v2,
|
||||
v_parameterization,
|
||||
@ -267,7 +257,6 @@ def train_model(
|
||||
# Run the command
|
||||
subprocess.run(command)
|
||||
|
||||
if train:
|
||||
image_num = len(
|
||||
[f for f in os.listdir(image_folder) if f.endswith('.npz')]
|
||||
)
|
||||
@ -386,6 +375,7 @@ def remove_doublequote(file_path):
|
||||
|
||||
return file_path
|
||||
|
||||
|
||||
def UI(username, password):
|
||||
|
||||
css = ''
|
||||
@ -398,10 +388,23 @@ def UI(username, password):
|
||||
interface = gr.Blocks(css=css)
|
||||
|
||||
with interface:
|
||||
dummy_true = gr.Label(value=True, visible=False)
|
||||
dummy_false = gr.Label(value=False, visible=False)
|
||||
with gr.Tab('Finetuning'):
|
||||
gr.Markdown('Enter kohya finetuner parameter using this interface.')
|
||||
with gr.Tab("Finetune"):
|
||||
finetune_tab()
|
||||
with gr.Tab("Utilities"):
|
||||
utilities_tab(enable_dreambooth_tab=False)
|
||||
|
||||
# Show the interface
|
||||
if not username == '':
|
||||
interface.launch(auth=(username, password))
|
||||
else:
|
||||
interface.launch()
|
||||
|
||||
def finetune_tab():
|
||||
dummy_ft_true = gr.Label(value=True, visible=False)
|
||||
dummy_ft_false = gr.Label(value=False, visible=False)
|
||||
gr.Markdown(
|
||||
'Enter kohya finetune training parameter using this interface.'
|
||||
)
|
||||
with gr.Accordion('Configuration File Load/Save', open=False):
|
||||
with gr.Row():
|
||||
button_open_config = gr.Button(
|
||||
@ -411,7 +414,8 @@ def UI(username, password):
|
||||
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'
|
||||
f'Save as... {save_style_symbol}',
|
||||
elem_id='open_folder',
|
||||
)
|
||||
config_file_name = gr.Textbox(
|
||||
label='', placeholder='type file path or use buttons...'
|
||||
@ -622,16 +626,14 @@ def UI(username, password):
|
||||
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 = gr.Button('Train model')
|
||||
|
||||
button_run.click(
|
||||
train_model,
|
||||
inputs=[
|
||||
create_caption,
|
||||
create_buckets,
|
||||
train,
|
||||
pretrained_model_name_or_path_input,
|
||||
v2_input,
|
||||
v_parameterization_input,
|
||||
@ -683,7 +685,6 @@ def UI(username, password):
|
||||
train_text_encoder_input,
|
||||
create_buckets,
|
||||
create_caption,
|
||||
train,
|
||||
save_model_as_dropdown,
|
||||
caption_extention_input,
|
||||
],
|
||||
@ -711,7 +712,6 @@ def UI(username, password):
|
||||
train_text_encoder_input,
|
||||
create_buckets,
|
||||
create_caption,
|
||||
train,
|
||||
save_model_as_dropdown,
|
||||
caption_extention_input,
|
||||
],
|
||||
@ -720,7 +720,7 @@ def UI(username, password):
|
||||
button_save_config.click(
|
||||
save_configuration,
|
||||
inputs=[
|
||||
dummy_false,
|
||||
dummy_ft_false,
|
||||
config_file_name,
|
||||
pretrained_model_name_or_path_input,
|
||||
v2_input,
|
||||
@ -744,7 +744,6 @@ def UI(username, password):
|
||||
train_text_encoder_input,
|
||||
create_buckets,
|
||||
create_caption,
|
||||
train,
|
||||
save_model_as_dropdown,
|
||||
caption_extention_input,
|
||||
],
|
||||
@ -754,7 +753,7 @@ def UI(username, password):
|
||||
button_save_as_config.click(
|
||||
save_configuration,
|
||||
inputs=[
|
||||
dummy_true,
|
||||
dummy_ft_true,
|
||||
config_file_name,
|
||||
pretrained_model_name_or_path_input,
|
||||
v2_input,
|
||||
@ -778,32 +777,22 @@ def UI(username, password):
|
||||
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
|
||||
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")
|
||||
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()
|
||||
|
||||
|
58
kohya_gui.py
Normal file
58
kohya_gui.py
Normal file
@ -0,0 +1,58 @@
|
||||
import gradio as gr
|
||||
import os
|
||||
import argparse
|
||||
from dreambooth_gui import dreambooth_tab
|
||||
from finetune_gui import finetune_tab
|
||||
from library.utilities import utilities_tab
|
||||
|
||||
|
||||
def UI(username, password):
|
||||
|
||||
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'
|
||||
|
||||
interface = gr.Blocks(css=css)
|
||||
|
||||
with interface:
|
||||
with gr.Tab('Dreambooth'):
|
||||
(
|
||||
train_data_dir_input,
|
||||
reg_data_dir_input,
|
||||
output_dir_input,
|
||||
logging_dir_input,
|
||||
) = dreambooth_tab()
|
||||
with gr.Tab('Finetune'):
|
||||
finetune_tab()
|
||||
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,
|
||||
)
|
||||
|
||||
# Show the interface
|
||||
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)
|
@ -72,6 +72,9 @@ def get_saveasfile_path(file_path='', defaultextension='.json'):
|
||||
def add_pre_postfix(
|
||||
folder='', prefix='', postfix='', caption_file_ext='.caption'
|
||||
):
|
||||
if prefix == '' and postfix == '':
|
||||
return
|
||||
|
||||
# set caption extention to default in case it was not provided
|
||||
if caption_file_ext == '':
|
||||
caption_file_ext = '.caption'
|
||||
|
@ -51,7 +51,12 @@ def dataset_balancing(concept_repeats, folder, insecure):
|
||||
if match:
|
||||
# Multiply the repeats value by the number inside the braces
|
||||
if not images == 0:
|
||||
repeats = max(1, round(concept_repeats / images * float(match.group(1))))
|
||||
repeats = max(
|
||||
1,
|
||||
round(
|
||||
concept_repeats / images * float(match.group(1))
|
||||
),
|
||||
)
|
||||
else:
|
||||
repeats = 0
|
||||
subdir = subdir[match.end() :]
|
||||
@ -95,7 +100,7 @@ def warning(insecure):
|
||||
|
||||
|
||||
def gradio_dataset_balancing_tab():
|
||||
with gr.Tab('Dataset balancing'):
|
||||
with gr.Tab('Dreambooth Dataset balancing'):
|
||||
gr.Markdown(
|
||||
'This utility will ensure that each concept folder in the dataset folder is used equally during the training process of the dreambooth machine learning model, regardless of the number of images in each folder. It will do this by renaming the concept folders to indicate the number of times they should be repeated during training.'
|
||||
)
|
||||
|
@ -68,14 +68,10 @@ def dreambooth_folder_preparation(
|
||||
print(f'Copy {util_training_images_dir_input} to {training_dir}...')
|
||||
shutil.copytree(util_training_images_dir_input, training_dir)
|
||||
|
||||
if not util_regularization_images_dir_input == '':
|
||||
# Create the regularization_dir path
|
||||
if (
|
||||
util_class_prompt_input == ''
|
||||
or not util_regularization_images_repeat_input > 0
|
||||
):
|
||||
print(
|
||||
'Regularization images directory or repeats is missing... not copying regularisation images...'
|
||||
)
|
||||
if not util_regularization_images_repeat_input > 0:
|
||||
print('Repeats is missing... not copying regularisation images...')
|
||||
else:
|
||||
regularization_dir = os.path.join(
|
||||
util_training_dir_output,
|
||||
@ -94,6 +90,10 @@ def dreambooth_folder_preparation(
|
||||
shutil.copytree(
|
||||
util_regularization_images_dir_input, regularization_dir
|
||||
)
|
||||
else:
|
||||
print(
|
||||
'Regularization images directory is missing... not copying regularisation images...'
|
||||
)
|
||||
|
||||
# create log and model folder
|
||||
# Check if the log folder exists and create it if it doesn't
|
||||
@ -110,10 +110,11 @@ def dreambooth_folder_preparation(
|
||||
|
||||
|
||||
def gradio_dreambooth_folder_creation_tab(
|
||||
train_data_dir_input,
|
||||
reg_data_dir_input,
|
||||
output_dir_input,
|
||||
logging_dir_input,
|
||||
train_data_dir_input=gr.Textbox(),
|
||||
reg_data_dir_input=gr.Textbox(),
|
||||
output_dir_input=gr.Textbox(),
|
||||
logging_dir_input=gr.Textbox(),
|
||||
enable_copy_info_button=bool(False),
|
||||
):
|
||||
with gr.Tab('Dreambooth folder preparation'):
|
||||
gr.Markdown(
|
||||
@ -191,6 +192,7 @@ def gradio_dreambooth_folder_creation_tab(
|
||||
util_training_dir_output,
|
||||
],
|
||||
)
|
||||
if enable_copy_info_button:
|
||||
button_copy_info_to_Directories_tab = gr.Button(
|
||||
'Copy info to Directories Tab'
|
||||
)
|
||||
|
84
library/utilities.py
Normal file
84
library/utilities.py
Normal file
@ -0,0 +1,84 @@
|
||||
# v1: initial release
|
||||
# v2: add open and save folder icons
|
||||
# v3: Add new Utilities tab for Dreambooth folder preparation
|
||||
# v3.1: Adding captionning of images to utilities
|
||||
|
||||
import gradio as gr
|
||||
import os
|
||||
import argparse
|
||||
from library.dreambooth_folder_creation_gui import (
|
||||
gradio_dreambooth_folder_creation_tab,
|
||||
)
|
||||
from library.basic_caption_gui import gradio_basic_caption_gui_tab
|
||||
from library.convert_model_gui import gradio_convert_model_tab
|
||||
from library.blip_caption_gui import gradio_blip_caption_gui_tab
|
||||
from library.wd14_caption_gui import gradio_wd14_caption_gui_tab
|
||||
from library.dataset_balancing_gui import gradio_dataset_balancing_tab
|
||||
|
||||
|
||||
def utilities_tab(
|
||||
train_data_dir_input=gr.Textbox(),
|
||||
reg_data_dir_input=gr.Textbox(),
|
||||
output_dir_input=gr.Textbox(),
|
||||
logging_dir_input=gr.Textbox(),
|
||||
enable_copy_info_button=bool(False),
|
||||
enable_dreambooth_tab=True,
|
||||
):
|
||||
with gr.Tab('Captioning'):
|
||||
gradio_basic_caption_gui_tab()
|
||||
gradio_blip_caption_gui_tab()
|
||||
gradio_wd14_caption_gui_tab()
|
||||
if enable_dreambooth_tab:
|
||||
with gr.Tab('Dreambooth'):
|
||||
gr.Markdown('This section provide Dreambooth specific tools.')
|
||||
gradio_dreambooth_folder_creation_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=enable_copy_info_button,
|
||||
)
|
||||
gradio_dataset_balancing_tab()
|
||||
gradio_convert_model_tab()
|
||||
|
||||
return (
|
||||
train_data_dir_input,
|
||||
reg_data_dir_input,
|
||||
output_dir_input,
|
||||
logging_dir_input,
|
||||
)
|
||||
|
||||
|
||||
def UI(username, password):
|
||||
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'
|
||||
|
||||
interface = gr.Blocks(css=css)
|
||||
|
||||
with interface:
|
||||
utilities_tab()
|
||||
|
||||
# Show the interface
|
||||
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)
|
1
utilities.cmd
Normal file
1
utilities.cmd
Normal file
@ -0,0 +1 @@
|
||||
.\venv\Scripts\python.exe library\utilities.py
|
Loading…
Reference in New Issue
Block a user