akseljoonas HF Staff commited on
Commit
43e3975
·
verified ·
1 Parent(s): ce0b7dc

Fix Gradio API: source -> sources parameter

Browse files
Files changed (1) hide show
  1. app.py +13 -17
app.py CHANGED
@@ -50,12 +50,12 @@ def sadtalker_demo():
50
  <br/><b>Alternatively, try our GitHub <a href=https://github.com/Winfredy/SadTalker> code </a> on your own GPU. </b> <a style='display:inline-block' href="https://github.com/Winfredy/SadTalker"><img src="https://img.shields.io/github/stars/Winfredy/SadTalker?style=social"/></a> \
51
  """)
52
 
53
- with gr.Row(): #.style(equal_height=False):
54
  with gr.Column(variant='panel'):
55
  with gr.Tabs(elem_id="sadtalker_source_image"):
56
  with gr.TabItem('Source image'):
57
  with gr.Row():
58
- source_image = gr.Image(label="Source image", source="upload", type="filepath", elem_id="img2img_image") # .style(width=512)
59
 
60
 
61
  with gr.Tabs(elem_id="sadtalker_driven_audio"):
@@ -63,22 +63,22 @@ def sadtalker_demo():
63
  gr.Markdown("Possible driving combinations: <br> 1. Audio only 2. Audio/IDLE Mode + Ref Video(pose, blink, pose+blink) 3. IDLE Mode only 4. Ref Video only (all) ")
64
 
65
  with gr.Row():
66
- driven_audio = gr.Audio(label="Input audio", source="upload", type="filepath", max_length=180) # 180s
67
- driven_audio_no = gr.Audio(label="Use IDLE mode, no audio is required", source="upload", type="filepath", visible=False)
68
 
69
  with gr.Column():
70
  use_idle_mode = gr.Checkbox(label="Use Idle Animation")
71
  length_of_audio = gr.Number(value=5, label="The length(seconds) of the generated video.")
72
- use_idle_mode.change(toggle_audio_file, inputs=use_idle_mode, outputs=[driven_audio, driven_audio_no]) # todo
73
 
74
  with gr.Row():
75
- ref_video = gr.Video(label="Reference Video", source="upload", type="filepath", elem_id="vidref") # .style(width=512)
76
 
77
  with gr.Column():
78
  use_ref_video = gr.Checkbox(label="Use Reference Video")
79
  ref_info = gr.Radio(['pose', 'blink','pose+blink', 'all'], value='pose', label='Reference Video',info="How to borrow from reference Video?((fully transfer, aka, video driving mode))")
80
 
81
- ref_video.change(ref_video_fn, inputs=ref_video, outputs=[use_ref_video]) # todo
82
 
83
 
84
  with gr.Column(variant='panel'):
@@ -86,15 +86,13 @@ def sadtalker_demo():
86
  with gr.TabItem('Settings'):
87
  gr.Markdown("need help? please visit our [[best practice page](https://github.com/OpenTalker/SadTalker/blob/main/docs/best_practice.md)] for more detials")
88
  with gr.Column(variant='panel'):
89
- # width = gr.Slider(minimum=64, elem_id="img2img_width", maximum=2048, step=8, label="Manually Crop Width", value=512) # img2img_width
90
- # height = gr.Slider(minimum=64, elem_id="img2img_height", maximum=2048, step=8, label="Manually Crop Height", value=512) # img2img_width
91
  with gr.Row():
92
- pose_style = gr.Slider(minimum=0, maximum=45, step=1, label="Pose style", value=0) #
93
- exp_weight = gr.Slider(minimum=0, maximum=3, step=0.1, label="expression scale", value=1) #
94
  blink_every = gr.Checkbox(label="use eye blink", value=True)
95
 
96
  with gr.Row():
97
- size_of_image = gr.Radio([256, 512], value=256, label='face model resolution', info="use 256/512 model?") #
98
  preprocess_type = gr.Radio(['crop', 'resize','full', 'extcrop', 'extfull'], value='crop', label='preprocess', info="How to handle input image?")
99
 
100
  with gr.Row():
@@ -108,7 +106,7 @@ def sadtalker_demo():
108
  submit = gr.Button('Generate', elem_id="sadtalker_generate", variant='primary')
109
 
110
  with gr.Tabs(elem_id="sadtalker_genearted"):
111
- gen_video = gr.Video(label="Generated video", format="mp4", scale=1) # .style(width=256)
112
 
113
 
114
 
@@ -209,7 +207,7 @@ def sadtalker_demo():
209
  enhancer],
210
  outputs=[gen_video],
211
  fn=sad_talker.test,
212
- cache_examples=os.getenv('SYSTEM') == 'spaces') #
213
 
214
  return sadtalker_interface
215
 
@@ -217,7 +215,5 @@ def sadtalker_demo():
217
  if __name__ == "__main__":
218
 
219
  demo = sadtalker_demo()
220
- demo.queue(max_size=10, api_open=True)
221
  demo.launch(debug=True)
222
-
223
-
 
50
  <br/><b>Alternatively, try our GitHub <a href=https://github.com/Winfredy/SadTalker> code </a> on your own GPU. </b> <a style='display:inline-block' href="https://github.com/Winfredy/SadTalker"><img src="https://img.shields.io/github/stars/Winfredy/SadTalker?style=social"/></a> \
51
  """)
