vinavfx / ComfyUI-for-Nuke

API to be able to use ComfyUI nodes within nuke, only using the ComfyUI server
GNU General Public License v3.0
193 stars 17 forks source link

Yuri dev branch #16

Closed yuricarrara closed 2 months ago

yuricarrara commented 2 months ago

this repo relates to the workflow import functionality.

changes:

  1. ability to load the groups backdrops as nuke backdrops
  2. if a node as been modified and the widget is now an input, it will be catched
  3. if a node uses dynamic JS widgets they should be catched and updated (this might need more testing)
  4. PrimitiveNodes are converted into different custom nodes that are not JS front end only (COMBO not supported). 'CR Seed' and 'Easy Use' custom nodes require (you can change it to anything you prefer, there is plenty of options)
  5. Get/Set nodes are catched as well and converted into hidden inputs

I had to modify some important function like create_node() to be able to pass the 'attrs' data, to parse important infos. The code could be indeed cleaner, maybe a 'unified' dictionary of the workflow file and the default nodes data might be the best solution. Also I had to 'bake' some infos to imitate JS behaviour, especially for the Primitive node, that might be another good candidate for some refactoring

vinavfx commented 2 months ago

Thanks, when I have some time I'll review it and merge it, and I can ask you to share with me the sample workflow.json to test what you did, in case I don't have any plugin in ComfyUI that I'm missing.

