vinavfx / nuke_comfyui

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

Processing interrupted #1

Open Dribliblu opened 2 months ago

Dribliblu commented 2 months ago

Hello, I tried to use a shared folder for the comfy installation like : COMFYUI_DIR = '\\FARM\Users\iiw\Documents\ComfyUI_windows_portable\ComfyUI'

But when submitting this error is returned : ERROR:websocket:error from callback <function progress..on_message at 0x0000018D981C2CB0>: 'utf-32-be' codec can't decode bytes in position 8-11: code point not in range(0x110000)

I guess this is related to this comfy folder but maybe not. Would yuo have any ideas on how to fix this ?

Thank you

vinavfx commented 2 months ago

Hello, what version of nuke are you using? Have you tried it in a local folder?

Dribliblu commented 2 months ago

I'm using Nuke 15.0 and indeed after a few more test i do have the same error on a local folder. In the comfy console I can see the process interupting itself : image

vinavfx commented 2 months ago

copy your script nk to me to try it please. You should also try confyui on the web, if it works there it should also work in nuke

Dribliblu commented 2 months ago

It's working on the web, and also with api call (i'v tried to do my own nuke gizmo to submit comfy generation a few days ago)

Here is the nuke script : (edit : removing for the sake of the scroll wheel)

vinavfx commented 2 months ago

nk doesn't work for me, copy the nodes and paste them here

Dribliblu commented 2 months ago

set cut_paste_input [stack 0] version 15.0 v1 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 -157 ypos -230 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 {epicrealism_naturalSinRC1VAE.safetensors juggernautXL_version6Rundiffusion.safetensors realvisxlV40_v40LightningBakedvae.safetensors sd_xl_base_1.0_0.9vae.safetensors sd_xl_refiner_1.0_0.9vae.safetensors}} ckptname realvisxlV40_v40LightningBakedvae.safetensors addUserKnob {22 update -STARTLINE T "models = exe('comfyui.models_node.get_models', 'checkpoints')\nif models:\n nuke.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 N2a698000 [stack 0] push $N2a698000 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 -208 ypos -119 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 $N2a698000 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 -22 ypos -137 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_ "a cat" 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 $N2a698000 Group { inputs 0 name EmptyLatentImage3 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 "this = nuke.thisNode()\nformat_knob = this.knob('format')\n\nformats = [\n [512, 512],\n [512, 768],\n [768, 512],\n [768, 768],\n [768, 1152],\n [1152, 768],\n [1024, 1024],\n [1024, 1536],\n [1536, 1024],\n]\n\nwidthknob = this.knob('width')\nheightknob = this.knob('height')\n\nwidth_knob.setEnabled(True)\nheight_knob.setEnabled(True)\n\nif not 'custom' in format_knob.value():\n index = int(format_knob.getValue())\n width, height = formats[index]\n \n width_knob.setValue(width)\n height_knob.setValue(height)\n\n width_knob.setEnabled(False)\n height_knob.setEnabled(False)\n" tilecolor 0xa57aaaff label "[value width ] x [value height_]" selected true xpos 38 ypos -82 addUserKnob {20 controls l Controls} addUserKnob {22 data +HIDDEN T "{\n 'class_type': 'EmptyLatentImage',\n 'inputs': [],\n 'outputs': ['latent']\n}\n\n# Save and Run to update inputs\ncomfyui.nodes.update_inputnodes(nuke.thisNode())" +STARTLINE} addUserKnob {4 format M {"Square - 512" "Portrait - 512" "Landscape - 512" "Square - 768" "Portrait - 768" "Landscape - 768" "Square - 1024" "Portrait - 1024" "Landscape - 1024" custom "" "" "" "" "" "" "" "" "" "" "" "" ""}} format "Square - 1024" addUserKnob {3 width l pixels +DISABLED} width 1024 addUserKnob {3 height l "" -STARTLINE +DISABLED} height_ 1024 addUserKnob {3 batchsize l "batch_size / frames"} batchsize 1 addUserKnob {20 about l About} addUserKnob {26 name l "" +STARTLINE T "EmptyLatentImage v1.11

Francisco Contreras - Senior Compositor
<a href=\"http://vinavfx.com\"><span style=\"color:#C8C8C8;\">vinavfx.com"} addUserKnob {26 ""} } Crop { inputs 0 box {0 0 {parent.width
} {parent.height_}} reformat true crop false name Crop1 xpos -40 ypos 182 } FrameRange { first_frame 1 last_frame {{parent.batchsize}} time "" name FrameRange1 xpos -40 ypos 206 } Output { name Output1 xpos -40 ypos 231 } 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 -108 ypos -66 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_ 1607 addUserKnob {6 fixedseed l fixed -STARTLINE} 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 sdVaeDecode 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 -108 ypos 37 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 SaveImage2 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 -108 ypos 74 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} outside_read true 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 C:/Users/iiw/Documents/ComfyUI_windows_portable/ComfyUI/output/Untitled_SaveImage2/UntitledSaveImage2#####_.png format "2276 1280 0 0 2276 1280 1 " last 0 origlast 0 origset true on_error black version 476 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

