快速结论:这个报错通常发生在 ComfyUI Impact Subpack 的 UltralyticsDetectorProvider 加载 YOLO 检测器权重时,PyTorch 的 weights_only=True 拒绝反序列化 ultralytics.nn.tasks.DetectionModel;优先排查 ultralytics 版本是否过旧,以及 segm_detector_opt 是否误接了 bbox 模型。
适用环境:ComfyUI 0.3.62(含桌面版 Electron 启动方式,路径中出现 @comfyorgcomfyui-electron);Windows;额外安装了 BizyAir 自定义节点,但 Issue 未确认其与问题相关;Issue 未确认 Python、CUDA、PyTorch、显卡型号与驱动版本。
最快修复方案:把运行 ComfyUI 的 Python 中的 ultralytics 升级到 ultralytics>=8.3.162;若使用 ComfyUI 便携版,可用 python_embeded\python.exe -m pip install -U "ultralytics>=8.3.162"。
注意事项:该版本要求来自 Issue 讨论中的说明,属于“当前 Subpack 与旧 ultralytics 组合”的针对性修复,不完全等同于“所有 weights_only 报错都由版本引起”。卸载重装 Impact Subpack 也能起到重装依赖的作用,但讨论中有人尝试手动加白名单未成功,Issue 结论不推荐改 subcore.py 或手动白名单。操作前建议备份环境,升级依赖可能影响其他依赖 ultralytics 的自定义节点。
问题场景
用户在 ComfyUI 的工作流中使用 UltralyticsDetectorProvider 节点加载 YOLO 检测器模型(报告里同时出现了如 bbox/face_yolov8m.pt 一类权重)时,节点无法加载检测器。讨论中还指出两种可能的连接错误:一是把 bbox 模型接进了 segm 检测器输入(segm_detector_opt),二是使用了非 Impact Pack 的检测节点。另有用户反馈在 ComfyUI 更新后突然出现同类问题。
报错原文
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 ultralytics.nn.tasks.DetectionModel was not an allowed global by default.
Please use `torch.serialization.add_safe_globals([ultralytics.nn.tasks.DetectionModel])` or the `torch.serialization.safe_globals([ultralytics.nn.tasks.DetectionModel])` context manager to allowlist this global if you trust this class/function.
原因分析
最可能的原因是 Impact Subpack 与 ultralytics 版本不匹配:按讨论中的说明,Subpack V1.3.5 起需要 ultralytics>=8.3.162;从该版本开始,ultralytics 以 Subpack 放行的方式加载自身模型,而旧版 ultralytics 的加载方式会触发 Subpack 的检查,并在 ultralytics.nn.tasks.DetectionModel 处停止,于是出现上面的 WeightsUnpickler 报错。
另一个独立可能原因是节点连接错误:把 bbox 模型接到 segm 检测器输入,或使用了其他检测节点而未使用 Impact Pack/Impact Subpack 的 UltralyticsDetectorProvider。这类问题与 PyTorch 反序列化报错性质不同,需要分别排除。
环境排查
- 确认当前运行的 Python 解释器,是否就是 ComfyUI 实际使用的解释器;便携版与桌面版路径不同,Issue 中出现的是 ComfyUI 0.3.62 桌面版。
- 确认 ultralytics 实际安装版本,判断是否低于 8.3.162。
- 确认 PyTorch 版本(报错提到 PyTorch 2.6 更改了
weights_only默认值);Issue 未给出用户实际 PyTorch 版本。 - 确认是否安装了 Impact Subpack,以及 UltralyticsDetectorProvider 是否来自该 Subpack 而非其他检测节点。
- 确认节点连线:bbox 模型不应接到
segm_detector_opt;如需分割模型,应再加一个 UltralyticsDetectorProvider 并选择 segm 模型。 - 确认模型权重来源可信,再考虑放行相关类;Issue 不建议把人工白名单作为首选方案。
解决步骤
- 先检查工作流连接:如果 UltralyticsDetectorProvider 的
segm_detector_opt接入了 bbox 模型,断开它;需要分割检测时,增加第二个 UltralyticsDetectorProvider 并选择 segm 模型。 - 确认检测节点使用的是 Impact Pack / Impact Subpack 提供的节点,而不是其他自定义节点的检测实现。
- 确认 ultralytics 版本低于 8.3.162 时,在运行 ComfyUI 的 Python 中执行升级:
pip install -U "ultralytics>=8.3.162"。 - 便携版用户改为在对应目录执行:
python_embeded\python.exe -m pip install -U "ultralytics>=8.3.162"。桌面版需确认python_embeded或目标解释器路径与实例一致。 - 如果升级无效,可尝试卸载并重新安装 Impact Subpack;讨论中有用户在 ComfyUI 更新后遇到该问题,通过重装 Subpack 恢复,因为重装会重新安装 Subpack 的依赖。
- 重启 ComfyUI,使新安装的 ultralytics 生效。
验证方法
重新打开包含 UltralyticsDetectorProvider 的工作流,加载检测器权重,确认不再出现 WeightsUnpickler error: Unsupported global: GLOBAL ultralytics.nn.tasks.DetectionModel,且节点能正常输出检测结果。同时确认 segm_detector_opt 未误接 bbox 模型。若仍报错,记录当前解释器路径和 ultralytics 版本再继续排查。
参考来源
ltdrdata/ComfyUI-Impact-Pack #1120
ltdrdata/ComfyUI-Impact-Subpack(讨论中建议安装的 Subpack 仓库,UltralyticsDetectorProvider 所在处)
ComfyUI-Impact-Subpack PR #41(讨论中提到该 PR 解决 PyTorch weights_only=True 相关问题)
AI 工具推荐
想把多个 AI 模型放在一个入口?
GamsGo AI 集成 ChatGPT、DeepSeek、Gemini、Claude、Midjourney、Veo 等常用模型,适合写作、绘图、视频和日常 AI 工作流。
推广链接:通过此链接购买,我可能获得佣金,不影响你的价格。
这个方案解决了吗?
可以继续搜索完整报错,或查看同一工具的其他排查指南。


![[BUG]: GitLab MCP shown as not running through mcp-remote, but agent tool calls work](https://www.chat-gpts.plus/wp-content/uploads/2026/11/7286-4706f9d3-768x403.jpg)