Support PuLID-FLUX

This commit is contained in:
YunjieYu
2025-01-15 12:34:55 +08:00
parent 9bc454e309
commit 992a5b483c
5 changed files with 1943 additions and 15 deletions
+12 -9
View File
@@ -6,12 +6,15 @@ Timestep Embedding Aware Cache ([TeaCache](https://github.com/ali-vilab/TeaCache
TeaCache has now been integrated into ComfyUI and is compatible with the ComfyUI native nodes. ComfyUI-TeaCache is easy to use, simply connect the TeaCache node with the ComfyUI native nodes for seamless usage.
## Updates
- Jan 14 2025: ComfyUI-TeaCache supports Compile Model and fixs a bug that TeaCache keeps forever even if we remove/bypass the node:
- Jan 15 2025: Thanks [@fantacytyx](https://github.com/fantacytyx), ComfyUI-TeaCache supports PuLID-FLUX and fixes bug about rel_l1_thresh:
- It can achieve a 1.2x lossless speedup and a 1.7x speedup without much visual quality degradation.
- Fixes a bug about rel_l1_thresh, when there are multiple TeaCache nodes in a workflow, the rel_l1_thresh value is always the value of the last TeaCache node.
- Jan 14 2025: ComfyUI-TeaCache supports Compile Model and fixes a bug that TeaCache keeps forever even if we remove/bypass the node:
- Support Compile Model, now it can bring a faster inference when you add Compile Model node!
- Fixs a bug related to usability, now we can go back to the workflow state without TeaCache if we remove/bypass TeaCache node.
- Fixes a bug related to usability, now we can go back to the workflow state without TeaCache if we remove/bypass TeaCache node.
- Jan 13 2025: Thanks [@fantacytyx](https://github.com/fantacytyx), ComfyUI-TeaCache remove the Steps setting from the node:
- Now, it works fine even if there are multiple sampling nodes with different sampling steps in the workflow.
- Fixs a bug, RuntimeError: The size of tensor a must match the size of tensor b at non-singleton dimension.
- Fixes a bug, RuntimeError: The size of tensor a must match the size of tensor b at non-singleton dimension.
- Jan 10 2025: ComfyUI-TeaCache supports LTX-Video:
- It can achieve a 1.4x lossless speedup and a 1.7x speedup without much visual quality degradation.
- Support Text to Video and Image to Video!
@@ -32,18 +35,18 @@ Installation via ComfyUI-Manager is preferred. Simply search for ComfyUI-TeaCach
### TeaCache
To use TeaCache node, simply add `TeaCache For Img Gen` or `TeaCache For Vid Gen` node to your workflow after `Load Diffusion Model` node or `Load LoRA` node (if you need LoRA). The following table gives the recommended rel_l1_thresh ​for different models:
| | FLUX | HunyuanVideo | LTX-Video |
|:---------------------:|:----------------------------:|:---------------------:|:---------------------:|
| rel_l1_thresh | 0.4 | 0.15 | 0.06 |
| speedup | ~2x | ~2x | ~1.7x |
| | FLUX | PuLID-FLUX | HunyuanVideo | LTX-Video |
|:---------------:|:-----------------:|:------------------:|:------------------:|:---------------:|
| rel_l1_thresh | 0.4 | 0.4 | 0.15 | 0.06 |
| speedup | ~2x | ~1.7x | ~2x | ~1.7x |
The demo workflows ([teacache_flux](./examples/teacache_flux.json), [teacache_hunyuanvideo](./examples/teacache_hunyuanvideo.json), [teacache_ltx_video](./examples/teacache_ltx_video.json)) are placed in examples folder.
The demo workflows ([teacache_flux](./examples/teacache_flux.json), [teacache_pulid_flux](./examples/teacache_pulid_flux.json), [teacache_hunyuanvideo](./examples/teacache_hunyuanvideo.json), [teacache_ltx_video](./examples/teacache_ltx_video.json)) are placed in examples folder.
### Compile Model
To use Compile Model node, simply add `Compile Model` node to your workflow after TeaCache node. Compile Model uses `torch.compile` to enhance the model performance by compiling model into more efficient intermediate representations (IRs). This compilation process leverages backend compilers to generate optimized code, which can significantly speed up inference. The compilation may take long time when you run the workflow at first, but once it is compiled, inference is extremely fast. The usage is shown below:
![](./assets/compile.png)
The demo workflows ([teacache_compile_flux](./examples/teacache_compile_flux.json), [teacache_compile_hunyuanvideo](./examples/teacache_compile_hunyuanvideo.json), [teacache_compile_ltx_video](./examples/teacache_compile_ltx_video.json)) are also placed in examples folder.
The demo workflows ([teacache_compile_flux](./examples/teacache_compile_flux.json), [teacache_compile_pulid_flux](./examples/teacache_compile_pulid_flux.json), [teacache_compile_hunyuanvideo](./examples/teacache_compile_hunyuanvideo.json), [teacache_compile_ltx_video](./examples/teacache_compile_ltx_video.json)) are also placed in examples folder.
## Demo
+987
View File
@@ -0,0 +1,987 @@
{
"last_node_id": 73,
"last_link_id": 154,
"nodes": [
{
"id": 26,
"type": "FluxGuidance",
"pos": [
372,
-171
],
"size": [
317.4000244140625,
58
],
"flags": {
"collapsed": false
},
"order": 13,
"mode": 0,
"inputs": [
{
"name": "conditioning",
"type": "CONDITIONING",
"link": 41
}
],
"outputs": [
{
"name": "CONDITIONING",
"type": "CONDITIONING",
"links": [
107
],
"slot_index": 0,
"shape": 3
}
],
"properties": {
"Node name for S&R": "FluxGuidance"
},
"widgets_values": [
3.5
],
"color": "#233",
"bgcolor": "#355"
},
{
"id": 6,
"type": "CLIPTextEncode",
"pos": [
372,
-55
],
"size": [
422.84503173828125,
164.31304931640625
],
"flags": {},
"order": 10,
"mode": 0,
"inputs": [
{
"name": "clip",
"type": "CLIP",
"link": 132
}
],
"outputs": [
{
"name": "CONDITIONING",
"type": "CONDITIONING",
"links": [
41
],
"slot_index": 0
}
],
"title": "CLIP Text Encode (Positive Prompt)",
"properties": {
"Node name for S&R": "CLIPTextEncode"
},
"widgets_values": [
"Half body portrait of 60 years old guy, with an surprised expression, he is lost in vectors of AI models, sourounded by PC monitors and many cables, on his tshirt is a text with words printed in Arial font:\"PuLID Flux\", detailed, glowy background, photorealistic style with skin inperfections, looks like shot with an smartphone, skin details without plastic look, ASUS Keyboard.",
true
],
"color": "#232",
"bgcolor": "#353"
},
{
"id": 27,
"type": "EmptySD3LatentImage",
"pos": [
383,
155
],
"size": [
315,
106
],
"flags": {},
"order": 0,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "LATENT",
"type": "LATENT",
"links": [
86
],
"slot_index": 0,
"shape": 3
}
],
"properties": {
"Node name for S&R": "EmptySD3LatentImage"
},
"widgets_values": [
768,
1024,
1
],
"color": "#323",
"bgcolor": "#535"
},
{
"id": 16,
"type": "KSamplerSelect",
"pos": [
384,
313
],
"size": [
315,
58
],
"flags": {},
"order": 1,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "SAMPLER",
"type": "SAMPLER",
"links": [
85
],
"slot_index": 0,
"shape": 3
}
],
"properties": {
"Node name for S&R": "KSamplerSelect"
},
"widgets_values": [
"euler"
]
},
{
"id": 54,
"type": "LoadImage",
"pos": [
729,
-490
],
"size": [
315,
314
],
"flags": {},
"order": 2,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
126
],
"slot_index": 0,
"shape": 3
},
{
"name": "MASK",
"type": "MASK",
"links": null,
"shape": 3
}
],
"properties": {
"Node name for S&R": "LoadImage"
},
"widgets_values": [
"einstein.jpg",
"image"
]
},
{
"id": 53,
"type": "PulidFluxInsightFaceLoader",
"pos": [
822,
-80
],
"size": [
365.4000244140625,
58
],
"flags": {},
"order": 3,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "FACEANALYSIS",
"type": "FACEANALYSIS",
"links": [
124
],
"slot_index": 0,
"shape": 3
}
],
"properties": {
"Node name for S&R": "PulidFluxInsightFaceLoader"
},
"widgets_values": [
"CPU"
]
},
{
"id": 51,
"type": "PulidFluxEvaClipLoader",
"pos": [
845,
52
],
"size": [
327.5999755859375,
26
],
"flags": {},
"order": 4,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "EVA_CLIP",
"type": "EVA_CLIP",
"links": [
123
],
"slot_index": 0,
"shape": 3
}
],
"properties": {
"Node name for S&R": "PulidFluxEvaClipLoader"
},
"widgets_values": []
},
{
"id": 45,
"type": "PulidFluxModelLoader",
"pos": [
846,
137
],
"size": [
315,
58
],
"flags": {},
"order": 5,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "PULIDFLUX",
"type": "PULIDFLUX",
"links": [
125
],
"slot_index": 0,
"shape": 3
}
],
"properties": {
"Node name for S&R": "PulidFluxModelLoader"
},
"widgets_values": [
"pulid_flux_v0.9.0.safetensors"
]
},
{
"id": 48,
"type": "SamplerCustomAdvanced",
"pos": [
1205,
-39
],
"size": [
355.20001220703125,
326
],
"flags": {},
"order": 17,
"mode": 0,
"inputs": [
{
"name": "noise",
"type": "NOISE",
"link": 84
},
{
"name": "guider",
"type": "GUIDER",
"link": 83
},
{
"name": "sampler",
"type": "SAMPLER",
"link": 85
},
{
"name": "sigmas",
"type": "SIGMAS",
"link": 93
},
{
"name": "latent_image",
"type": "LATENT",
"link": 86
}
],
"outputs": [
{
"name": "output",
"type": "LATENT",
"links": [
87
],
"slot_index": 0,
"shape": 3
},
{
"name": "denoised_output",
"type": "LATENT",
"links": null,
"shape": 3
}
],
"properties": {
"Node name for S&R": "SamplerCustomAdvanced"
},
"widgets_values": []
},
{
"id": 49,
"type": "VAEDecode",
"pos": [
1263,
-137
],
"size": [
210,
46
],
"flags": {},
"order": 18,
"mode": 0,
"inputs": [
{
"name": "samples",
"type": "LATENT",
"link": 87
},
{
"name": "vae",
"type": "VAE",
"link": 88
}
],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
89
],
"slot_index": 0,
"shape": 3
}
],
"properties": {
"Node name for S&R": "VAEDecode"
},
"widgets_values": []
},
{
"id": 50,
"type": "PreviewImage",
"pos": [
1587,
-169
],
"size": [
841.524169921875,
698.3060302734375
],
"flags": {},
"order": 19,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 89
}
],
"outputs": [],
"properties": {
"Node name for S&R": "PreviewImage"
},
"widgets_values": []
},
{
"id": 64,
"type": "DualCLIPLoader",
"pos": [
8,
124
],
"size": [
315,
106
],
"flags": {},
"order": 6,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "CLIP",
"type": "CLIP",
"links": [
132
],
"slot_index": 0,
"shape": 3
}
],
"properties": {
"Node name for S&R": "DualCLIPLoader"
},
"widgets_values": [
"t5xxl_fp16.safetensors",
"clip_l.safetensors",
"flux"
]
},
{
"id": 10,
"type": "VAELoader",
"pos": [
12,
285
],
"size": [
311.81634521484375,
60.429901123046875
],
"flags": {},
"order": 7,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "VAE",
"type": "VAE",
"links": [
88
],
"slot_index": 0,
"shape": 3
}
],
"properties": {
"Node name for S&R": "VAELoader"
},
"widgets_values": [
"ae.safetensors"
]
},
{
"id": 25,
"type": "RandomNoise",
"pos": [
6,
-135
],
"size": [
315,
82
],
"flags": {},
"order": 8,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "NOISE",
"type": "NOISE",
"links": [
84
],
"slot_index": 0,
"shape": 3
}
],
"properties": {
"Node name for S&R": "RandomNoise"
},
"widgets_values": [
872612149093450,
"randomize"
],
"color": "#2a363b",
"bgcolor": "#3f5159"
},
{
"id": 17,
"type": "BasicScheduler",
"pos": [
383.7604675292969,
447.450927734375
],
"size": [
315,
106
],
"flags": {
"collapsed": false
},
"order": 11,
"mode": 0,
"inputs": [
{
"name": "model",
"type": "MODEL",
"link": 141,
"slot_index": 0
}
],
"outputs": [
{
"name": "SIGMAS",
"type": "SIGMAS",
"links": [
93
],
"slot_index": 0,
"shape": 3
}
],
"properties": {
"Node name for S&R": "BasicScheduler"
},
"widgets_values": [
"simple",
20,
1
]
},
{
"id": 63,
"type": "UNETLoader",
"pos": [
6,
-7
],
"size": [
315,
82
],
"flags": {},
"order": 9,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "MODEL",
"type": "MODEL",
"links": [
141,
147
],
"slot_index": 0,
"shape": 3
}
],
"properties": {
"Node name for S&R": "UNETLoader"
},
"widgets_values": [
"flux1-dev.safetensors",
"default"
]
},
{
"id": 47,
"type": "BasicGuider",
"pos": [
1269.1497802734375,
353.4516296386719
],
"size": [
241.79998779296875,
46
],
"flags": {},
"order": 16,
"mode": 0,
"inputs": [
{
"name": "model",
"type": "MODEL",
"link": 154
},
{
"name": "conditioning",
"type": "CONDITIONING",
"link": 107
}
],
"outputs": [
{
"name": "GUIDER",
"type": "GUIDER",
"links": [
83
],
"slot_index": 0,
"shape": 3
}
],
"properties": {
"Node name for S&R": "BasicGuider"
},
"widgets_values": []
},
{
"id": 62,
"type": "ApplyPulidFlux",
"pos": [
842,
258
],
"size": [
315,
346
],
"flags": {},
"order": 12,
"mode": 0,
"inputs": [
{
"name": "model",
"type": "MODEL",
"link": 147
},
{
"name": "pulid_flux",
"type": "PULIDFLUX",
"link": 125
},
{
"name": "eva_clip",
"type": "EVA_CLIP",
"link": 123
},
{
"name": "face_analysis",
"type": "FACEANALYSIS",
"link": 124
},
{
"name": "image",
"type": "IMAGE",
"link": 126
},
{
"name": "attn_mask",
"type": "MASK",
"link": null,
"shape": 7
},
{
"name": "prior_image",
"type": "IMAGE",
"link": null,
"shape": 7
}
],
"outputs": [
{
"name": "MODEL",
"type": "MODEL",
"links": [
148
],
"slot_index": 0,
"shape": 3
}
],
"properties": {
"Node name for S&R": "ApplyPulidFlux"
},
"widgets_values": [
1,
0,
1,
"mean",
1,
0,
1000,
true
]
},
{
"id": 71,
"type": "TeaCacheForImgGen",
"pos": [
1228.98779296875,
504.7470397949219
],
"size": [
315,
82
],
"flags": {},
"order": 14,
"mode": 0,
"inputs": [
{
"name": "model",
"type": "MODEL",
"link": 148
}
],
"outputs": [
{
"name": "MODEL",
"type": "MODEL",
"links": [
153
],
"slot_index": 0
}
],
"properties": {
"Node name for S&R": "TeaCacheForImgGen"
},
"widgets_values": [
"flux",
0.4
]
},
{
"id": 73,
"type": "CompileModel",
"pos": [
1228.98779296875,
650.4599609375
],
"size": [
315,
130
],
"flags": {},
"order": 15,
"mode": 0,
"inputs": [
{
"name": "model",
"type": "MODEL",
"link": 153
}
],
"outputs": [
{
"name": "MODEL",
"type": "MODEL",
"links": [
154
],
"slot_index": 0
}
],
"properties": {
"Node name for S&R": "CompileModel"
},
"widgets_values": [
"default",
"inductor",
false,
false
]
}
],
"links": [
[
41,
6,
0,
26,
0,
"CONDITIONING"
],
[
83,
47,
0,
48,
1,
"GUIDER"
],
[
84,
25,
0,
48,
0,
"NOISE"
],
[
85,
16,
0,
48,
2,
"SAMPLER"
],
[
86,
27,
0,
48,
4,
"LATENT"
],
[
87,
48,
0,
49,
0,
"LATENT"
],
[
88,
10,
0,
49,
1,
"VAE"
],
[
89,
49,
0,
50,
0,
"IMAGE"
],
[
93,
17,
0,
48,
3,
"SIGMAS"
],
[
107,
26,
0,
47,
1,
"CONDITIONING"
],
[
123,
51,
0,
62,
2,
"EVA_CLIP"
],
[
124,
53,
0,
62,
3,
"FACEANALYSIS"
],
[
125,
45,
0,
62,
1,
"PULIDFLUX"
],
[
126,
54,
0,
62,
4,
"IMAGE"
],
[
132,
64,
0,
6,
0,
"CLIP"
],
[
141,
63,
0,
17,
0,
"MODEL"
],
[
147,
63,
0,
62,
0,
"MODEL"
],
[
148,
62,
0,
71,
0,
"MODEL"
],
[
153,
71,
0,
73,
0,
"MODEL"
],
[
154,
73,
0,
47,
0,
"MODEL"
]
],
"groups": [],
"config": {},
"extra": {
"ds": {
"scale": 0.6209213230591552,
"offset": [
46.61470785893289,
165.54519028313396
]
}
},
"version": 0.4
}
+938
View File
@@ -0,0 +1,938 @@
{
"last_node_id": 72,
"last_link_id": 152,
"nodes": [
{
"id": 26,
"type": "FluxGuidance",
"pos": [
372,
-171
],
"size": [
317.4000244140625,
58
],
"flags": {
"collapsed": false
},
"order": 13,
"mode": 0,
"inputs": [
{
"name": "conditioning",
"type": "CONDITIONING",
"link": 41
}
],
"outputs": [
{
"name": "CONDITIONING",
"type": "CONDITIONING",
"links": [
107
],
"slot_index": 0,
"shape": 3
}
],
"properties": {
"Node name for S&R": "FluxGuidance"
},
"widgets_values": [
3.5
],
"color": "#233",
"bgcolor": "#355"
},
{
"id": 6,
"type": "CLIPTextEncode",
"pos": [
372,
-55
],
"size": [
422.84503173828125,
164.31304931640625
],
"flags": {},
"order": 10,
"mode": 0,
"inputs": [
{
"name": "clip",
"type": "CLIP",
"link": 132
}
],
"outputs": [
{
"name": "CONDITIONING",
"type": "CONDITIONING",
"links": [
41
],
"slot_index": 0
}
],
"title": "CLIP Text Encode (Positive Prompt)",
"properties": {
"Node name for S&R": "CLIPTextEncode"
},
"widgets_values": [
"Half body portrait of 60 years old guy, with an surprised expression, he is lost in vectors of AI models, sourounded by PC monitors and many cables, on his tshirt is a text with words printed in Arial font:\"PuLID Flux\", detailed, glowy background, photorealistic style with skin inperfections, looks like shot with an smartphone, skin details without plastic look, ASUS Keyboard.",
true
],
"color": "#232",
"bgcolor": "#353"
},
{
"id": 27,
"type": "EmptySD3LatentImage",
"pos": [
383,
155
],
"size": [
315,
106
],
"flags": {},
"order": 0,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "LATENT",
"type": "LATENT",
"links": [
86
],
"slot_index": 0,
"shape": 3
}
],
"properties": {
"Node name for S&R": "EmptySD3LatentImage"
},
"widgets_values": [
768,
1024,
1
],
"color": "#323",
"bgcolor": "#535"
},
{
"id": 16,
"type": "KSamplerSelect",
"pos": [
384,
313
],
"size": [
315,
58
],
"flags": {},
"order": 1,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "SAMPLER",
"type": "SAMPLER",
"links": [
85
],
"slot_index": 0,
"shape": 3
}
],
"properties": {
"Node name for S&R": "KSamplerSelect"
},
"widgets_values": [
"euler"
]
},
{
"id": 54,
"type": "LoadImage",
"pos": [
729,
-490
],
"size": [
315,
314
],
"flags": {},
"order": 2,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
126
],
"slot_index": 0,
"shape": 3
},
{
"name": "MASK",
"type": "MASK",
"links": null,
"shape": 3
}
],
"properties": {
"Node name for S&R": "LoadImage"
},
"widgets_values": [
"einstein.jpg",
"image"
]
},
{
"id": 53,
"type": "PulidFluxInsightFaceLoader",
"pos": [
822,
-80
],
"size": [
365.4000244140625,
58
],
"flags": {},
"order": 3,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "FACEANALYSIS",
"type": "FACEANALYSIS",
"links": [
124
],
"slot_index": 0,
"shape": 3
}
],
"properties": {
"Node name for S&R": "PulidFluxInsightFaceLoader"
},
"widgets_values": [
"CPU"
]
},
{
"id": 51,
"type": "PulidFluxEvaClipLoader",
"pos": [
845,
52
],
"size": [
327.5999755859375,
26
],
"flags": {},
"order": 4,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "EVA_CLIP",
"type": "EVA_CLIP",
"links": [
123
],
"slot_index": 0,
"shape": 3
}
],
"properties": {
"Node name for S&R": "PulidFluxEvaClipLoader"
},
"widgets_values": []
},
{
"id": 45,
"type": "PulidFluxModelLoader",
"pos": [
846,
137
],
"size": [
315,
58
],
"flags": {},
"order": 5,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "PULIDFLUX",
"type": "PULIDFLUX",
"links": [
125
],
"slot_index": 0,
"shape": 3
}
],
"properties": {
"Node name for S&R": "PulidFluxModelLoader"
},
"widgets_values": [
"pulid_flux_v0.9.0.safetensors"
]
},
{
"id": 48,
"type": "SamplerCustomAdvanced",
"pos": [
1205,
-39
],
"size": [
355.20001220703125,
326
],
"flags": {},
"order": 16,
"mode": 0,
"inputs": [
{
"name": "noise",
"type": "NOISE",
"link": 84
},
{
"name": "guider",
"type": "GUIDER",
"link": 83
},
{
"name": "sampler",
"type": "SAMPLER",
"link": 85
},
{
"name": "sigmas",
"type": "SIGMAS",
"link": 93
},
{
"name": "latent_image",
"type": "LATENT",
"link": 86
}
],
"outputs": [
{
"name": "output",
"type": "LATENT",
"links": [
87
],
"slot_index": 0,
"shape": 3
},
{
"name": "denoised_output",
"type": "LATENT",
"links": null,
"shape": 3
}
],
"properties": {
"Node name for S&R": "SamplerCustomAdvanced"
},
"widgets_values": []
},
{
"id": 49,
"type": "VAEDecode",
"pos": [
1263,
-137
],
"size": [
210,
46
],
"flags": {},
"order": 17,
"mode": 0,
"inputs": [
{
"name": "samples",
"type": "LATENT",
"link": 87
},
{
"name": "vae",
"type": "VAE",
"link": 88
}
],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
89
],
"slot_index": 0,
"shape": 3
}
],
"properties": {
"Node name for S&R": "VAEDecode"
},
"widgets_values": []
},
{
"id": 50,
"type": "PreviewImage",
"pos": [
1587,
-169
],
"size": [
841.524169921875,
698.3060302734375
],
"flags": {},
"order": 18,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 89
}
],
"outputs": [],
"properties": {
"Node name for S&R": "PreviewImage"
},
"widgets_values": []
},
{
"id": 64,
"type": "DualCLIPLoader",
"pos": [
8,
124
],
"size": [
315,
106
],
"flags": {},
"order": 6,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "CLIP",
"type": "CLIP",
"links": [
132
],
"slot_index": 0,
"shape": 3
}
],
"properties": {
"Node name for S&R": "DualCLIPLoader"
},
"widgets_values": [
"t5xxl_fp16.safetensors",
"clip_l.safetensors",
"flux"
]
},
{
"id": 10,
"type": "VAELoader",
"pos": [
12,
285
],
"size": [
311.81634521484375,
60.429901123046875
],
"flags": {},
"order": 7,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "VAE",
"type": "VAE",
"links": [
88
],
"slot_index": 0,
"shape": 3
}
],
"properties": {
"Node name for S&R": "VAELoader"
},
"widgets_values": [
"ae.safetensors"
]
},
{
"id": 25,
"type": "RandomNoise",
"pos": [
6,
-135
],
"size": [
315,
82
],
"flags": {},
"order": 8,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "NOISE",
"type": "NOISE",
"links": [
84
],
"slot_index": 0,
"shape": 3
}
],
"properties": {
"Node name for S&R": "RandomNoise"
},
"widgets_values": [
872612149093450,
"randomize"
],
"color": "#2a363b",
"bgcolor": "#3f5159"
},
{
"id": 17,
"type": "BasicScheduler",
"pos": [
383.7604675292969,
447.450927734375
],
"size": [
315,
106
],
"flags": {
"collapsed": false
},
"order": 11,
"mode": 0,
"inputs": [
{
"name": "model",
"type": "MODEL",
"link": 141,
"slot_index": 0
}
],
"outputs": [
{
"name": "SIGMAS",
"type": "SIGMAS",
"links": [
93
],
"slot_index": 0,
"shape": 3
}
],
"properties": {
"Node name for S&R": "BasicScheduler"
},
"widgets_values": [
"simple",
20,
1
]
},
{
"id": 63,
"type": "UNETLoader",
"pos": [
6,
-7
],
"size": [
315,
82
],
"flags": {},
"order": 9,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "MODEL",
"type": "MODEL",
"links": [
141,
147
],
"slot_index": 0,
"shape": 3
}
],
"properties": {
"Node name for S&R": "UNETLoader"
},
"widgets_values": [
"flux1-dev.safetensors",
"default"
]
},
{
"id": 47,
"type": "BasicGuider",
"pos": [
1269.1497802734375,
353.4516296386719
],
"size": [
241.79998779296875,
46
],
"flags": {},
"order": 15,
"mode": 0,
"inputs": [
{
"name": "model",
"type": "MODEL",
"link": 152
},
{
"name": "conditioning",
"type": "CONDITIONING",
"link": 107
}
],
"outputs": [
{
"name": "GUIDER",
"type": "GUIDER",
"links": [
83
],
"slot_index": 0,
"shape": 3
}
],
"properties": {
"Node name for S&R": "BasicGuider"
},
"widgets_values": []
},
{
"id": 62,
"type": "ApplyPulidFlux",
"pos": [
842,
258
],
"size": [
315,
346
],
"flags": {},
"order": 12,
"mode": 0,
"inputs": [
{
"name": "model",
"type": "MODEL",
"link": 147
},
{
"name": "pulid_flux",
"type": "PULIDFLUX",
"link": 125
},
{
"name": "eva_clip",
"type": "EVA_CLIP",
"link": 123
},
{
"name": "face_analysis",
"type": "FACEANALYSIS",
"link": 124
},
{
"name": "image",
"type": "IMAGE",
"link": 126
},
{
"name": "attn_mask",
"type": "MASK",
"link": null,
"shape": 7
},
{
"name": "prior_image",
"type": "IMAGE",
"link": null,
"shape": 7
}
],
"outputs": [
{
"name": "MODEL",
"type": "MODEL",
"links": [
148
],
"slot_index": 0,
"shape": 3
}
],
"properties": {
"Node name for S&R": "ApplyPulidFlux"
},
"widgets_values": [
1,
0,
1,
"mean",
1,
0,
1000,
true
]
},
{
"id": 71,
"type": "TeaCacheForImgGen",
"pos": [
1228.98779296875,
504.7470397949219
],
"size": [
315,
82
],
"flags": {},
"order": 14,
"mode": 0,
"inputs": [
{
"name": "model",
"type": "MODEL",
"link": 148
}
],
"outputs": [
{
"name": "MODEL",
"type": "MODEL",
"links": [
152
],
"slot_index": 0
}
],
"properties": {
"Node name for S&R": "TeaCacheForImgGen"
},
"widgets_values": [
"flux",
0.4
]
}
],
"links": [
[
41,
6,
0,
26,
0,
"CONDITIONING"
],
[
83,
47,
0,
48,
1,
"GUIDER"
],
[
84,
25,
0,
48,
0,
"NOISE"
],
[
85,
16,
0,
48,
2,
"SAMPLER"
],
[
86,
27,
0,
48,
4,
"LATENT"
],
[
87,
48,
0,
49,
0,
"LATENT"
],
[
88,
10,
0,
49,
1,
"VAE"
],
[
89,
49,
0,
50,
0,
"IMAGE"
],
[
93,
17,
0,
48,
3,
"SIGMAS"
],
[
107,
26,
0,
47,
1,
"CONDITIONING"
],
[
123,
51,
0,
62,
2,
"EVA_CLIP"
],
[
124,
53,
0,
62,
3,
"FACEANALYSIS"
],
[
125,
45,
0,
62,
1,
"PULIDFLUX"
],
[
126,
54,
0,
62,
4,
"IMAGE"
],
[
132,
64,
0,
6,
0,
"CLIP"
],
[
141,
63,
0,
17,
0,
"MODEL"
],
[
147,
63,
0,
62,
0,
"MODEL"
],
[
148,
62,
0,
71,
0,
"MODEL"
],
[
152,
71,
0,
47,
0,
"MODEL"
]
],
"groups": [],
"config": {},
"extra": {
"ds": {
"scale": 0.620921323059155,
"offset": [
52.21858017949011,
279.11370195488706
]
}
},
"version": 0.4
}
+5 -5
View File
@@ -32,7 +32,7 @@ def teacache_flux_forward(
attn_mask: Tensor = None,
) -> Tensor:
patches_replace = transformer_options.get("patches_replace", {})
rel_l1_thresh = transformer_options.get("teacache_rel_l1_thresh", {})
rel_l1_thresh = transformer_options.get("rel_l1_thresh", {})
if img.ndim != 3 or txt.ndim != 3:
raise ValueError("Input img and txt tensors must have 3 dimensions.")
@@ -187,7 +187,7 @@ def teacache_hunyuanvideo_forward(
transformer_options={},
) -> Tensor:
patches_replace = transformer_options.get("patches_replace", {})
rel_l1_thresh = transformer_options.get("teacache_rel_l1_thresh", {})
rel_l1_thresh = transformer_options.get("rel_l1_thresh", {})
initial_shape = list(img.shape)
# running on sequences img
@@ -315,7 +315,7 @@ def teacache_ltxvmodel_forward(
**kwargs
):
patches_replace = transformer_options.get("patches_replace", {})
rel_l1_thresh = transformer_options.get("teacache_rel_l1_thresh", {})
rel_l1_thresh = transformer_options.get("rel_l1_thresh", {})
indices_grid = self.patchifier.get_grid(
orig_num_frames=x.shape[2],
@@ -482,7 +482,7 @@ class TeaCacheForImgGen:
new_model = model.clone()
if 'transformer_options' not in new_model.model_options:
new_model.model_options['transformer_options'] = {}
new_model.model_options["transformer_options"]["teacache_rel_l1_thresh"] = rel_l1_thresh
new_model.model_options["transformer_options"]["rel_l1_thresh"] = rel_l1_thresh
diffusion_model = new_model.get_model_object("diffusion_model")
if model_type == "flux":
@@ -528,7 +528,7 @@ class TeaCacheForVidGen:
new_model = model.clone()
if 'transformer_options' not in new_model.model_options:
new_model.model_options['transformer_options'] = {}
new_model.model_options["transformer_options"]["teacache_rel_l1_thresh"] = rel_l1_thresh
new_model.model_options["transformer_options"]["rel_l1_thresh"] = rel_l1_thresh
diffusion_model = new_model.get_model_object("diffusion_model")
if model_type == "hunyuan_video":
+1 -1
View File
@@ -1,7 +1,7 @@
[project]
name = "teacache"
description = "Unofficial implementation of [ali-vilab/TeaCache](https://github.com/ali-vilab/TeaCache) for ComfyUI"
version = "1.1.1"
version = "1.1.2"
license = {file = "LICENSE"}
[project.urls]