ComfyUI icon indicating copy to clipboard operation
ComfyUI copied to clipboard

new Controlnet for 3.5Large,'NoneType" object has no attribute 'keys’

Open slmonker opened this issue 2 years ago • 16 comments

Expected Behavior

loading the new 3.5 large controlnet file

Actual Behavior

'NoneType" object has no attribute 'keys’

Steps to Reproduce

29d8951689e4a2c14622373a9ad305d ![sd3 5_large_canny](https://github.com/user-attachments/assets/a6090e1d-2ca2-4146-a5a8-aeed693db2fa)

Debug Logs

Prompt executed in 0.14 seconds
got prompt
!!! Exception during processing !!! 'NoneType' object has no attribute 'keys'
Traceback (most recent call last):
  File "D:\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\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_windows_portable_nvidia\ComfyUI_windows_portable\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_windows_portable_nvidia\ComfyUI_windows_portable\ComfyUI\execution.py", line 169, in _map_node_over_list
    process_inputs(input_dict, i)
  File "D:\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\ComfyUI\execution.py", line 158, in process_inputs
    results.append(getattr(obj, func)(**inputs))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\ComfyUI\nodes.py", line 771, in load_controlnet
    controlnet = comfy.controlnet.load_controlnet(controlnet_path)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\ComfyUI\comfy\controlnet.py", line 654, in load_controlnet
    cnet = load_controlnet_state_dict(comfy.utils.load_torch_file(ckpt_path, safe_load=True), model=model, model_options=model_options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\ComfyUI\comfy\controlnet.py", line 563, in load_controlnet_state_dict
    return load_controlnet_mmdit(controlnet_data, model_options=model_options) #SD3 diffusers controlnet
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\ComfyUI\comfy\controlnet.py", line 432, in load_controlnet_mmdit
    model_config, operations, load_device, unet_dtype, manual_cast_dtype, offload_device = controlnet_config(new_sd, model_options=model_options)
                                                                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\ComfyUI\comfy\controlnet.py", line 398, in controlnet_config
    model_config = comfy.model_detection.model_config_from_unet(sd, "", True)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\ComfyUI\comfy\model_detection.py", line 327, in model_config_from_unet
    unet_config = detect_unet_config(state_dict, unet_key_prefix)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\ComfyUI\comfy\model_detection.py", line 37, in detect_unet_config
    state_dict_keys = list(state_dict.keys())
                           ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'keys'

Other

No response

slmonker avatar Nov 26 '24 16:11 slmonker

I'm seeing multiple other people with this as well.

festivus37 avatar Nov 26 '24 16:11 festivus37

Chiming in with the same error trying out the SD 3.5 demo workflows

ComfyUI Error Report

Error Details

  • Node ID: 57
  • Node Type: ControlNetLoader
  • Exception Type: AttributeError
  • Exception Message: 'NoneType' object has no attribute 'keys'

Stack Trace

  File "D:\ComfyUI05\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:\ComfyUI05\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:\ComfyUI05\ComfyUI\execution.py", line 169, in _map_node_over_list
    process_inputs(input_dict, i)

  File "D:\ComfyUI05\ComfyUI\execution.py", line 158, in process_inputs
    results.append(getattr(obj, func)(**inputs))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "D:\ComfyUI05\ComfyUI\nodes.py", line 771, in load_controlnet
    controlnet = comfy.controlnet.load_controlnet(controlnet_path)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "D:\ComfyUI05\ComfyUI\comfy\controlnet.py", line 654, in load_controlnet
    cnet = load_controlnet_state_dict(comfy.utils.load_torch_file(ckpt_path, safe_load=True), model=model, model_options=model_options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "D:\ComfyUI05\ComfyUI\comfy\controlnet.py", line 563, in load_controlnet_state_dict
    return load_controlnet_mmdit(controlnet_data, model_options=model_options) #SD3 diffusers controlnet
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "D:\ComfyUI05\ComfyUI\comfy\controlnet.py", line 432, in load_controlnet_mmdit
    model_config, operations, load_device, unet_dtype, manual_cast_dtype, offload_device = controlnet_config(new_sd, model_options=model_options)
                                                                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "D:\ComfyUI05\ComfyUI\comfy\controlnet.py", line 398, in controlnet_config
    model_config = comfy.model_detection.model_config_from_unet(sd, "", True)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "D:\ComfyUI05\ComfyUI\comfy\model_detection.py", line 327, in model_config_from_unet
    unet_config = detect_unet_config(state_dict, unet_key_prefix)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "D:\ComfyUI05\ComfyUI\comfy\model_detection.py", line 37, in detect_unet_config
    state_dict_keys = list(state_dict.keys()

arlechinu avatar Nov 26 '24 16:11 arlechinu

seems like they r working on it……

slmonker avatar Nov 26 '24 16:11 slmonker

Update ComfyUI. Just the blog was revealed before pushing the commit. lol.

ltdrdata avatar Nov 26 '24 16:11 ltdrdata

Funny, I updated before trying the workflows :) seems to work fine now after another ComfyUI update, cheers!

arlechinu avatar Nov 26 '24 16:11 arlechinu

Funny, I updated before trying the workflows :) seems to work fine now after another ComfyUI update, cheers!

33d1c1ec3a79e922cf90d52d9d74c60 4090,24GB Vram fully occupied

slmonker avatar Nov 26 '24 16:11 slmonker

It's fixed for me updating 3 minutes ago.

Laika92 avatar Nov 26 '24 17:11 Laika92

The desktop version still has this problem, I don't know how to fix it. Does someone has the same problem in the Comfy desktop v1?

jerryzhao173985 avatar Nov 27 '24 15:11 jerryzhao173985

The desktop version still has this problem, I don't know how to fix it. Does someone has the same problem in the Comfy desktop v1?

same here!

lars-hoeijmans avatar Nov 27 '24 16:11 lars-hoeijmans

How to fix this bug

vivian686er avatar Nov 28 '24 06:11 vivian686er

If you know how to pull, pull the newest verison. If not, download the latest 0.3.5 verison, unzip it, overwrite the old one, and you are good to go. Just tested it , no problem at all. So next time, when flux published new models, update comfyui (0.3.4), when sd published new models, update comfyui(0.3.5), do not try to fix it by yourself.

xqyd avatar Nov 28 '24 07:11 xqyd

my comfy is up to date and I am still seeing this error. Am I missing something?

vinguerrero avatar Dec 05 '24 20:12 vinguerrero

same error, comfyui 0.3.10

soldivelot avatar Jan 02 '25 17:01 soldivelot

I updated to the latest ComfyUI and I've tried all versions from 0.3.5 to the current head and I have the same error.

manjunaths avatar Jan 10 '25 17:01 manjunaths

same problem on latest version

greenei avatar Mar 16 '25 23:03 greenei

Speculating: I think the issue might be due to how the autodetection of SD3.x vs SD3.5 is happening.

controlnet.py line 654:

    elif "controlnet_blocks.0.weight" in controlnet_data:     
               if "double_blocks.0.img_attn.norm.key_norm.scale" in controlnet_data: 
                   return load_controlnet_flux_xlabs_mistoline(controlnet_data, model_options=model_options) 
               elif "pos_embed_input.proj.weight" in controlnet_data:                                                                        
                   if "transformer_blocks.0.adaLN_modulation.1.bias" in controlnet_data:                                                                                                                                                                                                  
                       return load_controlnet_sd35(controlnet_data, model_options=model_options) #Stability sd3.5 format                                                                                                                                                                  
                   else:                                                                                                                                                                                                                                                                  
                       return load_controlnet_mmdit(controlnet_data, model_options=model_options) #SD3 diffusers controlnet                      

But the controlnet data for the 3.5 depth model doesn't have the transformer_blocks.0.adaLN_modulation.1.bias structure. The nearest thing I can find is transformer_blocks.0.attn.to_k.bias, but that's just plain string matching. Off the top of my head I don't know what the adaLN modulation maps to, but I feel like an explicit node for SD3.5 controlnet loading would solve the problem.

EDIT: I've confirmed this is the case by hot-patching line 654 to this:

            if True: #"transformer_blocks.0.adaLN_modulation.1.bias" in controlnet_data:  

This skips the check and always runs the 3.5 controlnet loader. There's still some kind of numerical instability in my workflow, but it does load and run end-to-end.

JosephCatrambone avatar Jul 31 '25 05:07 JosephCatrambone