jiayong commited on
Commit
d0614ca
·
1 Parent(s): dc66f95

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -24
app.py CHANGED
@@ -121,12 +121,13 @@ def get_user_result_video_list(uuid, date_string, num):
121
  return valid_video_list, valid_image_list
122
 
123
  def refresh_video(uuid, request_id, profile):
124
- print(f'profile_name====={profile.name}')
125
- notes, process_status = myHumanGen.get_ranking_location(uuid)
126
  if is_wanx_platform:
127
  uuid = 'wanx_lab'
128
  if uuid is None or uuid == '':
129
- uuid = 'test_version_phone'
 
 
 
130
  print(f'[refresh_video] uuid: {uuid}')
131
  print(f'[refresh_video] request_id: {request_id}')
132
  new_list = []
@@ -173,16 +174,16 @@ def refresh_video(uuid, request_id, profile):
173
  new_list.append(None)
174
  new_image_list.append(None)
175
 
176
- return notes, new_list[0], new_list[1], new_list[2], new_list[3]#, new_image_list[0], new_image_list[1], new_image_list[2], new_image_list[3]
177
 
178
 
179
- def hello(profile: gr.OAuthProfile | None) -> str:
180
- if profile is None:
181
- return "I don't know you."
182
- # print(gr.OAuthProfile)
183
- profile_name = profile.name
184
- print(f'profile name={profile.name}')
185
- return f"Hello {profile.name}"
186
 
187
  with gr.Blocks(title = "Dreamoving",
188
  css='style.css',
@@ -191,13 +192,13 @@ with gr.Blocks(title = "Dreamoving",
191
  text_size=gr.themes.sizes.text_md
192
  )
193
  ) as demo:
194
- gr.Markdown(
195
- "# Gradio OAuth Space\n\nThis Space is a demo for the new **Sign in with Hugging Face** feature."
196
- )
197
- gr.LoginButton()
198
- gr.LogoutButton()
199
- m_text = gr.Markdown()
200
- demo.load(hello, inputs=None, outputs=m_text)
201
  with gr.Row():
