fffiloni commited on
Commit
e5bfcbc
·
verified ·
1 Parent(s): cc6a357

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -14
app.py CHANGED
@@ -169,6 +169,10 @@ def clear_directory(directory_path):
169
  else:
170
  print(f'The directory {directory_path} does not exist.')
171
 
 
 
 
 
172
  def main(image_path, b_lora_trained_folder, instance_prompt, training_type, training_steps):
173
 
174
  if is_shared_ui:
@@ -186,12 +190,6 @@ def main(image_path, b_lora_trained_folder, instance_prompt, training_type, trai
186
  if instance_prompt == "":
187
  raise gr.Error("You forgot to specify an instance prompt")
188
 
189
- # URL to be opened
190
- log_url = f"https://huggingface.co/spaces/{os.environ['SPACE_ID']}?logs=container"
191
-
192
- # Open URL in the current browser window
193
- webbrowser.get().open(log_url)
194
-
195
 
196
  local_dir = "image_to_train"
197
  # Check if the directory exists and create it if necessary
@@ -214,12 +212,6 @@ def main(image_path, b_lora_trained_folder, instance_prompt, training_type, trai
214
  train_dreambooth_blora_sdxl(local_dir, b_lora_trained_folder, instance_prompt, max_train_steps, checkpoint_steps)
215
 
216
  your_username = api.whoami(token=hf_token)["name"]
217
-
218
- # URL to be opened
219
- model_url = f"https://huggingface.co/{your_username}/{b_lora_trained_folder}"
220
-
221
- # Open URL in the current browser window
222
- webbrowser.get().open_new_tab(model_url)
223
 
224
  #swap_hardware(hardware="cpu-basic")
225
  swap_sleep_time(300)
@@ -360,8 +352,13 @@ with gr.Blocks(css=css) as demo:
360
 
361
 
362
  train_btn = gr.Button("Train B-LoRa", visible=False)
363
-
364
- status = gr.Textbox(label="status")
 
 
 
 
 
365
 
366
  current_sleep_time.change(
367
  fn = swap_sleep_time,
@@ -382,6 +379,10 @@ with gr.Blocks(css=css) as demo:
382
  )
383
 
384
  train_btn.click(
 
 
 
 
385
  fn = main,
386
  inputs = [image, b_lora_name, instance_prompt, training_type, training_steps],
387
  outputs = [status]
 
169
  else:
170
  print(f'The directory {directory_path} does not exist.')
171
 
172
+ def get_start_info(b_lora_name):
173
+ your_username = api.whoami(token=hf_token)["name"]
174
+ return f"https://hf.co/{your_username}/{b_lora_trained_folder}"
175
+
176
  def main(image_path, b_lora_trained_folder, instance_prompt, training_type, training_steps):
177
 
178
  if is_shared_ui:
 
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
 
212
  train_dreambooth_blora_sdxl(local_dir, b_lora_trained_folder, instance_prompt, max_train_steps, checkpoint_steps)
213
 
214
  your_username = api.whoami(token=hf_token)["name"]
 
 
 
 
 
 
215
 
216
  #swap_hardware(hardware="cpu-basic")
217
  swap_sleep_time(300)
 
352
 
353
 
354
  train_btn = gr.Button("Train B-LoRa", visible=False)
355
+
356
+ with gr.Row():
357
+ started_info = gr.Textbox(
358
+ label="Training has started",
359
+ info="You can open this space's logs to monitor logs training; once training is finished, your model will be available here:"
360
+ )
361
+ status = gr.Textbox(label="status")
362
 
363
  current_sleep_time.change(
364
  fn = swap_sleep_time,
 
379
  )
380
 
381
  train_btn.click(
382
+ fn = get_start_info,
383
+ inputs = [b_lora_name],
384
+ outputs = [started_info]
385
+ ).then(
386
  fn = main,
387
  inputs = [image, b_lora_name, instance_prompt, training_type, training_steps],
388
  outputs = [status]