Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -111,7 +111,7 @@ def check_sleep_time():
|
|
| 111 |
|
| 112 |
return sleep_time_value, gr.update(visible=True), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False)
|
| 113 |
|
| 114 |
-
def train_dreambooth_blora_sdxl(instance_data_dir, b_lora_trained_folder, instance_prompt,
|
| 115 |
|
| 116 |
script_filename = "train_dreambooth_b-lora_sdxl.py" # Assuming it's in the same folder
|
| 117 |
|
|
@@ -123,8 +123,8 @@ def train_dreambooth_blora_sdxl(instance_data_dir, b_lora_trained_folder, instan
|
|
| 123 |
f"--instance_data_dir={instance_data_dir}",
|
| 124 |
f"--output_dir={b_lora_trained_folder}",
|
| 125 |
f"--instance_prompt='{instance_prompt}'",
|
| 126 |
-
f"--class_prompt={class_prompt}",
|
| 127 |
-
|
| 128 |
"--num_validation_images=1",
|
| 129 |
"--validation_epochs=500",
|
| 130 |
"--resolution=1024",
|
|
@@ -168,7 +168,7 @@ def clear_directory(directory_path):
|
|
| 168 |
else:
|
| 169 |
print(f'The directory {directory_path} does not exist.')
|
| 170 |
|
| 171 |
-
def main(image_path, b_lora_trained_folder, instance_prompt,
|
| 172 |
|
| 173 |
if is_shared_ui:
|
| 174 |
raise gr.Error("This Space only works in duplicated instances")
|
|
@@ -207,7 +207,7 @@ def main(image_path, b_lora_trained_folder, instance_prompt, class_prompt, train
|
|
| 207 |
|
| 208 |
max_train_steps = training_steps
|
| 209 |
|
| 210 |
-
train_dreambooth_blora_sdxl(local_dir, b_lora_trained_folder, instance_prompt,
|
| 211 |
|
| 212 |
your_username = api.whoami(token=hf_token)["name"]
|
| 213 |
|
|
@@ -342,8 +342,8 @@ with gr.Blocks(css=css) as demo:
|
|
| 342 |
training_type = gr.Radio(label="Training type", choices=["style", "concept"], value="style", visible=False)
|
| 343 |
b_lora_name = gr.Textbox(label="Name your B-LoRa model", placeholder="b_lora_trained_folder", visible=False)
|
| 344 |
with gr.Row():
|
| 345 |
-
instance_prompt = gr.Textbox(label="Create instance prompt", placeholder="A [v42]
|
| 346 |
-
class_prompt = gr.Textbox(label="Specify class prompt", placeholder="style | person | dog ", visible=False)
|
| 347 |
training_steps = gr.Number(label="Training steps", value=1000, interactive=False, visible=False)
|
| 348 |
checkpoint_step = gr.Number(label="checkpoint step", visible=False, value=500)
|
| 349 |
|
|
@@ -362,7 +362,7 @@ with gr.Blocks(css=css) as demo:
|
|
| 362 |
demo.load(
|
| 363 |
fn = check_sleep_time,
|
| 364 |
inputs = None,
|
| 365 |
-
outputs = [current_sleep_time, sleep_time_message, b_lora_name, instance_prompt,
|
| 366 |
)
|
| 367 |
|
| 368 |
training_type.change(
|
|
@@ -373,7 +373,7 @@ with gr.Blocks(css=css) as demo:
|
|
| 373 |
|
| 374 |
train_btn.click(
|
| 375 |
fn = main,
|
| 376 |
-
inputs = [image, b_lora_name, instance_prompt,
|
| 377 |
outputs = [status]
|
| 378 |
)
|
| 379 |
|
|
|
|
| 111 |
|
| 112 |
return sleep_time_value, gr.update(visible=True), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False)
|
| 113 |
|
| 114 |
+
def train_dreambooth_blora_sdxl(instance_data_dir, b_lora_trained_folder, instance_prompt, max_train_steps, checkpoint_steps):
|
| 115 |
|
| 116 |
script_filename = "train_dreambooth_b-lora_sdxl.py" # Assuming it's in the same folder
|
| 117 |
|
|
|
|
| 123 |
f"--instance_data_dir={instance_data_dir}",
|
| 124 |
f"--output_dir={b_lora_trained_folder}",
|
| 125 |
f"--instance_prompt='{instance_prompt}'",
|
| 126 |
+
#f"--class_prompt={class_prompt}",
|
| 127 |
+
f"--validation_prompt={instance_prompt} in {instance_prompt} style",
|
| 128 |
"--num_validation_images=1",
|
| 129 |
"--validation_epochs=500",
|
| 130 |
"--resolution=1024",
|
|
|
|
| 168 |
else:
|
| 169 |
print(f'The directory {directory_path} does not exist.')
|
| 170 |
|
| 171 |
+
def main(image_path, b_lora_trained_folder, instance_prompt, training_type, training_steps):
|
| 172 |
|
| 173 |
if is_shared_ui:
|
| 174 |
raise gr.Error("This Space only works in duplicated instances")
|
|
|
|
| 207 |
|
| 208 |
max_train_steps = training_steps
|
| 209 |
|
| 210 |
+
train_dreambooth_blora_sdxl(local_dir, b_lora_trained_folder, instance_prompt, max_train_steps, checkpoint_steps)
|
| 211 |
|
| 212 |
your_username = api.whoami(token=hf_token)["name"]
|
| 213 |
|
|
|
|
| 342 |
training_type = gr.Radio(label="Training type", choices=["style", "concept"], value="style", visible=False)
|
| 343 |
b_lora_name = gr.Textbox(label="Name your B-LoRa model", placeholder="b_lora_trained_folder", visible=False)
|
| 344 |
with gr.Row():
|
| 345 |
+
instance_prompt = gr.Textbox(label="Create instance prompt", placeholder="A [v42]", visible=False)
|
| 346 |
+
#class_prompt = gr.Textbox(label="Specify class prompt", placeholder="style | person | dog ", visible=False)
|
| 347 |
training_steps = gr.Number(label="Training steps", value=1000, interactive=False, visible=False)
|
| 348 |
checkpoint_step = gr.Number(label="checkpoint step", visible=False, value=500)
|
| 349 |
|
|
|
|
| 362 |
demo.load(
|
| 363 |
fn = check_sleep_time,
|
| 364 |
inputs = None,
|
| 365 |
+
outputs = [current_sleep_time, sleep_time_message, b_lora_name, instance_prompt, training_type, training_steps, train_btn]
|
| 366 |
)
|
| 367 |
|
| 368 |
training_type.change(
|
|
|
|
| 373 |
|
| 374 |
train_btn.click(
|
| 375 |
fn = main,
|
| 376 |
+
inputs = [image, b_lora_name, instance_prompt, training_type, training_steps],
|
| 377 |
outputs = [status]
|
| 378 |
)
|
| 379 |
|