diff --git a/examples/liveportrait_image_example_01.json b/examples/liveportrait_image_example_01.json index b741d87..43b0868 100644 --- a/examples/liveportrait_image_example_01.json +++ b/examples/liveportrait_image_example_01.json @@ -1,6 +1,6 @@ { - "last_node_id": 196, - "last_link_id": 466, + "last_node_id": 197, + "last_link_id": 472, "nodes": [ { "id": 129, @@ -21,8 +21,8 @@ "name": "cropper", "type": "LPCROPPER", "links": [ - 403, - 444 + 444, + 468 ], "shape": 3, "slot_index": 0 @@ -87,9 +87,9 @@ "name": "image", "type": "IMAGE", "links": [ - 437, 443, - 451 + 451, + 469 ], "shape": 3, "slot_index": 0 @@ -135,7 +135,7 @@ { "name": "image", "type": "IMAGE", - "link": 402 + "link": 471 } ], "outputs": [ @@ -147,19 +147,19 @@ "slot_index": 0 }, { - "name": "256 width", + "name": "width", "type": "INT", "links": null, "shape": 3 }, { - "name": "256 height", + "name": "height", "type": "INT", "links": null, "shape": 3 }, { - "name": "128 count", + "name": "count", "type": "INT", "links": null, "shape": 3 @@ -169,112 +169,6 @@ "Node name for S&R": "GetImageSizeAndCount" } }, - { - "id": 174, - "type": "LivePortraitCropper", - "pos": [ - -636, - 187 - ], - "size": { - "0": 330, - "1": 246 - }, - "flags": {}, - "order": 13, - "mode": 0, - "inputs": [ - { - "name": "cropper", - "type": "LPCROPPER", - "link": 403, - "slot_index": 0 - }, - { - "name": "source_image", - "type": "IMAGE", - "link": 437 - }, - { - "name": "source_image", - "type": "IMAGE", - "link": null - } - ], - "outputs": [ - { - "name": "cropped_image", - "type": "IMAGE", - "links": [ - 402 - ], - "shape": 3, - "slot_index": 0 - }, - { - "name": "crop_info", - "type": "CROPINFO", - "links": [ - 426 - ], - "shape": 3, - "slot_index": 1 - } - ], - "properties": { - "Node name for S&R": "LivePortraitCropper" - }, - "widgets_values": [ - 512, - 2.3, - 0, - -0.125, - 0, - "large-small", - true - ] - }, - { - "id": 180, - "type": "LivePortraitRetargeting", - "pos": [ - -320, - -311 - ], - "size": { - "0": 430.8000183105469, - "1": 130 - }, - "flags": {}, - "order": 17, - "mode": 0, - "inputs": [ - { - "name": "driving_crop_info", - "type": "CROPINFO", - "link": 426, - "slot_index": 0 - } - ], - "outputs": [ - { - "name": "retargeting_info", - "type": "RETARGETINGINFO", - "links": [], - "shape": 3, - "slot_index": 0 - } - ], - "properties": { - "Node name for S&R": "LivePortraitRetargeting" - }, - "widgets_values": [ - true, - 1, - true, - 1 - ] - }, { "id": 188, "type": "Note", @@ -473,7 +367,8 @@ "type": "LIVEPORTRAITPIPE", "links": [ 446, - 448 + 448, + 472 ], "shape": 3, "slot_index": 0 @@ -977,10 +872,10 @@ -1256, -572 ], - "size": [ - 315, - 314 - ], + "size": { + "0": 315, + "1": 314 + }, "flags": {}, "order": 6, "mode": 0, @@ -1009,6 +904,182 @@ "image" ] }, + { + "id": 168, + "type": "VHS_VideoCombine", + "pos": [ + 1495, + -143 + ], + "size": [ + 1103.3974609375, + 865.69873046875 + ], + "flags": {}, + "order": 22, + "mode": 0, + "inputs": [ + { + "name": "images", + "type": "IMAGE", + "link": 441 + }, + { + "name": "audio", + "type": "VHS_AUDIO", + "link": null + }, + { + "name": "meta_batch", + "type": "VHS_BatchManager", + "link": null + }, + { + "name": "vae", + "type": "VAE", + "link": null + } + ], + "outputs": [ + { + "name": "Filenames", + "type": "VHS_FILENAMES", + "links": null, + "shape": 3 + } + ], + "properties": { + "Node name for S&R": "VHS_VideoCombine" + }, + "widgets_values": { + "frame_rate": 24, + "loop_count": 0, + "filename_prefix": "LivePortrait", + "format": "video/h264-mp4", + "pix_fmt": "yuv420p", + "crf": 19, + "save_metadata": true, + "pingpong": false, + "save_output": false, + "videopreview": { + "hidden": false, + "paused": false, + "params": { + "filename": "LivePortrait_00002.mp4", + "subfolder": "", + "type": "temp", + "format": "video/h264-mp4", + "frame_rate": 24 + } + } + } + }, + { + "id": 180, + "type": "LivePortraitRetargeting", + "pos": [ + -320, + -311 + ], + "size": { + "0": 430.8000183105469, + "1": 130 + }, + "flags": {}, + "order": 17, + "mode": 0, + "inputs": [ + { + "name": "driving_crop_info", + "type": "CROPINFO", + "link": 470, + "slot_index": 0 + } + ], + "outputs": [ + { + "name": "retargeting_info", + "type": "RETARGETINGINFO", + "links": [], + "shape": 3, + "slot_index": 0 + } + ], + "properties": { + "Node name for S&R": "LivePortraitRetargeting" + }, + "widgets_values": [ + true, + 1, + true, + 1 + ] + }, + { + "id": 197, + "type": "LivePortraitCropper", + "pos": [ + -636, + 187 + ], + "size": { + "0": 330, + "1": 242 + }, + "flags": {}, + "order": 13, + "mode": 0, + "inputs": [ + { + "name": "pipeline", + "type": "LIVEPORTRAITPIPE", + "link": 472, + "slot_index": 0 + }, + { + "name": "cropper", + "type": "LPCROPPER", + "link": 468 + }, + { + "name": "source_image", + "type": "IMAGE", + "link": 469 + } + ], + "outputs": [ + { + "name": "cropped_image", + "type": "IMAGE", + "links": [ + 471 + ], + "shape": 3, + "slot_index": 0 + }, + { + "name": "crop_info", + "type": "CROPINFO", + "links": [ + 470 + ], + "shape": 3, + "slot_index": 1 + } + ], + "properties": { + "Node name for S&R": "LivePortraitCropper" + }, + "widgets_values": [ + 512, + 2.3, + 0, + -0.125, + 0, + "large-small", + true + ] + }, { "id": 190, "type": "LivePortraitProcess", @@ -1082,76 +1153,6 @@ "relative", 0.000003 ] - }, - { - "id": 168, - "type": "VHS_VideoCombine", - "pos": [ - 1495, - -143 - ], - "size": [ - 1103.3974609375, - 865.69873046875 - ], - "flags": {}, - "order": 22, - "mode": 0, - "inputs": [ - { - "name": "images", - "type": "IMAGE", - "link": 441 - }, - { - "name": "audio", - "type": "VHS_AUDIO", - "link": null - }, - { - "name": "meta_batch", - "type": "VHS_BatchManager", - "link": null - }, - { - "name": "vae", - "type": "VAE", - "link": null - } - ], - "outputs": [ - { - "name": "Filenames", - "type": "VHS_FILENAMES", - "links": null, - "shape": 3 - } - ], - "properties": { - "Node name for S&R": "VHS_VideoCombine" - }, - "widgets_values": { - "frame_rate": 24, - "loop_count": 0, - "filename_prefix": "LivePortrait", - "format": "video/h264-mp4", - "pix_fmt": "yuv420p", - "crf": 19, - "save_metadata": true, - "pingpong": false, - "save_output": false, - "videopreview": { - "hidden": false, - "paused": false, - "params": { - "filename": "LivePortrait_00001.mp4", - "subfolder": "", - "type": "temp", - "format": "video/h264-mp4", - "frame_rate": 24 - } - } - } } ], "links": [ @@ -1179,30 +1180,6 @@ 2, "INT" ], - [ - 402, - 174, - 0, - 134, - 0, - "IMAGE" - ], - [ - 403, - 129, - 0, - 174, - 0, - "LPCROPPER" - ], - [ - 426, - 174, - 1, - 180, - 0, - "CROPINFO" - ], [ 434, 165, @@ -1219,14 +1196,6 @@ 0, "IMAGE" ], - [ - 437, - 182, - 0, - 174, - 1, - "IMAGE" - ], [ 440, 181, @@ -1362,16 +1331,56 @@ 165, 0, "IMAGE" + ], + [ + 468, + 129, + 0, + 197, + 1, + "LPCROPPER" + ], + [ + 469, + 182, + 0, + 197, + 2, + "IMAGE" + ], + [ + 470, + 197, + 1, + 180, + 0, + "CROPINFO" + ], + [ + 471, + 197, + 0, + 134, + 0, + "IMAGE" + ], + [ + 472, + 1, + 0, + 197, + 0, + "LIVEPORTRAITPIPE" ] ], "groups": [], "config": {}, "extra": { "ds": { - "scale": 0.5644739300537774, + "scale": 0.6209213230591553, "offset": { - "0": 1531.7385101344028, - "1": 1081.4586534396992 + "0": 1452.6772352406037, + "1": 986.9216386951317 } } }, diff --git a/examples/liveportrait_realtime_example_01.json b/examples/liveportrait_realtime_example_01.json index 38f1cf2..f86fd5d 100644 --- a/examples/liveportrait_realtime_example_01.json +++ b/examples/liveportrait_realtime_example_01.json @@ -1,6 +1,6 @@ { - "last_node_id": 202, - "last_link_id": 476, + "last_node_id": 203, + "last_link_id": 477, "nodes": [ { "id": 129, @@ -153,10 +153,10 @@ -1050, -550 ], - "size": [ - 315, - 314 - ], + "size": { + "0": 315, + "1": 314 + }, "flags": {}, "order": 2, "mode": 0, @@ -185,60 +185,6 @@ "image" ] }, - { - "id": 199, - "type": "GetImageSizeAndCount", - "pos": [ - 202, - -239 - ], - "size": { - "0": 210, - "1": 86 - }, - "flags": {}, - "order": 5, - "mode": 0, - "inputs": [ - { - "name": "image", - "type": "IMAGE", - "link": 474 - } - ], - "outputs": [ - { - "name": "image", - "type": "IMAGE", - "links": [ - 472 - ], - "shape": 3, - "slot_index": 0 - }, - { - "name": "512 width", - "type": "INT", - "links": null, - "shape": 3 - }, - { - "name": "512 height", - "type": "INT", - "links": null, - "shape": 3 - }, - { - "name": "1 count", - "type": "INT", - "links": null, - "shape": 3 - } - ], - "properties": { - "Node name for S&R": "GetImageSizeAndCount" - } - }, { "id": 78, "type": "GetImageSizeAndCount", @@ -251,7 +197,7 @@ "1": 86 }, "flags": {}, - "order": 7, + "order": 5, "mode": 0, "inputs": [ { @@ -294,6 +240,140 @@ "Node name for S&R": "GetImageSizeAndCount" } }, + { + "id": 190, + "type": "LivePortraitProcess", + "pos": [ + 563, + -418 + ], + "size": { + "0": 430.8000183105469, + "1": 282 + }, + "flags": {}, + "order": 7, + "mode": 0, + "inputs": [ + { + "name": "pipeline", + "type": "LIVEPORTRAITPIPE", + "link": 448 + }, + { + "name": "crop_info", + "type": "CROPINFO", + "link": 449 + }, + { + "name": "source_image", + "type": "IMAGE", + "link": 475 + }, + { + "name": "driving_images", + "type": "IMAGE", + "link": 477 + }, + { + "name": "opt_retargeting_info", + "type": "RETARGETINGINFO", + "link": null + } + ], + "outputs": [ + { + "name": "cropped_image", + "type": "IMAGE", + "links": [ + 470 + ], + "shape": 3, + "slot_index": 0 + }, + { + "name": "output", + "type": "LP_OUT", + "links": [], + "shape": 3, + "slot_index": 1 + } + ], + "properties": { + "Node name for S&R": "LivePortraitProcess" + }, + "widgets_values": [ + false, + 0.03, + false, + 1, + "constant", + "single_frame", + 0.000003 + ] + }, + { + "id": 198, + "type": "PreviewImage", + "pos": [ + 1027, + -409 + ], + "size": { + "0": 521.2196044921875, + "1": 566.1187133789062 + }, + "flags": {}, + "order": 8, + "mode": 0, + "inputs": [ + { + "name": "images", + "type": "IMAGE", + "link": 470 + } + ], + "properties": { + "Node name for S&R": "PreviewImage" + } + }, + { + "id": 203, + "type": "Screencap_mss", + "pos": [ + 5, + -277 + ], + "size": { + "0": 315, + "1": 178 + }, + "flags": {}, + "order": 3, + "mode": 0, + "outputs": [ + { + "name": "image", + "type": "IMAGE", + "links": [ + 477 + ], + "shape": 3, + "slot_index": 0 + } + ], + "properties": { + "Node name for S&R": "Screencap_mss" + }, + "widgets_values": [ + 0, + 0, + 512, + 512, + 1, + 0.1 + ] + }, { "id": 189, "type": "LivePortraitCropper", @@ -306,7 +386,7 @@ "1": 242 }, "flags": {}, - "order": 8, + "order": 6, "mode": 0, "inputs": [ { @@ -354,168 +434,8 @@ -0.125, 0, "large-small", - true + false ] - }, - { - "id": 202, - "type": "PreviewImage", - "pos": [ - 147.3814710186748, - -76.18841642883467 - ], - "size": { - "0": 521.2196044921875, - "1": 566.1187133789062 - }, - "flags": {}, - "order": 6, - "mode": 0, - "inputs": [ - { - "name": "images", - "type": "IMAGE", - "link": 476 - } - ], - "properties": { - "Node name for S&R": "PreviewImage" - } - }, - { - "id": 201, - "type": "ImageGrabPIL", - "pos": [ - -208, - -232 - ], - "size": { - "0": 315, - "1": 178 - }, - "flags": {}, - "order": 3, - "mode": 0, - "outputs": [ - { - "name": "image", - "type": "IMAGE", - "links": [ - 474, - 476 - ], - "shape": 3, - "slot_index": 0 - } - ], - "properties": { - "Node name for S&R": "ImageGrabPIL" - }, - "widgets_values": [ - 0, - 0, - 512, - 512, - 1, - 0.1 - ] - }, - { - "id": 190, - "type": "LivePortraitProcess", - "pos": [ - 563, - -418 - ], - "size": { - "0": 430.8000183105469, - "1": 282 - }, - "flags": {}, - "order": 9, - "mode": 0, - "inputs": [ - { - "name": "pipeline", - "type": "LIVEPORTRAITPIPE", - "link": 448 - }, - { - "name": "crop_info", - "type": "CROPINFO", - "link": 449 - }, - { - "name": "source_image", - "type": "IMAGE", - "link": 475 - }, - { - "name": "driving_images", - "type": "IMAGE", - "link": 472 - }, - { - "name": "opt_retargeting_info", - "type": "RETARGETINGINFO", - "link": null - } - ], - "outputs": [ - { - "name": "cropped_image", - "type": "IMAGE", - "links": [ - 470 - ], - "shape": 3, - "slot_index": 0 - }, - { - "name": "output", - "type": "LP_OUT", - "links": [], - "shape": 3, - "slot_index": 1 - } - ], - "properties": { - "Node name for S&R": "LivePortraitProcess" - }, - "widgets_values": [ - false, - 0.03, - false, - 1, - "constant", - "single_frame", - 0.000003 - ] - }, - { - "id": 198, - "type": "PreviewImage", - "pos": [ - 1027, - -409 - ], - "size": [ - 521.2195999999999, - 566.1186964538573 - ], - "flags": {}, - "order": 10, - "mode": 0, - "inputs": [ - { - "name": "images", - "type": "IMAGE", - "link": 470 - } - ], - "properties": { - "Node name for S&R": "PreviewImage" - } } ], "links": [ @@ -583,22 +503,6 @@ 0, "IMAGE" ], - [ - 472, - 199, - 0, - 190, - 3, - "IMAGE" - ], - [ - 474, - 201, - 0, - 199, - 0, - "IMAGE" - ], [ 475, 78, @@ -608,11 +512,11 @@ "IMAGE" ], [ - 476, - 201, - 0, - 202, + 477, + 203, 0, + 190, + 3, "IMAGE" ] ], @@ -622,8 +526,8 @@ "ds": { "scale": 0.7513148009015781, "offset": { - "0": 1419.6048777240007, - "1": 976.38813725403 + "0": 1170.2642381365986, + "1": 992.3601372540302 } } }, diff --git a/examples/liveportrait_video_example_02.json b/examples/liveportrait_video_example_02.json index beece45..5689f4a 100644 --- a/examples/liveportrait_video_example_02.json +++ b/examples/liveportrait_video_example_02.json @@ -1,7 +1,60 @@ { - "last_node_id": 194, - "last_link_id": 463, + "last_node_id": 195, + "last_link_id": 467, "nodes": [ + { + "id": 81, + "type": "GrowMaskWithBlur", + "pos": [ + 80, + 441 + ], + "size": { + "0": 315, + "1": 246 + }, + "flags": {}, + "order": 7, + "mode": 0, + "inputs": [ + { + "name": "mask", + "type": "MASK", + "link": 192, + "slot_index": 0 + } + ], + "outputs": [ + { + "name": "mask", + "type": "MASK", + "links": [ + 187 + ], + "shape": 3, + "slot_index": 0 + }, + { + "name": "mask_inverted", + "type": "MASK", + "links": null, + "shape": 3 + } + ], + "properties": { + "Node name for S&R": "GrowMaskWithBlur" + }, + "widgets_values": [ + 0, + 0, + true, + false, + 13.9, + 1, + 1, + false + ] + }, { "id": 165, "type": "ImageResizeKJ", @@ -14,7 +67,7 @@ "1": 242 }, "flags": {}, - "order": 10, + "order": 12, "mode": 0, "inputs": [ { @@ -99,8 +152,8 @@ "name": "cropper", "type": "LPCROPPER", "links": [ - 403, - 444 + 444, + 464 ], "shape": 3, "slot_index": 0 @@ -118,15 +171,15 @@ "id": 82, "type": "MaskPreview+", "pos": [ - 1380, - -820 + 436, + 434 ], "size": { "0": 210, "1": 246 }, "flags": {}, - "order": 13, + "order": 10, "mode": 0, "inputs": [ { @@ -139,6 +192,52 @@ "Node name for S&R": "MaskPreview+" } }, + { + "id": 83, + "type": "CreateShapeMask", + "pos": [ + -283, + 441 + ], + "size": { + "0": 315, + "1": 270 + }, + "flags": {}, + "order": 1, + "mode": 0, + "outputs": [ + { + "name": "mask", + "type": "MASK", + "links": [ + 192 + ], + "shape": 3, + "slot_index": 0 + }, + { + "name": "mask_inverted", + "type": "MASK", + "links": null, + "shape": 3 + } + ], + "properties": { + "Node name for S&R": "CreateShapeMask" + }, + "widgets_values": [ + "circle", + 1, + 256, + 256, + 0, + 512, + 512, + 472, + 472 + ] + }, { "id": 133, "type": "PrimitiveNode", @@ -151,7 +250,7 @@ "1": 82 }, "flags": {}, - "order": 1, + "order": 2, "mode": 0, "outputs": [ { @@ -188,7 +287,7 @@ "1": 86 }, "flags": {}, - "order": 9, + "order": 11, "mode": 0, "inputs": [ { @@ -202,9 +301,9 @@ "name": "image", "type": "IMAGE", "links": [ - 437, 443, - 451 + 451, + 465 ], "shape": 3, "slot_index": 0 @@ -244,13 +343,13 @@ "1": 86 }, "flags": {}, - "order": 16, + "order": 3, "mode": 0, "inputs": [ { "name": "image", "type": "IMAGE", - "link": 402 + "link": null } ], "outputs": [ @@ -284,112 +383,6 @@ "Node name for S&R": "GetImageSizeAndCount" } }, - { - "id": 174, - "type": "LivePortraitCropper", - "pos": [ - -636, - 187 - ], - "size": { - "0": 330, - "1": 246 - }, - "flags": {}, - "order": 14, - "mode": 0, - "inputs": [ - { - "name": "cropper", - "type": "LPCROPPER", - "link": 403, - "slot_index": 0 - }, - { - "name": "source_image", - "type": "IMAGE", - "link": 437 - }, - { - "name": "source_image", - "type": "IMAGE", - "link": null - } - ], - "outputs": [ - { - "name": "cropped_image", - "type": "IMAGE", - "links": [ - 402 - ], - "shape": 3, - "slot_index": 0 - }, - { - "name": "crop_info", - "type": "CROPINFO", - "links": [ - 426 - ], - "shape": 3, - "slot_index": 1 - } - ], - "properties": { - "Node name for S&R": "LivePortraitCropper" - }, - "widgets_values": [ - 512, - 2.3, - 0, - -0.125, - 0, - "large-small", - true - ] - }, - { - "id": 180, - "type": "LivePortraitRetargeting", - "pos": [ - -320, - -311 - ], - "size": { - "0": 430.8000183105469, - "1": 130 - }, - "flags": {}, - "order": 17, - "mode": 0, - "inputs": [ - { - "name": "driving_crop_info", - "type": "CROPINFO", - "link": 426, - "slot_index": 0 - } - ], - "outputs": [ - { - "name": "retargeting_info", - "type": "RETARGETINGINFO", - "links": [], - "shape": 3, - "slot_index": 0 - } - ], - "properties": { - "Node name for S&R": "LivePortraitRetargeting" - }, - "widgets_values": [ - true, - 1, - true, - 1 - ] - }, { "id": 188, "type": "Note", @@ -402,7 +395,7 @@ "1": 95.92726135253906 }, "flags": {}, - "order": 2, + "order": 4, "mode": 0, "properties": { "text": "" @@ -488,7 +481,7 @@ "1": 86 }, "flags": {}, - "order": 15, + "order": 16, "mode": 0, "inputs": [ { @@ -601,7 +594,7 @@ { "name": "mask", "type": "MASK", - "link": 463 + "link": null } ], "outputs": [ @@ -691,7 +684,7 @@ "1": 58 }, "flags": {}, - "order": 3, + "order": 5, "mode": 0, "outputs": [ { @@ -699,7 +692,8 @@ "type": "LIVEPORTRAITPIPE", "links": [ 446, - 448 + 448, + 466 ], "shape": 3, "slot_index": 0 @@ -712,80 +706,6 @@ "fp16" ] }, - { - "id": 190, - "type": "LivePortraitProcess", - "pos": [ - 551, - -383 - ], - "size": { - "0": 430.8000183105469, - "1": 282 - }, - "flags": {}, - "order": 20, - "mode": 0, - "inputs": [ - { - "name": "pipeline", - "type": "LIVEPORTRAITPIPE", - "link": 448 - }, - { - "name": "crop_info", - "type": "CROPINFO", - "link": 449 - }, - { - "name": "source_image", - "type": "IMAGE", - "link": 456 - }, - { - "name": "driving_images", - "type": "IMAGE", - "link": 451 - }, - { - "name": "opt_retargeting_info", - "type": "RETARGETINGINFO", - "link": null - } - ], - "outputs": [ - { - "name": "cropped_image", - "type": "IMAGE", - "links": [ - 454 - ], - "shape": 3, - "slot_index": 0 - }, - { - "name": "output", - "type": "LP_OUT", - "links": [ - 452 - ], - "shape": 3, - "slot_index": 1 - } - ], - "properties": { - "Node name for S&R": "LivePortraitProcess" - }, - "widgets_values": [ - false, - 0.03, - true, - 1, - "constant", - "source_video_smoothed", - 0.000003 - ] - }, { "id": 8, "type": "VHS_LoadVideo", @@ -798,7 +718,7 @@ 572.1555480957031 ], "flags": {}, - "order": 6, + "order": 8, "mode": 0, "inputs": [ { @@ -947,7 +867,7 @@ "hidden": false, "paused": false, "params": { - "filename": "LivePortrait_00006.mp4", + "filename": "LivePortrait_00005.mp4", "subfolder": "", "type": "temp", "format": "video/h264-mp4", @@ -1013,7 +933,7 @@ 420.83202731609344 ], "flags": {}, - "order": 7, + "order": 9, "mode": 0, "inputs": [ { @@ -1113,7 +1033,7 @@ "flags": { "collapsed": true }, - "order": 12, + "order": 14, "mode": 0, "inputs": [ { @@ -1203,7 +1123,7 @@ 26 ], "flags": {}, - "order": 11, + "order": 13, "mode": 0, "inputs": [ { @@ -1239,7 +1159,7 @@ "1": 58 }, "flags": {}, - "order": 4, + "order": 6, "mode": 0, "properties": { "text": "" @@ -1251,103 +1171,180 @@ "bgcolor": "#653" }, { - "id": 83, - "type": "CreateShapeMask", + "id": 180, + "type": "LivePortraitRetargeting", "pos": [ - 660, - -820 + -320, + -311 ], "size": { - "0": 315, - "1": 270 + "0": 430.8000183105469, + "1": 130 }, "flags": {}, - "order": 5, - "mode": 0, - "outputs": [ - { - "name": "mask", - "type": "MASK", - "links": [ - 192 - ], - "shape": 3, - "slot_index": 0 - }, - { - "name": "mask_inverted", - "type": "MASK", - "links": null, - "shape": 3 - } - ], - "properties": { - "Node name for S&R": "CreateShapeMask" - }, - "widgets_values": [ - "square", - 1, - 256, - 256, - 0, - 512, - 512, - 480, - 480 - ] - }, - { - "id": 81, - "type": "GrowMaskWithBlur", - "pos": [ - 1030, - -820 - ], - "size": { - "0": 315, - "1": 246 - }, - "flags": {}, - "order": 8, + "order": 17, "mode": 0, "inputs": [ { - "name": "mask", - "type": "MASK", - "link": 192, + "name": "driving_crop_info", + "type": "CROPINFO", + "link": 467, "slot_index": 0 } ], "outputs": [ { - "name": "mask", - "type": "MASK", + "name": "retargeting_info", + "type": "RETARGETINGINFO", + "links": [], + "shape": 3, + "slot_index": 0 + } + ], + "properties": { + "Node name for S&R": "LivePortraitRetargeting" + }, + "widgets_values": [ + true, + 1, + true, + 1 + ] + }, + { + "id": 195, + "type": "LivePortraitCropper", + "pos": [ + -636, + 187 + ], + "size": { + "0": 330, + "1": 242 + }, + "flags": {}, + "order": 15, + "mode": 0, + "inputs": [ + { + "name": "pipeline", + "type": "LIVEPORTRAITPIPE", + "link": 466, + "slot_index": 0 + }, + { + "name": "cropper", + "type": "LPCROPPER", + "link": 464 + }, + { + "name": "source_image", + "type": "IMAGE", + "link": 465 + } + ], + "outputs": [ + { + "name": "cropped_image", + "type": "IMAGE", + "links": null, + "shape": 3 + }, + { + "name": "crop_info", + "type": "CROPINFO", "links": [ - 187, - 463 + 467 + ], + "shape": 3, + "slot_index": 1 + } + ], + "properties": { + "Node name for S&R": "LivePortraitCropper" + }, + "widgets_values": [ + 512, + 2.3, + 0, + -0.125, + 0, + "large-small", + true + ] + }, + { + "id": 190, + "type": "LivePortraitProcess", + "pos": [ + 551, + -383 + ], + "size": { + "0": 430.8000183105469, + "1": 282 + }, + "flags": {}, + "order": 20, + "mode": 0, + "inputs": [ + { + "name": "pipeline", + "type": "LIVEPORTRAITPIPE", + "link": 448 + }, + { + "name": "crop_info", + "type": "CROPINFO", + "link": 449 + }, + { + "name": "source_image", + "type": "IMAGE", + "link": 456 + }, + { + "name": "driving_images", + "type": "IMAGE", + "link": 451 + }, + { + "name": "opt_retargeting_info", + "type": "RETARGETINGINFO", + "link": null + } + ], + "outputs": [ + { + "name": "cropped_image", + "type": "IMAGE", + "links": [ + 454 ], "shape": 3, "slot_index": 0 }, { - "name": "mask_inverted", - "type": "MASK", - "links": null, - "shape": 3 + "name": "output", + "type": "LP_OUT", + "links": [ + 452 + ], + "shape": 3, + "slot_index": 1 } ], "properties": { - "Node name for S&R": "GrowMaskWithBlur" + "Node name for S&R": "LivePortraitProcess" }, "widgets_values": [ - 0, - 0, - true, false, - 13.9, + 0.03, + true, 1, - 1, - false + "constant", + "source_video_smoothed", + 0.000003 ] } ], @@ -1384,30 +1381,6 @@ 2, "INT" ], - [ - 402, - 174, - 0, - 134, - 0, - "IMAGE" - ], - [ - 403, - 129, - 0, - 174, - 0, - "LPCROPPER" - ], - [ - 426, - 174, - 1, - 180, - 0, - "CROPINFO" - ], [ 433, 146, @@ -1432,14 +1405,6 @@ 0, "IMAGE" ], - [ - 437, - 182, - 0, - 174, - 1, - "IMAGE" - ], [ 440, 181, @@ -1593,22 +1558,46 @@ "VHS_AUDIO" ], [ - 463, - 81, + 464, + 129, 0, - 191, - 3, - "MASK" + 195, + 1, + "LPCROPPER" + ], + [ + 465, + 182, + 0, + 195, + 2, + "IMAGE" + ], + [ + 466, + 1, + 0, + 195, + 0, + "LIVEPORTRAITPIPE" + ], + [ + 467, + 195, + 1, + 180, + 0, + "CROPINFO" ] ], "groups": [], "config": {}, "extra": { "ds": { - "scale": 0.620921323059155, + "scale": 0.6209213230591556, "offset": { - "0": 1013.2156987569617, - "1": 1150.929304447328 + "0": 1561.0563501752945, + "1": 914.6435241564945 } } }, diff --git a/nodes.py b/nodes.py index 18db1c7..dd75375 100644 --- a/nodes.py +++ b/nodes.py @@ -84,19 +84,19 @@ class DownloadAndLoadLivePortraitModels: if precision == 'auto': try: if mm.is_device_mps(device): - print("LivePortrait using fp32 for MPS") + log.info("LivePortrait using fp32 for MPS") dtype = 'fp32' elif mm.should_use_fp16(): - print("LivePortrait using fp16") + log.info("LivePortrait using fp16") dtype = 'fp16' else: - print("LivePortrait using fp32") + log.info("LivePortrait using fp32") dtype = 'fp32' except: raise AttributeError("ComfyUI version too old, can't autodetect properly. Set your dtypes manually.") else: dtype = precision - print(f"LivePortrait using {dtype}") + log.info(f"LivePortrait using {dtype}") pbar = comfy.utils.ProgressBar(3) @@ -340,10 +340,8 @@ class LivePortraitProcess: mismatch_method ) - total_frames = len(out["out_list"]) - if total_frames > 1: cropped_image_list = [] for i in (range(total_frames)): @@ -396,21 +394,18 @@ class LivePortraitComposite: if mask is not None: crop_mask = mask.unsqueeze(-1).expand(-1, -1, -1, 3) - print(crop_mask.shape) else: log.info("Using default mask template") crop_mask = cv2.imread(os.path.join(script_directory, "liveportrait", "utils", "resources", "mask_template.png"), cv2.IMREAD_COLOR) crop_mask = torch.from_numpy(crop_mask) crop_mask = crop_mask.unsqueeze(0).float() / 255.0 - print(crop_mask.shape) crop_info = liveportrait_out["crop_info"] composited_image_list = [] out_mask_list = [] total_frames = len(liveportrait_out["out_list"]) - print(f"Total frames: {total_frames}") - print("crop_info_list: ", len(crop_info["crop_info_list"])) + log.info(f"Total frames: {total_frames}") pbar = comfy.utils.ProgressBar(total_frames) for i in tqdm(range(total_frames), desc='Compositing..', total=total_frames): @@ -555,29 +550,31 @@ class LivePortraitCropper: # Cropping operation crop_info = cropper.crop_single_image(source_image_np[i], dsize, scale, vy_ratio, vx_ratio, face_index, face_index_order, rotate) - if crop_info: - cropped_image = crop_info['img_crop_256x256'] - crop_info_list.append(crop_info) - else: - cropped_image = np.zeros((256, 256, 3), dtype=np.uint8) - crop_info_list.append(None) - log.warning(f"Warning: No face detected on frame {str(i)}, skipping") - cropped_images_list.append(cropped_image) - # Processing source images if crop_info: + crop_info_list.append(crop_info) + + cropped_image = crop_info['img_crop_256x256'] + cropped_images_list.append(cropped_image) + I_s = pipeline.live_portrait_wrapper.prepare_source(cropped_image) + x_s_info = pipeline.live_portrait_wrapper.get_kp_info(I_s) - f_s = pipeline.live_portrait_wrapper.extract_feature_3d(I_s) - f_s_list.append(f_s) source_info.append(x_s_info) - + x_s = pipeline.live_portrait_wrapper.transform_keypoint(x_s_info) x_s_list.append(x_s) - + R_s = get_rotation_matrix(x_s_info["pitch"], x_s_info["yaw"], x_s_info["roll"]) source_rot_list.append(R_s) + + f_s = pipeline.live_portrait_wrapper.extract_feature_3d(I_s) + f_s_list.append(f_s) + else: + log.warning(f"Warning: No face detected on frame {str(i)}, skipping") + cropped_image = np.zeros((256, 256, 3), dtype=np.uint8) + crop_info_list.append(None) f_s_list.append(None) x_s_list.append(None) source_info.append(None)