Commit
•
34a9bf9
1
Parent(s):
198a005
Update app.py
Browse files
app.py
CHANGED
@@ -209,6 +209,8 @@ def start_training(
|
|
209 |
progress = gr.Progress(track_tqdm=True)
|
210 |
):
|
211 |
print("Started training")
|
|
|
|
|
212 |
slugged_lora_name = slugify(lora_name)
|
213 |
spacerunner_folder = str(uuid.uuid4())
|
214 |
commands = [
|
@@ -305,10 +307,14 @@ git+https://github.com/huggingface/datasets.git'''
|
|
305 |
username = api.whoami()["name"]
|
306 |
subprocess_command = ["autotrain", "spacerunner", "--project-name", slugged_lora_name, "--script-path", spacerunner_folder, "--username", username, "--token", token, "--backend", "spaces-a10gs", "--env","HF_TOKEN=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;HF_HUB_ENABLE_HF_TRANSFER=1", "--args", spacerunner_args]
|
307 |
print(subprocess_command)
|
308 |
-
subprocess.run(subprocess_command)
|
309 |
-
|
|
|
|
|
310 |
## - Model page: <a href='https://huggingface.co/{username}/{slugged_lora_name}'>{username}/{slugged_lora_name}</a> <small>(the model will be available when training finishes)</small>
|
311 |
## - Training Status: <a href='https://huggingface.co/spaces/{username}/autotrain-{slugged_lora_name}?logs=container'>{username}/autotrain-{slugged_lora_name}</a> <small>(in the logs tab)</small>"""
|
|
|
|
|
312 |
|
313 |
def calculate_price(iterations):
|
314 |
seconds_per_iteration = 3.50
|
@@ -507,7 +513,7 @@ with gr.Blocks(css=css, theme=theme) as demo:
|
|
507 |
gr.Markdown('''# LoRA Ease 🧞♂️
|
508 |
### Train a high quality SDXL LoRA in a breeze ༄ with state-of-the-art techniques
|
509 |
<small>Dreambooth + Pivotal Tuning + Prodigy and more! [blog about the training script](#), [Colab Pro](#), [run locally or in a cloud](#)</small>''', elem_id="main_title")
|
510 |
-
lora_name = gr.Textbox(label="The name of your LoRA", placeholder="e.g.: Persian Miniature Painting style, Cat Toy")
|
511 |
training_option = gr.Radio(
|
512 |
label="What are you training?", choices=["object", "style", "face", "custom"]
|
513 |
)
|
|
|
209 |
progress = gr.Progress(track_tqdm=True)
|
210 |
):
|
211 |
print("Started training")
|
212 |
+
if not lora_name:
|
213 |
+
raise gr.Error("You forgot to insert your LoRA name! This name has to be unique.")
|
214 |
slugged_lora_name = slugify(lora_name)
|
215 |
spacerunner_folder = str(uuid.uuid4())
|
216 |
commands = [
|
|
|
307 |
username = api.whoami()["name"]
|
308 |
subprocess_command = ["autotrain", "spacerunner", "--project-name", slugged_lora_name, "--script-path", spacerunner_folder, "--username", username, "--token", token, "--backend", "spaces-a10gs", "--env","HF_TOKEN=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;HF_HUB_ENABLE_HF_TRANSFER=1", "--args", spacerunner_args]
|
309 |
print(subprocess_command)
|
310 |
+
outcome = subprocess.run(subprocess_command)
|
311 |
+
print(outcome)
|
312 |
+
if(outcome.returncode == 0):
|
313 |
+
return f"""# Your training has started.
|
314 |
## - Model page: <a href='https://huggingface.co/{username}/{slugged_lora_name}'>{username}/{slugged_lora_name}</a> <small>(the model will be available when training finishes)</small>
|
315 |
## - Training Status: <a href='https://huggingface.co/spaces/{username}/autotrain-{slugged_lora_name}?logs=container'>{username}/autotrain-{slugged_lora_name}</a> <small>(in the logs tab)</small>"""
|
316 |
+
else:
|
317 |
+
raise gr.Error("Something went wrong. Make sure the name of your LoRA is unique and try again")
|
318 |
|
319 |
def calculate_price(iterations):
|
320 |
seconds_per_iteration = 3.50
|
|
|
513 |
gr.Markdown('''# LoRA Ease 🧞♂️
|
514 |
### Train a high quality SDXL LoRA in a breeze ༄ with state-of-the-art techniques
|
515 |
<small>Dreambooth + Pivotal Tuning + Prodigy and more! [blog about the training script](#), [Colab Pro](#), [run locally or in a cloud](#)</small>''', elem_id="main_title")
|
516 |
+
lora_name = gr.Textbox(label="The name of your LoRA", info="This has to be a unique name", placeholder="e.g.: Persian Miniature Painting style, Cat Toy")
|
517 |
training_option = gr.Radio(
|
518 |
label="What are you training?", choices=["object", "style", "face", "custom"]
|
519 |
)
|