Spaces:
Runtime error
Runtime error
Update app.py
Browse files7 unmodified lines891011121336 unmodified lines5051525354555657585960611 unmodified line636465666768697071727374757677787980818283841 unmodified line86878889909192939495969798991007 unmodified lines10810911011111211311494 unmodified lines2092102112122132142151 unmodified line2172182192202217 unmodified linesdef get_source_image(image):return imagetry:import webui # in webuiin_webui = True36 unmodified lines<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> \""")with gr.Row(): #.style(equal_height=False):with gr.Column(variant='panel'):with gr.Tabs(elem_id="sadtalker_source_image"):with gr.TabItem('Source image'):with gr.Row():source_image = gr.Image(label="Source image", sources=["upload"], type="filepath", elem_id="img2img_image") # .style(width=512)with gr.Tabs(elem_id="sadtalker_driven_audio"):1 unmodified linegr.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) ")with gr.Row():driven_audio = gr.Audio(label="Input audio", sources=["upload"])driven_audio_no = gr.Audio(label="Use IDLE mode, no audio is required", sources=["upload"], visible=False)with gr.Column():use_idle_mode = gr.Checkbox(label="Use Idle Animation")length_of_audio = gr.Number(value=5, label="The length(seconds) of the generated video.")use_idle_mode.change(toggle_audio_file, inputs=use_idle_mode, outputs=[driven_audio, driven_audio_no]) # todowith gr.Row():ref_video = gr.Video(label="Reference Video", sources=["upload"], elem_id="vidref") # .style(width=512)with gr.Column():use_ref_video = gr.Checkbox(label="Use Reference Video")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))")ref_video.change(ref_video_fn, inputs=ref_video, outputs=[use_ref_video]) # todowith gr.Column(variant='panel'):1 unmodified linewith gr.TabItem('Settings'):gr.Markdown("need help? please visit our [[best practice page](https://github.com/OpenTalker/SadTalker/blob/main/docs/best_practice.md)] for more detials")with gr.Column(variant='panel'):# width = gr.Slider(minimum=64, elem_id="img2img_width", maximum=2048, step=8, label="Manually Crop Width", value=512) # img2img_width# height = gr.Slider(minimum=64, elem_id="img2img_height", maximum=2048, step=8, label="Manually Crop Height", value=512) # img2img_widthwith gr.Row():pose_style = gr.Slider(minimum=0, maximum=45, step=1, label="Pose style", value=0) #exp_weight = gr.Slider(minimum=0, maximum=3, step=0.1, label="expression scale", value=1) #blink_every = gr.Checkbox(label="use eye blink", value=True)with gr.Row():size_of_image = gr.Radio([256, 512], value=256, label='face model resolution', info="use 256/512 model?") #preprocess_type = gr.Radio(['crop', 'resize','full', 'extcrop', 'extfull'], value='crop', label='preprocess', info="How to handle input image?")with gr.Row():7 unmodified linessubmit = gr.Button('Generate', elem_id="sadtalker_generate", variant='primary')with gr.Tabs(elem_id="sadtalker_genearted"):gen_video = gr.Video(label="Generated video", format="mp4", scale=1) # .style(width=256)94 unmodified linesenhancer],outputs=[gen_video],fn=sad_talker.test,cache_examples=False) #return sadtalker_interface1 unmodified lineif __name__ == "__main__":demo = sadtalker_demo()demo.queue(max_size=10)demo.launch(server_name="0.0.0.0", server_port=7860)7 unmodified lines89101112131415161718192021222336 unmodified lines6061626364656667686970711 unmodified line737475767778798081828384858687888990919293941 unmodified line969798991001011021031041051061071087 unmodified lines11611711811912012112294 unmodified lines2172182192202212222231 unmodified line2252262272282297 unmodified linesdef get_source_image(image):return imagedef preprocess_audio(audio):"""Handle audio input - extract filepath if it's a tuple"""if audio is None:return Noneif isinstance(audio, tuple):# If it's a tuple (sample_rate, data), return None or handle differently# For file upload, we need the actual file pathreturn audio[1] if len(audio) > 1 else audio[0]return audiotry:import webui # in webuiin_webui = True36 unmodified lines<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> \""")with gr.Row():with gr.Column(variant='panel'):with gr.Tabs(elem_id="sadtalker_source_image"):with gr.TabItem('Source image'):with gr.Row():source_image = gr.Image(label="Source image", source="upload", type="filepath", elem_id="img2img_image")with gr.Tabs(elem_id="sadtalker_driven_audio"):1 unmodified linegr.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) ")with gr.Row():driven_audio = gr.Audio(label="Input audio", source="upload", type="filepath", format="wav")driven_audio_no = gr.Audio(label="Use IDLE mode, no audio is required", source="upload", type="filepath", format="wav", visible=False)with gr.Column():use_idle_mode = gr.Checkbox(label="Use Idle Animation")length_of_audio = gr.Number(value=5, label="The length(seconds) of the generated video.")use_idle_mode.change(toggle_audio_file, inputs=use_idle_mode, outputs=[driven_audio, driven_audio_no])with gr.Row():ref_video = gr.Video(label="Reference Video", source="upload", type="filepath", elem_id="vidref")with gr.Column():use_ref_video = gr.Checkbox(label="Use Reference Video")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))")ref_video.change(ref_video_fn, inputs=ref_video, outputs=[use_ref_video])with gr.Column(variant='panel'):1 unmodified linewith gr.TabItem('Settings'):gr.Markdown("need help? please visit our [[best practice page](https://github.com/OpenTalker/SadTalker/blob/main/docs/best_practice.md)] for more detials")with gr.Column(variant='panel'):with gr.Row():pose_style = gr.Slider(minimum=0, maximum=45, step=1, label="Pose style", value=0)exp_weight = gr.Slider(minimum=0, maximum=3, step=0.1, label="expression scale", value=1)blink_every = gr.Checkbox(label="use eye blink", value=True)with gr.Row():size_of_image = gr.Radio([256, 512], value=256, label='face model resolution', info="use 256/512 model?")preprocess_type = gr.Radio(['crop', 'resize','full', 'extcrop', 'extfull'], value='crop', label='preprocess', info="How to handle input image?")with gr.Row():7 unmodified linessubmit = gr.Button('Generate', elem_id="sadtalker_generate", variant='primary')with gr.Tabs(elem_id="sadtalker_genearted"):gen_video = gr.Video(label="Generated video", format="mp4")94 unmodified linesenhancer],outputs=[gen_video],fn=sad_talker.test,cache_examples=os.getenv('SYSTEM') == 'spaces')return sadtalker_interface1 unmodified lineif __name__ == "__main__":demo = sadtalker_demo()demo.queue()demo.launch()
app.py+24-16