yuricarrara commented 2 months ago
Click to expand { "last_node_id": 236, "last_link_id": 380, "nodes": [ { "id": 203, "type": "PrimitiveNode", "pos": [ 4430, 440 ], "size": { "0": 210, "1": 82 }, "flags": {}, "order": 0, "mode": 0, "outputs": [ { "name": "INT", "type": "INT", "links": [ 359 ], "slot_index": 0, "widget": { "name": "seed" } } ], "properties": { "Run widget replace on values": false }, "widgets_values": [ 200, "fixed" ] }, { "id": 8, "type": "VAEDecode", "pos": [ 5530, 589 ], "size": { "0": 210, "1": 46 }, "flags": {}, "order": 16, "mode": 0, "inputs": [ { "name": "samples", "type": "LATENT", "link": 184 }, { "name": "vae", "type": "VAE", "link": 341 } ], "outputs": [ { "name": "IMAGE", "type": "IMAGE", "links": [ 185, 380 ], "slot_index": 0 } ], "properties": { "Node name for S&R": "VAEDecode" } }, { "id": 109, "type": "PreviewImage", "pos": [ 6742, 385 ], "size": { "0": 210, "1": 250 }, "flags": {}, "order": 17, "mode": 0, "inputs": [ { "name": "images", "type": "IMAGE", "link": 185 } ], "properties": { "Node name for S&R": "PreviewImage" } }, { "id": 21, "type": "VAELoader", "pos": [ -2060, 1046 ], "size": { "0": 315, "1": 58 }, "flags": {}, "order": 1, "mode": 0, "outputs": [ { "name": "VAE", "type": "VAE", "links": [ 337, 341 ], "shape": 3, "slot_index": 0 } ], "properties": { "Node name for S&R": "VAELoader" }, "widgets_values": [ "sdxl_vae.safetensors" ] }, { "id": 216, "type": "easy setNode", "pos": [ -1493, 419 ], "size": { "0": 210, "1": 58 }, "flags": {}, "order": 11, "mode": 0, "inputs": [ { "name": "IMAGE", "type": "IMAGE", "link": 367, "slot_index": 0 } ], "title": "Set_exr", "properties": { "previousName": "exr" }, "widgets_values": [ "exr" ], "color": "#223" }, { "id": 232, "type": "easy setNode", "pos": [ -1444, -15 ], "size": { "0": 210, "1": 58 }, "flags": {}, "order": 10, "mode": 0, "inputs": [ { "name": "IMAGE", "type": "IMAGE", "link": 375, "slot_index": 0 } ], "title": "Set_png", "properties": { "previousName": "png" }, "widgets_values": [ "png" ], "color": "#223" }, { "id": 12, "type": "VAEEncode", "pos": [ 1969, 168 ], "size": { "0": 210, "1": 46 }, "flags": {}, "order": 14, "mode": 0, "inputs": [ { "name": "pixels", "type": "IMAGE", "link": 376 }, { "name": "vae", "type": "VAE", "link": 337 } ], "outputs": [ { "name": "LATENT", "type": "LATENT", "links": [ 352, 379 ], "shape": 3, "slot_index": 0 } ], "properties": { "Node name for S&R": "VAEEncode" } }, { "id": 106, "type": "Note", "pos": [ 1132, 92 ], "size": { "0": 210, "1": 65.23567962646484 }, "flags": {}, "order": 2, "mode": 0, "title": "Switch", "properties": { "text": "" }, "widgets_values": [ "Select 1 for exr\n 2 for png\n" ], "color": "#432", "bgcolor": "#653" }, { "id": 217, "type": "easy getNode", "pos": [ 1146, -251 ], "size": { "0": 210, "1": 58 }, "flags": {}, "order": 3, "mode": 0, "outputs": [ { "name": "IMAGE", "type": "IMAGE", "links": [ 377 ], "slot_index": 0 } ], "title": "Get_exr", "properties": {}, "widgets_values": [ "exr" ], "color": "#223" }, { "id": 233, "type": "easy getNode", "pos": [ 1112, -138 ], "size": { "0": 210, "1": 58 }, "flags": {}, "order": 4, "mode": 0, "outputs": [ { "name": "IMAGE", "type": "IMAGE", "links": [ 378 ], "slot_index": 0 } ], "title": "Get_png", "properties": {}, "widgets_values": [ "png" ], "color": "#223" }, { "id": 231, "type": "LoadImage", "pos": [ -2072, -14 ], "size": [ 315, 314 ], "flags": {}, "order": 5, "mode": 0, "outputs": [ { "name": "IMAGE", "type": "IMAGE", "links": [ 375 ], "shape": 3 }, { "name": "MASK", "type": "MASK", "links": null, "shape": 3 } ], "properties": { "Node name for S&R": "LoadImage" }, "widgets_values": [ "source.png", "image" ] }, { "id": 227, "type": "LoadEXRFrames", "pos": [ -2083, 416 ], "size": [ 386.0134745172436, 190 ], "flags": {}, "order": 6, "mode": 0, "outputs": [ { "name": "RGB", "type": "IMAGE", "links": [ 367 ], "shape": 3, "slot_index": 0 }, { "name": "alpha", "type": "MASK", "links": null, "shape": 3 }, { "name": "batch_size", "type": "INT", "links": null, "shape": 3 }, { "name": "start_frame", "type": "INT", "links": null, "shape": 3 } ], "properties": { "Node name for S&R": "LoadEXRFrames" }, "widgets_values": [ "/home/user/cmf/input/example.exr", true, 1001, 1001 ] }, { "id": 4, "type": "CheckpointLoaderSimple", "pos": [ -1972, 814 ], "size": { "0": 315, "1": 98 }, "flags": {}, "order": 7, "mode": 0, "outputs": [ { "name": "MODEL", "type": "MODEL", "links": [ 338 ], "slot_index": 0 }, { "name": "CLIP", "type": "CLIP", "links": [ 3, 5 ], "slot_index": 1 }, { "name": "VAE", "type": "VAE", "links": [], "slot_index": 2 } ], "properties": { "Node name for S&R": "CheckpointLoaderSimple" }, "widgets_values": [ "dreamshaperXL_v21TurboDPMSDE.safetensors" ], "color": "#432", "bgcolor": "#653" }, { "id": 235, "type": "LatentSwitch", "pos": [ 1615, 70 ], "size": { "0": 210, "1": 122 }, "flags": {}, "order": 9, "mode": 0, "inputs": [ { "name": "input1", "type": "IMAGE", "link": 377, "slot_index": 0 }, { "name": "input2", "type": "IMAGE", "link": 378, "slot_index": 1 }, { "name": "input3", "type": "IMAGE", "link": null } ], "outputs": [ { "name": "IMAGE", "type": "IMAGE", "links": [ 376 ], "shape": 3, "slot_index": 0, "label": "IMAGE" }, { "name": "selected_label", "type": "STRING", "links": null, "shape": 3 }, { "name": "selected_index", "type": "INT", "links": null, "shape": 3 } ], "properties": { "Node name for S&R": "LatentSwitch" }, "widgets_values": [ 2, true ] }, { "id": 6, "type": "CLIPTextEncode", "pos": [ 1061, 710 ], "size": { "0": 422.84503173828125, "1": 164.31304931640625 }, "flags": {}, "order": 12, "mode": 0, "inputs": [ { "name": "clip", "type": "CLIP", "link": 3 } ], "outputs": [ { "name": "CONDITIONING", "type": "CONDITIONING", "links": [], "slot_index": 0 } ], "properties": { "Node name for S&R": "CLIPTextEncode" }, "widgets_values": [ "high quality sun light, 4k high quality, soft light, perfect lighting, ultra detailed, 8k " ], "color": "#232", "bgcolor": "#353" }, { "id": 7, "type": "CLIPTextEncode", "pos": [ 1035, 927 ], "size": { "0": 425.27801513671875, "1": 180.6060791015625 }, "flags": {}, "order": 13, "mode": 0, "inputs": [ { "name": "clip", "type": "CLIP", "link": 5 } ], "outputs": [ { "name": "CONDITIONING", "type": "CONDITIONING", "links": [ 373, 374 ], "slot_index": 0 } ], "properties": { "Node name for S&R": "CLIPTextEncode" }, "widgets_values": [ "(deformed iris, deformed pupils, dilated pupils, ugly eyes, alien eyes, cartoon), (cloned face, duplicate:1.4), multiple people" ], "color": "#322", "bgcolor": "#533" }, { "id": 236, "type": "SaveEXR", "pos": [ 6624, 946 ], "size": [ 427.8277516891085, 190.4310724159086 ], "flags": {}, "order": 18, "mode": 0, "inputs": [ { "name": "images", "type": "IMAGE", "link": 380, "slot_index": 0 } ], "properties": { "Node name for S&R": "SaveEXR" }, "widgets_values": [ "/home/user/cmf/output/example", true, 2, 1001, 4, "ui" ] }, { "id": 108, "type": "KSampler", "pos": [ 4940, 589 ], "size": { "0": 317.8888244628906, "1": 446 }, "flags": { "pinned": false }, "order": 15, "mode": 0, "inputs": [ { "name": "model", "type": "MODEL", "link": 338 }, { "name": "positive", "type": "CONDITIONING", "link": 373 }, { "name": "negative", "type": "CONDITIONING", "link": 374, "slot_index": 2 }, { "name": "latent_image", "type": "LATENT", "link": 379 }, { "name": "seed", "type": "INT", "link": 359, "widget": { "name": "seed" }, "slot_index": 4 }, { "name": "cfg", "type": "FLOAT", "link": 370, "widget": { "name": "cfg" }, "slot_index": 5 } ], "outputs": [ { "name": "LATENT", "type": "LATENT", "links": [ 184, 330 ], "shape": 3, "slot_index": 0 } ], "properties": { "Node name for S&R": "KSampler" }, "widgets_values": [ 200, "fixed", 28, 5, "dpmpp_2m", "karras", 1 ], "color": "#223", "bgcolor": "#335" }, { "id": 230, "type": "PrimitiveNode", "pos": [ 4443, 842 ], "size": [ 256.21236707372555, 82 ], "flags": {}, "order": 8, "mode": 0, "outputs": [ { "name": "FLOAT", "type": "FLOAT", "links": [ 370 ], "slot_index": 0, "widget": { "name": "cfg" } } ], "properties": { "Run widget replace on values": false }, "widgets_values": [ 5, "fixed" ] } ], "links": [ [ 3, 4, 1, 6, 0, "CLIP" ], [ 5, 4, 1, 7, 0, "CLIP" ], [ 184, 108, 0, 8, 0, "LATENT" ], [ 185, 8, 0, 109, 0, "IMAGE" ], [ 330, 108, 0, 191, 1, "LATENT" ], [ 337, 21, 0, 12, 1, "VAE" ], [ 338, 4, 0, 108, 0, "MODEL" ], [ 341, 21, 0, 8, 1, "VAE" ], [ 352, 12, 0, 162, 0, "LATENT" ], [ 359, 203, 0, 108, 4, "INT" ], [ 367, 227, 0, 216, 0, "*" ], [ 370, 230, 0, 108, 5, "FLOAT" ], [ 373, 7, 0, 108, 1, "CONDITIONING" ], [ 374, 7, 0, 108, 2, "CONDITIONING" ], [ 375, 231, 0, 232, 0, "*" ], [ 376, 235, 0, 12, 0, "IMAGE" ], [ 377, 217, 0, 235, 0, "IMAGE" ], [ 378, 233, 0, 235, 1, "IMAGE" ], [ 379, 12, 0, 108, 3, "LATENT" ], [ 380, 8, 0, 236, 0, "IMAGE" ] ], "groups": [ { "title": "PROMPT", "bounding": [ 868, 587, 684, 602 ], "color": "#b58b2a", "font_size": 24 }, { "title": "files", "bounding": [ -2296, -95, 1050, 1303 ], "color": "#a1309b", "font_size": 24 }, { "title": "Text2Img / Img2Img", "bounding": [ 1088, -529, 1103, 793 ], "color": "#b58b2a", "font_size": 30 }, { "title": "ksampler", "bounding": [ 4409, 334, 1434, 859 ], "color": "#8A8", "font_size": 24 } ], "config": {}, "extra": { "ds": { "scale": 0.14000000000000035, "offset": [ 6674.106314244929, 3030.7667297818834 ] }, "groupNodes": {} }, "version": 0.4 }