This commit is contained in:
shadowcz007
2024-07-04 15:40:00 +08:00
parent 865d7056e5
commit 1c4446419c
6 changed files with 296 additions and 3 deletions
+8
View File
@@ -1,5 +1,13 @@
(进行ing,还没完工)
[LivePortrait](https://github.com/KwaiVGI/LivePortrait)的Comfyui版本。
### workflow
[![alt text](example/1720078701040.png)](example/live_workflow.json)
[Workflow JSON](example/live_workflow.json)
## models
Binary file not shown.

After

Width:  |  Height:  |  Size: 430 KiB

+280
View File
@@ -0,0 +1,280 @@
{
"last_node_id": 8,
"last_link_id": 8,
"nodes": [
{
"id": 6,
"type": "LivePortraitNode",
"pos": [
1218,
729
],
"size": {
"0": 330,
"1": 46
},
"flags": {},
"order": 2,
"mode": 0,
"inputs": [
{
"name": "source_image",
"type": "IMAGE",
"link": 4,
"slot_index": 0
},
{
"name": "driving_video",
"type": "SCENE_VIDEO",
"link": 5
}
],
"outputs": [
{
"name": "video",
"type": "SCENE_VIDEO",
"links": [
6
],
"shape": 3,
"slot_index": 0
},
{
"name": "video_concat",
"type": "SCENE_VIDEO",
"links": null,
"shape": 3
}
],
"properties": {
"Node name for S&R": "LivePortraitNode"
}
},
{
"id": 8,
"type": "VideoCombine_Adv",
"pos": [
1614,
534
],
"size": [
342.5999755859375,
558.5999755859375
],
"flags": {},
"order": 4,
"mode": 0,
"inputs": [
{
"name": "image_batch",
"type": "IMAGE",
"link": 8
}
],
"outputs": [
{
"name": "video_file_path",
"type": "STRING",
"links": null,
"shape": 3
}
],
"properties": {
"Node name for S&R": "VideoCombine_Adv"
},
"widgets_values": [
12,
0,
"Comfyui",
"video/h265-mp4",
false,
true,
false,
"/view?filename=Comfyui_00010_.mp4&subfolder=&type=output&format=video%2Fh265-mp4"
]
},
{
"id": 7,
"type": "LoadImage",
"pos": [
833,
523
],
"size": [
315,
314
],
"flags": {},
"order": 0,
"mode": 0,
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
4
],
"shape": 3
},
{
"name": "MASK",
"type": "MASK",
"links": null,
"shape": 3
}
],
"properties": {
"Node name for S&R": "LoadImage"
},
"widgets_values": [
"1.jpg",
"image"
]
},
{
"id": 1,
"type": "LoadVideoAndSegment_",
"pos": [
427,
501
],
"size": {
"0": 315,
"1": 214
},
"flags": {},
"order": 1,
"mode": 0,
"outputs": [
{
"name": "scenes_video",
"type": "SCENE_VIDEO",
"links": [
5
],
"shape": 6,
"slot_index": 0
},
{
"name": "scenes_count",
"type": "INT",
"links": null,
"shape": 3
},
{
"name": "frame_count",
"type": "INT",
"links": null,
"shape": 3
},
{
"name": "fps",
"type": "INT",
"links": null,
"shape": 3
}
],
"properties": {
"Node name for S&R": "LoadVideoAndSegment_"
},
"widgets_values": [
"d0.mp4",
-1,
0,
null,
"video"
]
},
{
"id": 2,
"type": "ScenesNode_",
"pos": [
1213,
565
],
"size": {
"0": 315,
"1": 78
},
"flags": {},
"order": 3,
"mode": 0,
"inputs": [
{
"name": "scenes_video",
"type": "SCENE_VIDEO",
"link": 6
}
],
"outputs": [
{
"name": "frames",
"type": "IMAGE",
"links": [
8
],
"shape": 3,
"slot_index": 0
},
{
"name": "count",
"type": "INT",
"links": null,
"shape": 3
}
],
"properties": {
"Node name for S&R": "ScenesNode_"
},
"widgets_values": [
0
]
}
],
"links": [
[
4,
7,
0,
6,
0,
"IMAGE"
],
[
5,
1,
0,
6,
1,
"SCENE_VIDEO"
],
[
6,
6,
0,
2,
0,
"SCENE_VIDEO"
],
[
8,
2,
0,
8,
0,
"IMAGE"
]
],
"groups": [],
"config": {},
"extra": {
"ds": {
"scale": 0.7972024500000015,
"offset": [
-255.09772894861337,
-212.16028421929738
]
}
},
"version": 0.4
}
@@ -38,7 +38,7 @@ class LivePortraitPipeline(object):
self.live_portrait_wrapper: LivePortraitWrapper = LivePortraitWrapper(cfg=inference_cfg)
self.cropper = Cropper(crop_cfg=crop_cfg,landmark_runner_ckpt=landmark_runner_ckpt,insightface_pretrained_weights=insightface_pretrained_weights)
def execute(self, args: ArgumentConfig):
def execute(self, args: ArgumentConfig,callback):
inference_cfg = self.live_portrait_wrapper.cfg # for convenience
######## process reference portrait ########
img_rgb = load_image_rgb(args.source_image)
@@ -100,6 +100,8 @@ class LivePortraitPipeline(object):
I_p_lst = []
R_d_0, x_d_0_info = None, None
for i in track(range(n_frames), description='Animating...', total=n_frames):
if callback:
callback(i,n_frames)
if is_video(args.driving_info):
# extract kp info by M
I_d_i = I_d_lst[i]
@@ -31,7 +31,7 @@ class LandmarkRunner(object):
device_id = kwargs.get('device_id', 0)
self.dsize = kwargs.get('dsize', 224)
self.timer = Timer()
print('---------------------------------#onnx_provider',ckpt_path)
# print('---------------------------------#onnx_provider',ckpt_path)
if onnx_provider.lower() == 'cuda':
self.session = onnxruntime.InferenceSession(
ckpt_path, providers=[
+4 -1
View File
@@ -238,8 +238,11 @@ class LivePortraitNode:
insightface_pretrained_weights=insightface_pretrained_weights
)
def progress_fn(i,n_frames):
print(i,n_frames)
# run
live_portrait_pipeline.execute(args)
live_portrait_pipeline.execute(args,callback=progress_fn)
return (v_path,output_path_concat,)