diff --git a/README.md b/README.md index 585e6cb..736d4bb 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,55 @@ # ComfyUI-ModelUtils -[WIP]Custom nodes for handling, inspecting, modifying and creating various model files. + +A collection of ComfyUI custom nodes for inspecting, modifying, merging, and creating model files. Supports Models, TextEncoders, LoRAs, Checkpoints, and Embeddings. + +## Features + +- **MetaKeys** – Inspect and display metadata and tensor keys from model files +- **RenameKeys** – Batch rename tensor keys using pattern matching +- **PruneKeys** – Remove unwanted layers/keys from models +- **Mergers** – Combine 2 or 3 models with configurable blend modes and ratios +- **LoRA Extraction** – Extract LoRA adapters from model pairs using various SVD rank selection methods (Fixed, Ratio, Quantile, Knee-detection, Frobenius-norm) + +## Example Workflows + +

+ Get Meta and Keys +
+ 📥 GetMetaAndkeys.json +

+ +--- + +

+ LoRA Extraction Nodes +
+ 📥 LoRA_Extract_nodes.json +

+ +--- + +

+ Merging Examples +
+ 📥 Merging_Examples.json +

+ +--- + +

+ Rename Keys in Model +
+ 📥 RenameKeysInModel.json +

+ +## Acknowledgements + +The LoRA extraction functionality was inspired by and references the excellent work from: + +- [kohya-ss/sd-scripts](https://github.com/kohya-ss/sd-scripts) – Training scripts for Stable Diffusion +- [KohakuBlueleaf/LyCORIS](https://github.com/KohakuBlueleaf/LyCORIS) – Advanced LoRA techniques +- [bmaltais/kohya_ss](https://github.com/bmaltais/kohya_ss) – Windows-friendly GUI for sd-scripts + +## License + +See [LICENSE](LICENSE) for details. diff --git a/assets/GetMetaAndkeys.png b/assets/GetMetaAndkeys.png new file mode 100644 index 0000000..9adf418 Binary files /dev/null and b/assets/GetMetaAndkeys.png differ diff --git a/assets/LoRA_Extract_nodes.png b/assets/LoRA_Extract_nodes.png new file mode 100644 index 0000000..6a18e68 Binary files /dev/null and b/assets/LoRA_Extract_nodes.png differ diff --git a/assets/Merging_Examples.png b/assets/Merging_Examples.png new file mode 100644 index 0000000..565f64e Binary files /dev/null and b/assets/Merging_Examples.png differ diff --git a/assets/RenameKeysInModel.png b/assets/RenameKeysInModel.png new file mode 100644 index 0000000..60f5858 Binary files /dev/null and b/assets/RenameKeysInModel.png differ diff --git a/example_workflows/GetMetaAndkeys.json b/example_workflows/GetMetaAndkeys.json new file mode 100644 index 0000000..b7395a3 --- /dev/null +++ b/example_workflows/GetMetaAndkeys.json @@ -0,0 +1,600 @@ +{ + "id": "e07ecc9b-30b9-45e4-9ed6-5fbb7e510257", + "revision": 0, + "last_node_id": 31, + "last_link_id": 19, + "nodes": [ + { + "id": 16, + "type": "PreviewAny", + "pos": [ + -3608, + 200 + ], + "size": [ + 832, + 232 + ], + "flags": {}, + "order": 7, + "mode": 0, + "inputs": [ + { + "name": "source", + "type": "*", + "link": 18 + } + ], + "outputs": [], + "properties": { + "enableTabs": false, + "tabWidth": 65, + "tabXOffset": 10, + "hasSecondTab": false, + "secondTabText": "Send Back", + "secondTabOffset": 80, + "secondTabWidth": 65, + "cnr_id": "comfy-core", + "ver": "0.7.0", + "Node name for S&R": "PreviewAny" + }, + "widgets_values": [ + null, + null, + true + ] + }, + { + "id": 17, + "type": "ModelMetaKeys", + "pos": [ + -2800, + 504 + ], + "size": [ + 346.253515625, + 78 + ], + "flags": {}, + "order": 2, + "mode": 0, + "inputs": [], + "outputs": [ + { + "name": "metadata", + "type": "STRING", + "links": [ + 13 + ] + }, + { + "name": "keys", + "type": "STRING", + "links": [ + 17 + ] + } + ], + "properties": { + "enableTabs": false, + "tabWidth": 65, + "tabXOffset": 10, + "hasSecondTab": false, + "secondTabText": "Send Back", + "secondTabOffset": 80, + "secondTabWidth": 65, + "cnr_id": "comfyui_modelutils", + "ver": "eef737706127fe4a2c28172ab706e92318e0dc60", + "Node name for S&R": "ModelMetaKeys" + }, + "widgets_values": [ + "flux2-dev.safetensors" + ] + }, + { + "id": 18, + "type": "TextEncoderMetaKeys", + "pos": [ + -3176, + 680 + ], + "size": [ + 329.4234375, + 78 + ], + "flags": {}, + "order": 3, + "mode": 0, + "inputs": [], + "outputs": [ + { + "name": "metadata", + "type": "STRING", + "links": [ + 15 + ] + }, + { + "name": "keys", + "type": "STRING", + "links": [ + 16 + ] + } + ], + "properties": { + "enableTabs": false, + "tabWidth": 65, + "tabXOffset": 10, + "hasSecondTab": false, + "secondTabText": "Send Back", + "secondTabOffset": 80, + "secondTabWidth": 65, + "cnr_id": "comfyui_modelutils", + "ver": "eef737706127fe4a2c28172ab706e92318e0dc60", + "Node name for S&R": "TextEncoderMetaKeys" + }, + "widgets_values": [ + "clip_l.safetensors" + ] + }, + { + "id": 19, + "type": "CheckpointMetaKeys", + "pos": [ + -3168, + 512 + ], + "size": [ + 317.6724609375, + 78 + ], + "flags": {}, + "order": 1, + "mode": 0, + "inputs": [], + "outputs": [ + { + "name": "metadata", + "type": "STRING", + "links": [ + 12 + ] + }, + { + "name": "keys", + "type": "STRING", + "links": [ + 18 + ] + } + ], + "properties": { + "enableTabs": false, + "tabWidth": 65, + "tabXOffset": 10, + "hasSecondTab": false, + "secondTabText": "Send Back", + "secondTabOffset": 80, + "secondTabWidth": 65, + "cnr_id": "comfyui_modelutils", + "ver": "eef737706127fe4a2c28172ab706e92318e0dc60", + "Node name for S&R": "CheckpointMetaKeys" + }, + "widgets_values": [ + "unsorted\\v1-5-pruned-emaonly.safetensors" + ] + }, + { + "id": 21, + "type": "LoRAMetaKeys", + "pos": [ + -2800, + 680 + ], + "size": [ + 277.0943359375, + 78 + ], + "flags": {}, + "order": 0, + "mode": 0, + "inputs": [], + "outputs": [ + { + "name": "metadata", + "type": "STRING", + "links": [ + 14 + ] + }, + { + "name": "keys", + "type": "STRING", + "links": [ + 19 + ] + } + ], + "properties": { + "enableTabs": false, + "tabWidth": 65, + "tabXOffset": 10, + "hasSecondTab": false, + "secondTabText": "Send Back", + "secondTabOffset": 80, + "secondTabWidth": 65, + "cnr_id": "comfyui_modelutils", + "ver": "eef737706127fe4a2c28172ab706e92318e0dc60", + "Node name for S&R": "LoRAMetaKeys" + }, + "widgets_values": [ + "Chroma\\FlatAnimeStyle_Chroma.safetensors" + ] + }, + { + "id": 24, + "type": "PreviewAny", + "pos": [ + -2728, + 216 + ], + "size": [ + 512, + 200 + ], + "flags": {}, + "order": 9, + "mode": 0, + "inputs": [ + { + "name": "source", + "type": "*", + "link": 17 + } + ], + "outputs": [], + "properties": { + "enableTabs": false, + "tabWidth": 65, + "tabXOffset": 10, + "hasSecondTab": false, + "secondTabText": "Send Back", + "secondTabOffset": 80, + "secondTabWidth": 65, + "cnr_id": "comfy-core", + "ver": "0.7.0", + "Node name for S&R": "PreviewAny" + }, + "widgets_values": [ + null, + null, + true + ] + }, + { + "id": 25, + "type": "PreviewAny", + "pos": [ + -2816, + 832 + ], + "size": [ + 736, + 248 + ], + "flags": {}, + "order": 5, + "mode": 0, + "inputs": [ + { + "name": "source", + "type": "*", + "link": 19 + } + ], + "outputs": [], + "properties": { + "enableTabs": false, + "tabWidth": 65, + "tabXOffset": 10, + "hasSecondTab": false, + "secondTabText": "Send Back", + "secondTabOffset": 80, + "secondTabWidth": 65, + "cnr_id": "comfy-core", + "ver": "0.7.0", + "Node name for S&R": "PreviewAny" + }, + "widgets_values": [ + null, + null, + true + ] + }, + { + "id": 27, + "type": "PreviewAny", + "pos": [ + -3496, + 848 + ], + "size": [ + 632, + 224 + ], + "flags": {}, + "order": 11, + "mode": 0, + "inputs": [ + { + "name": "source", + "type": "*", + "link": 16 + } + ], + "outputs": [], + "properties": { + "enableTabs": false, + "tabWidth": 65, + "tabXOffset": 10, + "hasSecondTab": false, + "secondTabText": "Send Back", + "secondTabOffset": 80, + "secondTabWidth": 65, + "cnr_id": "comfy-core", + "ver": "0.7.0", + "Node name for S&R": "PreviewAny" + }, + "widgets_values": [ + null, + null, + true + ] + }, + { + "id": 28, + "type": "PreviewAny", + "pos": [ + -3600, + 664 + ], + "size": [ + 352, + 136 + ], + "flags": {}, + "order": 10, + "mode": 0, + "inputs": [ + { + "name": "source", + "type": "*", + "link": 15 + } + ], + "outputs": [], + "properties": { + "enableTabs": false, + "tabWidth": 65, + "tabXOffset": 10, + "hasSecondTab": false, + "secondTabText": "Send Back", + "secondTabOffset": 80, + "secondTabWidth": 65, + "cnr_id": "comfy-core", + "ver": "0.7.0", + "Node name for S&R": "PreviewAny" + }, + "widgets_values": [ + null, + null, + true + ] + }, + { + "id": 29, + "type": "PreviewAny", + "pos": [ + -2408, + 648 + ], + "size": [ + 360, + 120 + ], + "flags": {}, + "order": 4, + "mode": 0, + "inputs": [ + { + "name": "source", + "type": "*", + "link": 14 + } + ], + "outputs": [], + "properties": { + "enableTabs": false, + "tabWidth": 65, + "tabXOffset": 10, + "hasSecondTab": false, + "secondTabText": "Send Back", + "secondTabOffset": 80, + "secondTabWidth": 65, + "cnr_id": "comfy-core", + "ver": "0.7.0", + "Node name for S&R": "PreviewAny" + }, + "widgets_values": [ + null, + null, + true + ] + }, + { + "id": 30, + "type": "PreviewAny", + "pos": [ + -3576, + 480 + ], + "size": [ + 336, + 128 + ], + "flags": {}, + "order": 6, + "mode": 0, + "inputs": [ + { + "name": "source", + "type": "*", + "link": 12 + } + ], + "outputs": [], + "properties": { + "enableTabs": false, + "tabWidth": 65, + "tabXOffset": 10, + "hasSecondTab": false, + "secondTabText": "Send Back", + "secondTabOffset": 80, + "secondTabWidth": 65, + "cnr_id": "comfy-core", + "ver": "0.7.0", + "Node name for S&R": "PreviewAny" + }, + "widgets_values": [ + null, + null, + true + ] + }, + { + "id": 31, + "type": "PreviewAny", + "pos": [ + -2368, + 472 + ], + "size": [ + 328, + 120 + ], + "flags": {}, + "order": 8, + "mode": 0, + "inputs": [ + { + "name": "source", + "type": "*", + "link": 13 + } + ], + "outputs": [], + "properties": { + "enableTabs": false, + "tabWidth": 65, + "tabXOffset": 10, + "hasSecondTab": false, + "secondTabText": "Send Back", + "secondTabOffset": 80, + "secondTabWidth": 65, + "cnr_id": "comfy-core", + "ver": "0.7.0", + "Node name for S&R": "PreviewAny" + }, + "widgets_values": [ + null, + null, + true + ] + } + ], + "links": [ + [ + 12, + 19, + 0, + 30, + 0, + "STRING" + ], + [ + 13, + 17, + 0, + 31, + 0, + "STRING" + ], + [ + 14, + 21, + 0, + 29, + 0, + "STRING" + ], + [ + 15, + 18, + 0, + 28, + 0, + "STRING" + ], + [ + 16, + 18, + 1, + 27, + 0, + "STRING" + ], + [ + 17, + 17, + 1, + 24, + 0, + "STRING" + ], + [ + 18, + 19, + 1, + 16, + 0, + "STRING" + ], + [ + 19, + 21, + 1, + 25, + 0, + "STRING" + ] + ], + "groups": [], + "config": {}, + "extra": { + "workflowRendererVersion": "LG", + "ds": { + "scale": 0.9070294784580497, + "offset": [ + 3855.323424397858, + -56.106573378634465 + ] + }, + "frontendVersion": "1.37.2", + "VHS_latentpreview": false, + "VHS_latentpreviewrate": 0, + "VHS_MetadataImage": true, + "VHS_KeepIntermediate": true + }, + "version": 0.4 +} \ No newline at end of file diff --git a/example_workflows/LoRA_Extract_nodes.json b/example_workflows/LoRA_Extract_nodes.json new file mode 100644 index 0000000..62c4668 --- /dev/null +++ b/example_workflows/LoRA_Extract_nodes.json @@ -0,0 +1,522 @@ +{ + "id": "e07ecc9b-30b9-45e4-9ed6-5fbb7e510257", + "revision": 0, + "last_node_id": 10, + "last_link_id": 5, + "nodes": [ + { + "id": 1, + "type": "LoRAExtractFixed", + "pos": [ + -1848, + 16 + ], + "size": [ + 296, + 352 + ], + "flags": {}, + "order": 2, + "mode": 0, + "inputs": [], + "outputs": [ + { + "name": "output_path", + "type": "STRING", + "links": [ + 3 + ] + } + ], + "properties": { + "enableTabs": false, + "tabWidth": 65, + "tabXOffset": 10, + "hasSecondTab": false, + "secondTabText": "Send Back", + "secondTabOffset": 80, + "secondTabWidth": 65, + "cnr_id": "comfyui_modelutils", + "ver": "eef737706127fe4a2c28172ab706e92318e0dc60", + "Node name for S&R": "LoRAExtractFixed" + }, + "widgets_values": [ + "13499-bf16.safetensors", + "13499-bf16.safetensors", + 64, + 32, + false, + 0.99, + 0, + "skip", + "extracted_lora", + "fp16", + "cuda", + "" + ] + }, + { + "id": 2, + "type": "LoRAExtractFrobenius", + "pos": [ + -2432, + 24 + ], + "size": [ + 296, + 352 + ], + "flags": {}, + "order": 0, + "mode": 0, + "inputs": [], + "outputs": [ + { + "name": "output_path", + "type": "STRING", + "links": [ + 1 + ] + } + ], + "properties": { + "enableTabs": false, + "tabWidth": 65, + "tabXOffset": 10, + "hasSecondTab": false, + "secondTabText": "Send Back", + "secondTabOffset": 80, + "secondTabWidth": 65, + "cnr_id": "comfyui_modelutils", + "ver": "eef737706127fe4a2c28172ab706e92318e0dc60", + "Node name for S&R": "LoRAExtractFrobenius" + }, + "widgets_values": [ + "13499-bf16.safetensors", + "13499-bf16.safetensors", + 0.9, + 0.9, + false, + 0.99, + 0, + "skip", + "extracted_lora", + "fp16", + "cuda", + "" + ] + }, + { + "id": 3, + "type": "LoRAExtractKnee", + "pos": [ + -2416, + 440 + ], + "size": [ + 280, + 328 + ], + "flags": {}, + "order": 1, + "mode": 0, + "inputs": [], + "outputs": [ + { + "name": "output_path", + "type": "STRING", + "links": [ + 2 + ] + } + ], + "properties": { + "enableTabs": false, + "tabWidth": 65, + "tabXOffset": 10, + "hasSecondTab": false, + "secondTabText": "Send Back", + "secondTabOffset": 80, + "secondTabWidth": 65, + "cnr_id": "comfyui_modelutils", + "ver": "eef737706127fe4a2c28172ab706e92318e0dc60", + "Node name for S&R": "LoRAExtractKnee" + }, + "widgets_values": [ + "13499-bf16.safetensors", + "13499-bf16.safetensors", + "sv_knee", + false, + 0.99, + 0, + "skip", + "extracted_lora", + "fp16", + "cuda", + "" + ] + }, + { + "id": 4, + "type": "LoRAExtractQuantile", + "pos": [ + -1248, + 128 + ], + "size": [ + 288, + 352 + ], + "flags": {}, + "order": 4, + "mode": 0, + "inputs": [], + "outputs": [ + { + "name": "output_path", + "type": "STRING", + "links": [ + 5 + ] + } + ], + "properties": { + "enableTabs": false, + "tabWidth": 65, + "tabXOffset": 10, + "hasSecondTab": false, + "secondTabText": "Send Back", + "secondTabOffset": 80, + "secondTabWidth": 65, + "cnr_id": "comfyui_modelutils", + "ver": "eef737706127fe4a2c28172ab706e92318e0dc60", + "Node name for S&R": "LoRAExtractQuantile" + }, + "widgets_values": [ + "13499-bf16.safetensors", + "13499-bf16.safetensors", + 0.9, + 0.9, + false, + 0.99, + 0, + "skip", + "extracted_lora", + "fp16", + "cuda", + "" + ] + }, + { + "id": 5, + "type": "LoRAExtractRatio", + "pos": [ + -1824, + 424 + ], + "size": [ + 296, + 352 + ], + "flags": {}, + "order": 3, + "mode": 0, + "inputs": [], + "outputs": [ + { + "name": "output_path", + "type": "STRING", + "links": [ + 4 + ] + } + ], + "properties": { + "enableTabs": false, + "tabWidth": 65, + "tabXOffset": 10, + "hasSecondTab": false, + "secondTabText": "Send Back", + "secondTabOffset": 80, + "secondTabWidth": 65, + "cnr_id": "comfyui_modelutils", + "ver": "eef737706127fe4a2c28172ab706e92318e0dc60", + "Node name for S&R": "LoRAExtractRatio" + }, + "widgets_values": [ + "13499-bf16.safetensors", + "13499-bf16.safetensors", + 0.5, + 0.5, + false, + 0.99, + 0, + "skip", + "extracted_lora", + "fp16", + "cuda", + "" + ] + }, + { + "id": 6, + "type": "PreviewAny", + "pos": [ + -2096, + 136 + ], + "size": [ + 210, + 168 + ], + "flags": {}, + "order": 5, + "mode": 0, + "inputs": [ + { + "name": "source", + "type": "*", + "link": 1 + } + ], + "outputs": [], + "properties": { + "enableTabs": false, + "tabWidth": 65, + "tabXOffset": 10, + "hasSecondTab": false, + "secondTabText": "Send Back", + "secondTabOffset": 80, + "secondTabWidth": 65, + "cnr_id": "comfy-core", + "ver": "0.7.0", + "Node name for S&R": "PreviewAny" + }, + "widgets_values": [ + null, + null, + true + ] + }, + { + "id": 7, + "type": "PreviewAny", + "pos": [ + -2096, + 448 + ], + "size": [ + 210, + 168 + ], + "flags": {}, + "order": 6, + "mode": 0, + "inputs": [ + { + "name": "source", + "type": "*", + "link": 2 + } + ], + "outputs": [], + "properties": { + "enableTabs": false, + "tabWidth": 65, + "tabXOffset": 10, + "hasSecondTab": false, + "secondTabText": "Send Back", + "secondTabOffset": 80, + "secondTabWidth": 65, + "cnr_id": "comfy-core", + "ver": "0.7.0", + "Node name for S&R": "PreviewAny" + }, + "widgets_values": [ + null, + null, + true + ] + }, + { + "id": 8, + "type": "PreviewAny", + "pos": [ + -1504, + 96 + ], + "size": [ + 210, + 168 + ], + "flags": {}, + "order": 7, + "mode": 0, + "inputs": [ + { + "name": "source", + "type": "*", + "link": 3 + } + ], + "outputs": [], + "properties": { + "enableTabs": false, + "tabWidth": 65, + "tabXOffset": 10, + "hasSecondTab": false, + "secondTabText": "Send Back", + "secondTabOffset": 80, + "secondTabWidth": 65, + "cnr_id": "comfy-core", + "ver": "0.7.0", + "Node name for S&R": "PreviewAny" + }, + "widgets_values": [ + null, + null, + true + ] + }, + { + "id": 9, + "type": "PreviewAny", + "pos": [ + -1472, + 432 + ], + "size": [ + 210, + 168 + ], + "flags": {}, + "order": 8, + "mode": 0, + "inputs": [ + { + "name": "source", + "type": "*", + "link": 4 + } + ], + "outputs": [], + "properties": { + "enableTabs": false, + "tabWidth": 65, + "tabXOffset": 10, + "hasSecondTab": false, + "secondTabText": "Send Back", + "secondTabOffset": 80, + "secondTabWidth": 65, + "cnr_id": "comfy-core", + "ver": "0.7.0", + "Node name for S&R": "PreviewAny" + }, + "widgets_values": [ + null, + null, + true + ] + }, + { + "id": 10, + "type": "PreviewAny", + "pos": [ + -904, + 184 + ], + "size": [ + 210, + 168 + ], + "flags": {}, + "order": 9, + "mode": 0, + "inputs": [ + { + "name": "source", + "type": "*", + "link": 5 + } + ], + "outputs": [], + "properties": { + "enableTabs": false, + "tabWidth": 65, + "tabXOffset": 10, + "hasSecondTab": false, + "secondTabText": "Send Back", + "secondTabOffset": 80, + "secondTabWidth": 65, + "cnr_id": "comfy-core", + "ver": "0.7.0", + "Node name for S&R": "PreviewAny" + }, + "widgets_values": [ + null, + null, + true + ] + } + ], + "links": [ + [ + 1, + 2, + 0, + 6, + 0, + "STRING" + ], + [ + 2, + 3, + 0, + 7, + 0, + "STRING" + ], + [ + 3, + 1, + 0, + 8, + 0, + "STRING" + ], + [ + 4, + 5, + 0, + 9, + 0, + "STRING" + ], + [ + 5, + 4, + 0, + 10, + 0, + "STRING" + ] + ], + "groups": [], + "config": {}, + "extra": { + "workflowRendererVersion": "LG", + "ds": { + "scale": 1.05, + "offset": [ + 2532, + 84 + ] + }, + "frontendVersion": "1.37.2", + "VHS_latentpreview": false, + "VHS_latentpreviewrate": 0, + "VHS_MetadataImage": true, + "VHS_KeepIntermediate": true + }, + "version": 0.4 +} \ No newline at end of file diff --git a/example_workflows/Merging_Examples.json b/example_workflows/Merging_Examples.json new file mode 100644 index 0000000..5f92f11 --- /dev/null +++ b/example_workflows/Merging_Examples.json @@ -0,0 +1,460 @@ +{ + "id": "e07ecc9b-30b9-45e4-9ed6-5fbb7e510257", + "revision": 0, + "last_node_id": 16, + "last_link_id": 11, + "nodes": [ + { + "id": 6, + "type": "PreviewAny", + "pos": [ + -3552, + 136 + ], + "size": [ + 336, + 160 + ], + "flags": {}, + "order": 5, + "mode": 0, + "inputs": [ + { + "name": "source", + "type": "*", + "link": 6 + } + ], + "outputs": [], + "properties": { + "enableTabs": false, + "tabWidth": 65, + "tabXOffset": 10, + "hasSecondTab": false, + "secondTabText": "Send Back", + "secondTabOffset": 80, + "secondTabWidth": 65, + "cnr_id": "comfy-core", + "ver": "0.7.0", + "Node name for S&R": "PreviewAny" + }, + "widgets_values": [ + null, + null, + true + ] + }, + { + "id": 7, + "type": "PreviewAny", + "pos": [ + -2792, + 144 + ], + "size": [ + 456, + 464 + ], + "flags": {}, + "order": 6, + "mode": 0, + "inputs": [ + { + "name": "source", + "type": "*", + "link": 9 + } + ], + "outputs": [], + "properties": { + "enableTabs": false, + "tabWidth": 65, + "tabXOffset": 10, + "hasSecondTab": false, + "secondTabText": "Send Back", + "secondTabOffset": 80, + "secondTabWidth": 65, + "cnr_id": "comfy-core", + "ver": "0.7.0", + "Node name for S&R": "PreviewAny" + }, + "widgets_values": [ + null, + null, + false + ] + }, + { + "id": 11, + "type": "ModelThreeMerger", + "pos": [ + -3120, + 112 + ], + "size": [ + 296, + 522 + ], + "flags": {}, + "order": 2, + "mode": 0, + "inputs": [], + "outputs": [ + { + "name": "output_filename", + "type": "STRING", + "links": null + }, + { + "name": "documentation", + "type": "STRING", + "links": [ + 9 + ] + } + ], + "properties": { + "enableTabs": false, + "tabWidth": 65, + "tabXOffset": 10, + "hasSecondTab": false, + "secondTabText": "Send Back", + "secondTabOffset": 80, + "secondTabWidth": 65, + "cnr_id": "comfyui_modelutils", + "ver": "eef737706127fe4a2c28172ab706e92318e0dc60", + "Node name for S&R": "ModelThreeMerger" + }, + "widgets_values": [ + "DOCUMENTATION ONLY", + "Chroma1-HD.safetensors", + "Chroma-DC-2K.safetensors", + "None", + "Add-Difference", + "skip", + 0.5, + 0.5, + 0.5, + 0.5, + 996811747788113, + "randomize", + "merged_3_model", + "fp32", + "cuda", + "", + "" + ] + }, + { + "id": 12, + "type": "ModelTwoMerger", + "pos": [ + -3120, + 704 + ], + "size": [ + 304, + 474 + ], + "flags": {}, + "order": 0, + "mode": 0, + "inputs": [], + "outputs": [ + { + "name": "output_filename", + "type": "STRING", + "links": [ + 11 + ] + }, + { + "name": "documentation", + "type": "STRING", + "links": null + } + ], + "properties": { + "enableTabs": false, + "tabWidth": 65, + "tabXOffset": 10, + "hasSecondTab": false, + "secondTabText": "Send Back", + "secondTabOffset": 80, + "secondTabWidth": 65, + "cnr_id": "comfyui_modelutils", + "ver": "eef737706127fe4a2c28172ab706e92318e0dc60", + "Node name for S&R": "ModelTwoMerger" + }, + "widgets_values": [ + "MERGE", + "None", + "None", + "Weight-Sum", + "skip", + 0.5, + 0.5, + 0.99, + 388546580517523, + "randomize", + "merged_2_model", + "fp32", + "cuda", + "", + "" + ] + }, + { + "id": 13, + "type": "LoRAThreeMerger", + "pos": [ + -3872, + 128 + ], + "size": [ + 296, + 522 + ], + "flags": {}, + "order": 1, + "mode": 0, + "inputs": [], + "outputs": [ + { + "name": "output_filename", + "type": "STRING", + "links": [ + 6 + ] + }, + { + "name": "documentation", + "type": "STRING", + "links": [] + } + ], + "properties": { + "enableTabs": false, + "tabWidth": 65, + "tabXOffset": 10, + "hasSecondTab": false, + "secondTabText": "Send Back", + "secondTabOffset": 80, + "secondTabWidth": 65, + "cnr_id": "comfyui_modelutils", + "ver": "eef737706127fe4a2c28172ab706e92318e0dc60", + "Node name for S&R": "LoRAThreeMerger" + }, + "widgets_values": [ + "MERGE", + "None", + "None", + "None", + "Add-Difference", + "skip", + 0.5, + 0.5, + 0.5, + 0.5, + 1120102695669269, + "randomize", + "merged_3_lora", + "fp32", + "cuda", + "", + "" + ] + }, + { + "id": 14, + "type": "LoRATwoMerger", + "pos": [ + -3872, + 720 + ], + "size": [ + 296, + 474 + ], + "flags": {}, + "order": 3, + "mode": 0, + "inputs": [], + "outputs": [ + { + "name": "output_filename", + "type": "STRING", + "links": [] + }, + { + "name": "documentation", + "type": "STRING", + "links": [ + 10 + ] + } + ], + "properties": { + "enableTabs": false, + "tabWidth": 65, + "tabXOffset": 10, + "hasSecondTab": false, + "secondTabText": "Send Back", + "secondTabOffset": 80, + "secondTabWidth": 65, + "cnr_id": "comfyui_modelutils", + "ver": "eef737706127fe4a2c28172ab706e92318e0dc60", + "Node name for S&R": "LoRATwoMerger" + }, + "widgets_values": [ + "DOCUMENTATION ONLY", + "Hyper-FLUX.1-dev-16steps-lora-rescale_z1.safetensors", + "Hyper-FLUX.1-dev-16steps-lora-rescale_z2.safetensors", + "Weight-Sum", + "skip", + 0.5, + 0.5, + 0.99, + 1020143314396572, + "randomize", + "merged_2_lora", + "fp32", + "cuda", + "", + "" + ] + }, + { + "id": 15, + "type": "PreviewAny", + "pos": [ + -2768, + 720 + ], + "size": [ + 432, + 160 + ], + "flags": {}, + "order": 4, + "mode": 0, + "inputs": [ + { + "name": "source", + "type": "*", + "link": 11 + } + ], + "outputs": [], + "properties": { + "enableTabs": false, + "tabWidth": 65, + "tabXOffset": 10, + "hasSecondTab": false, + "secondTabText": "Send Back", + "secondTabOffset": 80, + "secondTabWidth": 65, + "cnr_id": "comfy-core", + "ver": "0.7.0", + "Node name for S&R": "PreviewAny" + }, + "widgets_values": [ + null, + null, + true + ] + }, + { + "id": 16, + "type": "PreviewAny", + "pos": [ + -3544, + 712 + ], + "size": [ + 400, + 448 + ], + "flags": {}, + "order": 7, + "mode": 0, + "inputs": [ + { + "name": "source", + "type": "*", + "link": 10 + } + ], + "outputs": [], + "properties": { + "enableTabs": false, + "tabWidth": 65, + "tabXOffset": 10, + "hasSecondTab": false, + "secondTabText": "Send Back", + "secondTabOffset": 80, + "secondTabWidth": 65, + "cnr_id": "comfy-core", + "ver": "0.7.0", + "Node name for S&R": "PreviewAny" + }, + "widgets_values": [ + null, + null, + false + ] + } + ], + "links": [ + [ + 6, + 13, + 0, + 6, + 0, + "STRING" + ], + [ + 9, + 11, + 1, + 7, + 0, + "STRING" + ], + [ + 10, + 14, + 1, + 16, + 0, + "STRING" + ], + [ + 11, + 12, + 0, + 15, + 0, + "STRING" + ] + ], + "groups": [], + "config": {}, + "extra": { + "workflowRendererVersion": "LG", + "ds": { + "scale": 0.9070294784580494, + "offset": [ + 3972, + -12 + ] + }, + "frontendVersion": "1.37.2", + "VHS_latentpreview": false, + "VHS_latentpreviewrate": 0, + "VHS_MetadataImage": true, + "VHS_KeepIntermediate": true + }, + "version": 0.4 +} \ No newline at end of file diff --git a/example_workflows/RenameKeysInModel.json b/example_workflows/RenameKeysInModel.json new file mode 100644 index 0000000..4fbabcc --- /dev/null +++ b/example_workflows/RenameKeysInModel.json @@ -0,0 +1,583 @@ +{ + "id": "e07ecc9b-30b9-45e4-9ed6-5fbb7e510257", + "revision": 0, + "last_node_id": 46, + "last_link_id": 31, + "nodes": [ + { + "id": 35, + "type": "LoRAMetaKeys", + "pos": [ + -3136, + 512 + ], + "size": [ + 376, + 78 + ], + "flags": {}, + "order": 0, + "mode": 0, + "inputs": [], + "outputs": [ + { + "name": "metadata", + "type": "STRING", + "links": null + }, + { + "name": "keys", + "type": "STRING", + "links": [ + 21, + 22 + ] + } + ], + "properties": { + "enableTabs": false, + "tabWidth": 65, + "tabXOffset": 10, + "hasSecondTab": false, + "secondTabText": "Send Back", + "secondTabOffset": 80, + "secondTabWidth": 65, + "cnr_id": "comfyui_modelutils", + "ver": "eef737706127fe4a2c28172ab706e92318e0dc60", + "Node name for S&R": "LoRAMetaKeys" + }, + "widgets_values": [ + "qwen\\gmqwen_k8_piid_4step.safetensors" + ] + }, + { + "id": 36, + "type": "LoRARenameKeys", + "pos": [ + -2856, + 864 + ], + "size": [ + 320, + 190 + ], + "flags": {}, + "order": 7, + "mode": 0, + "inputs": [ + { + "name": "old_keys", + "type": "STRING", + "widget": { + "name": "old_keys" + }, + "link": 27 + }, + { + "name": "new_keys", + "type": "STRING", + "widget": { + "name": "new_keys" + }, + "link": 28 + } + ], + "outputs": [ + { + "name": "output_path", + "type": "STRING", + "links": [ + 31 + ] + } + ], + "properties": { + "enableTabs": false, + "tabWidth": 65, + "tabXOffset": 10, + "hasSecondTab": false, + "secondTabText": "Send Back", + "secondTabOffset": 80, + "secondTabWidth": 65, + "cnr_id": "comfyui_modelutils", + "ver": "eef737706127fe4a2c28172ab706e92318e0dc60", + "Node name for S&R": "LoRARenameKeys" + }, + "widgets_values": [ + "qwen\\gmqwen_k8_piid_4step.safetensors", + "", + "", + "gmqwen_k8_piid_4step" + ] + }, + { + "id": 37, + "type": "PreviewAny", + "pos": [ + -3792, + 920 + ], + "size": [ + 592, + 384 + ], + "flags": {}, + "order": 1, + "mode": 0, + "inputs": [ + { + "name": "source", + "type": "*", + "link": 21 + } + ], + "outputs": [], + "properties": { + "enableTabs": false, + "tabWidth": 65, + "tabXOffset": 10, + "hasSecondTab": false, + "secondTabText": "Send Back", + "secondTabOffset": 80, + "secondTabWidth": 65, + "cnr_id": "comfy-core", + "ver": "0.7.0", + "Node name for S&R": "PreviewAny" + }, + "widgets_values": [ + null, + null, + true + ] + }, + { + "id": 40, + "type": "RegexReplace", + "pos": [ + -3400, + 568 + ], + "size": [ + 210, + 292 + ], + "flags": {}, + "order": 2, + "mode": 0, + "inputs": [ + { + "name": "string", + "type": "STRING", + "widget": { + "name": "string" + }, + "link": 22 + } + ], + "outputs": [ + { + "name": "STRING", + "type": "STRING", + "links": [ + 23, + 25 + ] + } + ], + "properties": { + "enableTabs": false, + "tabWidth": 65, + "tabXOffset": 10, + "hasSecondTab": false, + "secondTabText": "Send Back", + "secondTabOffset": 80, + "secondTabWidth": 65, + "cnr_id": "comfy-core", + "ver": "0.7.0", + "Node name for S&R": "RegexReplace" + }, + "widgets_values": [ + "", + ",\\s\\[.+$", + "", + true, + true, + false, + 0 + ] + }, + { + "id": 41, + "type": "PreviewAny", + "pos": [ + -3784, + 528 + ], + "size": [ + 360, + 328 + ], + "flags": {}, + "order": 3, + "mode": 0, + "inputs": [ + { + "name": "source", + "type": "*", + "link": 23 + } + ], + "outputs": [], + "properties": { + "enableTabs": false, + "tabWidth": 65, + "tabXOffset": 10, + "hasSecondTab": false, + "secondTabText": "Send Back", + "secondTabOffset": 80, + "secondTabWidth": 65, + "cnr_id": "comfy-core", + "ver": "0.7.0", + "Node name for S&R": "PreviewAny" + }, + "widgets_values": [ + null, + null, + true + ] + }, + { + "id": 42, + "type": "RegexReplace", + "pos": [ + -3176, + 1016 + ], + "size": [ + 288, + 292 + ], + "flags": {}, + "order": 5, + "mode": 0, + "inputs": [ + { + "name": "string", + "type": "STRING", + "widget": { + "name": "string" + }, + "link": 26 + } + ], + "outputs": [ + { + "name": "STRING", + "type": "STRING", + "links": [ + 28, + 30 + ] + } + ], + "properties": { + "enableTabs": false, + "tabWidth": 65, + "tabXOffset": 10, + "hasSecondTab": false, + "secondTabText": "Send Back", + "secondTabOffset": 80, + "secondTabWidth": 65, + "cnr_id": "comfy-core", + "ver": "0.7.0", + "Node name for S&R": "RegexReplace" + }, + "widgets_values": [ + "", + "^(\\w+)", + "diffusion_model.\\1", + true, + true, + false, + 0 + ] + }, + { + "id": 43, + "type": "RegexReplace", + "pos": [ + -3152, + 648 + ], + "size": [ + 288, + 292 + ], + "flags": {}, + "order": 4, + "mode": 0, + "inputs": [ + { + "name": "string", + "type": "STRING", + "widget": { + "name": "string" + }, + "link": 25 + } + ], + "outputs": [ + { + "name": "STRING", + "type": "STRING", + "links": [ + 26, + 27, + 29 + ] + } + ], + "properties": { + "enableTabs": false, + "tabWidth": 65, + "tabXOffset": 10, + "hasSecondTab": false, + "secondTabText": "Send Back", + "secondTabOffset": 80, + "secondTabWidth": 65, + "cnr_id": "comfy-core", + "ver": "0.7.0", + "Node name for S&R": "RegexReplace" + }, + "widgets_values": [ + "", + "^(proj_out.+|norm_out.+)$\\n", + "", + true, + true, + false, + 0 + ] + }, + { + "id": 44, + "type": "PreviewAny", + "pos": [ + -2832, + 632 + ], + "size": [ + 640, + 192 + ], + "flags": {}, + "order": 6, + "mode": 0, + "inputs": [ + { + "name": "source", + "type": "*", + "link": 29 + } + ], + "outputs": [], + "properties": { + "enableTabs": false, + "tabWidth": 65, + "tabXOffset": 10, + "hasSecondTab": false, + "secondTabText": "Send Back", + "secondTabOffset": 80, + "secondTabWidth": 65, + "cnr_id": "comfy-core", + "ver": "0.7.0", + "Node name for S&R": "PreviewAny" + }, + "widgets_values": [ + null, + null, + true + ] + }, + { + "id": 45, + "type": "PreviewAny", + "pos": [ + -2848, + 1096 + ], + "size": [ + 640, + 192 + ], + "flags": {}, + "order": 8, + "mode": 0, + "inputs": [ + { + "name": "source", + "type": "*", + "link": 30 + } + ], + "outputs": [], + "properties": { + "enableTabs": false, + "tabWidth": 65, + "tabXOffset": 10, + "hasSecondTab": false, + "secondTabText": "Send Back", + "secondTabOffset": 80, + "secondTabWidth": 65, + "cnr_id": "comfy-core", + "ver": "0.7.0", + "Node name for S&R": "PreviewAny" + }, + "widgets_values": [ + null, + null, + true + ] + }, + { + "id": 46, + "type": "PreviewAny", + "pos": [ + -2520, + 872 + ], + "size": [ + 336, + 168 + ], + "flags": {}, + "order": 9, + "mode": 0, + "inputs": [ + { + "name": "source", + "type": "*", + "link": 31 + } + ], + "outputs": [], + "properties": { + "enableTabs": false, + "tabWidth": 65, + "tabXOffset": 10, + "hasSecondTab": false, + "secondTabText": "Send Back", + "secondTabOffset": 80, + "secondTabWidth": 65, + "cnr_id": "comfy-core", + "ver": "0.7.0", + "Node name for S&R": "PreviewAny" + }, + "widgets_values": [ + null, + null, + true + ] + } + ], + "links": [ + [ + 21, + 35, + 1, + 37, + 0, + "STRING" + ], + [ + 22, + 35, + 1, + 40, + 0, + "STRING" + ], + [ + 23, + 40, + 0, + 41, + 0, + "STRING" + ], + [ + 25, + 40, + 0, + 43, + 0, + "STRING" + ], + [ + 26, + 43, + 0, + 42, + 0, + "STRING" + ], + [ + 27, + 43, + 0, + 36, + 0, + "STRING" + ], + [ + 28, + 42, + 0, + 36, + 1, + "STRING" + ], + [ + 29, + 43, + 0, + 44, + 0, + "STRING" + ], + [ + 30, + 42, + 0, + 45, + 0, + "STRING" + ], + [ + 31, + 36, + 0, + 46, + 0, + "STRING" + ] + ], + "groups": [], + "config": {}, + "extra": { + "workflowRendererVersion": "LG", + "ds": { + "scale": 1, + "offset": [ + 4191.258750150775, + -356.1917593715161 + ] + }, + "frontendVersion": "1.37.2", + "VHS_latentpreview": false, + "VHS_latentpreviewrate": 0, + "VHS_MetadataImage": true, + "VHS_KeepIntermediate": true + }, + "version": 0.4 +} \ No newline at end of file