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
173 stars 16 forks source link

Inpainting example #7

Closed aracid closed 1 month ago

aracid commented 4 months ago

Hi Francisco,

I'm encountering an issue with a use case that functions correctly in the ComfyUI web interface but not within Nuke. I'm trying to replicate the inpainting example.

As a test, I successfully connected the Ksampler into an empty latent. However, when I replace it with sdVaeEncode_for_inpainting1 and submit, nothing appears to happen. If I submit again, it displays "inference in execution," but I don't see any output in the script or terminal. Do you have any suggestions?

Additionally, I'm wondering how to cancel the current process similar to what we do in the manager. Is there a specific method you'd recommend for this?

Thanks again for your help.

Best regards,

set cut_paste_input [stack 0] version 14.0 v5 Group { inputs 0 name LoadCheckpoint onCreate "def exe(func, args):\n allowed_knobs = ['Boolean_Knob', 'PyScript_Knob']\n exclude_knobs = ['selected']\n\n knob = nuke.thisKnob()\n allowed_knob = knob.Class() in allowed_knobs and not knob.name() in exclude_knobs\n\n try:\n return eval(func)(args)\n except Exception as e:\n\n if not allowed_knob:\n return\n\n if not 'vina' in str(e):\n return\n\n message = 'ask Francisco Contreras for the script \"{}\", since the script for this method is not embedded in the node. Thank you.'.format(\n func)\n nuke.message(message)\n" tile_color 0x335b7cff label "[value ckptname]" note_font "Bitstream Vera Sans" selected true xpos 48 ypos -338 addUserKnob {20 controls l Controls} addUserKnob {22 data +HIDDEN T "{\n 'class_type': 'CheckpointLoaderSimple',\n 'inputs': [],\n 'outputs': ['model', 'clip', 'vae']\n}\n\n# Save and Run to update inputs\ncomfyui.nodes.update_input_nodes(nuke.thisNode())" +STARTLINE} addUserKnob {4 ckptname l ckpt_name M {sd_xl_refiner_1.0.safetensors sd_xl_base_1.0.safetensors juggernautXL_versionXInpaint.safetensors sd_v2-1_512-ema-pruned.safetensors 512-inpainting-ema.safetensors AOM3A3_orangemixs.safetensors wd-illusion-fp16.safetensors AOM3A1_orangemixs.safetensors anything-v3-fp16-pruned.safetensors sd_xl_refiner_1.0_0.9vae.safetensors AbyssOrangeMix2_hard.safetensors juggernautXL_v9Rundiffusionphoto2.safetensors illuminatiDiffusionV1_v11-unclip-h-fp16.safetensors sd_xl_base_1.0_0.9vae.safetensors sd_v1-5-pruned-emaonly.ckpt wd-1-5-beta2-aesthetic-unclip-h-fp16.safetensors sd_v2-1_768-ema-pruned.safetensors}} ckptname 512-inpainting-ema.safetensors addUserKnob {22 update -STARTLINE T "models = exe('comfyui.models_node.get_models', 'checkpoints')\nnuke.thisNode().knob('ckptname').setValues(models)"} addUserKnob {20 about l About} addUserKnob {26 _name l "" +STARTLINE T "LoadCheckpoint v1.17

Francisco Contreras - Senior Compositor
<a href=\"http://vinavfx.com\"><span style=\"color:#C8C8C8;\">vinavfx.com"} addUserKnob {26 ""} } Output { inputs 0 name Output1 xpos 0 ypos 300 } end_group set Nfce0e30 [stack 0] push $Nfce0e30 Dot { name Dot6 selected true xpos 234 ypos -328 } set Nfb54690 [stack 0] Group { name sdNegative onCreate "def exe(func, args):\n allowed_knobs = ['Boolean_Knob', 'PyScript_Knob']\n exclude_knobs = ['selected']\n\n knob = nuke.thisKnob()\n allowed_knob = knob.Class() in allowed_knobs and not knob.name() in exclude_knobs\n\n try:\n return eval(func)(args)\n except Exception as e:\n\n if not allowed_knob:\n return\n\n if not 'vina' in str(e):\n return\n\n message = 'ask Francisco Contreras for the script \"{}\", since the script for this method is not embedded in the node. Thank you.'.format(\n func)\n nuke.message(message)\n" tile_color 0x7c3433ff note_font "Bitstream Vera Sans" selected true xpos 163 ypos -252 addUserKnob {20 controls l Controls} addUserKnob {22 data +HIDDEN T "{\n 'class_type': 'CLIPTextEncode',\n 'inputs': [\n {'name': 'clip', 'outputs': ['clip']}\n ],\n 'outputs': ['conditioning']\n}\n\n# Save and Run to update inputs\ncomfyui.nodes.update_inputnodes(nuke.thisNode())" +STARTLINE} addUserKnob {43 text l text} text_ "art, concept, paint, painting, sketch, anime, cartoon, graphic, text, crayon, abstract, drawing, draw, 3d, render, illustration, cgi, digital art, design, unrealistic, semi-realistic, low quality, graphite, impressionist, artstation, watermark, overexposed, draft, blender, amateur, manga, out of focus, airbrushed, glitch, ugly, jpeg artifacts, cropped, frame, brush, watercolor, strokes, cubism, renaissance, baroque, rococo, romanticism, neoclassicism, fauvism, dadaism, post-impressionism, contemporary art, framed, stamping, impressed" addUserKnob {20 about l About} addUserKnob {26 _name l "" +STARTLINE T "sdNegative v1.10

Francisco Contreras - Senior Compositor
<a href=\"http://vinavfx.com\"><span style=\"color:#C8C8C8;\">vinavfx.com"} addUserKnob {26 ""} } Output { inputs 0 name Output1 xpos 0 ypos 300 } Input { inputs 0 name clip } end_group push $Nfb54690 Group { name sdPositive1 onCreate "def exe(func, args):\n allowed_knobs = ['Boolean_Knob', 'PyScript_Knob']\n exclude_knobs = ['selected']\n\n knob = nuke.thisKnob()\n allowed_knob = knob.Class() in allowed_knobs and not knob.name() in exclude_knobs\n\n try:\n return eval(func)(args)\n except Exception as e:\n\n if not allowed_knob:\n return\n\n if not 'vina' in str(e):\n return\n\n message = 'ask Francisco Contreras for the script \"{}\", since the script for this method is not embedded in the node. Thank you.'.format(\n func)\n nuke.message(message)\n" tile_color 0x3b6300ff selected true xpos 272 ypos -255 addUserKnob {20 controls l Controls} addUserKnob {22 data +HIDDEN T "{\n 'class_type': 'CLIPTextEncode',\n 'inputs': [\n {'name': 'clip', 'outputs': ['clip']}\n ],\n 'outputs': ['conditioning']\n}\n\n# Save and Run to update inputs\ncomfyui.nodes.update_inputnodes(nuke.thisNode())" +STARTLINE} addUserKnob {43 text l text} text_ "closeup photograph of maine coon (cat:1.2) in the yosemite national park mountains nature" addUserKnob {20 about l About} addUserKnob {26 _name l "" +STARTLINE T "sdPositive v1.5

Francisco Contreras - Senior Compositor
<a href=\"http://vinavfx.com\"><span style=\"color:#C8C8C8;\">vinavfx.com"} addUserKnob {26 ""} } Output { inputs 0 name Output1 xpos 0 ypos 300 } Input { inputs 0 name clip } end_group push $Nfce0e30 Read { inputs 0 file_type png file /net/users/linux/brian.goodwin/Desktop/yosemite_inpaint_example.png format "1024 769 0 0 1024 769 1 " origset true name Read4 label "[value first]-[value last]\n[expr \"[value last]-[value first]+1\"]" selected true xpos -341 ypos -384 } set Nfb51d30 [stack 0] Dot { name Dot2 selected true xpos -307 ypos -164 } push $Nfce0e30 push $Nfb51d30 Dot { name Dot1 selected true xpos -61 ypos -333 } Group { inputs 3 name sdVaeEncode_for_inpainting1 onCreate "def exe(func, args):\n allowed_knobs = ['Boolean_Knob', 'PyScript_Knob']\n exclude_knobs = ['selected']\n\n knob = nuke.thisKnob()\n allowed_knob = knob.Class() in allowed_knobs and not knob.name() in exclude_knobs\n\n try:\n return eval(func)(args)\n except Exception as e:\n\n if not allowed_knob:\n return\n\n if not 'vina' in str(e):\n return\n\n message = 'ask Francisco Contreras for the script \"{}\", since the script for this method is not embedded in the node. Thank you.'.format(\n func)\n nuke.message(message)\n" tile_color 0xf9962fff selected true xpos -95 ypos -162 addUserKnob {20 controls l Controls} addUserKnob {22 data +HIDDEN T "{\n 'class_type': 'VAEEncodeForInpaint',\n 'inputs': [\n {'name': 'pixels', 'outputs': ['image']},\n {'name': 'vae', 'outputs': ['vae']},\n {'name': 'mask', 'outputs': ['mask']}\n\n ],\n 'outputs': ['latent']\n}\n\n# Save and Run to update inputs\ncomfyui.nodes.update_input_nodes(nuke.thisNode())" +STARTLINE} addUserKnob {3 grow_maskby l grow_mask_by} grow_maskby 6 addUserKnob {20 about l About} addUserKnob {26 _name l "" +STARTLINE T "sdVaeEncode_for_inpainting v1.3

Francisco Contreras - Senior Compositor
<a href=\"http://vinavfx.com\"><span style=\"color:#C8C8C8;\">vinavfx.com"} addUserKnob {26 ""} } Input { inputs 0 name mask xpos 329 ypos 95 number 2 } Shuffle { in alpha green black blue black name Shuffle1 xpos 329 ypos 154 } Input { inputs 0 name pixels xpos 510 ypos -9 } Merge2 { inputs 2 bbox B mix 0.5 name Merge1 xpos 510 ypos 154 } Output { name Output1 xpos 510 ypos 244 } Input { inputs 0 name vae xpos 776 ypos 124 number 1 } end_group Group { inputs 4 name KSampler onCreate "def exe(func, args):\n allowed_knobs = ['Boolean_Knob', 'PyScript_Knob']\n exclude_knobs = ['selected']\n\n knob = nuke.thisKnob()\n allowed_knob = knob.Class() in allowed_knobs and not knob.name() in exclude_knobs\n\n try:\n return eval(func)(args)\n except Exception as e:\n\n if not allowed_knob:\n return\n\n if not 'vina' in str(e):\n return\n\n message = 'ask Francisco Contreras for the script \"{}\", since the script for this method is not embedded in the node. Thank you.'.format(\n func)\n nuke.message(message)\n" label "[value samplername]" note_font "Bitstream Vera Sans" selected true xpos 128 ypos -168 addUserKnob {20 controls l Controls} addUserKnob {22 data +HIDDEN T "{\n 'class_type': 'KSampler',\n 'inputs': [\n {'name': 'latent_image', 'outputs': ['latent']},\n {'name': 'model', 'outputs': ['model']},\n {'name': 'positive', 'outputs': ['conditioning', 'positive']},\n {'name': 'negative', 'outputs': ['conditioning', 'negative']}\n ],\n 'outputs': ['latent']\n}\n\n# Save and Run to update inputs\ncomfyui.nodes.update_inputnodes(nuke.thisNode())" +STARTLINE} addUserKnob {3 seed l seed} seed_ 2 addUserKnob {6 fixed_seed l fixed -STARTLINE} fixedseed true addUserKnob {3 steps l steps} steps 15 addUserKnob {7 cfg l cfg R 0.1 10} cfg_ 8 addUserKnob {4 samplername l sampler_name M {euler euler_ancestral heun heunpp2 dpm_2 dpm_2_ancestral lms dpm_fast dpm_adaptive dpmpp_2s_ancestral dpmpp_sde dpmpp_sde_gpu dpmpp_2m dpmpp_2m_sde dpmpp_2m_sde_gpu dpmpp_3m_sde dpmpp_3m_sde_gpu ddpm lcm ddim uni_pc uni_pc_bh2 ""}} samplername dpmppsde addUserKnob {4 scheduler l scheduler M {normal karras exponential sgm_uniform simple ddimuniform "" "" ""}} scheduler karras addUserKnob {7 denoise l denoise R 0.1 1} denoise 1 addUserKnob {20 about l About} addUserKnob {26 _name l "" +STARTLINE T "KSampler v1.20

Francisco Contreras - Senior Compositor
<a href=\"http://vinavfx.com\"><span style=\"color:#C8C8C8;\">vinavfx.com"} addUserKnob {26 ""} } Input { inputs 0 name latent_image } Output { name Output1 xpos 231 ypos 63 } Input { inputs 0 name model number 1 } Input { inputs 0 name positive number 2 } Input { inputs 0 name negative number 3 } end_group Group { inputs 2 name sdVaeDecode1 onCreate "def exe(func, args):\n allowed_knobs = ['Boolean_Knob', 'PyScript_Knob']\n exclude_knobs = ['selected']\n\n knob = nuke.thisKnob()\n allowed_knob = knob.Class() in allowed_knobs and not knob.name() in exclude_knobs\n\n try:\n return eval(func)(args)\n except Exception as e:\n\n if not allowed_knob:\n return\n\n if not 'vina' in str(e):\n return\n\n message = 'ask Francisco Contreras for the script \"{}\", since the script for this method is not embedded in the node. Thank you.'.format(\n func)\n nuke.message(message)\n" tile_color 0xf9962fff selected true xpos 48 ypos -96 addUserKnob {20 controls l Controls} addUserKnob {22 data +HIDDEN T "{\n 'class_type': 'VAEDecode',\n 'inputs': [\n {'name': 'samples', 'outputs': ['latent']},\n {'name': 'vae', 'outputs': ['vae']}\n ],\n 'outputs': ['image']\n}\n\n# Save and Run to update inputs\ncomfyui.nodes.update_input_nodes(nuke.thisNode())" +STARTLINE} addUserKnob {20 about l About} addUserKnob {26 _name l "" +STARTLINE T "sdVaeDecode v1.4

Francisco Contreras - Senior Compositor
<a href=\"http://vinavfx.com\"><span style=\"color:#C8C8C8;\">vinavfx.com"} addUserKnob {26 ""} } Input { inputs 0 name vae xpos 180 ypos -9 number 1 } Input { inputs 0 name samples xpos 70 ypos -9 } Output { name Output1 xpos 59 ypos 67 } end_group Group { name SaveImage1 onCreate "def exe(func, args):\n allowed_knobs = ['Boolean_Knob', 'PyScript_Knob']\n exclude_knobs = ['selected']\n\n knob = nuke.thisKnob()\n allowed_knob = knob.Class() in allowed_knobs and not knob.name() in exclude_knobs\n\n try:\n return eval(func)(args)\n except Exception as e:\n\n if not allowed_knob:\n return\n\n if not 'vina' in str(e):\n return\n\n message = 'ask Francisco Contreras for the script \"{}\", since the script for this method is not embedded in the node. Thank you.'.format(\n func)\n nuke.message(message)\n" knobChanged "\nif nuke.thisKnob().name() == 'outside_read':\n comfyui.submit.outside_read(nuke.thisNode())\n\n" tile_color 0x609e38ff note_font "Bitstream Vera Sans" selected true xpos 42 ypos -36 addUserKnob {20 controls l Controls} addUserKnob {22 data +HIDDEN T "{\n 'class_type': 'SaveImage',\n 'inputs': [\n {'name': 'images', 'outputs': ['image']}\n ],\n 'outputs': []\n}\n\n# Save and Run to update inputs\ncomfyui.nodes.update_input_nodes(nuke.thisNode())" +STARTLINE} addUserKnob {22 comfyui_submit l submit T exe('comfyui.submit.comfyui_submit') +STARTLINE} addUserKnob {22 backup_result -STARTLINE T exe('comfyui.saveimage_node.save_image_backup')} addUserKnob {6 outside_read +STARTLINE} addUserKnob {20 about l About} addUserKnob {26 _name l "" +STARTLINE T "SaveImage v1.24

Francisco Contreras - Senior Compositor
<a href=\"http://vinavfx.com\"><span style=\"color:#C8C8C8;\">vinavfx.com"} addUserKnob {26 ""} } Input { inputs 0 name images xpos 145 ypos 93 } Read { inputs 0 file_type png file TRK_0010_compositing_comfyuitest_v003SaveImage1#####_.png format "2276 1280 0 0 2276 1280 1 " origset true on_error black version 482 colorspace sRGB in_colorspace scene_linear out_colorspace scene_linear name read xpos -120 ypos 25 } Output { name Output xpos 145 ypos 257 } end_group

aracid commented 4 months ago

Capture

vinavfx commented 1 month ago

Example ok