viperyl / ComfyUI-BiRefNet

196 stars 19 forks source link

RuntimeError: Model loading failed: invalid load key, 'v'. #9

Open florestefano1975 opened 5 months ago

florestefano1975 commented 5 months ago

2024-03-26T17:02:18.884730049Z 2024-03-26 17:02:18.884 | ERROR | ComfyUI-BiRefNet.BiRefNet_node:load:65 - Failed to load the model: invalid load key, 'v'. 2024-03-26T17:02:18.890070547Z !!! Exception during processing !!! 2024-03-26T17:02:18.895161496Z Traceback (most recent call last): 2024-03-26T17:02:18.895166696Z File "/workspace/ComfyUI/custom_nodes/ComfyUI-BiRefNet/BiRefNet_node.py", line 49, in load 2024-03-26T17:02:18.895168566Z self.model = BiRefNet() 2024-03-26T17:02:18.895170136Z File "/workspace/ComfyUI/custom_nodes/ComfyUI-BiRefNet/models/baseline.py", line 28, in init 2024-03-26T17:02:18.895171836Z self.bb = build_backbone(self.config.bb, pretrained=True) 2024-03-26T17:02:18.895173186Z File "/workspace/ComfyUI/custom_nodes/ComfyUI-BiRefNet/models/backbones/build_backbone.py", line 25, in build_backbone 2024-03-26T17:02:18.895174406Z bb = load_weights(bb, bb_name) 2024-03-26T17:02:18.895175526Z File "/workspace/ComfyUI/custom_nodes/ComfyUI-BiRefNet/models/backbones/build_backbone.py", line 29, in load_weights 2024-03-26T17:02:18.895176716Z save_model = torch.load(config.weights[model_name], map_location=torch.device('cpu')) 2024-03-26T17:02:18.895177946Z File "/venv/lib/python3.10/site-packages/torch/serialization.py", line 815, in load 2024-03-26T17:02:18.895179146Z return _legacy_load(opened_file, map_location, pickle_module, pickle_load_args) 2024-03-26T17:02:18.895180276Z File "/venv/lib/python3.10/site-packages/torch/serialization.py", line 1033, in _legacy_load 2024-03-26T17:02:18.895181406Z magic_number = pickle_module.load(f, pickle_load_args) 2024-03-26T17:02:18.895182536Z _pickle.UnpicklingError: invalid load key, 'v'. 2024-03-26T17:02:18.895183646Z 2024-03-26T17:02:18.895184746Z During handling of the above exception, another exception occurred: 2024-03-26T17:02:18.895186376Z 2024-03-26T17:02:18.895187456Z Traceback (most recent call last): 2024-03-26T17:02:18.895188596Z File "/workspace/ComfyUI/execution.py", line 151, in recursive_execute 2024-03-26T17:02:18.895189716Z output_data, output_ui = get_output_data(obj, input_data_all) 2024-03-26T17:02:18.895190816Z File "/workspace/ComfyUI/execution.py", line 81, in get_output_data 2024-03-26T17:02:18.895192236Z return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True) 2024-03-26T17:02:18.895204716Z File "/workspace/ComfyUI/execution.py", line 74, in map_node_over_list 2024-03-26T17:02:18.895205966Z results.append(getattr(obj, func)(**slice_dict(input_data_all, i))) 2024-03-26T17:02:18.895207096Z File "/workspace/ComfyUI/custom_nodes/ComfyUI-BiRefNet/BiRefNet_node.py", line 101, in matting 2024-03-26T17:02:18.895208196Z self.load(weight_path, device=device) 2024-03-26T17:02:18.895209376Z File "/workspace/ComfyUI/custom_nodes/ComfyUI-BiRefNet/BiRefNet_node.py", line 67, in load 2024-03-26T17:02:18.895210466Z raise RuntimeError(f"Model loading failed: {e}") 2024-03-26T17:02:18.895211656Z RuntimeError: Model loading failed: invalid load key, 'v'.

viperyl commented 5 months ago

