Hebatullah commited on
Commit
747cdf9
·
verified ·
1 Parent(s): 4855356

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -125
app.py DELETED
@@ -1,125 +0,0 @@
1
- import os
2
- import gradio as gr
3
- from src.gradio_demo import SadTalker
4
-
5
- try:
6
- import webui # in webui
7
- IN_WEBUi = True
8
- except ImportError:
9
- IN_WEBUi = False
10
-
11
- def toggle_audio_file(choice):
12
- if not choice:
13
- return gr.update("visible", True), gr.update("visible", False)
14
- else:
15
- return gr.update("visible", False), gr.update("visible", True)
16
-
17
- def ref_video_fn(path_of_ref_video):
18
- if path_of_ref_video:
19
- return gr.update("value", True)
20
- else:
21
- return gr.update("value", False)
22
-
23
- def sadtalker_demo(checkpoint_path="checkpoints", config_path="src/config", warpfn=None):
24
- sad_talker = SadTalker(checkpoint_path, config_path, lazy_load=True)
25
-
26
- with gr.Blocks(analytics_enabled=False) as sadtalker_interface:
27
- gr.markdown("<div align='center'> <h2> 😭 SadTalker: Learning Realistic 3D Motion Coefficients for Stylized Audio-Driven Single Image Talking Face Animation (CVPR 2023) </span> \
28
- <a style='font-size:18px;color: #efefef' href='https://arxiv.org/abs/2211.12194'>Arxiv</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
29
- <a style='font-size:18px;color: #efefef' href='https://sadtalker.github.io'>Homepage</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
30
- <a style='font-size:18px;color: #efefef' href='https://github.com/Winfredy/SadTalker'> Github </div>")
31
-
32
- with gr.Row(style="equal_height: False"):
33
- with gr.Column(variant="panel"):
34
- with gr.Tabs(elem_id="sadtalker_source_image"):
35
- with gr.TabItem("Upload image"):
36
- with gr.Row():
37
- source_image = gr.Image(label="Source image", source="upload", type="filepath", elem_id="img2img_image", style="width: 512px")
38
-
39
- with gr.Tabs(elem_id="sadtalker_driven_audio"):
40
- with gr.TabItem("Upload OR TTS"):
41
- with gr.Column(variant="panel"):
42
- driven_audio = gr.Audio(label="Input audio", source="upload", type="filepath")
43
-
44
- if sys.platform != "win32" and not IN_WEBUi:
45
- from src.utils.text2speech import TTSTalker
46
-
47
- tts_talker = TTSTalker()
48
- with gr.Column(variant="panel"):
49
- input_text = gr.Textbox(
50
- label="Generating audio from text",
51
- lines=5,
52
- placeholder="Enter text for audio generation using @Coqui.ai TTS.",
53
- )
54
- tts = gr.Button("Generate audio", elem_id="sadtalker_audio_generate", variant="primary")
55
- tts.click(tts_talker.test, [input_text], [driven_audio])
56
-
57
- with gr.Column(variant="panel"):
58
- with gr.Tabs(elem_id="sadtalker_checkbox"):
59
- with gr.TabItem("Settings"):
60
- gr.markdown(
61
- "Need help? Visit our [best practice page](https://github.com/OpenTalker/SadTalker/blob/main/docs/best_practice.md) for details."
62
- )
63
- with gr.Column(variant="panel"):
64
- # width = gr.Slider(
65
- # minimum=64,
66
- # elem_id="img2img_width",
67
- # maximum=2048,
68
- # step=8,
69
- # label="Manually Crop Width",
70
- # value=512,
71
- # ) # img2img_width
72
- # height = gr.Slider(
73
- # minimum=64,
74
- # elem_id="img2img_height",
75
- # maximum=2048,
76
- # step=8,
77
- # label="Manually Crop Height",
78
- # value=512,
79
- # ) # img2img_width
80
- pose_style = gr.Slider(
81
- minimum=0, maximum=46, step=1, label="Pose style", value=0
82
- )
83
- size_of_image = gr.Radio(
84
- [256, 512],
85
- value=256,
86
- label="face model resolution",
87
- info="Use 256/512 model?",
88
- )
89
- preprocess_type = gr.Radio(
90
- ["crop", "resize", "full", "extcrop", "extfull"],
91
- value="crop",
92
- label="preprocess",
93
- info="How to handle input image?",
94
- )
95
- is_still_mode = gr.Checkbox(
96
- label="Still Mode (fewer head motion, works with preprocess `full`)"
97
- )
98
- batch_size = gr.Slider(
99
- label="batch size in generation", step=1, maximum=10, value=2
100
- )
101
- enhancer = gr.Checkbox(label="GFPGAN as Face enhancer")
102
- submit = gr.Button("Generate", elem_id="sadtalker_generate", variant="primary")
103
-
104
- with gr.Tabs(elem_id="sadtalker_genearted"):
105
- gen_video = gr.Video(label="Generated video", format="mp4", style="width: 256px")
106
-
107
- if warpfn:
108
- submit.click(
109
- warpfn(sad_talker.test),
110
- [source_image, driven_audio, preprocess_type, is_still_mode, enhancer, batch_size, size_of_image, pose_style],
111
- [gen_video],
112
- )
113
- else:
114
- submit.click(
115
- sad_talker.test,
116
- [source_image, driven_audio, preprocess_type, is_still_mode, enhancer, batch_size, size_of_image, pose_style],
117
- [gen_video],
118
- )
119
-
120
- return sadtalker_interface
121
-
122
- if __name__ == "__main__":
123
- demo = sadtalker_demo()
124
- demo.queue()
125
- demo.launch()