202
  gr.HTML(f"""
203
  <div id=css_img_dreamoving>
@@ -323,8 +324,8 @@ with gr.Blocks(title = "Dreamoving",
323
  output_video2 = gr.Video(format="mp4", show_label=False, label="Result Video", autoplay=True,elem_id='show_window_result')
324
  output_video3 = gr.Video(format="mp4", show_label=False, label="Result Video", autoplay=True,elem_id='show_window_result')
325
 
326
- uuid = gr.Text(label="modelscope_uuid", visible=False)
327
- request_id = gr.Text(label="modelscope_request_id", visible=False)
328
 
329
  # Sample Video
330
  num_video = 8
@@ -359,7 +360,7 @@ with gr.Blocks(title = "Dreamoving",
359
  fn=refresh_video,
360
  queue = False,
361
  inputs=[uuid, request_id, gr.OAuthProfile],
362
- outputs=[user_notes, output_video0, output_video1, output_video2, output_video3]
363
  )
364
 
365
 
@@ -378,6 +379,9 @@ with gr.Blocks(title = "Dreamoving",
378
  tab1.select(fn=tab_func_prompt, outputs=[ref_video, input_mode]) # prompt mode
379
 
380
  def async_process(user_id, request_id, input_mode, ref_image_path, ref_video_path, input_prompt='', prompt_template='',model_id=False):
 
 
 
381
  # parm-chheck
382
  check_note_info = myHumanGen.valid_check(user_id, request_id, input_mode, ref_image_path, ref_video_path, input_prompt, prompt_template,model_id)
383
 
@@ -389,10 +393,10 @@ with gr.Blocks(title = "Dreamoving",
389
 
390
  return refresh_video(user_id, request_id)
391
  else:
392
- notes, video_0, video_1, video_2, video_3 = refresh_video(user_id, request_id)
393
- return check_note_info, video_0, video_1, video_2, video_3
394
 
395
- run_button.click(fn=async_process, inputs=[uuid, request_id, input_mode, ref_image, ref_video, prompt, prompt_template, model_id], outputs=[user_notes, output_video0, output_video1, output_video2, output_video3])
396
 
397
  with gr.Row():
398
  # DingTalk
 
121
  return valid_video_list, valid_image_list
122
 
123
  def refresh_video(uuid, request_id, profile):
 
 
124
  if is_wanx_platform:
125
  uuid = 'wanx_lab'
126
  if uuid is None or uuid == '':
127
+ uuid = get_random_string()
128
+
129
+ # print(f'profile_name====={profile.name}')
130
+ notes, process_status = myHumanGen.get_ranking_location(uuid)
131
  print(f'[refresh_video] uuid: {uuid}')
132
  print(f'[refresh_video] request_id: {request_id}')
133
  new_list = []
 
174
  new_list.append(None)
175
  new_image_list.append(None)
176
 
177
+ return uuid, notes, new_list[0], new_list[1], new_list[2], new_list[3]#, new_image_list[0], new_image_list[1], new_image_list[2], new_image_list[3]
178
 
179
 
180
+ # def hello(profile: gr.OAuthProfile | None) -> str:
181
+ # if profile is None:
182
+ # return "I don't know you."
183
+ # # print(gr.OAuthProfile)
184
+ # profile_name = profile.name
185
+ # print(f'profile name={profile.name}')
186
+ # return f"Hello {profile.name}"
187
 
188
  with gr.Blocks(title = "Dreamoving",
189
  css='style.css',
 
192
  text_size=gr.themes.sizes.text_md
193
  )
194
  ) as demo:
195
+ # gr.Markdown(
196
+ # "# Gradio OAuth Space\n\nThis Space is a demo for the new **Sign in with Hugging Face** feature."
197
+ # )
198
+ # gr.LoginButton()
199
+ # gr.LogoutButton()
200
+ # m_text = gr.Markdown()
201
+ # demo.load(hello, inputs=None, outputs=m_text)
202
  with gr.Row():
203
  gr.HTML(f"""
204
  <div id=css_img_dreamoving>
 
324
  output_video2 = gr.Video(format="mp4", show_label=False, label="Result Video", autoplay=True,elem_id='show_window_result')
325
  output_video3 = gr.Video(format="mp4", show_label=False, label="Result Video", autoplay=True,elem_id='show_window_result')
326
 
327
+ uuid = gr.Text(label="hf_uuid", visible=False)
328
+ request_id = gr.Text(label="hf_request_id", visible=False)
329
 
330
  # Sample Video
331
  num_video = 8
 
360
  fn=refresh_video,
361
  queue = False,
362
  inputs=[uuid, request_id, gr.OAuthProfile],
363
+ outputs=[uuid, user_notes, output_video0, output_video1, output_video2, output_video3]
364
  )
365
 
366
 
 
379
  tab1.select(fn=tab_func_prompt, outputs=[ref_video, input_mode]) # prompt mode
380
 
381
  def async_process(user_id, request_id, input_mode, ref_image_path, ref_video_path, input_prompt='', prompt_template='',model_id=False):
382
+ if uuid is None or uuid == '':
383
+ uuid = get_random_string()
384
+
385
  # parm-chheck
386
  check_note_info = myHumanGen.valid_check(user_id, request_id, input_mode, ref_image_path, ref_video_path, input_prompt, prompt_template,model_id)
387
 
 
393
 
394
  return refresh_video(user_id, request_id)
395
  else:
396
+ uuid, notes, video_0, video_1, video_2, video_3 = refresh_video(user_id, request_id)
397
+ return uuid, check_note_info, video_0, video_1, video_2, video_3
398
 
399
+ run_button.click(fn=async_process, inputs=[uuid, request_id, input_mode, ref_image, ref_video, prompt, prompt_template, model_id], outputs=[uuid, user_notes, output_video0, output_video1, output_video2, output_video3])
400
 
401
  with gr.Row():
402
  # DingTalk