anyisalin commited on
Commit
abbbf4f
·
1 Parent(s): 5068398

add free trial

Browse files

Signed-off-by: AnyISalIn <anyisalin@gmail.com>

Files changed (2) hide show
  1. app.py +15 -8
  2. requirements.txt +1 -1
app.py CHANGED
@@ -49,10 +49,12 @@ def create_ui():
49
  <img src="https://raw.githubusercontent.com/wiki/novitalabs/sd-webui-cleaner/images/logo2.png" width="120px;" alt="Unsplash" />
50
  </a>
51
  <h1>Face Stylization Playground</h1>
52
- <h3>Powered by <a href="https://novita.ai/?utm_source=huggingface&utm_medium=face-stylization&utm_campaign=face-stylization">Novita.AI</a></h2>
53
- <h3> Get Novita.AI API Key from <a href="https://novita.ai/?utm_source=huggingface&utm_medium=face-stylization&utm_campaign=face-stylization">Novita.AI</a></h2>
54
  '''
55
  )
 
 
56
  with gr.Row():
57
  with gr.Column(scale=1):
58
  novita_key = gr.Textbox(value="", label="Novita.AI API KEY (store in broweser)", placeholder="novita.ai api key", type="password")
@@ -191,7 +193,8 @@ def create_ui():
191
  _hide_lora_training_response = gr.JSON(visible=False)
192
  style_height = gr.Slider(minimum=1, maximum=1024, step=1, label="Style Height", value=512)
193
  style_width = gr.Slider(minimum=1, maximum=1024, step=1, label="Style Width", value=512)
194
- style_method = gr.Radio(choices=["txt2img", "controlnet-depth", "controlnet-pose", "controlnet-canny", "controlnet-lineart", "controlnet-scribble", "controlnet-tile"], label="Style Method")
 
195
 
196
  style_advanced = gr.Checkbox(label="Advanced")
197
  with gr.Column(scale=1, visible=False) as style_advanced_tab:
@@ -587,22 +590,26 @@ def create_ui():
587
 
588
  def onload(novita_key):
589
  if novita_key is None or novita_key == "":
590
- return novita_key, gr.update(choices=[], value=None), gr.update(value=None), f"$ UNKNOWN"
591
  try:
592
  user_info_json = get_noviata_client(novita_key).user_info()
593
  serving_models = [_.models[0].model_name for _ in get_noviata_client(novita_key).list_training().filter_by_model_status("SERVING")]
594
  serving_models_labels = [_.task_name for _ in get_noviata_client(novita_key).list_training().filter_by_model_status("SERVING")]
595
  except Exception as e:
596
  logging.error(e)
597
- return novita_key, gr.update(choices=[], value=None), gr.update(value=None), f"$ UNKNOWN"
598
  default_serving_model = serving_models_labels[0] if len(serving_models_labels) > 0 else None
599
- return novita_key, gr.update(choices=serving_models_labels, value=default_serving_model), gr.update(value=serving_models), f"$ {user_info_json.credit_balance / 100 / 100:.2f}"
 
 
 
600
 
601
- 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]; }")
 
602
 
603
  demo.load(
604
  inputs=[novita_key],
605
- outputs=[novita_key, style_lora, _hide_lora_training_response, user_balance],
606
  fn=onload,
607
  _js=get_local_storage,
608
  )
 
49
  <img src="https://raw.githubusercontent.com/wiki/novitalabs/sd-webui-cleaner/images/logo2.png" width="120px;" alt="Unsplash" />
50
  </a>
51
  <h1>Face Stylization Playground</h1>
52
+ <h3>Start integrate with <a href="https://novita.ai/get-started/Model_training.html?utm_source=huggingface&utm_medium=face-stylization&utm_campaign=face-stylization">Model_training API</a>
53
+ <h3> Get Novita.AI API Key from <a href="https://novita.ai/get-started/Account_account_and_key.html?utm_source=huggingface&utm_medium=face-stylization&utm_campaign=face-stylization">Novita.AI</a></h2>
54
  '''
55
  )
56
+
57
+ free_trial_notice = gr.HTML('', visible=False)
58
  with gr.Row():
59
  with gr.Column(scale=1):
60
  novita_key = gr.Textbox(value="", label="Novita.AI API KEY (store in broweser)", placeholder="novita.ai api key", type="password")
 
193
  _hide_lora_training_response = gr.JSON(visible=False)
194
  style_height = gr.Slider(minimum=1, maximum=1024, step=1, label="Style Height", value=512)
195
  style_width = gr.Slider(minimum=1, maximum=1024, step=1, label="Style Width", value=512)
196
+ style_method = gr.Radio(choices=["txt2img", "controlnet-depth", "controlnet-pose", "controlnet-canny",
197
+ "controlnet-lineart", "controlnet-scribble", "controlnet-tile"], label="Style Method")
198
 
199
  style_advanced = gr.Checkbox(label="Advanced")
200
  with gr.Column(scale=1, visible=False) as style_advanced_tab:
 
590
 
591
  def onload(novita_key):
592
  if novita_key is None or novita_key == "":
593
+ return novita_key, gr.update(choices=[], value=None), gr.update(value=None), f"$ UNKNOWN", gr.update(visible=False)
594
  try:
595
  user_info_json = get_noviata_client(novita_key).user_info()
596
  serving_models = [_.models[0].model_name for _ in get_noviata_client(novita_key).list_training().filter_by_model_status("SERVING")]
597
  serving_models_labels = [_.task_name for _ in get_noviata_client(novita_key).list_training().filter_by_model_status("SERVING")]
598
  except Exception as e:
599
  logging.error(e)
600
+ return novita_key, gr.update(choices=[], value=None), gr.update(value=None), f"$ UNKNOWN", gr.update(visible=False)
601
  default_serving_model = serving_models_labels[0] if len(serving_models_labels) > 0 else None
602
+ free_trial = user_info_json.free_trial.get('training', 0)
603
+ trial_html = f'''<h2 style="color: red"> 🌟 Free trial quota: {free_trial} </h2>'''
604
+
605
+ return novita_key, gr.update(choices=serving_models_labels, value=default_serving_model), gr.update(value=serving_models), f"$ {user_info_json.credit_balance / 100 / 100:.2f}", gr.update(value=trial_html, visible=free_trial > 0)
606
 
607
+ novita_key.change(onload, inputs=novita_key, outputs=[novita_key, style_lora, _hide_lora_training_response,
608
+ user_balance, free_trial_notice], _js="(v)=>{ setStorage('novita_key',v); return [v]; }")
609
 
610
  demo.load(
611
  inputs=[novita_key],
612
+ outputs=[novita_key, style_lora, _hide_lora_training_response, user_balance, free_trial_notice],
613
  fn=onload,
614
  _js=get_local_storage,
615
  )
requirements.txt CHANGED
@@ -1,2 +1,2 @@
1
- novita_client==0.4.5
2
  gradio==3.50.2
 
1
+ novita_client==0.4.6
2
  gradio==3.50.2