multimodalart HF staff commited on
Commit
cab8b2c
1 Parent(s): 2cd9a44

Fix gr.update

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -274,9 +274,9 @@ def convert_to_ckpt():
274
  convert("output_model", "model.ckpt")
275
  return gr.update(visible=True, value=["diffusers_model.zip", "model.ckpt"])
276
 
277
- def check_status():
278
  if os.path.exists("hastrained.success"):
279
- update_top_tag = gr.Update(value=f'''
280
  <div class="gr-prose" style="max-width: 80%">
281
  <h2>Your model has finished training ✅</h2>
282
  <p>Yay, congratulations on training your model. Scroll down to play with with it, save it (either downloading it or on the Hugging Face Hub). Once you are done, your model is safe, and you don't want to train a new one, go to the <a href="https://huggingface.co/spaces/{os.environ['SPACE_ID']}">settings page</a> and downgrade your Space to a CPU Basic</p>
@@ -284,7 +284,7 @@ def check_status():
284
  ''')
285
  show_outputs = True
286
  elif os.path.exists("intraining.lock"):
287
- update_top_tag = gr.Update(value='''
288
  <div class="gr-prose" style="max-width: 80%">
289
  <h2>Don't worry, your model is still training! ⌛</h2>
290
  <p>You closed the tab while your model was training, but it's all good! It is still training right now. You can click the "Open logs" button above here to check the training status. Once training is done, reload this tab to interact with your model</p>
@@ -292,7 +292,8 @@ def check_status():
292
  ''')
293
  show_outputs = False
294
  else:
295
- update_top_tag = gr.Update()
 
296
  return [
297
  update_top_tag, #top_description
298
  gr.update(visible=show_outputs), #try_your_model
@@ -320,7 +321,7 @@ with gr.Blocks(css=css) as demo:
320
  top_description = gr.HTML(f'''
321
  <div class="gr-prose" style="max-width: 80%">
322
  <h2>You have successfully duplicated the Dreambooth Training Space 🎉</h2>
323
- <p>If you haven't already, <a href="https://huggingface.co/spaces/{os.environ['SPACE_ID']}/settings">attribute a T4 GPU to it (via the Settings tab)</a> and run the training below. You will be billed by the minute from when you activate the GPU until when you turn it off.</p>
324
  </div>
325
  ''')
326
  gr.Markdown("# Dreambooth training")
@@ -430,7 +431,7 @@ with gr.Blocks(css=css) as demo:
430
  #Give more options if the user wants to finish everything after training
431
  training_summary_checkbox.change(fn=checkbox_swap, inputs=training_summary_checkbox, outputs=[training_summary_token_message, training_summary_token, training_summary_model_name])
432
  #Add a message for while it is in training
433
- train_btn.click(lambda:gr.Update(visible=True), inputs=None, outputs=training_ongoing)
434
 
435
  #The main train function
436
  train_btn.click(fn=train, inputs=is_visible+concept_collection+file_collection+[training_summary_model_name]+[training_summary_checkbox]+[training_summary_token]+[type_of_thing]+[steps]+[perc_txt_encoder]+[swap_auto_calculated], outputs=[result, try_your_model, push_to_hub, convert_button, training_ongoing, completed_training])
@@ -443,6 +444,6 @@ with gr.Blocks(css=css) as demo:
443
  convert_button.click(fn=convert_to_ckpt, inputs=[], outputs=result)
444
 
445
  #Checks if the training is running
446
- demo.load(fn=check_status, inputs=[], outputs=[top_description, try_your_model, push_to_hub, result, convert_button])
447
 
448
  demo.launch(debug=True)
 
274
  convert("output_model", "model.ckpt")
275
  return gr.update(visible=True, value=["diffusers_model.zip", "model.ckpt"])
276
 
277
+ def check_status(top_description):
278
  if os.path.exists("hastrained.success"):
279
+ update_top_tag = gr.update(value=f'''
280
  <div class="gr-prose" style="max-width: 80%">
281
  <h2>Your model has finished training ✅</h2>
282
  <p>Yay, congratulations on training your model. Scroll down to play with with it, save it (either downloading it or on the Hugging Face Hub). Once you are done, your model is safe, and you don't want to train a new one, go to the <a href="https://huggingface.co/spaces/{os.environ['SPACE_ID']}">settings page</a> and downgrade your Space to a CPU Basic</p>
 
284
  ''')
285
  show_outputs = True
286
  elif os.path.exists("intraining.lock"):
287
+ update_top_tag = gr.update(value='''
288
  <div class="gr-prose" style="max-width: 80%">
289
  <h2>Don't worry, your model is still training! ⌛</h2>
290
  <p>You closed the tab while your model was training, but it's all good! It is still training right now. You can click the "Open logs" button above here to check the training status. Once training is done, reload this tab to interact with your model</p>
 
292
  ''')
293
  show_outputs = False
294
  else:
295
+ update_top_tag = gr.update(value=top_description)
296
+ show_outputs = False
297
  return [
298
  update_top_tag, #top_description
299
  gr.update(visible=show_outputs), #try_your_model
 
321
  top_description = gr.HTML(f'''
322
  <div class="gr-prose" style="max-width: 80%">
323
  <h2>You have successfully duplicated the Dreambooth Training Space 🎉</h2>
324
+ <p>If you haven't already, <a href="https://huggingface.co/spaces/{os.environ['SPACE_ID']}/settings">attribute a T4 GPU to it (via the Settings tab)</a> and run the training below. You will be billed by the minute from when you activate the GPU until when it is turned it off.</p>
325
  </div>
326
  ''')
327
  gr.Markdown("# Dreambooth training")
 
431
  #Give more options if the user wants to finish everything after training
432
  training_summary_checkbox.change(fn=checkbox_swap, inputs=training_summary_checkbox, outputs=[training_summary_token_message, training_summary_token, training_summary_model_name])
433
  #Add a message for while it is in training
434
+ train_btn.click(lambda:gr.update(visible=True), inputs=None, outputs=training_ongoing)
435
 
436
  #The main train function
437
  train_btn.click(fn=train, inputs=is_visible+concept_collection+file_collection+[training_summary_model_name]+[training_summary_checkbox]+[training_summary_token]+[type_of_thing]+[steps]+[perc_txt_encoder]+[swap_auto_calculated], outputs=[result, try_your_model, push_to_hub, convert_button, training_ongoing, completed_training])
 
444
  convert_button.click(fn=convert_to_ckpt, inputs=[], outputs=result)
445
 
446
  #Checks if the training is running
447
+ demo.load(fn=check_status, inputs=top_description, outputs=[top_description, try_your_model, push_to_hub, result, convert_button])
448
 
449
  demo.launch(debug=True)