diff --git a/examples/liveportrait_example_01.json b/examples/liveportrait_example_01.json deleted file mode 100644 index def7705..0000000 --- a/examples/liveportrait_example_01.json +++ /dev/null @@ -1,500 +0,0 @@ -{ - "last_node_id": 31, - "last_link_id": 68, - "nodes": [ - { - "id": 4, - "type": "LoadImage", - "pos": [ - 138, - 323 - ], - "size": { - "0": 272.85791015625, - "1": 331.60894775390625 - }, - "flags": {}, - "order": 0, - "mode": 0, - "outputs": [ - { - "name": "IMAGE", - "type": "IMAGE", - "links": [ - 59 - ], - "shape": 3, - "slot_index": 0 - }, - { - "name": "MASK", - "type": "MASK", - "links": null, - "shape": 3 - } - ], - "properties": { - "Node name for S&R": "LoadImage" - }, - "widgets_values": [ - "oldman.jpg", - "image" - ] - }, - { - "id": 19, - "type": "ImageResizeKJ", - "pos": [ - 507, - 675 - ], - "size": { - "0": 315, - "1": 242 - }, - "flags": {}, - "order": 4, - "mode": 0, - "inputs": [ - { - "name": "image", - "type": "IMAGE", - "link": 30 - }, - { - "name": "get_image_size", - "type": "IMAGE", - "link": 68 - }, - { - "name": "width_input", - "type": "INT", - "link": null, - "widget": { - "name": "width_input" - } - }, - { - "name": "height_input", - "type": "INT", - "link": null, - "widget": { - "name": "height_input" - } - } - ], - "outputs": [ - { - "name": "IMAGE", - "type": "IMAGE", - "links": [ - 32 - ], - "shape": 3, - "slot_index": 0 - }, - { - "name": "width", - "type": "INT", - "links": null, - "shape": 3 - }, - { - "name": "height", - "type": "INT", - "links": null, - "shape": 3 - } - ], - "properties": { - "Node name for S&R": "ImageResizeKJ" - }, - "widgets_values": [ - 512, - 512, - "nearest-exact", - false, - 2, - 0, - 0 - ] - }, - { - "id": 18, - "type": "ImageConcatMulti", - "pos": [ - 860, - 679 - ], - "size": { - "0": 210, - "1": 150 - }, - "flags": {}, - "order": 5, - "mode": 0, - "inputs": [ - { - "name": "image_1", - "type": "IMAGE", - "link": 32 - }, - { - "name": "image_2", - "type": "IMAGE", - "link": 67 - } - ], - "outputs": [ - { - "name": "images", - "type": "IMAGE", - "links": [ - 64 - ], - "shape": 3, - "slot_index": 0 - } - ], - "properties": {}, - "widgets_values": [ - 2, - "right", - false, - null - ] - }, - { - "id": 23, - "type": "VHS_VideoCombine", - "pos": [ - 1098, - 240 - ], - "size": [ - 1253.234130859375, - 940.6170654296875 - ], - "flags": {}, - "order": 6, - "mode": 0, - "inputs": [ - { - "name": "images", - "type": "IMAGE", - "link": 64 - }, - { - "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 - } - } - } - }, - { - "id": 1, - "type": "DownloadAndLoadLivePortraitModels", - "pos": [ - 142, - 205 - ], - "size": { - "0": 252, - "1": 58 - }, - "flags": {}, - "order": 1, - "mode": 0, - "outputs": [ - { - "name": "live_portrait_pipe", - "type": "LIVEPORTRAITPIPE", - "links": [ - 58 - ], - "shape": 3, - "slot_index": 0 - } - ], - "properties": { - "Node name for S&R": "DownloadAndLoadLivePortraitModels" - }, - "widgets_values": [ - "fp16" - ] - }, - { - "id": 8, - "type": "VHS_LoadVideo", - "pos": [ - 161, - 714 - ], - "size": [ - 235.1999969482422, - 491.1999969482422 - ], - "flags": {}, - "order": 2, - "mode": 0, - "inputs": [ - { - "name": "meta_batch", - "type": "VHS_BatchManager", - "link": null - }, - { - "name": "vae", - "type": "VAE", - "link": null - } - ], - "outputs": [ - { - "name": "IMAGE", - "type": "IMAGE", - "links": [ - 30, - 60 - ], - "shape": 3, - "slot_index": 0 - }, - { - "name": "frame_count", - "type": "INT", - "links": null, - "shape": 3 - }, - { - "name": "audio", - "type": "VHS_AUDIO", - "links": null, - "shape": 3 - }, - { - "name": "video_info", - "type": "VHS_VIDEOINFO", - "links": null, - "shape": 3 - } - ], - "properties": { - "Node name for S&R": "VHS_LoadVideo" - }, - "widgets_values": { - "video": "d3.mp4", - "force_rate": 0, - "force_size": "Disabled", - "custom_width": 512, - "custom_height": 512, - "frame_load_cap": 0, - "skip_first_frames": 0, - "select_every_nth": 1, - "choose video to upload": "image", - "videopreview": { - "hidden": false, - "paused": false, - "params": { - "frame_load_cap": 0, - "skip_first_frames": 0, - "force_rate": 0, - "filename": "d3.mp4", - "type": "input", - "format": "video/mp4", - "select_every_nth": 1 - } - } - } - }, - { - "id": 30, - "type": "LivePortraitProcess", - "pos": [ - 500, - 249 - ], - "size": { - "0": 367.79998779296875, - "1": 362 - }, - "flags": {}, - "order": 3, - "mode": 0, - "inputs": [ - { - "name": "pipeline", - "type": "LIVEPORTRAITPIPE", - "link": 58 - }, - { - "name": "source_image", - "type": "IMAGE", - "link": 59 - }, - { - "name": "driving_images", - "type": "IMAGE", - "link": 60 - } - ], - "outputs": [ - { - "name": "cropped_images", - "type": "IMAGE", - "links": [], - "shape": 3, - "slot_index": 0 - }, - { - "name": "full_images", - "type": "IMAGE", - "links": [ - 67, - 68 - ], - "shape": 3, - "slot_index": 1 - } - ], - "properties": { - "Node name for S&R": "LivePortraitProcess" - }, - "widgets_values": [ - 512, - 2.3, - 0, - -0.11, - true, - false, - 1, - false, - 1, - true, - true, - "CPU" - ] - } - ], - "links": [ - [ - 30, - 8, - 0, - 19, - 0, - "IMAGE" - ], - [ - 32, - 19, - 0, - 18, - 0, - "IMAGE" - ], - [ - 58, - 1, - 0, - 30, - 0, - "LIVEPORTRAITPIPE" - ], - [ - 59, - 4, - 0, - 30, - 1, - "IMAGE" - ], - [ - 60, - 8, - 0, - 30, - 2, - "IMAGE" - ], - [ - 64, - 18, - 0, - 23, - 0, - "IMAGE" - ], - [ - 67, - 30, - 1, - 18, - 1, - "IMAGE" - ], - [ - 68, - 30, - 1, - 19, - 1, - "IMAGE" - ] - ], - "groups": [], - "config": {}, - "extra": { - "ds": { - "scale": 0.8264462809917354, - "offset": { - "0": 173.40487670898438, - "1": -0.9636010527610779 - } - } - }, - "version": 0.4 -} \ No newline at end of file diff --git a/examples/liveportrait_video_example.json b/examples/liveportrait_video_example.json new file mode 100644 index 0000000..ef7dd0f --- /dev/null +++ b/examples/liveportrait_video_example.json @@ -0,0 +1,1398 @@ +{ + "last_node_id": 142, + "last_link_id": 318, + "nodes": [ + { + "id": 82, + "type": "MaskPreview+", + "pos": [ + 298, + 387 + ], + "size": { + "0": 210, + "1": 246 + }, + "flags": {}, + "order": 12, + "mode": 0, + "inputs": [ + { + "name": "mask", + "type": "MASK", + "link": 187 + } + ], + "properties": { + "Node name for S&R": "MaskPreview+" + } + }, + { + "id": 99, + "type": "KeypointsToImage", + "pos": [ + 144, + -595 + ], + "size": { + "0": 317.4000244140625, + "1": 26 + }, + "flags": {}, + "order": 16, + "mode": 0, + "inputs": [ + { + "name": "crop_info", + "type": "CROPINFO", + "link": 232 + } + ], + "outputs": [ + { + "name": "keypoints_image", + "type": "IMAGE", + "links": [ + 227 + ], + "shape": 3, + "slot_index": 0 + } + ], + "properties": { + "Node name for S&R": "KeypointsToImage" + } + }, + { + "id": 101, + "type": "LivePortraitCropper", + "pos": [ + 144, + -502 + ], + "size": { + "0": 330, + "1": 246 + }, + "flags": {}, + "order": 13, + "mode": 0, + "inputs": [ + { + "name": "source_image", + "type": "IMAGE", + "link": 289 + }, + { + "name": "opt_driving_images", + "type": "IMAGE", + "link": null, + "slot_index": 1 + } + ], + "outputs": [ + { + "name": "cropped_image", + "type": "IMAGE", + "links": null, + "shape": 3, + "slot_index": 0 + }, + { + "name": "crop_info", + "type": "CROPINFO", + "links": [ + 232, + 281 + ], + "shape": 3, + "slot_index": 1 + } + ], + "properties": { + "Node name for S&R": "LivePortraitCropper" + }, + "widgets_values": [ + 512, + 2.3000000000000003, + 0, + -0.125, + 0, + "CUDA", + "CUDA", + true + ] + }, + { + "id": 126, + "type": "LivePortraitProcess", + "pos": [ + 100, + -140 + ], + "size": { + "0": 367.79998779296875, + "1": 330 + }, + "flags": {}, + "order": 17, + "mode": 0, + "inputs": [ + { + "name": "pipeline", + "type": "LIVEPORTRAITPIPE", + "link": 280 + }, + { + "name": "crop_info", + "type": "CROPINFO", + "link": 281 + }, + { + "name": "source_image", + "type": "IMAGE", + "link": 294 + }, + { + "name": "driving_images", + "type": "IMAGE", + "link": 313 + }, + { + "name": "mask", + "type": "MASK", + "link": 310 + } + ], + "outputs": [ + { + "name": "cropped_images", + "type": "IMAGE", + "links": [ + 285 + ], + "shape": 3, + "slot_index": 0 + }, + { + "name": "full_images", + "type": "IMAGE", + "links": [ + 286 + ], + "shape": 3, + "slot_index": 1 + }, + { + "name": "mask", + "type": "MASK", + "links": null, + "shape": 3 + } + ], + "properties": { + "Node name for S&R": "LivePortraitProcess" + }, + "widgets_values": [ + true, + 0.03, + false, + 0.71, + false, + 1, + true, + true, + "cut" + ] + }, + { + "id": 124, + "type": "GetImageSizeAndCount", + "pos": [ + 569, + 78 + ], + "size": { + "0": 210, + "1": 86 + }, + "flags": {}, + "order": 20, + "mode": 0, + "inputs": [ + { + "name": "image", + "type": "IMAGE", + "link": 286 + } + ], + "outputs": [ + { + "name": "image", + "type": "IMAGE", + "links": [ + 309 + ], + "shape": 3, + "slot_index": 0 + }, + { + "name": "1024 width", + "type": "INT", + "links": null, + "shape": 3 + }, + { + "name": "1024 height", + "type": "INT", + "links": null, + "shape": 3 + }, + { + "name": "46 count", + "type": "INT", + "links": null, + "shape": 3 + } + ], + "properties": { + "Node name for S&R": "GetImageSizeAndCount" + } + }, + { + "id": 107, + "type": "GetImageSizeAndCount", + "pos": [ + 574, + -70 + ], + "size": { + "0": 210, + "1": 86 + }, + "flags": {}, + "order": 19, + "mode": 0, + "inputs": [ + { + "name": "image", + "type": "IMAGE", + "link": 285 + } + ], + "outputs": [ + { + "name": "image", + "type": "IMAGE", + "links": [ + 308 + ], + "shape": 3, + "slot_index": 0 + }, + { + "name": "512 width", + "type": "INT", + "links": null, + "shape": 3 + }, + { + "name": "512 height", + "type": "INT", + "links": null, + "shape": 3 + }, + { + "name": "46 count", + "type": "INT", + "links": null, + "shape": 3 + } + ], + "properties": { + "Node name for S&R": "GetImageSizeAndCount" + } + }, + { + "id": 73, + "type": "VHS_LoadVideo", + "pos": [ + -1117, + -637 + ], + "size": [ + 300.816650390625, + 556.816650390625 + ], + "flags": {}, + "order": 0, + "mode": 0, + "inputs": [ + { + "name": "meta_batch", + "type": "VHS_BatchManager", + "link": null + }, + { + "name": "vae", + "type": "VAE", + "link": null + } + ], + "outputs": [ + { + "name": "IMAGE", + "type": "IMAGE", + "links": [ + 292, + 306 + ], + "shape": 3, + "slot_index": 0 + }, + { + "name": "frame_count", + "type": "INT", + "links": [ + 314 + ], + "shape": 3, + "slot_index": 1 + }, + { + "name": "audio", + "type": "VHS_AUDIO", + "links": null, + "shape": 3 + }, + { + "name": "video_info", + "type": "VHS_VIDEOINFO", + "links": null, + "shape": 3 + } + ], + "properties": { + "Node name for S&R": "VHS_LoadVideo" + }, + "widgets_values": { + "video": "Mordor.mp4", + "force_rate": 0, + "force_size": "Disabled", + "custom_width": 512, + "custom_height": 512, + "frame_load_cap": 64, + "skip_first_frames": 0, + "select_every_nth": 1, + "choose video to upload": "image", + "videopreview": { + "hidden": false, + "paused": false, + "params": { + "frame_load_cap": 64, + "skip_first_frames": 0, + "force_rate": 0, + "filename": "Mordor.mp4", + "type": "input", + "format": "video/mp4", + "select_every_nth": 1 + } + } + } + }, + { + "id": 8, + "type": "VHS_LoadVideo", + "pos": [ + -1095, + 59 + ], + "size": [ + 235.1999969482422, + 467.1999969482422 + ], + "flags": {}, + "order": 7, + "mode": 0, + "inputs": [ + { + "name": "meta_batch", + "type": "VHS_BatchManager", + "link": null + }, + { + "name": "vae", + "type": "VAE", + "link": null + }, + { + "name": "frame_load_cap", + "type": "INT", + "link": 314, + "widget": { + "name": "frame_load_cap" + } + } + ], + "outputs": [ + { + "name": "IMAGE", + "type": "IMAGE", + "links": [ + 311, + 312 + ], + "shape": 3, + "slot_index": 0 + }, + { + "name": "frame_count", + "type": "INT", + "links": null, + "shape": 3 + }, + { + "name": "audio", + "type": "VHS_AUDIO", + "links": null, + "shape": 3 + }, + { + "name": "video_info", + "type": "VHS_VIDEOINFO", + "links": null, + "shape": 3 + } + ], + "properties": { + "Node name for S&R": "VHS_LoadVideo" + }, + "widgets_values": { + "video": "d6.mp4", + "force_rate": 0, + "force_size": "Disabled", + "custom_width": 512, + "custom_height": 512, + "frame_load_cap": 64, + "skip_first_frames": 0, + "select_every_nth": 1, + "choose video to upload": "image", + "videopreview": { + "hidden": false, + "paused": false, + "params": { + "frame_load_cap": 64, + "skip_first_frames": 0, + "force_rate": 0, + "filename": "d6.mp4", + "type": "input", + "format": "video/mp4", + "select_every_nth": 1 + } + } + } + }, + { + "id": 135, + "type": "ImageConcatMulti", + "pos": [ + 834, + -118 + ], + "size": { + "0": 210, + "1": 190 + }, + "flags": {}, + "order": 21, + "mode": 0, + "inputs": [ + { + "name": "image_1", + "type": "IMAGE", + "link": 306 + }, + { + "name": "image_2", + "type": "IMAGE", + "link": 317 + }, + { + "name": "image_3", + "type": "IMAGE", + "link": 308 + }, + { + "name": "image_4", + "type": "IMAGE", + "link": 309 + } + ], + "outputs": [ + { + "name": "images", + "type": "IMAGE", + "links": [ + 303 + ], + "shape": 3, + "slot_index": 0 + } + ], + "properties": {}, + "widgets_values": [ + 4, + "right", + true, + null + ] + }, + { + "id": 138, + "type": "Reroute", + "pos": [ + 718, + 200 + ], + "size": [ + 82, + 26 + ], + "flags": {}, + "order": 15, + "mode": 0, + "inputs": [ + { + "name": "", + "type": "*", + "link": 316 + } + ], + "outputs": [ + { + "name": "IMAGE", + "type": "IMAGE", + "links": [ + 317 + ], + "slot_index": 0 + } + ], + "properties": { + "showOutputText": true, + "horizontal": false + } + }, + { + "id": 137, + "type": "Reroute", + "pos": [ + -140, + 202 + ], + "size": [ + 82, + 26 + ], + "flags": {}, + "order": 11, + "mode": 0, + "inputs": [ + { + "name": "", + "type": "*", + "link": 312 + } + ], + "outputs": [ + { + "name": "IMAGE", + "type": "IMAGE", + "links": [ + 313, + 316 + ], + "slot_index": 0 + } + ], + "properties": { + "showOutputText": true, + "horizontal": false + } + }, + { + "id": 139, + "type": "Reroute", + "pos": [ + -274, + 233 + ], + "size": [ + 82, + 26 + ], + "flags": {}, + "order": 14, + "mode": 0, + "inputs": [ + { + "name": "", + "type": "*", + "link": 318 + } + ], + "outputs": [ + { + "name": "IMAGE", + "type": "IMAGE", + "links": null + } + ], + "properties": { + "showOutputText": true, + "horizontal": false + } + }, + { + "id": 136, + "type": "LivePortraitCropper", + "pos": [ + -777, + 242 + ], + "size": { + "0": 330, + "1": 246 + }, + "flags": {}, + "order": 10, + "mode": 0, + "inputs": [ + { + "name": "source_image", + "type": "IMAGE", + "link": 311 + }, + { + "name": "opt_driving_images", + "type": "IMAGE", + "link": null, + "slot_index": 1 + } + ], + "outputs": [ + { + "name": "cropped_image", + "type": "IMAGE", + "links": [ + 318 + ], + "shape": 3, + "slot_index": 0 + }, + { + "name": "crop_info", + "type": "CROPINFO", + "links": [], + "shape": 3, + "slot_index": 1 + } + ], + "properties": { + "Node name for S&R": "LivePortraitCropper" + }, + "widgets_values": [ + 512, + 2.3000000000000003, + 0, + -0.125, + 0, + false, + "CUDA", + true + ] + }, + { + "id": 83, + "type": "CreateShapeMask", + "pos": [ + -399, + 390 + ], + "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, + 456, + 456 + ] + }, + { + "id": 81, + "type": "GrowMaskWithBlur", + "pos": [ + -49, + 394 + ], + "size": { + "0": 315, + "1": 246 + }, + "flags": {}, + "order": 8, + "mode": 0, + "inputs": [ + { + "name": "mask", + "type": "MASK", + "link": 192, + "slot_index": 0 + } + ], + "outputs": [ + { + "name": "mask", + "type": "MASK", + "links": [ + 187, + 310 + ], + "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, + 16.2, + 1, + 1, + false + ] + }, + { + "id": 134, + "type": "VHS_VideoCombine", + "pos": [ + 1105, + -350 + ], + "size": [ + 1162.5255126953125, + 609.6313781738281 + ], + "flags": {}, + "order": 22, + "mode": 0, + "inputs": [ + { + "name": "images", + "type": "IMAGE", + "link": 303, + "slot_index": 0 + }, + { + "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": true, + "videopreview": { + "hidden": false, + "paused": false, + "params": { + "filename": "LivePortrait_00001.mp4", + "subfolder": "", + "type": "output", + "format": "video/h264-mp4", + "frame_rate": 24 + } + } + } + }, + { + "id": 95, + "type": "VHS_VideoCombine", + "pos": [ + 506, + -856 + ], + "size": [ + 292.72515869140625, + 596.7251586914062 + ], + "flags": {}, + "order": 18, + "mode": 0, + "inputs": [ + { + "name": "images", + "type": "IMAGE", + "link": 227, + "slot_index": 0 + }, + { + "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": 16, + "loop_count": 0, + "filename_prefix": "LivePortraitKeypoints", + "format": "video/h264-mp4", + "pix_fmt": "yuv420p", + "crf": 19, + "save_metadata": true, + "pingpong": false, + "save_output": false, + "videopreview": { + "hidden": false, + "paused": false, + "params": { + "filename": "LivePortraitKeypoints_00001.mp4", + "subfolder": "", + "type": "temp", + "format": "video/h264-mp4", + "frame_rate": 16 + } + } + } + }, + { + "id": 141, + "type": "Note", + "pos": [ + -271, + -30 + ], + "size": { + "0": 292.2458190917969, + "1": 66.36383819580078 + }, + "flags": {}, + "order": 2, + "mode": 0, + "properties": { + "text": "" + }, + "widgets_values": [ + "The input face should be cropped and centered, if it's not you can also try cropping it with this node" + ], + "color": "#432", + "bgcolor": "#653" + }, + { + "id": 1, + "type": "DownloadAndLoadLivePortraitModels", + "pos": [ + -261, + -139 + ], + "size": { + "0": 252, + "1": 58 + }, + "flags": {}, + "order": 3, + "mode": 0, + "outputs": [ + { + "name": "live_portrait_pipe", + "type": "LIVEPORTRAITPIPE", + "links": [ + 280 + ], + "shape": 3, + "slot_index": 0 + } + ], + "properties": { + "Node name for S&R": "DownloadAndLoadLivePortraitModels" + }, + "widgets_values": [ + "auto" + ] + }, + { + "id": 130, + "type": "ImageResizeKJ", + "pos": [ + -608, + -865 + ], + "size": { + "0": 315, + "1": 242 + }, + "flags": {}, + "order": 6, + "mode": 0, + "inputs": [ + { + "name": "image", + "type": "IMAGE", + "link": 292 + }, + { + "name": "get_image_size", + "type": "IMAGE", + "link": null + }, + { + "name": "width_input", + "type": "INT", + "link": null, + "widget": { + "name": "width_input" + } + }, + { + "name": "height_input", + "type": "INT", + "link": null, + "widget": { + "name": "height_input" + } + } + ], + "outputs": [ + { + "name": "IMAGE", + "type": "IMAGE", + "links": [ + 293 + ], + "shape": 3, + "slot_index": 0 + }, + { + "name": "width", + "type": "INT", + "links": null, + "shape": 3 + }, + { + "name": "height", + "type": "INT", + "links": null, + "shape": 3 + } + ], + "properties": { + "Node name for S&R": "ImageResizeKJ" + }, + "widgets_values": [ + 1024, + 1024, + "lanczos", + true, + 2, + 0, + 0 + ] + }, + { + "id": 128, + "type": "GetImageSizeAndCount", + "pos": [ + -110, + -508 + ], + "size": { + "0": 210, + "1": 86 + }, + "flags": {}, + "order": 9, + "mode": 0, + "inputs": [ + { + "name": "image", + "type": "IMAGE", + "link": 293 + } + ], + "outputs": [ + { + "name": "image", + "type": "IMAGE", + "links": [ + 289, + 294 + ], + "shape": 3, + "slot_index": 0 + }, + { + "name": "1024 width", + "type": "INT", + "links": null, + "shape": 3 + }, + { + "name": "1024 height", + "type": "INT", + "links": null, + "shape": 3 + }, + { + "name": "46 count", + "type": "INT", + "links": null, + "shape": 3 + } + ], + "properties": { + "Node name for S&R": "GetImageSizeAndCount" + } + }, + { + "id": 140, + "type": "Note", + "pos": [ + -771, + 532 + ], + "size": { + "0": 292.2458190917969, + "1": 66.36383819580078 + }, + "flags": {}, + "order": 4, + "mode": 0, + "properties": { + "text": "" + }, + "widgets_values": [ + "The input face should be cropped and centered, if it's not you can also try cropping it with this node" + ], + "color": "#432", + "bgcolor": "#653" + }, + { + "id": 142, + "type": "Note", + "pos": [ + -41, + 280 + ], + "size": { + "0": 292.2458190917969, + "1": 66.36383819580078 + }, + "flags": {}, + "order": 5, + "mode": 0, + "properties": { + "text": "" + }, + "widgets_values": [ + "The mask is ONLY used for the compositing at very end. Only single mask is supported. If not provided, the default square mask is used." + ], + "color": "#432", + "bgcolor": "#653" + } + ], + "links": [ + [ + 187, + 81, + 0, + 82, + 0, + "MASK" + ], + [ + 192, + 83, + 0, + 81, + 0, + "MASK" + ], + [ + 227, + 99, + 0, + 95, + 0, + "IMAGE" + ], + [ + 232, + 101, + 1, + 99, + 0, + "CROPINFO" + ], + [ + 280, + 1, + 0, + 126, + 0, + "LIVEPORTRAITPIPE" + ], + [ + 281, + 101, + 1, + 126, + 1, + "CROPINFO" + ], + [ + 285, + 126, + 0, + 107, + 0, + "IMAGE" + ], + [ + 286, + 126, + 1, + 124, + 0, + "IMAGE" + ], + [ + 289, + 128, + 0, + 101, + 0, + "IMAGE" + ], + [ + 292, + 73, + 0, + 130, + 0, + "IMAGE" + ], + [ + 293, + 130, + 0, + 128, + 0, + "IMAGE" + ], + [ + 294, + 128, + 0, + 126, + 2, + "IMAGE" + ], + [ + 303, + 135, + 0, + 134, + 0, + "IMAGE" + ], + [ + 306, + 73, + 0, + 135, + 0, + "IMAGE" + ], + [ + 308, + 107, + 0, + 135, + 2, + "IMAGE" + ], + [ + 309, + 124, + 0, + 135, + 3, + "IMAGE" + ], + [ + 310, + 81, + 0, + 126, + 4, + "MASK" + ], + [ + 311, + 8, + 0, + 136, + 0, + "IMAGE" + ], + [ + 312, + 8, + 0, + 137, + 0, + "*" + ], + [ + 313, + 137, + 0, + 126, + 3, + "IMAGE" + ], + [ + 314, + 73, + 1, + 8, + 2, + "INT" + ], + [ + 316, + 137, + 0, + 138, + 0, + "*" + ], + [ + 317, + 138, + 0, + 135, + 1, + "IMAGE" + ], + [ + 318, + 136, + 0, + 139, + 0, + "*" + ] + ], + "groups": [], + "config": {}, + "extra": { + "ds": { + "scale": 0.6209213230591553, + "offset": { + "0": 1570.09716796875, + "1": 1008.5413818359375 + } + } + }, + "version": 0.4 +} \ No newline at end of file diff --git a/nodes.py b/nodes.py index aafb7f3..a7454d2 100644 --- a/nodes.py +++ b/nodes.py @@ -69,8 +69,9 @@ class DownloadAndLoadLivePortraitModels: [ "fp16", "fp32", + "auto", ], - {"default": "fp16"}, + {"default": "auto"}, ), }, } @@ -84,6 +85,23 @@ class DownloadAndLoadLivePortraitModels: device = mm.get_torch_device() mm.soft_empty_cache() + if precision == 'auto': + try: + if mm.is_device_mps(device): + print("LivePortrait using fp32 for MPS") + dtype = 'fp32' + elif mm.should_use_fp16(): + print("LivePortrait using fp16") + dtype = 'fp16' + else: + print("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}") + pbar = comfy.utils.ProgressBar(3) download_path = os.path.join(folder_paths.models_dir, "liveportrait")