cpuai commited on
Commit
e0ac1f0
·
verified ·
1 Parent(s): 11a6c07

Upload 171 files

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +32 -0
  2. .gitignore +18 -0
  3. LICENSE +21 -0
  4. README.md +13 -6
  5. animations/source_e33d514c950545819174b4deb53be62d--d0.mp4 +3 -0
  6. animations/source_e33d514c950545819174b4deb53be62d--d0_concat.mp4 +3 -0
  7. app.py +244 -0
  8. assets/docs/inference.gif +3 -0
  9. assets/docs/showcase.gif +3 -0
  10. assets/docs/showcase2.gif +3 -0
  11. assets/examples/driving/d0.mp4 +3 -0
  12. assets/examples/driving/d1.mp4 +0 -0
  13. assets/examples/driving/d2.mp4 +0 -0
  14. assets/examples/driving/d3.mp4 +3 -0
  15. assets/examples/driving/d5.mp4 +3 -0
  16. assets/examples/driving/d6.mp4 +3 -0
  17. assets/examples/driving/d7.mp4 +3 -0
  18. assets/examples/driving/d8.mp4 +3 -0
  19. assets/examples/driving/d9.mp4 +3 -0
  20. assets/examples/source/s0.jpg +3 -0
  21. assets/examples/source/s1.jpg +0 -0
  22. assets/examples/source/s10.jpg +3 -0
  23. assets/examples/source/s2.jpg +3 -0
  24. assets/examples/source/s3.jpg +0 -0
  25. assets/examples/source/s4.jpg +3 -0
  26. assets/examples/source/s5.jpg +3 -0
  27. assets/examples/source/s6.jpg +3 -0
  28. assets/examples/source/s7.jpg +3 -0
  29. assets/examples/source/s8.jpg +3 -0
  30. assets/examples/source/s9.jpg +3 -0
  31. assets/gradio_description_animation.md +17 -0
  32. assets/gradio_description_retargeting.md +1 -0
  33. assets/gradio_description_upload.md +9 -0
  34. assets/gradio_title.md +10 -0
  35. gradio.stderr.log +5 -0
  36. gradio.stdout.log +32 -0
  37. gradio_uploads/source_e33d514c950545819174b4deb53be62d.png +3 -0
  38. gradio_uploads/source_ed459b133125493299d41e0b246b5cb7.png +3 -0
  39. inference.py +33 -0
  40. pretrained_weights/.gitkeep +0 -0
  41. pretrained_weights/insightface/models/buffalo_l/2d106det.onnx +3 -0
  42. pretrained_weights/insightface/models/buffalo_l/det_10g.onnx +3 -0
  43. pretrained_weights/liveportrait/base_models/appearance_feature_extractor.pth +3 -0
  44. pretrained_weights/liveportrait/base_models/motion_extractor.pth +3 -0
  45. pretrained_weights/liveportrait/base_models/spade_generator.pth +3 -0
  46. pretrained_weights/liveportrait/base_models/warping_module.pth +3 -0
  47. pretrained_weights/liveportrait/landmark.onnx +3 -0
  48. pretrained_weights/liveportrait/retargeting_models/stitching_retargeting_module.pth +3 -0
  49. requirements.txt +24 -0
  50. smoke_oneframe.mp4 +0 -0
