mishig HF staff commited on
Commit
c49de8e
1 Parent(s): 9b688d5

Add share_btn

Browse files
Files changed (1) hide show
  1. app.py +12 -4
app.py CHANGED
@@ -8,6 +8,8 @@ import cv2
8
  from io import BytesIO
9
  from PIL import Image, ImageFilter
10
 
 
 
11
  # Constants
12
  low_threshold = 100
13
  high_threshold = 200
@@ -30,7 +32,7 @@ async () => {
30
  get_js_image = """
31
  async (canvas, prompt) => {
32
  const poseMakerEl = document.querySelector("pose-maker");
33
- const imgBase64 = poseMakerEl.captureScreenshot();
34
  return [imgBase64, prompt]
35
  }
36
  """
@@ -80,7 +82,7 @@ def generate_images(canvas, prompt):
80
  num_inference_steps=20,
81
  negative_prompt="longbody, lowres, bad anatomy, bad hands, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality",
82
  )
83
- all_outputs = [input_img]
84
  for image in output.images:
85
  all_outputs.append(image)
86
  return all_outputs
@@ -104,7 +106,7 @@ async (pose) => {
104
  }
105
  """
106
 
107
- with gr.Blocks() as blocks:
108
  gr.HTML(
109
  """
110
  <div style="text-align: center; margin: 0 auto;">
@@ -137,10 +139,15 @@ with gr.Blocks() as blocks:
137
  label="Enter your prompt",
138
  max_lines=1,
139
  placeholder="best quality, extremely detailed",
 
140
  )
141
  run_button = gr.Button("Generate")
 
 
 
 
142
  with gr.Column():
143
- gallery = gr.Gallery().style(grid=[2], height="auto")
144
  rotation_axis.change(fn=placeholder_fn,
145
  inputs=[rotation_axis],
146
  outputs=[],
@@ -155,6 +162,7 @@ with gr.Blocks() as blocks:
155
  inputs=[canvas, prompt],
156
  outputs=[gallery],
157
  _js=get_js_image)
 
158
  blocks.load(None, None, None, _js=load_js)
159
 
160
  blocks.launch(debug=True)
 
8
  from io import BytesIO
9
  from PIL import Image, ImageFilter
10
 
11
+ from share_btn import community_icon_html, loading_icon_html, share_js, share_btn_css
12
+
13
  # Constants
14
  low_threshold = 100
15
  high_threshold = 200
 
32
  get_js_image = """
33
  async (canvas, prompt) => {
34
  const poseMakerEl = document.querySelector("pose-maker");
35
+ const imgBase64 = poseMakerEl.captureScreenshotDepthMap();
36
  return [imgBase64, prompt]
37
  }
38
  """
 
82
  num_inference_steps=20,
83
  negative_prompt="longbody, lowres, bad anatomy, bad hands, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality",
84
  )
85
+ all_outputs = []
86
  for image in output.images:
87
  all_outputs.append(image)
88
  return all_outputs
 
106
  }
107
  """
108
 
109
+ with gr.Blocks(css=share_btn_css) as blocks:
110
  gr.HTML(
111
  """
112
  <div style="text-align: center; margin: 0 auto;">
 
139
  label="Enter your prompt",
140
  max_lines=1,
141
  placeholder="best quality, extremely detailed",
142
+ elem_id="prompt",
143
  )
144
  run_button = gr.Button("Generate")
145
+ with gr.Group(elem_id="share-btn-container"):
146
+ community_icon = gr.HTML(community_icon_html)
147
+ loading_icon = gr.HTML(loading_icon_html)
148
+ share_button = gr.Button("Share to community", elem_id="share-btn")
149
  with gr.Column():
150
+ gallery = gr.Gallery(elem_id="gallery").style(grid=[2], height="auto")
151
  rotation_axis.change(fn=placeholder_fn,
152
  inputs=[rotation_axis],
153
  outputs=[],
 
162
  inputs=[canvas, prompt],
163
  outputs=[gallery],
164
  _js=get_js_image)
165
+ share_button.click(None, [], [], _js=share_js)
166
  blocks.load(None, None, None, _js=load_js)
167
 
168
  blocks.launch(debug=True)