52
 
53
+ with gr.Row():
54
  with gr.Column(variant='panel'):
55
  with gr.Tabs(elem_id="sadtalker_source_image"):
56
  with gr.TabItem('Source image'):
57
  with gr.Row():
58
+ source_image = gr.Image(label="Source image", sources=["upload"], type="filepath", elem_id="img2img_image")
59
 
60
 
61
  with gr.Tabs(elem_id="sadtalker_driven_audio"):
 
63
  gr.Markdown("Possible driving combinations: <br> 1. Audio only 2. Audio/IDLE Mode + Ref Video(pose, blink, pose+blink) 3. IDLE Mode only 4. Ref Video only (all) ")
64
 
65
  with gr.Row():
66
+ driven_audio = gr.Audio(label="Input audio", sources=["upload"], type="filepath")
67
+ driven_audio_no = gr.Audio(label="Use IDLE mode, no audio is required", sources=["upload"], type="filepath", visible=False)
68
 
69
  with gr.Column():
70
  use_idle_mode = gr.Checkbox(label="Use Idle Animation")
71
  length_of_audio = gr.Number(value=5, label="The length(seconds) of the generated video.")
72
+ use_idle_mode.change(toggle_audio_file, inputs=use_idle_mode, outputs=[driven_audio, driven_audio_no])
73
 
74
  with gr.Row():
75
+ ref_video = gr.Video(label="Reference Video", sources=["upload"], elem_id="vidref")
76
 
77
  with gr.Column():
78
  use_ref_video = gr.Checkbox(label="Use Reference Video")
79
  ref_info = gr.Radio(['pose', 'blink','pose+blink', 'all'], value='pose', label='Reference Video',info="How to borrow from reference Video?((fully transfer, aka, video driving mode))")
80
 
81
+ ref_video.change(ref_video_fn, inputs=ref_video, outputs=[use_ref_video])
82
 
83
 
84
  with gr.Column(variant='panel'):
 
86
  with gr.TabItem('Settings'):
87
  gr.Markdown("need help? please visit our [[best practice page](https://github.com/OpenTalker/SadTalker/blob/main/docs/best_practice.md)] for more detials")
88
  with gr.Column(variant='panel'):
 
 
89
  with gr.Row():
90
+ pose_style = gr.Slider(minimum=0, maximum=45, step=1, label="Pose style", value=0)
91
+ exp_weight = gr.Slider(minimum=0, maximum=3, step=0.1, label="expression scale", value=1)
92
  blink_every = gr.Checkbox(label="use eye blink", value=True)
93
 
94
  with gr.Row():
95
+ size_of_image = gr.Radio([256, 512], value=256, label='face model resolution', info="use 256/512 model?")
96
  preprocess_type = gr.Radio(['crop', 'resize','full', 'extcrop', 'extfull'], value='crop', label='preprocess', info="How to handle input image?")
97
 
98
  with gr.Row():
 
106
  submit = gr.Button('Generate', elem_id="sadtalker_generate", variant='primary')
107
 
108
  with gr.Tabs(elem_id="sadtalker_genearted"):
109
+ gen_video = gr.Video(label="Generated video", format="mp4")
110
 
111
 
112
 
 
207
  enhancer],
208
  outputs=[gen_video],
209
  fn=sad_talker.test,
210
+ cache_examples=os.getenv('SYSTEM') == 'spaces')
211
 
212
  return sadtalker_interface
213
 
 
215
  if __name__ == "__main__":
216
 
217
  demo = sadtalker_demo()
218
+ demo.queue(max_size=10)
219
  demo.launch(debug=True)