2024-03-26T17:02:18.884730049Z 2024-03-26 17:02:18.884 | ERROR | ComfyUI-BiRefNet.BiRefNet_node:load:65 - Failed to load the model: invalid load key, 'v'. 2024-03-26T17:02:18.890070547Z !!! Exception during processing !!! 2024-03-26T17:02:18.895161496Z Traceback (most recent call last): 2024-03-26T17:02:18.895166696Z File "/workspace/ComfyUI/custom_nodes/ComfyUI-BiRefNet/BiRefNet_node.py", line 49, in load 2024-03-26T17:02:18.895168566Z self.model = BiRefNet() 2024-03-26T17:02:18.895170136Z File "/workspace/ComfyUI/custom_nodes/ComfyUI-BiRefNet/models/baseline.py", line 28, in init 2024-03-26T17:02:18.895171836Z self.bb = build_backbone(self.config.bb, pretrained=True) 2024-03-26T17:02:18.895173186Z File "/workspace/ComfyUI/custom_nodes/ComfyUI-BiRefNet/models/backbones/build_backbone.py", line 25, in build_backbone 2024-03-26T17:02:18.895174406Z bb = load_weights(bb, bb_name) 2024-03-26T17:02:18.895175526Z File "/workspace/ComfyUI/custom_nodes/ComfyUI-BiRefNet/models/backbones/build_backbone.py", line 29, in load_weights 2024-03-26T17:02:18.895176716Z save_model = torch.load(config.weights[model_name], map_location=torch.device('cpu')) 2024-03-26T17:02:18.895177946Z File "/venv/lib/python3.10/site-packages/torch/serialization.py", line 815, in load 2024-03-26T17:02:18.895179146Z return _legacy_load(opened_file, map_location, pickle_module, pickle_load_args) 2024-03-26T17:02:18.895180276Z File "/venv/lib/python3.10/site-packages/torch/serialization.py", line 1033, in _legacy_load 2024-03-26T17:02:18.895181406Z magic_number = pickle_module.load(f, pickle_load_args) 2024-03-26T17:02:18.895182536Z _pickle.UnpicklingError: invalid load key, 'v'. 2024-03-26T17:02:18.895183646Z 2024-03-26T17:02:18.895184746Z During handling of the above exception, another exception occurred: 2024-03-26T17:02:18.895186376Z 2024-03-26T17:02:18.895187456Z Traceback (most recent call last): 2024-03-26T17:02:18.895188596Z File "/workspace/ComfyUI/execution.py", line 151, in recursive_execute 2024-03-26T17:02:18.895189716Z output_data, output_ui = get_output_data(obj, input_data_all) 2024-03-26T17:02:18.895190816Z File "/workspace/ComfyUI/execution.py", line 81, in get_output_data 2024-03-26T17:02:18.895192236Z return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True) 2024-03-26T17:02:18.895204716Z File "/workspace/ComfyUI/execution.py", line 74, in map_node_over_list 2024-03-26T17:02:18.895205966Z results.append(getattr(obj, func)(**slice_dict(input_data_all, i))) 2024-03-26T17:02:18.895207096Z File "/workspace/ComfyUI/custom_nodes/ComfyUI-BiRefNet/BiRefNet_node.py", line 101, in matting 2024-03-26T17:02:18.895208196Z self.load(weight_path, device=device) 2024-03-26T17:02:18.895209376Z File "/workspace/ComfyUI/custom_nodes/ComfyUI-BiRefNet/BiRefNet_node.py", line 67, in load 2024-03-26T17:02:18.895210466Z raise RuntimeError(f"Model loading failed: {e}") 2024-03-26T17:02:18.895211656Z RuntimeError: Model loading failed: invalid load key, 'v'.

base on your post log, I guess this is due to you did not download full of model checkpoitns, trouble shooting is following

  1. if you are using Linux system, go to the BiRefNet model folder by terminal
  2. exectue du -sh * to check the file size, compare the result with Huggingface dataset page
  3. if you local checkpoint size much less then my uploaded one, please redownload the checkpoint, and move them to your BiRefNet checkpoints folder.

If the file size matched, I guess sth happend due to checkpoint transferring or storing. the trough shooting is following

  1. if you are using Linux system or Mac OS, go to BiRefNet model folder by terminal
  2. exectute sha256sum * and comapre the result with BiRefNet checkpoint sha256 on huggingface.

BTW, the ultimate solution is redownload checkpoint from page based on your post info

florestefano1975 commented 4 months ago

I have downloaded everything 5 times, but I always get the same error. I will try again. Thank you.