chflame163 / ComfyUI_LayerStyle

A set of nodes for ComfyUI that can composite layer and mask to achieve Photoshop like functionality.
MIT License
1.31k stars 71 forks source link

运行JoyCaption2提示如下错误请问要如何解决呢? #339

Open lzhfdwu007 opened 2 days ago

lzhfdwu007 commented 2 days ago

系统环境是WINDOWS+torch2.4.1+cuda12.4错误信息如下 ayerUtility: JoyCaption2 apply_chat_template requires jinja2>=3.1.0 to be installed. Your version is 3.0.3.

2024-10-12 01:11:09,476 - root - INFO - got prompt 2024-10-12 01:11:32,014 - root - ERROR - !!! Exception during processing !!! apply_chat_template requires jinja2>=3.1.0 to be installed. Your version is 3.0.3. 2024-10-12 01:11:32,017 - root - ERROR - Traceback (most recent call last): File "D:\ComfyUI\ComfyUI\execution.py", line 323, in execute output_data, output_ui, has_subgraph = get_output_data(obj, input_data_all, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\ComfyUI\ComfyUI\execution.py", line 198, in get_output_data return_values = _map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\ComfyUI\ComfyUI\execution.py", line 169, in _map_node_over_list process_inputs(input_dict, i) File "D:\ComfyUI\ComfyUI\execution.py", line 158, in process_inputs results.append(getattr(obj, func)(*inputs)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\ComfyUI\ComfyUI\custom_nodes\ComfyUI_LayerStyle\py\joycaption_alpha_2.py", line 501, in joycaption2 caption = stream_chat([img], caption_type, caption_length, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\ComfyUI\py_cu124\Lib\site-packages\torch\utils_contextlib.py", line 116, in decorate_context return func(args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "D:\ComfyUI\ComfyUI\custom_nodes\ComfyUI_LayerStyle\py\joycaption_alpha_2.py", line 286, in stream_chat convo_string = tokenizer.apply_chat_template(convo, tokenize=False, add_generation_prompt=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\ComfyUI\py_cu124\Lib\site-packages\transformers\tokenization_utils_base.py", line 1809, in apply_chat_template compiled_template = _compile_jinja_template(chat_template) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\ComfyUI\py_cu124\Lib\site-packages\transformers\utils\chat_template_utils.py", line 405, in _compile_jinja_template raise ImportError( ImportError: apply_chat_template requires jinja2>=3.1.0 to be installed. Your version is 3.0.3.

2024-10-12 01:11:32,018 - root - INFO - Prompt executed in 22.47 seconds 2024-10-12 01:12:01,516 - root - INFO - got prompt 2024-10-12 01:12:07,971 - accelerate.utils.modeling - INFO - We will use 90% of the memory on device 0 for storing the model, and 10% for the buffer to avoid OOM. You can set max_memory in to a higher value to use more memory (at your own risk). 2024-10-12 01:12:20,211 - root - ERROR - !!! Exception during processing !!! apply_chat_template requires jinja2>=3.1.0 to be installed. Your version is 3.0.3. 2024-10-12 01:12:20,211 - root - ERROR - Traceback (most recent call last): File "D:\ComfyUI\ComfyUI\execution.py", line 323, in execute output_data, output_ui, has_subgraph = get_output_data(obj, input_data_all, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\ComfyUI\ComfyUI\execution.py", line 198, in get_output_data return_values = _map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\ComfyUI\ComfyUI\execution.py", line 169, in _map_node_over_list process_inputs(input_dict, i) File "D:\ComfyUI\ComfyUI\execution.py", line 158, in process_inputs results.append(getattr(obj, func)(*inputs)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\ComfyUI\ComfyUI\custom_nodes\ComfyUI_LayerStyle\py\joycaption_alpha_2.py", line 501, in joycaption2 caption = stream_chat([img], caption_type, caption_length, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\ComfyUI\py_cu124\Lib\site-packages\torch\utils_contextlib.py", line 116, in decorate_context return func(args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "D:\ComfyUI\ComfyUI\custom_nodes\ComfyUI_LayerStyle\py\joycaption_alpha_2.py", line 286, in stream_chat convo_string = tokenizer.apply_chat_template(convo, tokenize=False, add_generation_prompt=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\ComfyUI\py_cu124\Lib\site-packages\transformers\tokenization_utils_base.py", line 1809, in apply_chat_template compiled_template = _compile_jinja_template(chat_template) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\ComfyUI\py_cu124\Lib\site-packages\transformers\utils\chat_template_utils.py", line 405, in _compile_jinja_template raise ImportError( ImportError: apply_chat_template requires jinja2>=3.1.0 to be installed. Your version is 3.0.3.

2024-10-12 01:12:20,212 - root - INFO - Prompt executed in 18.61 seconds

## Attached Workflow
Please make sure that workflow does not contain any sensitive information such as API keys or passwords.

{"last_node_id":16,"last_link_id":26,"nodes":[{"id":3,"type":"LoadImage","pos":{"0":66,"1":460},"size":{"0":313,"1":366},"flags":{},"order":0,"mode":0,"inputs":[],"outputs":[{"name":"IMAGE","type":"IMAGE","links":[24],"slot_index":0,"label":"图像"},{"name":"MASK","type":"MASK","links":null,"label":"遮罩"}],"properties":{"Node name for S&R":"LoadImage"},"widgets_values":["00000-2576117923.jpeg","image"]},{"id":15,"type":"ShowText|pysssss","pos":{"0":1197,"1":470},"size":{"0":506,"1":385},"flags":{},"order":3,"mode":0,"inputs":[{"name":"text","type":"STRING","link":26,"widget":{"name":"text"},"label":"文本"}],"outputs":[{"name":"STRING","type":"STRING","links":null,"shape":6,"label":"字符串"}],"properties":{"Node name for S&R":"ShowText|pysssss"},"widgets_values":["","Huluwa, a young girl with a radiant smile, sits atop a vibrant green Tyrannosaurus Rex, surrounded by the lush foliage of a dense jungle. The warm, golden light of the early morning sun filters through the canopy above, casting dappled shadows on the forest floor. In this idyllic scene, Huluwa appears carefree, her eyes shining with excitement as she gazes out at the camera.\n\nThe camera, positioned at a slight angle, captures the dynamic interaction between Huluwa and the T-Rex, emphasizing their symbiotic relationship. The composition of the image is guided by the rule of thirds, with the T-Rex's massive head positioned along the top third line, and Huluwa situated along the bottom third line, creating a sense of balance and harmony.\n\nAs the camera pans across the jungle, the viewer's attention is drawn to the intricate details of the foliage, from the delicate fronds of the tropical plants to the towering trunks of the ancient trees. The use of leading lines, in the form of the winding jungle path, adds depth and visual interest to the image, drawing the viewer's eye into the heart of the jungle.\n\nIn this captivating scene, Huluwa's bright orange t-shirt and blue shorts provide a pop of color against the lush greenery, while the T-Rex's vibrant green and orange scales seem to come alive in the soft, diffused light. The overall effect is one of enchantment and wonder, as if the"]},{"id":13,"type":"LayerUtility: JoyCaption2ExtraOptions","pos":{"0":391,"1":581},"size":{"0":328,"1":466},"flags":{},"order":1,"mode":0,"inputs":[],"outputs":[{"name":"extra_option","type":"JoyCaption2ExtraOption","links":[25],"slot_index":0,"shape":3,"label":"extra_option"}],"properties":{"Node name for S&R":"LayerUtility: JoyCaption2ExtraOptions"},"widgets_values":[true,false,true,true,false,false,false,false,false,true,true,false,false,false,true,true,false,"Huluwa"],"color":"rgba(38, 73, 116, 0.7)"},{"id":16,"type":"LayerUtility: JoyCaption2","pos":{"0":739,"1":466},"size":{"0":419,"1":322},"flags":{},"order":2,"mode":0,"inputs":[{"name":"image","type":"IMAGE","link":24,"label":"image"},{"name":"extra_options","type":"JoyCaption2ExtraOption","link":25,"shape":7,"label":"extra_options"}],"outputs":[{"name":"text","type":"STRING","links":[26],"slot_index":0,"shape":6,"label":"text"}],"properties":{"Node name for S&R":"LayerUtility: JoyCaption2"},"widgets_values":["Orenguteng/Llama-3.1-8B-Lexi-Uncensored-V2","cuda","bf16","text_model","Descriptive (Informal)","any","",300,0.9,0.6,false],"color":"rgba(38, 73, 116, 0.7)"}],"links":[[24,3,0,16,0,"IMAGE"],[25,13,0,16,1,"JoyCaption2ExtraOption"],[26,16,0,15,0,"STRING"]],"groups":[],"config":{},"extra":{"ds":{"scale":1.3310000000000006,"offset":[17.17247131590798,-147.97473321518703]}},"version":0.4}



## Additional Context
(Please add any additional context or steps to reproduce the error here)
lzhfdwu007 commented 2 days ago

不知道这个要如何解决呢?

lzhfdwu007 commented 2 days ago

又有一个新的报错。。。 cannot access local variable 'text_model' where it is not associated with a value

Loading checkpoint shards: 0%| | 0/4 [00:00<?, ?it/s] Error loading models: No such file or directory: "D:\ComfyUI\ComfyUI\models\LLM\Meta-Llama-3.1-8B-Instruct\model-00001-of-00004.safetensors" !!! Exception during processing !!! cannot access local variable 'text_model' where it is not associated with a value Traceback (most recent call last): File "D:\ComfyUI\ComfyUI\execution.py", line 323, in execute output_data, output_ui, has_subgraph = get_output_data(obj, input_data_all, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\ComfyUI\ComfyUI\execution.py", line 198, in get_output_data return_values = _map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\ComfyUI\ComfyUI\execution.py", line 169, in _map_node_over_list process_inputs(input_dict, i) File "D:\ComfyUI\ComfyUI\execution.py", line 158, in process_inputs results.append(getattr(obj, func)(**inputs)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\ComfyUI\ComfyUI\custom_nodes\ComfyUI_LayerStyle\py\joycaption_alpha_2.py", line 489, in joycaption2 models = load_models(model_path, dtype, vlm_lora, device) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\ComfyUI\ComfyUI\custom_nodes\ComfyUI_LayerStyle\py\joycaption_alpha_2.py", line 157, in load_models return clip_processor, clip_model, tokenizer, text_model, image_adapter ^^^^^^^^^^ UnboundLocalError: cannot access local variable 'text_model' where it is not associated with a value

chflame163 commented 2 days ago

1、requires jinja2>=3.1.0 to be installed. Your version is 3.0.3. 2、检查transformers版本是否过低

K-O-N-B commented 2 days ago

1、requires jinja2>=3.1.0 to be installed. Your version is 3.0.3. 2、检查transformers版本是否过低

大佬还有我的问题: Error loading models: Descriptors cannot be created directly. If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0. If you cannot immediately regenerate your protos, some other possible workarounds are:

  1. Downgrade the protobuf package to 3.20.x or lower.
  2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).

More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates !!! Exception during processing !!! cannot access local variable 'clip_processor' where it is not associated with a value Traceback (most recent call last): File "H:\ComfyUI-qiuye\ComfyUI\execution.py", line 323, in execute output_data, output_ui, has_subgraph = get_output_data(obj, input_data_all, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "H:\ComfyUI-qiuye\ComfyUI\execution.py", line 198, in get_output_data return_values = _map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "H:\ComfyUI-qiuye\ComfyUI\execution.py", line 169, in _map_node_over_list process_inputs(input_dict, i) File "H:\ComfyUI-qiuye\ComfyUI\execution.py", line 158, in process_inputs results.append(getattr(obj, func)(**inputs)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "H:\ComfyUI-qiuye\ComfyUI\custom_nodes\ComfyUI_LayerStyle\py\joycaption_alpha_2.py", line 489, in joycaption2 models = load_models(model_path, dtype, vlm_lora, device) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "H:\ComfyUI-qiuye\ComfyUI\custom_nodes\ComfyUI_LayerStyle\py\joycaption_alpha_2.py", line 157, in load_models return clip_processor, clip_model, tokenizer, text_model, image_adapter ^^^^^^^^^^^^^^ UnboundLocalError: cannot access local variable 'clip_processor' where it is not associated with a value

lzhfdwu007 commented 2 days ago

1、requires jinja2>=3.1.0 to be installed. Your version is 3.0.3.1、需要安装 jinja2>=3.1.0。您的版本是 3.0.3。 2、检查transformers版本是否过低

谢谢!!!还是有问题,请问下jinja2和transformers都是要安装在便携包的依赖环境文件夹里吗? 比如我自己的comfyui便携包的python是放在py_cu124下面,那么是是要进到py_cu124里安装最新的transformers和jinja2吗? 如果是的话,安装这两个依赖的代码您方便告诉我吗?

lzhfdwu007 commented 2 days ago

python -m pip install Jinja2 请问这样对吗?

lzhfdwu007 commented 2 days ago

2、检查transformers版本是否过低 不知道哪个版本的transformers会比较推荐呢?

chflame163 commented 2 days ago

Refer this: https://github.com/chflame163/ComfyUI_LayerStyle/issues/344#issuecomment-2408556733

lzhfdwu007 commented 1 day ago

Refer this: #344 (comment)

非常感谢,你帮我解决了问题!! 我把transformers版本改成==4.45.0后就解决了问题。THX

K-O-N-B commented 1 day ago

Refer this: #344 (comment)

非常感谢,你帮我解决了问题!! 我把transformers版本改成==4.45.0后就解决了问题。THX

请问怎么改transformers版本?小白发问

lzhfdwu007 commented 2 hours ago

Refer this: #344 (comment)

非常感谢,你帮我解决了问题!! 我把transformers版本改成==4.45.0后就解决了问题。THX

请问怎么改transformers版本?小白发问

在你自己的依赖环境目录下进入CMD 然后输入 python -m pip install transformers==4.45.0 我是这么弄的

K-O-N-B commented 1 hour ago

Refer this: #344 (comment)

非常感谢,你帮我解决了问题!! 我把transformers版本改成==4.45.0后就解决了问题。THX

请问怎么改transformers版本?小白发问

在你自己的依赖环境目录下进入CMD 然后输入 python -m pip install transformers==4.45.0 我是这么弄的

谢谢!我回头试试!