.gitattributes CHANGED
@@ -33,3 +33,35 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ assets/docs/showcase.gif filter=lfs diff=lfs merge=lfs -text
37
+ assets/docs/showcase2.gif filter=lfs diff=lfs merge=lfs -text
38
+ assets/examples/driving/d0.mp4 filter=lfs diff=lfs merge=lfs -text
39
+ assets/examples/driving/d3.mp4 filter=lfs diff=lfs merge=lfs -text
40
+ assets/examples/driving/d6.mp4 filter=lfs diff=lfs merge=lfs -text
41
+ assets/examples/driving/d9.mp4 filter=lfs diff=lfs merge=lfs -text
42
+ pretrained_weights/liveportrait/retargeting_models/stitching_retargeting_module.pth filter=lfs diff=lfs merge=lfs -text
43
+ pretrained_weights/liveportrait/base_models/appearance_feature_extractor.pth filter=lfs diff=lfs merge=lfs -text
44
+ pretrained_weights/liveportrait/base_models/motion_extractor.pth filter=lfs diff=lfs merge=lfs -text
45
+ pretrained_weights/liveportrait/base_models/spade_generator.pth filter=lfs diff=lfs merge=lfs -text
46
+ pretrained_weights/liveportrait/base_models/warping_module.pth filter=lfs diff=lfs merge=lfs -text
47
+ pretrained_weights/insightface/models/buffalo_l/2d106det.onnx filter=lfs diff=lfs merge=lfs -text
48
+ pretrained_weights/insightface/models/buffalo_l/det_10g.onnx filter=lfs diff=lfs merge=lfs -text
49
+ pretrained_weights/liveportrait/landmark.onnx filter=lfs diff=lfs merge=lfs -text
50
+ animations/source_e33d514c950545819174b4deb53be62d--d0_concat.mp4 filter=lfs diff=lfs merge=lfs -text
51
+ animations/source_e33d514c950545819174b4deb53be62d--d0.mp4 filter=lfs diff=lfs merge=lfs -text
52
+ assets/docs/inference.gif filter=lfs diff=lfs merge=lfs -text
53
+ assets/examples/driving/d5.mp4 filter=lfs diff=lfs merge=lfs -text
54
+ assets/examples/driving/d7.mp4 filter=lfs diff=lfs merge=lfs -text
55
+ assets/examples/driving/d8.mp4 filter=lfs diff=lfs merge=lfs -text
56
+ assets/examples/source/s0.jpg filter=lfs diff=lfs merge=lfs -text
57
+ assets/examples/source/s10.jpg filter=lfs diff=lfs merge=lfs -text
58
+ assets/examples/source/s2.jpg filter=lfs diff=lfs merge=lfs -text
59
+ assets/examples/source/s4.jpg filter=lfs diff=lfs merge=lfs -text
60
+ assets/examples/source/s5.jpg filter=lfs diff=lfs merge=lfs -text
61
+ assets/examples/source/s6.jpg filter=lfs diff=lfs merge=lfs -text
62
+ assets/examples/source/s7.jpg filter=lfs diff=lfs merge=lfs -text
63
+ assets/examples/source/s8.jpg filter=lfs diff=lfs merge=lfs -text
64
+ assets/examples/source/s9.jpg filter=lfs diff=lfs merge=lfs -text
65
+ gradio_uploads/source_e33d514c950545819174b4deb53be62d.png filter=lfs diff=lfs merge=lfs -text
66
+ gradio_uploads/source_ed459b133125493299d41e0b246b5cb7.png filter=lfs diff=lfs merge=lfs -text
67
+ src/utils/dependencies/insightface/data/images/t1.jpg filter=lfs diff=lfs merge=lfs -text
.gitignore ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ **/__pycache__/
4
+ *.py[cod]
5
+ **/*.py[cod]
6
+ *$py.class
7
+
8
+ # Model weights
9
+ #**/*.pth
10
+ #**/*.onnx
11
+
12
+ # Ipython notebook
13
+ *.ipynb
14
+
15
+ # Temporary files or benchmark resources
16
+ animations/*
17
+ tmp/*
18
+ gradio_cached_examples/
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Kuaishou Visual Generation and Interaction Center
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
README.md CHANGED
@@ -1,13 +1,20 @@
1
  ---
2
- title: LivePortrait
3
- emoji: 🌖
4
  colorFrom: red
5
- colorTo: purple
6
  sdk: gradio
7
- sdk_version: 6.10.0
8
  app_file: app.py
9
  pinned: false
10
- short_description: LivePortrait
 
 
 
 
 
 
 
11
  ---
12
 
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: Live Portrait
3
+ emoji: 🤪
4
  colorFrom: red
5
+ colorTo: yellow
6
  sdk: gradio
7
+ sdk_version: 4.37.2
8
  app_file: app.py
9
  pinned: false
10
+ tags:
11
+ - Multimodal
12
+ - Motion control
13
+ - Image-to-Video
14
+ - Video-to-Video
15
+ - language models
16
+ - LLMs
17
+ short_description: Apply the motion of a video on a portrait
18
  ---
19
 
20
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
animations/source_e33d514c950545819174b4deb53be62d--d0.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5836c4baffe0ee562ebf80064ef0fd67ef18dd7b515857ea624ef56898bbc7ec
3
+ size 185631
animations/source_e33d514c950545819174b4deb53be62d--d0_concat.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5689cae2a4b94d5c1bc03d8dd3dbd31dcd762534e6bf616a0defaa195fd1d440
3
+ size 419394
app.py ADDED
@@ -0,0 +1,244 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding: utf-8
2
+
3
+ """
4
+ The entrance of the gradio
5
+ """
6
+
7
+ import tyro
8
+ import gradio as gr
9
+ import os.path as osp
10
+ import torch
11
+ from gradio_client import utils as gradio_client_utils
12
+ from src.utils.helper import load_description
13
+ from src.gradio_pipeline import GradioPipeline
14
+ from src.config.crop_config import CropConfig
15
+ from src.config.argument_config import ArgumentConfig
16
+ from src.config.inference_config import InferenceConfig
17
+ import cv2
18
+
19
+ try:
20
+ import spaces
21
+ except ImportError:
22
+ spaces = None
23
+
24
+ # import gdown
25
+ # folder_url = f"https://drive.google.com/drive/folders/1UtKgzKjFAOmZkhNK-OYT0caJ_w2XAnib"
26
+ # gdown.download_folder(url=folder_url, output="pretrained_weights", quiet=False)
27
+
28
+ def partial_fields(target_class, kwargs):
29
+ return target_class(**{k: v for k, v in kwargs.items() if hasattr(target_class, k)})
30
+
31
+ # set tyro theme
32
+ tyro.extras.set_accent_color("bright_cyan")
33
+ args = tyro.cli(ArgumentConfig)
34
+
35
+ # specify configs for inference
36
+ inference_cfg = partial_fields(InferenceConfig, args.__dict__) # use attribute of args to initial InferenceConfig
37
+ crop_cfg = partial_fields(CropConfig, args.__dict__) # use attribute of args to initial CropConfig
38
+
39
+ gradio_pipeline = GradioPipeline(
40
+ inference_cfg=inference_cfg,
41
+ crop_cfg=crop_cfg,
42
+ args=args
43
+ )
44
+
45
+ def maybe_gpu(fn):
46
+ if spaces is not None and torch.cuda.is_available():
47
+ return spaces.GPU(fn)
48
+ return fn
49
+
50
+
51
+ _original_json_schema_to_python_type = gradio_client_utils._json_schema_to_python_type
52
+
53
+
54
+ def _patched_json_schema_to_python_type(schema, defs):
55
+ if isinstance(schema, bool):
56
+ return "Any" if schema else "None"
57
+ return _original_json_schema_to_python_type(schema, defs)
58
+
59
+
60
+ gradio_client_utils._json_schema_to_python_type = _patched_json_schema_to_python_type
61
+
62
+ @maybe_gpu
63
+ def gpu_wrapped_execute_video(
64
+ input_image_path,
65
+ input_video_path,
66
+ flag_relative_input,
67
+ flag_do_crop_input,
68
+ flag_remap_input,
69
+ ):
70
+ return gradio_pipeline.execute_video(
71
+ input_image_path,
72
+ input_video_path,
73
+ flag_relative_input,
74
+ flag_do_crop_input,
75
+ flag_remap_input,
76
+ )
77
+
78
+ @maybe_gpu
79
+ def gpu_wrapped_execute_image(input_eye_ratio: float, input_lip_ratio: float):
80
+ return gradio_pipeline.execute_image(input_eye_ratio, input_lip_ratio)
81
+
82
+ def is_square_video(video_path):
83
+ video = cv2.VideoCapture(video_path)
84
+
85
+ width = int(video.get(cv2.CAP_PROP_FRAME_WIDTH))
86
+ height = int(video.get(cv2.CAP_PROP_FRAME_HEIGHT))
87
+
88
+ video.release()
89
+ if width != height:
90
+ raise gr.Error("Error: the video does not have a square aspect ratio. We currently only support square videos")
91
+
92
+ return gr.update(visible=True)
93
+
94
+ # assets
95
+ title_md = "assets/gradio_title.md"
96
+ example_portrait_dir = "assets/examples/source"
97
+ example_video_dir = "assets/examples/driving"
98
+ data_examples = [
99
+ [osp.join(example_portrait_dir, "s9.jpg"), osp.join(example_video_dir, "d0.mp4"), True, True, True],
100
+ [osp.join(example_portrait_dir, "s6.jpg"), osp.join(example_video_dir, "d0.mp4"), True, True, True],
101
+ [osp.join(example_portrait_dir, "s10.jpg"), osp.join(example_video_dir, "d5.mp4"), True, True, True],
102
+ [osp.join(example_portrait_dir, "s5.jpg"), osp.join(example_video_dir, "d6.mp4"), True, True, True],
103
+ [osp.join(example_portrait_dir, "s7.jpg"), osp.join(example_video_dir, "d7.mp4"), True, True, True],
104
+ ]
105
+ #################### interface logic ####################
106
+
107
+ # Define components first
108
+ eye_retargeting_slider = gr.Slider(minimum=0, maximum=0.8, step=0.01, label="target eyes-open ratio")
109
+ lip_retargeting_slider = gr.Slider(minimum=0, maximum=0.8, step=0.01, label="target lip-open ratio")
110
+ retargeting_input_image = gr.Image(type="numpy")
111
+ output_image = gr.Image(type="numpy")
112
+ output_image_paste_back = gr.Image(type="numpy")
113
+ output_video = gr.Video()
114
+ output_video_concat = gr.Video()
115
+
116
+ with gr.Blocks(theme=gr.themes.Soft(),title="LivePortrait: Revolutionary AI-Powered Portrait Animation Technology") as demo:
117
+ gr.HTML(load_description(title_md))
118
+ gr.Markdown(load_description("assets/gradio_description_upload.md"))
119
+ with gr.Row():
120
+ with gr.Accordion(open=True, label="Source Portrait"):
121
+ image_input = gr.Image(type="numpy")
122
+ gr.Examples(
123
+ examples=[
124
+ [osp.join(example_portrait_dir, "s9.jpg")],
125
+ [osp.join(example_portrait_dir, "s6.jpg")],
126
+ [osp.join(example_portrait_dir, "s10.jpg")],
127
+ [osp.join(example_portrait_dir, "s5.jpg")],
128
+ [osp.join(example_portrait_dir, "s7.jpg")],
129
+ ],
130
+ inputs=[image_input],
131
+ cache_examples=False,
132
+ )
133
+ with gr.Accordion(open=True, label="Driving Video"):
134
+ video_input = gr.Video()
135
+ gr.Examples(
136
+ examples=[
137
+ [osp.join(example_video_dir, "d0.mp4")],
138
+ [osp.join(example_video_dir, "d5.mp4")],
139
+ [osp.join(example_video_dir, "d6.mp4")],
140
+ [osp.join(example_video_dir, "d7.mp4")],
141
+ ],
142
+ inputs=[video_input],
143
+ cache_examples=False,
144
+ )
145
+ with gr.Row():
146
+ with gr.Accordion(open=False, label="Animation Instructions and Options"):
147
+ gr.Markdown(load_description("assets/gradio_description_animation.md"))
148
+ with gr.Row():
149
+ flag_relative_input = gr.Checkbox(value=True, label="relative motion")
150
+ flag_do_crop_input = gr.Checkbox(value=True, label="do crop")
151
+ flag_remap_input = gr.Checkbox(value=True, label="paste-back")
152
+ with gr.Row():
153
+ with gr.Column():
154
+ process_button_animation = gr.Button("🚀 Animate", variant="primary")
155
+ with gr.Column():
156
+ process_button_reset = gr.ClearButton([image_input, video_input, output_video, output_video_concat], value="🧹 Clear")
157
+ with gr.Row():
158
+ with gr.Column():
159
+ with gr.Accordion(open=True, label="The animated video in the original image space"):
160
+ output_video.render()
161
+ with gr.Column():
162
+ with gr.Accordion(open=True, label="The animated video"):
163
+ output_video_concat.render()
164
+ with gr.Row():
165
+ # Examples
166
+ gr.Markdown("## You could choose the examples below ⬇️")
167
+ with gr.Row():
168
+ gr.Examples(
169
+ examples=data_examples,
170
+ fn=gpu_wrapped_execute_video,
171
+ inputs=[
172
+ image_input,
173
+ video_input,
174
+ flag_relative_input,
175
+ flag_do_crop_input,
176
+ flag_remap_input
177
+ ],
178
+ outputs=[output_video, output_video_concat],
179
+ examples_per_page=5,
180
+ cache_examples=False,
181
+ )
182
+ gr.Markdown(load_description("assets/gradio_description_retargeting.md"), visible=False)
183
+ with gr.Row(visible=False):
184
+ eye_retargeting_slider.render()
185
+ lip_retargeting_slider.render()
186
+ with gr.Row(visible=False):
187
+ process_button_retargeting = gr.Button("🚗 Retargeting", variant="primary")
188
+ process_button_reset_retargeting = gr.ClearButton(
189
+ [
190
+ eye_retargeting_slider,
191
+ lip_retargeting_slider,
192
+ retargeting_input_image,
193
+ output_image,
194
+ output_image_paste_back
195
+ ],
196
+ value="🧹 Clear"
197
+ )
198
+ with gr.Row(visible=False):
199
+ with gr.Column():
200
+ with gr.Accordion(open=True, label="Retargeting Input"):
201
+ retargeting_input_image.render()
202
+ with gr.Column():
203
+ with gr.Accordion(open=True, label="Retargeting Result"):
204
+ output_image.render()
205
+ with gr.Column():
206
+ with gr.Accordion(open=True, label="Paste-back Result"):
207
+ output_image_paste_back.render()
208
+ # binding functions for buttons
209
+ process_button_retargeting.click(
210
+ # fn=gradio_pipeline.execute_image,
211
+ fn=gpu_wrapped_execute_image,
212
+ inputs=[eye_retargeting_slider, lip_retargeting_slider],
213
+ outputs=[output_image, output_image_paste_back],
214
+ show_progress=True
215
+ )
216
+ process_button_animation.click(
217
+ fn=gpu_wrapped_execute_video,
218
+ inputs=[
219
+ image_input,
220
+ video_input,
221
+ flag_relative_input,
222
+ flag_do_crop_input,
223
+ flag_remap_input
224
+ ],
225
+ outputs=[output_video, output_video_concat],
226
+ show_progress=True
227
+ )
228
+ image_input.change(
229
+ fn=gradio_pipeline.prepare_retargeting,
230
+ inputs=image_input,
231
+ outputs=[eye_retargeting_slider, lip_retargeting_slider, retargeting_input_image]
232
+ )
233
+ video_input.upload(
234
+ fn=is_square_video,
235
+ inputs=video_input,
236
+ outputs=video_input
237
+ )
238
+
239
+ demo.launch(
240
+ server_port=args.server_port,
241
+ share=args.share,
242
+ server_name=args.server_name,
243
+ show_api=False
244
+ )
assets/docs/inference.gif ADDED

Git LFS Details

  • SHA256: e1316eca5556ba5a8da7c53bcadbc1df26aa822bbde68fbad94813139803d0c6
  • Pointer size: 131 Bytes
  • Size of remote file: 820 kB
assets/docs/showcase.gif ADDED

Git LFS Details

  • SHA256: 7bca5f38bfd555bf7c013312d87883afdf39d97fba719ac171c60f897af49e21
  • Pointer size: 132 Bytes
  • Size of remote file: 6.62 MB
assets/docs/showcase2.gif ADDED

Git LFS Details

  • SHA256: eb1fffb139681775780b2956e7d0289f55d199c1a3e14ab263887864d4b0d586
  • Pointer size: 132 Bytes
  • Size of remote file: 2.88 MB
assets/examples/driving/d0.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:63f6f9962e1fdf6e6722172e7a18155204858d5d5ce3b1e0646c150360c33bed
3
+ size 2958395
assets/examples/driving/d1.mp4 ADDED
Binary file (48.8 kB). View file
 
assets/examples/driving/d2.mp4 ADDED
Binary file (47.8 kB). View file
 
assets/examples/driving/d3.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ef5c86e49b1b43dcb1449b499eb5a7f0cbae2f78aec08b5598193be1e4257099
3
+ size 1430968
assets/examples/driving/d5.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:021af59d9e1d89c967699efd374e7acc77fd14c30b052abd98665de401d9e511
3
+ size 135015
assets/examples/driving/d6.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:00e3ea79bbf28cbdc4fbb67ec655d9a0fe876e880ec45af55ae481348d0c0fff
3
+ size 1967790
assets/examples/driving/d7.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9e3ecc59a7285d52ca3666be6562e59ed45ad8afcef28d0f69a9be0e2850ed37
3
+ size 185258
assets/examples/driving/d8.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:912a02dcffef9b1a6d6641c9a48e170490080c3715dc9f55d91e168483d27e6e
3
+ size 312295
assets/examples/driving/d9.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9a414aa1d547be35306d692065a2157434bf40a6025ba8e30ce12e5bb322cc33
3
+ size 2257929
assets/examples/source/s0.jpg ADDED

Git LFS Details

  • SHA256: ccd094951787cec391f3d444e056ee9a58d715f84152f49100c03bb3ce2962fc
  • Pointer size: 131 Bytes
  • Size of remote file: 116 kB
assets/examples/source/s1.jpg ADDED
assets/examples/source/s10.jpg ADDED

Git LFS Details

  • SHA256: 49bdee735bed389d289c20d0bdff9bf0a485068e128cec8eb9e5bb11ae1f0422
  • Pointer size: 131 Bytes
  • Size of remote file: 537 kB
assets/examples/source/s2.jpg ADDED

Git LFS Details

  • SHA256: 4d950dc1c6560e0c7d0bcdca258079ba605d26f0979b7a602af75511a15e4c03
  • Pointer size: 131 Bytes
  • Size of remote file: 760 kB
assets/examples/source/s3.jpg ADDED
assets/examples/source/s4.jpg ADDED

Git LFS Details

  • SHA256: d62af6c554e211942f954237f7b898abb41d9d6166b5079564e76c25ff804c55
  • Pointer size: 131 Bytes
  • Size of remote file: 144 kB
assets/examples/source/s5.jpg ADDED

Git LFS Details

  • SHA256: 9c368d9aa2eea0c5319b7d76e3b6c339819e49565ef064933a4511c11b581549
  • Pointer size: 131 Bytes
  • Size of remote file: 134 kB
assets/examples/source/s6.jpg ADDED

Git LFS Details

  • SHA256: fa226be24fc24c11c4bb276c2d7d789218eba88b8e49155855f5685d1b4d7809
  • Pointer size: 131 Bytes
  • Size of remote file: 108 kB
assets/examples/source/s7.jpg ADDED

Git LFS Details

  • SHA256: 7a94b38bb66b58c3d44b98b86be3138cd3fb3ca40f89017294476b879353ebc4
  • Pointer size: 131 Bytes
  • Size of remote file: 140 kB
assets/examples/source/s8.jpg ADDED

Git LFS Details

  • SHA256: 01b6af295ebefcac1291cbe3b84fc6af37e40b168c528113662519aace4bbce5
  • Pointer size: 131 Bytes
  • Size of remote file: 227 kB
assets/examples/source/s9.jpg ADDED

Git LFS Details

  • SHA256: 84a6bfcb3346951cef85c0b0bb07856794e0b04d5b65322c18d77198fbf43f2a
  • Pointer size: 131 Bytes
  • Size of remote file: 443 kB
assets/gradio_description_animation.md ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <span style="font-size: 1.2em;">🔥 To animate the source portrait with the driving video, please follow these steps:</span>
2
+ <div style="font-size: 1.2em; margin-left: 20px;">
3
+ 1. In the <strong>Animation Options</strong> section, we recommend enabling the <strong>do crop</strong> option if faces occupy a small portion of your image.
4
+ </div>
5
+ <div style="font-size: 1.2em; margin-left: 20px;">
6
+ 2. Press the <strong>🚀 Animate</strong> button and wait for a moment. Your animated video will appear in the result block. This may take a few moments.
7
+ </div>
8
+ <div style="font-size: 1.2em; margin-left: 20px;">
9
+ 3. If you want to upload your own driving video, <strong>the best practice</strong>:
10
+
11
+ - Crop it to a 1:1 aspect ratio (e.g., 512x512 or 256x256 pixels).
12
+ - Focus on the head area, similar to the example videos.
13
+ - Minimize shoulder movement.
14
+ - Make sure the first frame of driving video is a frontal face with neutral expression.
15
+
16
+ Auto cropping will be available soon. 🤗
17
+ </div>
assets/gradio_description_retargeting.md ADDED
@@ -0,0 +1 @@
 
 
1
+ <span style="font-size: 1.2em;">🔥 To change the target eyes-open and lip-open ratio of the source portrait, please drag the sliders and then click the <strong>🚗 Retargeting</strong> button. The result would be shown in the middle block. You can try running it multiple times. <strong>😊 Set both ratios to 0.8 to see what's going on!</strong> </span>
assets/gradio_description_upload.md ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ <span style="font-size: 18px; color: red;">Due to limited GPU resources here, to have a better user experience, please visit our alternative website:</span>
2
+
3
+ <div align="center">
4
+ <a href="https://liveportrait.wingetgui.com/" target="_blank" style="display: inline-block; padding: 10px 20px; font-size: 16px; text-align: center; text-decoration: none; background-color: #4CAF50; color: white; border-radius: 5px;">
5
+ Visit liveportrait Alternative Site
6
+ </a>
7
+ </div>
8
+
9
+ <span style="font-size: 18px;">You can use **liveportrait** there, with faster speed and a better experience.</span>
assets/gradio_title.md ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <div style="display: flex; justify-content: center; align-items: center; text-align: center;">
2
+ <div>
3
+ <h1>LivePortrait: Efficient Portrait Animation with Stitching and Retargeting Control</h1>
4
+ <div style="display: flex; justify-content: center; align-items: center; text-align: center;>
5
+ <a href="https://arxiv.org/pdf/2407.03168"><img src="https://img.shields.io/badge/arXiv-2407.03168-red"></a>
6
+ <a href="https://liveportrait.github.io"><img src="https://img.shields.io/badge/Project_Page-LivePortrait-green" alt="Project Page"></a>
7
+ <a href="https://github.com/KwaiVGI/LivePortrait"><img src="https://img.shields.io/badge/Github-Code-blue"></a>
8
+ </div>
9
+ </div>
10
+ </div>
gradio.stderr.log ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ D:\huggingfaceClone\LivePortrait\spaces--innoai--LivePortrait\snapshots\0034eef4222844d7ef98d57b52569455229ce665\.venv\lib\site-packages\tyro\_fields.py:330: UserWarning: The field server_name is annotated with type <class 'str'>, but the default value None has type <class 'NoneType'>. We'll try to handle this gracefully, but it may cause unexpected behavior.
2
+ warnings.warn(
3
+ D:\huggingfaceClone\LivePortrait\spaces--innoai--LivePortrait\snapshots\0034eef4222844d7ef98d57b52569455229ce665\.venv\lib\site-packages\gradio\analytics.py:106: UserWarning: IMPORTANT: You are using gradio version 4.37.1, however version 4.44.1 is available, please upgrade.
4
+ --------
5
+ warnings.warn(
gradio.stdout.log ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [19:14:35] CUDA is unavailable, disabling half live_portrait_wrapper.py:30
2
+ precision and running on CPU.
3
+ Load appearance_feature_extractor done. live_portrait_wrapper.py:34
4
+ Load motion_extractor done. live_portrait_wrapper.py:37
5
+ [19:14:36] Load warping_module done. live_portrait_wrapper.py:40
6
+ [19:14:37] Load spade_generator done. live_portrait_wrapper.py:43
7
+ Load stitching_retargeting_module done. live_portrait_wrapper.py:47
8
+ LandmarkRunner warmup time: 0.056s landmark_runner.py:89
9
+ FaceAnalysisDIY warmup time: 0.077s face_analysis_diy.py:79
10
+ Running on local URL: http://127.0.0.1:7860
11
+
12
+ To create a public link, set `share=True` in `launch()`.
13
+ [19:21:34] Load source image from gradio input. gradio_pipeline.py:145
14
+ [19:21:37] Load source image from live_portrait_pipeline.py:46
15
+ D:\huggingfaceClone\LivePortrait\spaces
16
+ --innoai--LivePortrait\snapshots\0034ee
17
+ f4222844d7ef98d57b52569455229ce665\grad
18
+ io_uploads\source_e33d514c950545819174b
19
+ 4deb53be62d.png
20
+ [19:21:38] Load from video file (mp4 mov avi live_portrait_pipeline.py:72
21
+ etc...):
22
+ C:\Users\huahuahua\AppData\Local\Temp\g
23
+ radio\3d58cc0bedbf8fd0dec70a1178f4312bf
24
+ 9682855\d0.mp4
25
+ Animating... ---------------------------------------- 100% 0:06:46
26
+ Concatenating result... ---------------------------------------- 100% 0:00:00
27
+
28
+ Dump to animations/source_e33d514c950545819174b4deb53be62d--d0_concat.mp4
29
+
30
+
31
+ Dump to animations/source_e33d514c950545819174b4deb53be62d--d0.mp4
32
+
gradio_uploads/source_e33d514c950545819174b4deb53be62d.png ADDED

Git LFS Details

  • SHA256: 1af096b6a92bc1602134a859deac73ad982b4413caee39f83f2ac11460c8dbd1
  • Pointer size: 131 Bytes
  • Size of remote file: 452 kB
gradio_uploads/source_ed459b133125493299d41e0b246b5cb7.png ADDED

Git LFS Details

  • SHA256: 15a0ac12af4dfa5c2f43e4afc5c9006dd560c7fa1324110871b265dd1c76b29e
  • Pointer size: 131 Bytes
  • Size of remote file: 561 kB
inference.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding: utf-8
2
+
3
+ import tyro
4
+ from src.config.argument_config import ArgumentConfig
5
+ from src.config.inference_config import InferenceConfig
6
+ from src.config.crop_config import CropConfig
7
+ from src.live_portrait_pipeline import LivePortraitPipeline
8
+
9
+
10
+ def partial_fields(target_class, kwargs):
11
+ return target_class(**{k: v for k, v in kwargs.items() if hasattr(target_class, k)})
12
+
13
+
14
+ def main():
15
+ # set tyro theme
16
+ tyro.extras.set_accent_color("bright_cyan")
17
+ args = tyro.cli(ArgumentConfig)
18
+
19
+ # specify configs for inference
20
+ inference_cfg = partial_fields(InferenceConfig, args.__dict__) # use attribute of args to initial InferenceConfig
21
+ crop_cfg = partial_fields(CropConfig, args.__dict__) # use attribute of args to initial CropConfig
22
+
23
+ live_portrait_pipeline = LivePortraitPipeline(
24
+ inference_cfg=inference_cfg,
25
+ crop_cfg=crop_cfg
26
+ )
27
+
28
+ # run
29
+ live_portrait_pipeline.execute(args)
30
+
31
+
32
+ if __name__ == '__main__':
33
+ main()
pretrained_weights/.gitkeep ADDED
File without changes
pretrained_weights/insightface/models/buffalo_l/2d106det.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f001b856447c413801ef5c42091ed0cd516fcd21f2d6b79635b1e733a7109dbf
3
+ size 5030888
pretrained_weights/insightface/models/buffalo_l/det_10g.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5838f7fe053675b1c7a08b633df49e7af5495cee0493c7dcf6697200b85b5b91
3
+ size 16923827
pretrained_weights/liveportrait/base_models/appearance_feature_extractor.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5279bb8654293dbdf327030b397f107237dd9212fb11dd75b83dfb635211ceb5
3
+ size 3387959
pretrained_weights/liveportrait/base_models/motion_extractor.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:251e6a94ad667a1d0c69526d292677165110ef7f0cf0f6d199f0e414e8aa0ca5
3
+ size 112545506
pretrained_weights/liveportrait/base_models/spade_generator.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4780afc7909a9f84e24c01d73b31a555ef651521a1fe3b2429bd04534d992aee
3
+ size 221813590
pretrained_weights/liveportrait/base_models/warping_module.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2f61a6f265fe344f14132364859a78bdbbc2068577170693da57fb96d636e282
3
+ size 182180086
pretrained_weights/liveportrait/landmark.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:31d22a5041326c31f19b78886939a634a5aedcaa5ab8b9b951a1167595d147db
3
+ size 114666491
pretrained_weights/liveportrait/retargeting_models/stitching_retargeting_module.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3652d5a3f95099141a56986aaddec92fadf0a73c87a20fac9a2c07c32b28b611
3
+ size 2393098
requirements.txt ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ torch==2.3.0
2
+ torchvision==0.18.0
3
+ torchaudio==2.3.0
4
+
5
+ numpy==1.26.4
6
+ pyyaml==6.0.1
7
+ opencv-python==4.10.0.84
8
+ scipy==1.13.1
9
+ imageio==2.34.2
10
+ lmdb==1.4.1
11
+ tqdm==4.66.4
12
+ rich==13.7.1
13
+ ffmpeg==1.4
14
+ onnxruntime==1.18.0
15
+ onnx==1.16.1
16
+ scikit-image==0.24.0
17
+ albumentations==1.4.10
18
+ matplotlib==3.9.0
19
+ imageio-ffmpeg==0.5.1
20
+ tyro==0.8.5
21
+ gradio==4.37.1
22
+ fastapi==0.112.2
23
+ huggingface-hub<1.0
24
+ gdown
smoke_oneframe.mp4 ADDED
Binary file (15.2 kB). View file