mishig HF staff commited on
Commit
04230f2
β€’
1 Parent(s): 12e7184

implement gradio share

Browse files
Files changed (1) hide show
  1. app.py +31 -3
app.py CHANGED
@@ -1,5 +1,6 @@
1
  import gradio as gr
2
  import os
 
3
 
4
  img_to_text = gr.Interface.load("spaces/pharma/CLIP-Interrogator")
5
  stable_diffusion = gr.Blocks.load(name="spaces/stabilityai/stable-diffusion")
@@ -11,7 +12,30 @@ def get_images(prompt):
11
  def get_prompts(uploaded_image):
12
  return img_to_text(uploaded_image)
13
 
14
- with gr.Blocks() as demo:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  gr.Markdown(
16
  """
17
  ## Stable Diffusion Perception πŸŽ†πŸŒŒ
@@ -34,8 +58,12 @@ with gr.Blocks() as demo:
34
  with gr.Row():
35
  diffuse_btn = gr.Button(value="Diffuse it!", elem_id="diffuse_btn")
36
  with gr.Column():
37
- sd_output = gr.Gallery().style(grid=2, height="auto")
38
-
 
 
 
 
39
  def translate_directly(img):
40
  images = get_images(get_prompts(img))
41
  return images
 
1
  import gradio as gr
2
  import os
3
+ from share_btn import community_icon_html, loading_icon_html, share_js
4
 
5
  img_to_text = gr.Interface.load("spaces/pharma/CLIP-Interrogator")
6
  stable_diffusion = gr.Blocks.load(name="spaces/stabilityai/stable-diffusion")
 
12
  def get_prompts(uploaded_image):
13
  return img_to_text(uploaded_image)
14
 
15
+ css = '''
16
+ .animate-spin {
17
+ animation: spin 1s linear infinite;
18
+ }
19
+ @keyframes spin {
20
+ from {
21
+ transform: rotate(0deg);
22
+ }
23
+ to {
24
+ transform: rotate(360deg);
25
+ }
26
+ }
27
+ #share-btn-container {
28
+ display: flex; padding-left: 0.5rem !important; padding-right: 0.5rem !important; background-color: #000000; justify-content: center; align-items: center; border-radius: 9999px !important; width: 13rem;
29
+ }
30
+ #share-btn {
31
+ all: initial; color: #ffffff;font-weight: 600; cursor:pointer; font-family: 'IBM Plex Sans', sans-serif; margin-left: 0.5rem !important; padding-top: 0.25rem !important; padding-bottom: 0.25rem !important;
32
+ }
33
+ #share-btn * {
34
+ all: unset;
35
+ }
36
+ '''
37
+
38
+ with gr.Blocks(css=css) as demo:
39
  gr.Markdown(
40
  """
41
  ## Stable Diffusion Perception πŸŽ†πŸŒŒ
 
58
  with gr.Row():
59
  diffuse_btn = gr.Button(value="Diffuse it!", elem_id="diffuse_btn")
60
  with gr.Column():
61
+ sd_output = gr.Gallery().style(grid=2, height="auto", elem_id="generated-gallery")
62
+ with gr.Group(elem_id="share-btn-container"):
63
+ community_icon = gr.HTML(community_icon_html)
64
+ loading_icon = gr.HTML(loading_icon_html)
65
+ share_button = gr.Button("Share to community", elem_id="share-btn")
66
+
67
  def translate_directly(img):
68
  images = get_images(get_prompts(img))
69
  return images