Spaces:
Runtime error
Runtime error
change default params
Browse filesSigned-off-by: AnyISalIn <anyisalin@gmail.com>
app.py
CHANGED
|
@@ -16,6 +16,7 @@ suggestion_checkpoints = [
|
|
| 16 |
"dreamshaper_8_93211.safetensors",
|
| 17 |
"epicrealism_pureEvolutionV5_97793.safetensors",
|
| 18 |
]
|
|
|
|
| 19 |
|
| 20 |
|
| 21 |
get_local_storage = """
|
|
@@ -53,15 +54,15 @@ def create_ui():
|
|
| 53 |
with gr.Tab(label="Training"):
|
| 54 |
with gr.Row():
|
| 55 |
with gr.Column(scale=1):
|
| 56 |
-
base_model = gr.Dropdown(choices=
|
| 57 |
geneder = gr.Radio(choices=["man", "woman"], value="man", label="Geneder")
|
| 58 |
training_name = gr.Text(label="Training Name", placeholder="training name", elem_id="training_name", value="my-face-001")
|
| 59 |
max_train_steps = gr.Slider(minimum=200, maximum=4000, step=1, label="Max Train Steps", value=2000)
|
| 60 |
-
training_images = gr.File(file_types=["image"], file_count="multiple")
|
| 61 |
training_button = gr.Button(value="Train")
|
| 62 |
training_payload = gr.JSON(label="Training Payload, POST /v3/training/subject")
|
| 63 |
with gr.Column(scale=1):
|
| 64 |
-
training_refresh_button = gr.Button(value="Refresh
|
| 65 |
training_refresh_json = gr.JSON()
|
| 66 |
|
| 67 |
def train(novita_key, gender, base_model, training_name, max_train_steps, training_images):
|
|
@@ -70,30 +71,39 @@ def create_ui():
|
|
| 70 |
get_noviata_client(novita_key).create_training_subject(
|
| 71 |
base_model=base_model,
|
| 72 |
name=training_name,
|
| 73 |
-
instance_prompt=f"a closeup photo of ohwx
|
| 74 |
class_prompt="person",
|
| 75 |
max_train_steps=max_train_steps,
|
| 76 |
images=training_images,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
with_prior_preservation=True,
|
| 78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
)
|
|
|
|
| 80 |
payload = dict(
|
| 81 |
name=training_name,
|
| 82 |
base_model=base_model,
|
| 83 |
image_dataset_items=["....assets_ids, please manually upload to novita.ai"],
|
| 84 |
expert_setting=TrainingExpertSetting(
|
| 85 |
-
instance_prompt=f"a closeup photo of ohwx
|
| 86 |
class_prompt="person",
|
| 87 |
max_train_steps=max_train_steps,
|
| 88 |
-
learning_rate=
|
| 89 |
seed=None,
|
| 90 |
-
lr_scheduler=
|
| 91 |
with_prior_preservation=True,
|
| 92 |
-
prior_loss_weight=
|
| 93 |
-
lora_r=
|
| 94 |
-
lora_alpha=
|
| 95 |
-
lora_text_encoder_r=
|
| 96 |
-
lora_text_encoder_alpha=
|
| 97 |
),
|
| 98 |
components=[_.to_dict() for _ in FACE_TRAINING_DEFAULT_COMPONENTS],
|
| 99 |
)
|
|
@@ -140,7 +150,7 @@ def create_ui():
|
|
| 140 |
# trained_loras_models = [_.name for _ in get_noviata_client(novita_key).models_v3(refresh=True).filter_by_type("lora").filter_by_visibility("private")]
|
| 141 |
serving_models = [_.models[0].model_name for _ in get_noviata_client(novita_key).list_training().filter_by_model_status("SERVING")]
|
| 142 |
serving_models_labels = [_.task_name for _ in get_noviata_client(novita_key).list_training().filter_by_model_status("SERVING")]
|
| 143 |
-
return gr.update(choices=serving_models_labels
|
| 144 |
|
| 145 |
inference_refresh_button.click(
|
| 146 |
inputs=[novita_key],
|
|
@@ -346,7 +356,7 @@ def create_ui():
|
|
| 346 |
except Exception as e:
|
| 347 |
logging.error(e)
|
| 348 |
return novita_key, gr.update(choices=[], value=None), gr.update(value=None), f"$ UNKNOWN"
|
| 349 |
-
return novita_key, gr.update(choices=serving_models_labels
|
| 350 |
|
| 351 |
novita_key.change(onload, inputs=novita_key, outputs=[novita_key, style_lora, _hide_lora_training_response, user_balance], _js="(v)=>{ setStorage('novita_key',v); return [v]; }")
|
| 352 |
|
|
|
|
| 16 |
"dreamshaper_8_93211.safetensors",
|
| 17 |
"epicrealism_pureEvolutionV5_97793.safetensors",
|
| 18 |
]
|
| 19 |
+
base_checkpoints = ["epicrealism_naturalSin_121250", "v1-5-pruned-emaonly"]
|
| 20 |
|
| 21 |
|
| 22 |
get_local_storage = """
|
|
|
|
| 54 |
with gr.Tab(label="Training"):
|
| 55 |
with gr.Row():
|
| 56 |
with gr.Column(scale=1):
|
| 57 |
+
base_model = gr.Dropdown(choices=base_checkpoints, label="Base Model", value=base_checkpoints[0])
|
| 58 |
geneder = gr.Radio(choices=["man", "woman"], value="man", label="Geneder")
|
| 59 |
training_name = gr.Text(label="Training Name", placeholder="training name", elem_id="training_name", value="my-face-001")
|
| 60 |
max_train_steps = gr.Slider(minimum=200, maximum=4000, step=1, label="Max Train Steps", value=2000)
|
| 61 |
+
training_images = gr.File(file_types=["image"], file_count="multiple", label="6-10 face images.")
|
| 62 |
training_button = gr.Button(value="Train")
|
| 63 |
training_payload = gr.JSON(label="Training Payload, POST /v3/training/subject")
|
| 64 |
with gr.Column(scale=1):
|
| 65 |
+
training_refresh_button = gr.Button(value="Refresh Training Status")
|
| 66 |
training_refresh_json = gr.JSON()
|
| 67 |
|
| 68 |
def train(novita_key, gender, base_model, training_name, max_train_steps, training_images):
|
|
|
|
| 71 |
get_noviata_client(novita_key).create_training_subject(
|
| 72 |
base_model=base_model,
|
| 73 |
name=training_name,
|
| 74 |
+
instance_prompt=f"a closeup photo of ohwx person",
|
| 75 |
class_prompt="person",
|
| 76 |
max_train_steps=max_train_steps,
|
| 77 |
images=training_images,
|
| 78 |
+
components=FACE_TRAINING_DEFAULT_COMPONENTS,
|
| 79 |
+
learning_rate=3e-4,
|
| 80 |
+
seed=None,
|
| 81 |
+
lr_scheduler='cosine_with_restarts',
|
| 82 |
with_prior_preservation=True,
|
| 83 |
+
prior_loss_weight=1.0,
|
| 84 |
+
lora_r=32,
|
| 85 |
+
lora_alpha=32,
|
| 86 |
+
lora_text_encoder_r=32,
|
| 87 |
+
lora_text_encoder_alpha=32,
|
| 88 |
)
|
| 89 |
+
|
| 90 |
payload = dict(
|
| 91 |
name=training_name,
|
| 92 |
base_model=base_model,
|
| 93 |
image_dataset_items=["....assets_ids, please manually upload to novita.ai"],
|
| 94 |
expert_setting=TrainingExpertSetting(
|
| 95 |
+
instance_prompt=f"a closeup photo of ohwx person",
|
| 96 |
class_prompt="person",
|
| 97 |
max_train_steps=max_train_steps,
|
| 98 |
+
learning_rate="8e-5",
|
| 99 |
seed=None,
|
| 100 |
+
lr_scheduler='cosine_with_restarts',
|
| 101 |
with_prior_preservation=True,
|
| 102 |
+
prior_loss_weight=1.0,
|
| 103 |
+
lora_r=32,
|
| 104 |
+
lora_alpha=32,
|
| 105 |
+
lora_text_encoder_r=32,
|
| 106 |
+
lora_text_encoder_alpha=32,
|
| 107 |
),
|
| 108 |
components=[_.to_dict() for _ in FACE_TRAINING_DEFAULT_COMPONENTS],
|
| 109 |
)
|
|
|
|
| 150 |
# trained_loras_models = [_.name for _ in get_noviata_client(novita_key).models_v3(refresh=True).filter_by_type("lora").filter_by_visibility("private")]
|
| 151 |
serving_models = [_.models[0].model_name for _ in get_noviata_client(novita_key).list_training().filter_by_model_status("SERVING")]
|
| 152 |
serving_models_labels = [_.task_name for _ in get_noviata_client(novita_key).list_training().filter_by_model_status("SERVING")]
|
| 153 |
+
return gr.update(choices=serving_models_labels), gr.update(value=serving_models)
|
| 154 |
|
| 155 |
inference_refresh_button.click(
|
| 156 |
inputs=[novita_key],
|
|
|
|
| 356 |
except Exception as e:
|
| 357 |
logging.error(e)
|
| 358 |
return novita_key, gr.update(choices=[], value=None), gr.update(value=None), f"$ UNKNOWN"
|
| 359 |
+
return novita_key, gr.update(choices=serving_models_labels), gr.update(value=serving_models), f"$ {user_info_json.credit_balance / 100 / 100:.2f}"
|
| 360 |
|
| 361 |
novita_key.change(onload, inputs=novita_key, outputs=[novita_key, style_lora, _hide_lora_training_response, user_balance], _js="(v)=>{ setStorage('novita_key',v); return [v]; }")
|
| 362 |
|