ComfyUI-PhotoMaker-ZHO icon indicating copy to clipboard operation
ComfyUI-PhotoMaker-ZHO copied to clipboard

Error when running: Missing key(s) in state_dict: "vision_model.embeddings.position_ids".

Open chille9 opened this issue 1 year ago • 4 comments

I get this when running the queue.

Error occurred when executing PhotoMaker_Zho:

Error(s) in loading state_dict for PhotoMakerIDEncoder: Missing key(s) in state_dict: "vision_model.embeddings.position_ids".

  File "C:\AI\ComfyUI\ComfyUI\execution.py", line 155, in recursive_execute
    output_data, output_ui = get_output_data(obj, input_data_all)
  File "C:\AI\ComfyUI\ComfyUI\execution.py", line 85, in get_output_data
    return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True)
  File "C:\AI\ComfyUI\ComfyUI\execution.py", line 78, in map_node_over_list
    results.append(getattr(obj, func)(**slice_dict(input_data_all, i)))
  File "C:\AI\ComfyUI\ComfyUI\custom_nodes\ComfyUI-PhotoMaker\PhotoMakerNode.py", line 60, in process_images
    pipe.load_photomaker_adapter(
  File "C:\AI\ComfyUI\python_embeded\lib\site-packages\huggingface_hub\utils\_validators.py", line 118, in _inner_fn
    return fn(*args, **kwargs)
  File "C:\AI\ComfyUI\ComfyUI\custom_nodes\ComfyUI-PhotoMaker\pipeline.py", line 114, in load_photomaker_adapter
    id_encoder.load_state_dict(state_dict["id_encoder"], strict=True)
  File "C:\AI\ComfyUI\python_embeded\lib\site-packages\torch\nn\modules\module.py", line 2041, in load_state_dict
    raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
Queue size: 0
Extra options

Doesn´t make any sense from trying to google. Any help would be greatly appreciated.

chille9 avatar Jan 18 '24 04:01 chille9

So if i change line 114: "id_encoder.load_state_dict(state_dict["id_encoder"], strict=False)" in PIPELINE.PY to false from true the program runs.

But will this cause the software to not load in the photomaker model correctly?

chille9 avatar Jan 18 '24 19:01 chille9

Same here,have you fixed it?

Inmanguo avatar Jan 22 '24 02:01 Inmanguo

https://github.com/TencentARC/PhotoMaker/issues/13

this just fixed the error.

Inmanguo avatar Jan 22 '24 02:01 Inmanguo

Tried the fixes, didn't work for me!

Here is the full code, any ideas?

Error occurred when executing PhotoMakerAdapter_Loader_local:

Error(s) in loading state_dict for PhotoMakerIDEncoder: Missing key(s) in state_dict: "vision_model.embeddings.position_ids".

File "J:\Software\AI\ComfyUI_windows_portable\ComfyUI\execution.py", line 154, in recursive_execute output_data, output_ui = get_output_data(obj, input_data_all) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "J:\Software\AI\ComfyUI_windows_portable\ComfyUI\execution.py", line 84, in get_output_data return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "J:\Software\AI\ComfyUI_windows_portable\ComfyUI\execution.py", line 77, in map_node_over_list results.append(getattr(obj, func)(**slice_dict(input_data_all, i))) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "J:\Software\AI\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-PhotoMakerv2\PhotoMakerNode.py", line 151, in load_photomaker_adapter pipe.load_photomaker_adapter( File "J:\Software\AI\ComfyUI_windows_portable\python_embeded\Lib\site-packages\huggingface_hub\utils_validators.py", line 118, in _inner_fn return fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^ File "J:\Software\AI\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-PhotoMakerv2\pipeline.py", line 114, in load_photomaker_adapter id_encoder.load_state_dict(state_dict["id_encoder"], strict=True) File "J:\Software\AI\ComfyUI_windows_portable\python_embeded\Lib\site-packages\torch\nn\modules\module.py", line 2152, in load_state_dict raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(

sweetramen avatar Jan 23 '24 05:01 sweetramen