Ultralytics issues
Expected Behavior
Weights only load failed. This file can still be loaded, to do so you have two options, [1mdo those steps only if you trust the source of the checkpoint[0m. (1) In PyTorch 2.6, we changed the default value of the weights_onlyargument intorch.loadfromFalsetoTrue. Re-running torch.loadwithweights_onlyset toFalsewill likely succeed, but it can result in arbitrary code execution. Do it only if you got the file from a trusted source. (2) Alternatively, to load withweights_only=Trueplease check the recommended steps in the following error message. WeightsUnpickler error: Unsupported global: GLOBAL getattr was not an allowed global by default. Please usetorch.serialization.add_safe_globals([getattr])or thetorch.serialization.safe_globals([getattr])` context manager to allowlist this global if you trust this class/function.
Check the documentation of torch.load to learn more about types accepted by default with weights_only https://pytorch.org/docs/stable/generated/torch.load.html.` Hi guys, i don't have the expertise to understand what is going on here, can someone check on it please? This is new, i didn't have that last night before updating comfy so i guess its related. Regards
Actual Behavior
Steps to Reproduce
just my regular workflow with facedetailer
Debug Logs
Check the documentation of torch.load to learn more about types accepted by default with weights_only https://pytorch.org/docs/stable/generated/torch.load.html.
Traceback (most recent call last):
File "D:\AImatrix\Data\Packages\ComfyUI\execution.py", line 347, 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:\AImatrix\Data\Packages\ComfyUI\execution.py", line 222, 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:\AImatrix\Data\Packages\ComfyUI\execution.py", line 194, in _map_node_over_list
process_inputs(input_dict, i)
File "D:\AImatrix\Data\Packages\ComfyUI\execution.py", line 183, in process_inputs
results.append(getattr(obj, func)(**inputs))
File "D:\AImatrix\Data\Packages\ComfyUI\custom_nodes\comfyui-impact-subpack\modules\subpack_nodes.py", line 49, in doit
model = subcore.load_yolo(model_path)
File "D:\AImatrix\Data\Packages\ComfyUI\custom_nodes\comfyui-impact-subpack\modules\subcore.py", line 168, in load_yolo
return YOLO(model_path)
File "D:\AImatrix\Data\Packages\ComfyUI\venv\lib\site-packages\ultralytics\models\yolo\model.py", line 23, in __init__
super().__init__(model=model, task=task, verbose=verbose)
File "D:\AImatrix\Data\Packages\ComfyUI\venv\lib\site-packages\ultralytics\engine\model.py", line 145, in __init__
self._load(model, task=task)
File "D:\AImatrix\Data\Packages\ComfyUI\venv\lib\site-packages\ultralytics\engine\model.py", line 288, in _load
self.model, self.ckpt = attempt_load_one_weight(weights)
File "D:\AImatrix\Data\Packages\ComfyUI\venv\lib\site-packages\ultralytics\nn\tasks.py", line 910, in attempt_load_one_weight
ckpt, weight = torch_safe_load(weight) # load ckpt
File "D:\AImatrix\Data\Packages\ComfyUI\venv\lib\site-packages\ultralytics\nn\tasks.py", line 837, in torch_safe_load
ckpt = torch.load(file, map_location="cpu")
File "D:\AImatrix\Data\Packages\ComfyUI\custom_nodes\comfyui-impact-subpack\modules\subcore.py", line 150, in torch_wrapper
return orig_torch_load(*args, **kwargs) # NOTE: This code simply delegates the call to torch.load, and any errors that occur here are not the responsibility of Subpack.
File "D:\AImatrix\Data\Packages\ComfyUI\venv\lib\site-packages\torch\serialization.py", line 1524, in load
raise pickle.UnpicklingError(_get_wo_message(str(e))) from None
_pickle.UnpicklingError: Weights only load failed. This file can still be loaded, to do so you have two options, do those steps only if you trust the source of the checkpoint.
(1) In PyTorch 2.6, we changed the default value of the `weights_only` argument in `torch.load` from `False` to `True`. Re-running `torch.load` with `weights_only` set to `False` will likely succeed, but it can result in arbitrary code execution. Do it only if you got the file from a trusted source.
(2) Alternatively, to load with `weights_only=True` please check the recommended steps in the following error message.
WeightsUnpickler error: Unsupported global: GLOBAL getattr was not an allowed global by default. Please use `torch.serialization.add_safe_globals([getattr])` or the `torch.serialization.safe_globals([getattr])` context manager to allowlist this global if you trust this class/function.
Check the documentation of torch.load to learn more about types accepted by default with weights_only https://pytorch.org/docs/stable/generated/torch.load.html.
Prompt executed in 3.35 seconds
Other
No response
Look at this code: https://github.com/Gourieff/ComfyUI-ReActor/issues/73
This is fixed already. Now the Impact Subpack supports whitelist feature. https://github.com/ltdrdata/ComfyUI-Impact-Subpack#model-loading-configuration-related-to-weights_only
This is fixed already.
Fixed how? The error still persists.
The error still persists.
Provide console log of your error.
On cmd.exe window: Alt+Space --> Edit --> Mark all --> Copy --> Paste here
This is still happening in ComfyUI Desktop on Windows with just-updated Impact nodes, the Ultralytics Detector is incapable of loading the person_yolov8m-seg.pt
I am not attaching console logs because there's PII in my paths
p.s. why did you close an issue that isn't fixed and then ask for more logs, reopen the issue if you are looking for more information from users
from the error message:
Check the documentation of torch.load to learn more about types accepted by default with weights_only https://pytorch.org/docs/stable/generated/torch.load.html.
The issue is explained in here https://github.com/ltdrdata/comfyui-unsafe-torch
Although, this thread reports an issue that occurred within the Impact subpack, but the issue itself can happen in any situation where a torch model is loaded. Impact Subpack and ComfyUI Unsafe Torch provide a mechanism to bypass this.
yeah, I don't really know how to fix it. Loading of .pt models is inherently unsafe, users may need to alter behavior when downloading these models.
Write to file \ComfyUI\user\default\ComfyUI-Impact-Subpack\model-whitelist.txt
person_yolov8m-seg.pt
OR (NOT SAFE)
Open file \python_embeded\Lib\site-packages\ultralytics\nn\tasks.py
Add:
torch.serialization.add_safe_globals([getattr])
Before:
class BaseModel(nn.Module):
And replace:
with open(file, "rb") as f:
ckpt = torch.load(f, pickle_module=safe_pickle,weights_only="False")
else:
ckpt = torch.load(file, map_location="cpu",weights_only="False")
@RomixERR I've added a model to the whitelist as described. I am still getting the error. It started after updating everything earlier today.
I've added a model to the whitelist as described. I am still getting the error
1 -- Update your Ultralytics. 2a-b -- If not help - use "bad patch" - unsafe-torch.
1/ --https://github.com/ltdrdata/ComfyUI-Impact-Subpack/issues/61#issuecomment-3042332056 -- Reactor Masking Helper "weights_only" error -- ultralytics fix
2a/ ltdrdata --https://github.com/ltdrdata/ComfyUI-Impact-Subpack/issues/64#issuecomment-3035141084 --> https://github.com/ltdrdata/comfyui-unsafe-torch
2b/ How to install unsafe torch -- https://github.com/comfyanonymous/ComfyUI/issues/9000#issuecomment-3101941163