multimodalart HF staff commited on
Commit
fbb3ef2
1 Parent(s): 62af647

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -8
app.py CHANGED
@@ -65,7 +65,7 @@ def load_captioning(uploaded_images, option):
65
 
66
  def check_removed_and_restart(images):
67
  visible = bool(images)
68
- return [gr.update(visible=visible) for _ in range(3)]
69
 
70
  def make_options_visible(option):
71
  if (option == "object") or (option == "face"):
@@ -440,6 +440,19 @@ def run_captioning(*inputs):
440
  final_captions[index] = final_caption
441
  yield final_captions
442
 
 
 
 
 
 
 
 
 
 
 
 
 
 
443
  with gr.Blocks() as demo:
444
  dataset_folder = gr.State()
445
  gr.Markdown("# SDXL LoRA Dreambooth Training")
@@ -708,20 +721,28 @@ To improve the quality of your outputs, you can add a custom caption for each im
708
  local_rank = gr.Number(label="local_rank", value=-1)
709
  with gr.Row():
710
  with gr.Group():
711
- gr.Markdown('''### This training is estimated to cost <b>US$ 3,50</b> with your current settings
712
- - Get your Hugging Face <b>write</b> token [here](https://huggingface.co/settings/tokens)
713
- - (For the training to your you need to have a credit card set up in your account, set it up [here](https://huggingface.co/settings/billing/payment))
714
  ''')
715
  token = gr.Textbox(label="Your Hugging Face write token", info="A Hugging Face write token you can obtain on the settings page")
716
-
717
  with gr.Group() as no_payment_method:
718
  with gr.Row():
719
- gr.Markdown("Your Hugging Face account doesn't have a payment method. You need to set it up to train your LoRA")
720
- gr.Button("I have set up my payment method")
721
  start = gr.Button("Start training", visible=False)
722
  progress_area = gr.HTML("...")
723
  output_components.insert(1, advanced)
724
  output_components.insert(1, start)
 
 
 
 
 
 
 
 
 
 
725
  use_snr_gamma.change(
726
  lambda x: gr.update(visible=x),
727
  inputs=use_snr_gamma,
@@ -767,7 +788,7 @@ To improve the quality of your outputs, you can add a custom caption for each im
767
  images.change(
768
  check_removed_and_restart,
769
  inputs=[images],
770
- outputs=[captioning_area, advanced, start],
771
  )
772
  training_option.change(
773
  make_options_visible,
 
65
 
66
  def check_removed_and_restart(images):
67
  visible = bool(images)
68
+ return [gr.update(visible=visible) for _ in range(2)]
69
 
70
  def make_options_visible(option):
71
  if (option == "object") or (option == "face"):
 
440
  final_captions[index] = final_caption
441
  yield final_captions
442
 
443
+ def check_token(token):
444
+ api = HfApi(token=token)
445
+ user_data = api.whoami()
446
+ if (username['auth']['accessToken']['role'] != "write"):
447
+ gr.Warning("Oops, you've uploaded a `Read` token. We need a Write token!")
448
+ else:
449
+ if user_data['canPay']:
450
+ return gr.update(visible=False), gr.update(visible=True)
451
+ else:
452
+ return gr.update(visible=True), gr.update(visible=False)
453
+
454
+ return gr.update(visible=False), gr.update(visible=False)
455
+
456
  with gr.Blocks() as demo:
457
  dataset_folder = gr.State()
458
  gr.Markdown("# SDXL LoRA Dreambooth Training")
 
721
  local_rank = gr.Number(label="local_rank", value=-1)
722
  with gr.Row():
723
  with gr.Group():
724
+ gr.Markdown('''### This training is estimated to cost <b>< US$ 1,50</b> with your current train settings
725
+ Grab a Hugging Face <b>write</b> token [here](https://huggingface.co/settings/tokens)
 
726
  ''')
727
  token = gr.Textbox(label="Your Hugging Face write token", info="A Hugging Face write token you can obtain on the settings page")
 
728
  with gr.Group() as no_payment_method:
729
  with gr.Row():
730
+ gr.Markdown("Your Hugging Face account doesn't have a payment method. Set it up [here](https://huggingface.co/settings/billing/payment) to train your LoRA")
731
+ payment_setup = gr.Button("I have set up my payment method")
732
  start = gr.Button("Start training", visible=False)
733
  progress_area = gr.HTML("...")
734
  output_components.insert(1, advanced)
735
  output_components.insert(1, start)
736
+
737
+ gr.on(
738
+ triggers=[
739
+ token.change,
740
+ payment_setup.click
741
+ ],
742
+ fn=check_token,
743
+ inputs=token,
744
+ outputs=no_payment_method, start
745
+ )
746
  use_snr_gamma.change(
747
  lambda x: gr.update(visible=x),
748
  inputs=use_snr_gamma,
 
788
  images.change(
789
  check_removed_and_restart,
790
  inputs=[images],
791
+ outputs=[captioning_area, advanced],
792
  )
793
  training_option.change(
794
  make_options_visible,