selfit-camera commited on
Commit
1862389
·
1 Parent(s): 5063ec4
Files changed (3) hide show
  1. __pycache__/utils.cpython-310.pyc +0 -0
  2. app.py +17 -3
  3. utils.py +1 -0
__pycache__/utils.cpython-310.pyc CHANGED
Binary files a/__pycache__/utils.cpython-310.pyc and b/__pycache__/utils.cpython-310.pyc differ
 
app.py CHANGED
@@ -43,8 +43,12 @@ def is_http_resource_accessible(url):
43
  return False
44
 
45
 
46
- def onPoseChange(prompt_text, source_image, request: gr.Request):
47
  """Handle pose change request"""
 
 
 
 
48
  if source_image is None:
49
  return "Please provide source image first!", None, None, None
50
 
@@ -228,7 +232,17 @@ with gr.Blocks() as demo:
228
 
229
  # Add pose changer module
230
  with gr.Accordion('pose changer', open=False):
231
- # Top: text box and button
 
 
 
 
 
 
 
 
 
 
232
  with gr.Row():
233
  pose_prompt = gr.Textbox(
234
  value="Change the pose: hands on hips.#Change the pose: arms extended.",
@@ -257,7 +271,7 @@ with gr.Blocks() as demo:
257
  # Bind pose changer change button
258
  change_button.click(
259
  fn=onPoseChange,
260
- inputs=[pose_prompt, pose_changer_image],
261
  outputs=[pose_change_info, pose_result_1, pose_result_2, pose_result_3]
262
  )
263
 
 
43
  return False
44
 
45
 
46
+ def onPoseChange(prompt_text, source_image, token_input, request: gr.Request):
47
  """Handle pose change request"""
48
+ # Check token first
49
+ if token_input != POSEToken:
50
+ return "please input the correct token!", None, None, None
51
+
52
  if source_image is None:
53
  return "Please provide source image first!", None, None, None
54
 
 
232
 
233
  # Add pose changer module
234
  with gr.Accordion('pose changer', open=False):
235
+ # Top: token input
236
+ with gr.Row():
237
+ token_input = gr.Textbox(
238
+ value="",
239
+ label="Access Token",
240
+ placeholder="请输入token...",
241
+ type="password",
242
+ scale=1
243
+ )
244
+
245
+ # Middle: text box and button
246
  with gr.Row():
247
  pose_prompt = gr.Textbox(
248
  value="Change the pose: hands on hips.#Change the pose: arms extended.",
 
271
  # Bind pose changer change button
272
  change_button.click(
273
  fn=onPoseChange,
274
+ inputs=[pose_prompt, pose_changer_image, token_input],
275
  outputs=[pose_change_info, pose_result_1, pose_result_2, pose_result_3]
276
  )
277
 
utils.py CHANGED
@@ -15,6 +15,7 @@ OssUrl = "https://selfit-deploy-1256039085.cos.accelerate.myqcloud.com/"
15
  Regions = "IndiaPakistanBengal"
16
  TOKEN = os.environ['TOKEN']
17
  UKAPIURL = os.environ['UKAPIURL']
 
18
 
19
 
20
  proj_dir = os.path.dirname(os.path.abspath(__file__))
 
15
  Regions = "IndiaPakistanBengal"
16
  TOKEN = os.environ['TOKEN']
17
  UKAPIURL = os.environ['UKAPIURL']
18
+ POSEToken = os.environ['POSEToken']
19
 
20
 
21
  proj_dir = os.path.dirname(os.path.abspath(__file__))