vinavfx commented 2 months ago

I already tried it on nuke 15 Windows, it works for me, you can verify that the system's python version is on the same python version as on nuke, nuke 15 is with python 3.10.

recently fixed a similar error, maybe cloning the repo before this was like 20 hours ago: https://github.com/vinavfx/nuke_comfyui/commit/2e19a860c1392a5618eab977f6a519ba1f395099

menu.py:

import nuke nuke.pluginAddPath('C:/Users/vm/AppData/Local/Programs/Python/Python310/Lib/site-packages')

import nuke_comfyui as comfyui comfyui.setup()

theridefox commented 2 months ago

Hi! i have this problem if i start nuke

Traceback (most recent call last): File "C:/Users/USER/.nuke/menu.py", line 87, in import nuke_comfyui as comfyui File "C:/Users/USER/.nuke\nuke_comfyui__init.py", line 8, in from .src import * File "C:/Users/USER/.nuke\nuke_comfyui\src__init__.py", line 1, in from . import ( File "C:/Users/USER/.nuke\nuke_comfyui\src\submit.py", line 14, in import websocket File "C:/Users/USER/AppData/Local/Programs/Python/Python39/Lib/site-packages\websocket\init__.py", line 20, in from ._app import WebSocketApp, setReconnect File "C:/Users/USER/AppData/Local/Programs/Python/Python39/Lib/site-packages\websocket_app.py", line 10, in from ._core import WebSocket, getdefaulttimeout File "C:/Users/USER/AppData/Local/Programs/Python/Python39/Lib/site-packages\websocket_core.py", line 10, in from ._handshake import * File "C:/Users/USER/AppData/Local/Programs/Python/Python39/Lib/site-packages\websocket_handshake.py", line 122 if subprotocols := options.get("subprotocols"): ^ SyntaxError: invalid syntax

vinavfx commented 2 months ago

open another issue for this.

but first try just importing the add line where the websocket is, and then add in the script editor, import websocket, it should work that way first. For nuke to work you have to be able to import websocket

Dribliblu commented 2 months ago

I have tried with python 9 10 and 11 without success and i'm up to date on the repo. I will try to do a fresh install of comfy since the one i'm using is full of custom nodes and i'll let you know if it help; Thank you

DerickYau commented 2 months ago

Hello, Thank you for your nice work. When I use the submit of the SaveImage node, the following error message pops up:

Traceback (most recent call last): File "C:\Users/About/.nuke\nuke_comfyui\src\connection.py", line 31, in send_request error = json.loads(e.read()) File "C:\Program Files\Nuke15.0v4\python310.zip\json__init__.py", line 346, in loads return _default_decoder.decode(s) File "C:\Program Files\Nuke15.0v4\python310.zip\json\decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "C:\Program Files\Nuke15.0v4\python310.zip\json\decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Then Nuke crashed.