Add dtype choice

This commit is contained in:
kijai
2024-07-08 15:55:15 +03:00
parent a8aabdd66d
commit 9826cf083f
2 changed files with 142 additions and 116 deletions
+128 -114
View File
@@ -2,35 +2,6 @@
"last_node_id": 31,
"last_link_id": 68,
"nodes": [
{
"id": 1,
"type": "DownloadAndLoadLivePortraitModels",
"pos": [
144,
218
],
"size": {
"0": 252,
"1": 33.333343505859375
},
"flags": {},
"order": 0,
"mode": 0,
"outputs": [
{
"name": "live_portrait_pipe",
"type": "LIVEPORTRAITPIPE",
"links": [
58
],
"shape": 3,
"slot_index": 0
}
],
"properties": {
"Node name for S&R": "DownloadAndLoadLivePortraitModels"
}
},
{
"id": 4,
"type": "LoadImage",
@@ -43,7 +14,7 @@
"1": 331.60894775390625
},
"flags": {},
"order": 1,
"order": 0,
"mode": 0,
"outputs": [
{
@@ -70,85 +41,6 @@
"image"
]
},
{
"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
}
],
"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": 32,
"skip_first_frames": 0,
"select_every_nth": 1,
"choose video to upload": "image",
"videopreview": {
"hidden": false,
"paused": false,
"params": {
"frame_load_cap": 32,
"skip_first_frames": 0,
"force_rate": 0,
"filename": "d3.mp4",
"type": "input",
"format": "video/mp4",
"select_every_nth": 1
}
}
}
},
{
"id": 19,
"type": "ImageResizeKJ",
@@ -281,7 +173,7 @@
],
"size": [
1253.234130859375,
920.6170654296875
940.6170654296875
],
"flags": {},
"order": 6,
@@ -301,6 +193,11 @@
"name": "meta_batch",
"type": "VHS_BatchManager",
"link": null
},
{
"name": "vae",
"type": "VAE",
"link": null
}
],
"outputs": [
@@ -328,10 +225,11 @@
"hidden": false,
"paused": false,
"params": {
"filename": "LivePortrait_00005.mp4",
"filename": "LivePortrait_00004.mp4",
"subfolder": "",
"type": "temp",
"format": "video/h264-mp4"
"format": "video/h264-mp4",
"frame_rate": 24
}
}
}
@@ -402,6 +300,122 @@
true,
true
]
},
{
"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
}
}
}
}
],
"links": [
@@ -476,8 +490,8 @@
"ds": {
"scale": 0.8264462809917354,
"offset": {
"0": 128.11993408203125,
"1": 16.40328598022461
"0": 96.80999755859375,
"1": 39.060001373291016
}
}
},
+14 -2
View File
@@ -95,6 +95,15 @@ class DownloadAndLoadLivePortraitModels:
def INPUT_TYPES(s):
return {"required": {
},
"optional": {
"precision": (
[
'fp16',
'fp32',
], {
"default": 'fp16'
}),
}
}
RETURN_TYPES = ("LIVEPORTRAITPIPE",)
@@ -102,7 +111,7 @@ class DownloadAndLoadLivePortraitModels:
FUNCTION = "loadmodel"
CATEGORY = "LivePortrait"
def loadmodel(self):
def loadmodel(self, precision='fp16'):
device = mm.get_torch_device()
mm.soft_empty_cache()
@@ -200,7 +209,10 @@ class DownloadAndLoadLivePortraitModels:
self.warping_module,
self.spade_generator,
self.stich_retargeting_module,
InferenceConfig(device_id=device)
InferenceConfig(
device_id=device,
flag_use_half_precision = True if precision == 'fp16' else False
)
)
return (pipeline,)