ironjr commited on
Commit
f64f0cd
1 Parent(s): 5d6a7d3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +52 -0
app.py CHANGED
@@ -38,10 +38,12 @@ import torch
38
 
39
  import gradio as gr
40
  from huggingface_hub import snapshot_download
 
41
 
42
  from model import StableMultiDiffusion3Pipeline
43
  from util import seed_everything
44
  from prompt_util import preprocess_prompts, _quality_dict, _style_dict
 
45
 
46
 
47
  ### Utils
@@ -302,6 +304,7 @@ def import_state(state, json_text):
302
 
303
  ### Main worker
304
 
 
305
  def generate(state, *args, **kwargs):
306
  return models[state.model_id](*args, **kwargs)
307
 
@@ -500,6 +503,52 @@ css = f"""
500
  conic-gradient(from 45deg at left ,#0000,#000 1deg 89deg,#0000 90deg)
501
  50% calc(50% - var(--z))/100% calc(2*var(--z)) repeat-y;
502
  }}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
503
  """
504
 
505
  for i in range(opt.max_palettes + 1):
@@ -727,6 +776,7 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
727
  elem_id='run-button'
728
  )
729
 
 
730
 
731
  gr.HTML(
732
  """
@@ -927,6 +977,8 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
927
  # api_name='quality_select',
928
  # )
929
 
 
 
930
  iface.btn_export_state.click(lambda x: vars(x), state, iface.json_state_export)
931
  iface.btn_import_state.click(import_state, [state, iface.tbox_state_import], [
932
  state,
 
38
 
39
  import gradio as gr
40
  from huggingface_hub import snapshot_download
41
+ import spaces
42
 
43
  from model import StableMultiDiffusion3Pipeline
44
  from util import seed_everything
45
  from prompt_util import preprocess_prompts, _quality_dict, _style_dict
46
+ from share_btn import share_js
47
 
48
 
49
  ### Utils
 
304
 
305
  ### Main worker
306
 
307
+ @spaces.GPU
308
  def generate(state, *args, **kwargs):
309
  return models[state.model_id](*args, **kwargs)
310
 
 
503
  conic-gradient(from 45deg at left ,#0000,#000 1deg 89deg,#0000 90deg)
504
  50% calc(50% - var(--z))/100% calc(2*var(--z)) repeat-y;
505
  }}
506
+
507
+
508
+ #share-btn {{
509
+ color: #ffffff;font-weight: 600;
510
+ background-color: #000000;
511
+ font-family: 'IBM Plex Sans', sans-serif;
512
+ // border-radius: 9999px !important;
513
+
514
+ --border-angle: 0turn; // For animation.
515
+ --main-bg: conic-gradient(
516
+ from var(--border-angle),
517
+ #213,
518
+ #112 5%,
519
+ #112 60%,
520
+ #213 95%
521
+ );
522
+
523
+ border: solid 5px transparent;
524
+ border-radius: 2em;
525
+ --gradient-border: conic-gradient(from var(--border-angle), transparent 25%, #08f, #f03 99%, transparent);
526
+
527
+ background:
528
+ // padding-box clip this background in to the overall element except the border.
529
+ var(--main-bg) padding-box,
530
+ // border-box extends this background to the border space
531
+ var(--gradient-border) border-box,
532
+ // Duplicate main background to fill in behind the gradient border. You can remove this if you want the border to extend "outside" the box background.
533
+ var(--main-bg) border-box;
534
+
535
+ background-position: center center;
536
+
537
+ animation: bg-spin 3s linear infinite;
538
+ @keyframes bg-spin {{
539
+ to {{
540
+ --border-angle: 1turn;
541
+ }}
542
+ }}
543
+ }}
544
+ #share-btn:hover {{
545
+ color: #ffffff;font-weight: 600;
546
+ background-color: #000000;
547
+ font-family: 'IBM Plex Sans', sans-serif;
548
+ border-radius: 9999px !important;
549
+ box-shadow: 0 0 20px #eee;
550
+ animation-play-state: paused;
551
+ }}
552
  """
553
 
554
  for i in range(opt.max_palettes + 1):
 
776
  elem_id='run-button'
777
  )
778
 
779
+ iface.btn_share = gr.Button('🤗 Share with Community', elem_id='share-btn')
780
 
781
  gr.HTML(
782
  """
 
977
  # api_name='quality_select',
978
  # )
979
 
980
+ iface.btn_share.click(None, [], [], js=share_js)
981
+
982
  iface.btn_export_state.click(lambda x: vars(x), state, iface.json_state_export)
983
  iface.btn_import_state.click(import_state, [state, iface.tbox_state_import], [
984
  state,