krita-ai-diffusion icon indicating copy to clipboard operation
krita-ai-diffusion copied to clipboard

'NoneType' object has no attribute 'tokenize'

Open CannibalKush opened this issue 1 year ago • 4 comments

Firstly, thanks for adding Flux support. The instructions outlined in this guide work great!

However, when I try a specific popular flux checkpoint found on Civitai, I get the error 'NoneType' object has no attribute 'tokenize'.

In my client.log, it shows:

2024-09-15 00:17:06,624 ERROR Job Job[local=373959a4-4f30-4099-a27d-492d62524497, remote=9567c79b-0807-4a95-a6e1-db31eeef12ea] failed: 'NoneType' object has no attribute 'tokenize'
['  File "H:\\Krita\\server\\ComfyUI\\execution.py", line 323, in execute\n    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)\n', '  File "H:\\Krita\\server\\ComfyUI\\execution.py", line 198, in get_output_data\n    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)\n', '  File "H:\\Krita\\server\\ComfyUI\\execution.py", line 169, in _map_node_over_list\n    process_inputs(input_dict, i)\n', '  File "H:\\Krita\\server\\ComfyUI\\execution.py", line 158, in process_inputs\n    results.append(getattr(obj, func)(**inputs))\n', '  File "H:\\Krita\\server\\ComfyUI\\nodes.py", line 64, in encode\n    tokens = clip.tokenize(text)\n']

Seems we're having trouble finding the correct clip or something. The model uses t5xxl_fp8_e4m3fn.safetensors I believe, and the file is present in my clip folder as outlined in above guide.

Am I missing something simple?

CannibalKush avatar Sep 14 '24 22:09 CannibalKush

Which folder did you put it in? If it needs T5 as external file it should go into diffusion_models.

Acly avatar Sep 16 '24 07:09 Acly

Firstly, thanks for adding Flux support. The instructions outlined in this guide work great!

However, when I try a specific popular flux checkpoint found on Civitai, I get the error 'NoneType' object has no attribute 'tokenize'.

In my client.log, it shows:

2024-09-15 00:17:06,624 ERROR Job Job[local=373959a4-4f30-4099-a27d-492d62524497, remote=9567c79b-0807-4a95-a6e1-db31eeef12ea] failed: 'NoneType' object has no attribute 'tokenize'
['  File "H:\\Krita\\server\\ComfyUI\\execution.py", line 323, in execute\n    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)\n', '  File "H:\\Krita\\server\\ComfyUI\\execution.py", line 198, in get_output_data\n    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)\n', '  File "H:\\Krita\\server\\ComfyUI\\execution.py", line 169, in _map_node_over_list\n    process_inputs(input_dict, i)\n', '  File "H:\\Krita\\server\\ComfyUI\\execution.py", line 158, in process_inputs\n    results.append(getattr(obj, func)(**inputs))\n', '  File "H:\\Krita\\server\\ComfyUI\\nodes.py", line 64, in encode\n    tokens = clip.tokenize(text)\n']

Seems we're having trouble finding the correct clip or something. The model uses t5xxl_fp8_e4m3fn.safetensors I believe, and the file is present in my clip folder as outlined in above guide.

Am I missing something simple?

same to you, I tried using ae.safetensors or placing T5 in the diffusion_models folder, but still got the same error.

sunnysnake avatar Sep 18 '24 05:09 sunnysnake

I meant whatever "checkpoint" you downloaded might have to go into diffusion_models. Can't really say without seeing the model.

T5 should always be in clip.

Acly avatar Sep 19 '24 08:09 Acly

Is this issue related to https://github.com/comfyanonymous/ComfyUI/issues/4624#issuecomment-2311971542 ?

These smaller models ( ~ 11 GB ), don't have CLIP/text encoder weights. The larger ones ( ~ 22 GB ) also don't have CLIP/text encoder weights ( but they are in FP16 format, instead of FP8 ).

For them, you use the UNET loader.

https://comfyanonymous.github.io/ComfyUI_examples/flux/

361731201-28f99366-322b-46cb-a6b0-28ea3ae1c1a2

Only the ones with 15 GB ~ 17 GB are checkpoint versions and include CLIP/text encoder weights ( they are all in FP8 ).

maplecasino avatar Sep 21 '24 17:09 maplecasino

I have a similar problem with this particular model (the main download, i.e. 11.08Gb f16 version):

https://civitai.com/models/161068/stoiqo-newreality-flux-sd-xl-lightning

The model has the .safetensors extension. If I put it under diffusion_models, it doesn't appear in Krita. And, if I move it to the checkpoints directory, it is listed but fails with the same error as shown above.

I have no problem with the 20.34Gb fp8 version, which seems to include the text encoder and clip. And I have t5xxl_fp8_e4m3fn.safetensors and clip_l.safetensors in my models/clip folder.

Am I missing something?

mysticfall avatar Oct 24 '24 16:10 mysticfall

It should work. Make sure you have latest versions. Verify it's listed in http://127.0.0.1:8188/api/etn/model_info/diffusion_models

Acly avatar Oct 25 '24 08:10 Acly

It should work. Make sure you have latest versions. Verify it's listed in http://127.0.0.1:8188/api/etn/model_info/diffusion_models

I think I already have everything up-to-date. The endpoint in question shows a suspicious error, however:

{
  "FLUX1/stoiqoNewrealityFLUXSD_f1DAlphaTwo.safetensors": {
    "base_model": "unknown", 
    "error": "Failed to detect base model: argument of type 'NoneType' is not iterable"
}}

If there's anything I can help debug the issue please let me know.

mysticfall avatar Oct 25 '24 08:10 mysticfall

Looks like that model uses some prefix that is usually used by checkpoints (Flux base model does not do this).

It should be detected if you update comfyui-tooling-nodes: https://github.com/Acly/comfyui-tooling-nodes/commit/20c8039a98e69b93ba7e58ac2e2cef846f2072c2

Acly avatar Oct 25 '24 11:10 Acly

Looks like that model uses some prefix that is usually used by checkpoints (Flux base model does not do this).

It should be detected if you update comfyui-tooling-nodes: Acly/comfyui-tooling-nodes@20c8039

I just tested the patch and it fixed my problem, indeed. The model now works flawlessly on Krita.

Thanks much for the help!

mysticfall avatar Oct 25 '24 11:10 mysticfall

Looks like that model uses some prefix that is usually used by checkpoints (Flux base model does not do this).

It should be detected if you update comfyui-tooling-nodes: Acly/comfyui-tooling-nodes@20c8039

Could you please tell me what I'm doing wrong? I updated comfyui-tooling-nodes, added fluxTextencoderT5XxlFp8_v10 to the diffusion_models folder, but it still says 'NoneType' object has no attribute 'tokenize'. I use the https://civitai.com/models/141592/pixelwave model image

oleshanepro avatar Oct 26 '24 16:10 oleshanepro

Looks like that model uses some prefix that is usually used by checkpoints (Flux base model does not do this). It should be detected if you update comfyui-tooling-nodes: Acly/comfyui-tooling-nodes@20c8039

Could you please tell me what I'm doing wrong? I updated comfyui-tooling-nodes, added fluxTextencoderT5XxlFp8_v10 to the diffusion_models folder, but it still says 'NoneType' object has no attribute 'tokenize'. I use the https://civitai.com/models/141592/pixelwave model image

so I added the checkpoint to Diffusion_models and it works fine, thanks for your great work!

oleshanepro avatar Oct 26 '24 16:10 oleshanepro