mirror of https://github.com/bmaltais/kohya_ss
Update code to last version of gradio 3.x
parent
1a0d8ec4b2
commit
7167b33d03
|
|
@ -96,6 +96,7 @@ def UI(**kwargs):
|
|||
launch_kwargs["inbrowser"] = inbrowser
|
||||
if share:
|
||||
launch_kwargs["share"] = share
|
||||
launch_kwargs["debug"] = True
|
||||
interface.launch(**launch_kwargs)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -11,13 +11,13 @@ class AdvancedTraining:
|
|||
def noise_offset_type_change(noise_offset_type):
|
||||
if noise_offset_type == 'Original':
|
||||
return (
|
||||
gr.Group.update(visible=True),
|
||||
gr.Group.update(visible=False),
|
||||
gr.Group(visible=True),
|
||||
gr.Group(visible=False),
|
||||
)
|
||||
else:
|
||||
return (
|
||||
gr.Group.update(visible=False),
|
||||
gr.Group.update(visible=True),
|
||||
gr.Group(visible=False),
|
||||
gr.Group(visible=True),
|
||||
)
|
||||
|
||||
with gr.Row(visible=not finetuning):
|
||||
|
|
@ -88,9 +88,9 @@ class AdvancedTraining:
|
|||
full_bf16_active = False
|
||||
if full_bf16:
|
||||
full_fp16_active = False
|
||||
return gr.Checkbox.update(
|
||||
return gr.Checkbox(
|
||||
interactive=full_fp16_active,
|
||||
), gr.Checkbox.update(interactive=full_bf16_active)
|
||||
), gr.Checkbox(interactive=full_bf16_active)
|
||||
|
||||
self.keep_tokens = gr.Slider(
|
||||
label='Keep n tokens', value='0', minimum=0, maximum=32, step=1
|
||||
|
|
|
|||
|
|
@ -222,9 +222,9 @@ class BasicTraining:
|
|||
|
||||
def update_learning_rate_te(sdxl_checkbox, finetuning, dreambooth):
|
||||
return (
|
||||
gr.Number.update(visible=(not sdxl_checkbox and (finetuning or dreambooth))),
|
||||
gr.Number.update(visible=(sdxl_checkbox and (finetuning or dreambooth))),
|
||||
gr.Number.update(visible=(sdxl_checkbox and (finetuning or dreambooth))),
|
||||
gr.Number(visible=(not sdxl_checkbox and (finetuning or dreambooth))),
|
||||
gr.Number(visible=(sdxl_checkbox and (finetuning or dreambooth))),
|
||||
gr.Number(visible=(sdxl_checkbox and (finetuning or dreambooth))),
|
||||
)
|
||||
|
||||
self.sdxl_checkbox.change(
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class SDXLParameters:
|
|||
)
|
||||
|
||||
self.sdxl_checkbox.change(
|
||||
lambda sdxl_checkbox: gr.Accordion.update(visible=sdxl_checkbox),
|
||||
lambda sdxl_checkbox: gr.Accordion(visible=sdxl_checkbox),
|
||||
inputs=[self.sdxl_checkbox],
|
||||
outputs=[self.sdxl_row],
|
||||
)
|
||||
|
|
|
|||
|
|
@ -405,9 +405,9 @@ def color_aug_changed(color_aug):
|
|||
msgbox(
|
||||
'Disabling "Cache latent" because "Color augmentation" has been selected...'
|
||||
)
|
||||
return gr.Checkbox.update(value=False, interactive=False)
|
||||
return gr.Checkbox(value=False, interactive=False)
|
||||
else:
|
||||
return gr.Checkbox.update(value=True, interactive=True)
|
||||
return gr.Checkbox(value=True, interactive=True)
|
||||
|
||||
|
||||
def save_inference_file(output_dir, v2, v_parameterization, output_name):
|
||||
|
|
@ -454,14 +454,14 @@ def set_pretrained_model_name_or_path_input(
|
|||
# Check if the given model_list is in the list of SDXL models
|
||||
if str(model_list) in SDXL_MODELS:
|
||||
log.info("SDXL model selected. Setting sdxl parameters")
|
||||
v2 = gr.Checkbox.update(value=False, visible=False)
|
||||
v_parameterization = gr.Checkbox.update(value=False, visible=False)
|
||||
sdxl = gr.Checkbox.update(value=True, visible=False)
|
||||
pretrained_model_name_or_path = gr.Textbox.update(
|
||||
v2 = gr.Checkbox(value=False, visible=False)
|
||||
v_parameterization = gr.Checkbox(value=False, visible=False)
|
||||
sdxl = gr.Checkbox(value=True, visible=False)
|
||||
pretrained_model_name_or_path = gr.Textbox(
|
||||
value=str(model_list), visible=False
|
||||
)
|
||||
pretrained_model_name_or_path_file = gr.Button.update(visible=False)
|
||||
pretrained_model_name_or_path_folder = gr.Button.update(visible=False)
|
||||
pretrained_model_name_or_path_file = gr.Button(visible=False)
|
||||
pretrained_model_name_or_path_folder = gr.Button(visible=False)
|
||||
return (
|
||||
model_list,
|
||||
pretrained_model_name_or_path,
|
||||
|
|
@ -475,14 +475,14 @@ def set_pretrained_model_name_or_path_input(
|
|||
# Check if the given model_list is in the list of V2 base models
|
||||
if str(model_list) in V2_BASE_MODELS:
|
||||
log.info("SD v2 base model selected. Setting --v2 parameter")
|
||||
v2 = gr.Checkbox.update(value=True, visible=False)
|
||||
v_parameterization = gr.Checkbox.update(value=False, visible=False)
|
||||
sdxl = gr.Checkbox.update(value=False, visible=False)
|
||||
pretrained_model_name_or_path = gr.Textbox.update(
|
||||
v2 = gr.Checkbox(value=True, visible=False)
|
||||
v_parameterization = gr.Checkbox(value=False, visible=False)
|
||||
sdxl = gr.Checkbox(value=False, visible=False)
|
||||
pretrained_model_name_or_path = gr.Textbox(
|
||||
value=str(model_list), visible=False
|
||||
)
|
||||
pretrained_model_name_or_path_file = gr.Button.update(visible=False)
|
||||
pretrained_model_name_or_path_folder = gr.Button.update(visible=False)
|
||||
pretrained_model_name_or_path_file = gr.Button(visible=False)
|
||||
pretrained_model_name_or_path_folder = gr.Button(visible=False)
|
||||
return (
|
||||
model_list,
|
||||
pretrained_model_name_or_path,
|
||||
|
|
@ -498,14 +498,14 @@ def set_pretrained_model_name_or_path_input(
|
|||
log.info(
|
||||
"SD v2 model selected. Setting --v2 and --v_parameterization parameters"
|
||||
)
|
||||
v2 = gr.Checkbox.update(value=True, visible=False)
|
||||
v_parameterization = gr.Checkbox.update(value=True, visible=False)
|
||||
sdxl = gr.Checkbox.update(value=False, visible=False)
|
||||
pretrained_model_name_or_path = gr.Textbox.update(
|
||||
v2 = gr.Checkbox(value=True, visible=False)
|
||||
v_parameterization = gr.Checkbox(value=True, visible=False)
|
||||
sdxl = gr.Checkbox(value=False, visible=False)
|
||||
pretrained_model_name_or_path = gr.Textbox(
|
||||
value=str(model_list), visible=False
|
||||
)
|
||||
pretrained_model_name_or_path_file = gr.Button.update(visible=False)
|
||||
pretrained_model_name_or_path_folder = gr.Button.update(visible=False)
|
||||
pretrained_model_name_or_path_file = gr.Button(visible=False)
|
||||
pretrained_model_name_or_path_folder = gr.Button(visible=False)
|
||||
return (
|
||||
model_list,
|
||||
pretrained_model_name_or_path,
|
||||
|
|
@ -519,14 +519,14 @@ def set_pretrained_model_name_or_path_input(
|
|||
# Check if the given model_list is in the list of V1 models
|
||||
if str(model_list) in V1_MODELS:
|
||||
log.info(f"{model_list} model selected.")
|
||||
v2 = gr.Checkbox.update(value=False, visible=False)
|
||||
v_parameterization = gr.Checkbox.update(value=False, visible=False)
|
||||
sdxl = gr.Checkbox.update(value=False, visible=False)
|
||||
pretrained_model_name_or_path = gr.Textbox.update(
|
||||
v2 = gr.Checkbox(value=False, visible=False)
|
||||
v_parameterization = gr.Checkbox(value=False, visible=False)
|
||||
sdxl = gr.Checkbox(value=False, visible=False)
|
||||
pretrained_model_name_or_path = gr.Textbox(
|
||||
value=str(model_list), visible=False
|
||||
)
|
||||
pretrained_model_name_or_path_file = gr.Button.update(visible=False)
|
||||
pretrained_model_name_or_path_folder = gr.Button.update(visible=False)
|
||||
pretrained_model_name_or_path_file = gr.Button(visible=False)
|
||||
pretrained_model_name_or_path_folder = gr.Button(visible=False)
|
||||
return (
|
||||
model_list,
|
||||
pretrained_model_name_or_path,
|
||||
|
|
@ -539,12 +539,12 @@ def set_pretrained_model_name_or_path_input(
|
|||
|
||||
# Check if the model_list is set to 'custom'
|
||||
if model_list == "custom":
|
||||
v2 = gr.Checkbox.update(visible=True)
|
||||
v_parameterization = gr.Checkbox.update(visible=True)
|
||||
sdxl = gr.Checkbox.update(visible=True)
|
||||
pretrained_model_name_or_path = gr.Textbox.update(visible=True)
|
||||
pretrained_model_name_or_path_file = gr.Button.update(visible=True)
|
||||
pretrained_model_name_or_path_folder = gr.Button.update(visible=True)
|
||||
v2 = gr.Checkbox(visible=True)
|
||||
v_parameterization = gr.Checkbox(visible=True)
|
||||
sdxl = gr.Checkbox(visible=True)
|
||||
pretrained_model_name_or_path = gr.Textbox(visible=True)
|
||||
pretrained_model_name_or_path_file = gr.Button(visible=True)
|
||||
pretrained_model_name_or_path_folder = gr.Button(visible=True)
|
||||
return (
|
||||
model_list,
|
||||
pretrained_model_name_or_path,
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ def extract_lora(
|
|||
|
||||
def gradio_extract_lora_tab(headless=False):
|
||||
def change_sdxl(sdxl):
|
||||
return gr.update(visible=sdxl), gr.update(visible=sdxl)
|
||||
return gr(visible=sdxl), gr(visible=sdxl)
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -104,13 +104,13 @@ def extract_lycoris_locon(
|
|||
# def update_mode(mode):
|
||||
# # 'fixed', 'threshold','ratio','quantile'
|
||||
# if mode == 'fixed':
|
||||
# return gr.Row.update(visible=True), gr.Row.update(visible=False), gr.Row.update(visible=False), gr.Row.update(visible=False)
|
||||
# return gr.Row(visible=True), gr.Row(visible=False), gr.Row(visible=False), gr.Row(visible=False)
|
||||
# if mode == 'threshold':
|
||||
# return gr.Row.update(visible=False), gr.Row.update(visible=True), gr.Row.update(visible=False), gr.Row.update(visible=False)
|
||||
# return gr.Row(visible=False), gr.Row(visible=True), gr.Row(visible=False), gr.Row(visible=False)
|
||||
# if mode == 'ratio':
|
||||
# return gr.Row.update(visible=False), gr.Row.update(visible=False), gr.Row.update(visible=True), gr.Row.update(visible=False)
|
||||
# return gr.Row(visible=False), gr.Row(visible=False), gr.Row(visible=True), gr.Row(visible=False)
|
||||
# if mode == 'threshold':
|
||||
# return gr.Row.update(visible=False), gr.Row.update(visible=False), gr.Row.update(visible=False), gr.Row.update(visible=True)
|
||||
# return gr.Row(visible=False), gr.Row(visible=False), gr.Row(visible=False), gr.Row(visible=True)
|
||||
|
||||
|
||||
def update_mode(mode):
|
||||
|
|
@ -123,7 +123,7 @@ def update_mode(mode):
|
|||
# Iterate through the possible modes
|
||||
for m in modes:
|
||||
# Add a visibility update for each mode, setting it to True if the input mode matches the current mode in the loop
|
||||
updates.append(gr.Row.update(visible=(mode == m)))
|
||||
updates.append(gr.Row(visible=(mode == m)))
|
||||
|
||||
# Return the visibility updates as a tuple
|
||||
return tuple(updates)
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ def _get_tag_checkbox_updates(caption, quick_tags, quick_tags_set):
|
|||
t for t in caption_tags_have if t not in quick_tags_set
|
||||
]
|
||||
caption_tags_all = quick_tags + caption_tags_unique
|
||||
return gr.CheckboxGroup.update(
|
||||
return gr.CheckboxGroup(
|
||||
choices=caption_tags_all, value=caption_tags_have
|
||||
)
|
||||
|
||||
|
|
@ -118,7 +118,7 @@ def import_tags_from_captions(
|
|||
"""
|
||||
|
||||
def empty_return():
|
||||
return gr.Text.update()
|
||||
return gr.Text()
|
||||
|
||||
# Check for images_dir
|
||||
if not images_dir:
|
||||
|
|
@ -247,7 +247,7 @@ def update_images(
|
|||
tag_checkboxes = _get_tag_checkbox_updates(
|
||||
caption, quick_tags, quick_tags_set
|
||||
)
|
||||
rows.append(gr.Row.update(visible=show_row))
|
||||
rows.append(gr.Row(visible=show_row))
|
||||
image_paths.append(image_path)
|
||||
captions.append(caption)
|
||||
tag_checkbox_groups.append(tag_checkboxes)
|
||||
|
|
@ -258,7 +258,7 @@ def update_images(
|
|||
+ image_paths
|
||||
+ captions
|
||||
+ tag_checkbox_groups
|
||||
+ [gr.Row.update(visible=True), gr.Row.update(visible=True)]
|
||||
+ [gr.Row(visible=True), gr.Row(visible=True)]
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -473,7 +473,7 @@ def gradio_manual_caption_gui_tab(headless=False):
|
|||
# Save buttons visibility
|
||||
# (on auto-save on/off)
|
||||
auto_save.change(
|
||||
lambda auto_save: [gr.Button.update(visible=not auto_save)]
|
||||
lambda auto_save: [gr.Button(visible=not auto_save)]
|
||||
* IMAGES_TO_SHOW,
|
||||
inputs=auto_save,
|
||||
outputs=save_buttons,
|
||||
|
|
|
|||
19
lora_gui.py
19
lora_gui.py
|
|
@ -362,15 +362,16 @@ def open_configuration(
|
|||
|
||||
# Check if we are "applying" a preset or a config
|
||||
if apply_preset:
|
||||
log.info(f"Applying preset {training_preset}...")
|
||||
file_path = f"./presets/lora/{training_preset}.json"
|
||||
if training_preset != "none":
|
||||
log.info(f"Applying preset {training_preset}...")
|
||||
file_path = f"./presets/lora/{training_preset}.json"
|
||||
else:
|
||||
# If not applying a preset, set the `training_preset` field to an empty string
|
||||
# Find the index of the `training_preset` parameter using the `index()` method
|
||||
training_preset_index = parameters.index(("training_preset", training_preset))
|
||||
|
||||
# Update the value of `training_preset` by directly assigning an empty string value
|
||||
parameters[training_preset_index] = ("training_preset", "")
|
||||
parameters[training_preset_index] = ("training_preset", "none")
|
||||
|
||||
original_file_path = file_path
|
||||
|
||||
|
|
@ -414,9 +415,9 @@ def open_configuration(
|
|||
"LyCORIS/LoCon",
|
||||
"LyCORIS/GLoRA",
|
||||
}:
|
||||
values.append(gr.Row.update(visible=True))
|
||||
values.append(gr.Row(visible=True))
|
||||
else:
|
||||
values.append(gr.Row.update(visible=False))
|
||||
values.append(gr.Row(visible=False))
|
||||
|
||||
return tuple(values)
|
||||
|
||||
|
|
@ -1074,6 +1075,9 @@ def lora_tab(
|
|||
|
||||
def list_presets(path):
|
||||
json_files = []
|
||||
|
||||
# Insert an empty string at the beginning
|
||||
json_files.insert(0, "none")
|
||||
|
||||
for file in os.listdir(path):
|
||||
if file.endswith(".json"):
|
||||
|
|
@ -1092,6 +1096,7 @@ def lora_tab(
|
|||
label="Presets",
|
||||
choices=list_presets("./presets/lora"),
|
||||
elem_id="myDropdown",
|
||||
value="none"
|
||||
)
|
||||
|
||||
with gr.Tab("Basic", elem_id="basic_tab"):
|
||||
|
|
@ -1129,7 +1134,7 @@ def lora_tab(
|
|||
interactive=True
|
||||
# info="https://github.com/KohakuBlueleaf/LyCORIS/blob/0006e2ffa05a48d8818112d9f70da74c0cd30b99/docs/Preset.md"
|
||||
)
|
||||
with gr.Box():
|
||||
with gr.Group():
|
||||
with gr.Row():
|
||||
lora_network_weights = gr.Textbox(
|
||||
label="LoRA network weights",
|
||||
|
|
@ -1673,7 +1678,7 @@ def lora_tab(
|
|||
for attr, settings in lora_settings_config.items():
|
||||
update_params = settings["update_params"]
|
||||
|
||||
results.append(settings["gr_type"].update(**update_params))
|
||||
results.append(settings["gr_type"](**update_params))
|
||||
|
||||
return tuple(results)
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ easygui==0.98.3
|
|||
einops==0.6.1
|
||||
fairscale==0.4.13
|
||||
ftfy==6.1.1
|
||||
gradio==3.36.1
|
||||
gradio==3.50.2
|
||||
huggingface-hub==0.20.1
|
||||
# for loading Diffusers' SDXL
|
||||
invisible-watermark==0.2.0
|
||||
|
|
|
|||
Loading…
Reference in New Issue