Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -169,12 +169,8 @@ def clear_directory(directory_path):
|
|
169 |
else:
|
170 |
print(f'The directory {directory_path} does not exist.')
|
171 |
|
172 |
-
def get_start_info(b_lora_name):
|
173 |
-
|
174 |
-
return gr.update(visible=True, value=f"https://hf.co/{your_username}/{b_lora_name}"), gr.update(visible=True)
|
175 |
-
|
176 |
-
def main(image_path, b_lora_trained_folder, instance_prompt, training_type, training_steps):
|
177 |
-
|
178 |
if is_shared_ui:
|
179 |
raise gr.Error("This Space only works in duplicated instances")
|
180 |
|
@@ -184,13 +180,18 @@ def main(image_path, b_lora_trained_folder, instance_prompt, training_type, trai
|
|
184 |
if image_path == None:
|
185 |
raise gr.Error("You forgot to specify an image reference")
|
186 |
|
187 |
-
if
|
188 |
raise gr.Error("You forgot to specify a name for you model")
|
189 |
|
190 |
if instance_prompt == "":
|
191 |
raise gr.Error("You forgot to specify an instance prompt")
|
192 |
-
|
193 |
|
|
|
|
|
|
|
|
|
|
|
|
|
194 |
local_dir = "image_to_train"
|
195 |
# Check if the directory exists and create it if necessary
|
196 |
if not os.path.exists(local_dir):
|
@@ -381,7 +382,7 @@ with gr.Blocks(css=css) as demo:
|
|
381 |
|
382 |
train_btn.click(
|
383 |
fn = get_start_info,
|
384 |
-
inputs = [b_lora_name],
|
385 |
outputs = [started_info, status]
|
386 |
).then(
|
387 |
fn = main,
|
|
|
169 |
else:
|
170 |
print(f'The directory {directory_path} does not exist.')
|
171 |
|
172 |
+
def get_start_info(image_path, b_lora_name, instance_prompt):
|
173 |
+
|
|
|
|
|
|
|
|
|
174 |
if is_shared_ui:
|
175 |
raise gr.Error("This Space only works in duplicated instances")
|
176 |
|
|
|
180 |
if image_path == None:
|
181 |
raise gr.Error("You forgot to specify an image reference")
|
182 |
|
183 |
+
if b_lora_name == "":
|
184 |
raise gr.Error("You forgot to specify a name for you model")
|
185 |
|
186 |
if instance_prompt == "":
|
187 |
raise gr.Error("You forgot to specify an instance prompt")
|
|
|
188 |
|
189 |
+
your_username = api.whoami(token=hf_token)["name"]
|
190 |
+
|
191 |
+
return gr.update(visible=True, value=f"https://hf.co/{your_username}/{b_lora_name}"), gr.update(visible=True)
|
192 |
+
|
193 |
+
def main(image_path, b_lora_trained_folder, instance_prompt, training_type, training_steps):
|
194 |
+
|
195 |
local_dir = "image_to_train"
|
196 |
# Check if the directory exists and create it if necessary
|
197 |
if not os.path.exists(local_dir):
|
|
|
382 |
|
383 |
train_btn.click(
|
384 |
fn = get_start_info,
|
385 |
+
inputs = [image, b_lora_name, instance_prompt],
|
386 |
outputs = [started_info, status]
|
387 |
).then(
|
388 |
fn = main,
|