openfree commited on
Commit
86a34dd
ยท
verified ยท
1 Parent(s): 849a2fb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -40
app.py CHANGED
@@ -264,14 +264,8 @@ def start_training(
264
  return f"""# Training completed successfully!
265
  ## Your model is available at: <a href='https://huggingface.co/{username}/{slugged_lora_name}'>{username}/{slugged_lora_name}</a>"""
266
 
267
- def swap_visibilty(profile: Union[gr.OAuthProfile, None]):
268
- # HF_TOKEN์ด ์žˆ์œผ๋ฏ€๋กœ ํ•ญ์ƒ ๋กœ๊ทธ์ธ๋œ ์ƒํƒœ๋กœ ์ฒ˜๋ฆฌ
269
- return gr.update(elem_classes=["main_ui_logged_in"])
270
-
271
- def update_pricing(steps, oauth_token: Union[gr.OAuthToken, None]):
272
- # HF_TOKEN์„ ์‚ฌ์šฉํ•˜์—ฌ ์ง์ ‘ ํ™•์ธ
273
  try:
274
- user = whoami()
275
  seconds_per_iteration = 7.54
276
  total_seconds = (steps * seconds_per_iteration) + 240
277
  cost_per_second = 0.80/60/60
@@ -281,7 +275,7 @@ def update_pricing(steps, oauth_token: Union[gr.OAuthToken, None]):
281
  return gr.update(visible=True), cost_preview, gr.update(visible=False), gr.update(visible=True)
282
  except:
283
  return gr.update(visible=False), "", gr.update(visible=False), gr.update(visible=True)
284
-
285
 
286
 
287
  def swap_base_model(model):
@@ -346,8 +340,10 @@ with gr.Blocks(theme=theme, css=css) as demo:
346
  """# ๐Ÿ†” Gini LoRA ํ•™์Šต
347
  ### ์ด๋ฏธ์ง€๋“ค(์ตœ๋Œ€ 150์žฅ ์•„๋‹ˆ)์„ ์—…๋กœ๋“œํ•˜์„ธ์š”. """
348
  )
349
- with gr.Tab("Train"): # "Train on Spaces" ๋Œ€์‹  ๋‹จ์ˆœํžˆ "Train"์œผ๋กœ ๋ณ€๊ฒฝ
350
- with gr.Column() as main_ui:
 
 
351
 
352
  with gr.Group():
353
  with gr.Row():
@@ -506,38 +502,33 @@ with gr.Blocks(theme=theme, css=css) as demo:
506
  )
507
 
508
  gr.on(
509
- triggers=[steps.change, payment_update.click],
510
- fn=update_pricing,
511
- inputs=[steps],
512
- outputs=[cost_preview, cost_preview_info, payment_update, start]
513
- )
514
-
515
- which_model.change(
516
- fn=swap_base_model,
517
- inputs=which_model,
518
- outputs=model_warning
519
- )
520
- start.click(fn=create_dataset, inputs=[images] + caption_list, outputs=dataset_folder).then(
521
- fn=start_training,
522
- inputs=[
523
- lora_name,
524
- concept_sentence,
525
- which_model,
526
- steps,
527
- lr,
528
- rank,
529
- dataset_folder,
530
- sample_1,
531
- sample_2,
532
- sample_3,
533
- use_more_advanced_options,
534
- more_advanced_options
535
  ],
536
- outputs=progress_area,
537
- )
 
 
538
 
539
- do_captioning.click(fn=run_captioning, inputs=[images, concept_sentence] + caption_list, outputs=caption_list)
540
- demo.load(fn=swap_visibilty, outputs=main_ui)
541
 
542
  if __name__ == "__main__":
543
  demo.launch(
 
264
  return f"""# Training completed successfully!
265
  ## Your model is available at: <a href='https://huggingface.co/{username}/{slugged_lora_name}'>{username}/{slugged_lora_name}</a>"""
266
 
267
+ def update_pricing(steps):
 
 
 
 
 
268
  try:
 
269
  seconds_per_iteration = 7.54
270
  total_seconds = (steps * seconds_per_iteration) + 240
271
  cost_per_second = 0.80/60/60
 
275
  return gr.update(visible=True), cost_preview, gr.update(visible=False), gr.update(visible=True)
276
  except:
277
  return gr.update(visible=False), "", gr.update(visible=False), gr.update(visible=True)
278
+
279
 
280
 
281
  def swap_base_model(model):
 
340
  """# ๐Ÿ†” Gini LoRA ํ•™์Šต
341
  ### ์ด๋ฏธ์ง€๋“ค(์ตœ๋Œ€ 150์žฅ ์•„๋‹ˆ)์„ ์—…๋กœ๋“œํ•˜์„ธ์š”. """
342
  )
343
+
344
+ with gr.Tab("Train"): # ํƒญ ์ด๋ฆ„ ๋ณ€๊ฒฝ
345
+ with gr.Column(): # main_ui ๋Œ€์‹  ์ง์ ‘ Column ์‚ฌ์šฉ
346
+ with gr.Group():
347
 
348
  with gr.Group():
349
  with gr.Row():
 
502
  )
503
 
504
  gr.on(
505
+ triggers=[steps.change],
506
+ fn=update_pricing,
507
+ inputs=[steps],
508
+ outputs=[cost_preview, cost_preview_info, payment_update, start]
509
+ )
510
+
511
+ start.click(fn=create_dataset, inputs=[images] + caption_list, outputs=dataset_folder).then(
512
+ fn=start_training,
513
+ inputs=[
514
+ lora_name,
515
+ concept_sentence,
516
+ which_model,
517
+ steps,
518
+ lr,
519
+ rank,
520
+ dataset_folder,
521
+ sample_1,
522
+ sample_2,
523
+ sample_3,
524
+ use_more_advanced_options,
525
+ more_advanced_options
 
 
 
 
 
526
  ],
527
+ outputs=progress_area,
528
+ )
529
+
530
+ do_captioning.click(fn=run_captioning, inputs=[images, concept_sentence] + caption_list, outputs=caption_list)
531
 
 
 
532
 
533
  if __name__ == "__main__":
534
  demo.launch(