CivArchive
    ← All articles
    Published April 11, 2025by midnight1111

    FIX YOLO Model Compatibility in ComfyUI

    172 views0 reactions1 comments on CivitAI6 collected
    resource guidecomfyui

    YOLO Model Compatibility in New ComfyUI // Impact Pack Edition

    A Quick Guide to Patching PyTorch's New Security Changes for YOLOv8+

    If you're using YOLO models with ComfyUI + the Impact Pack, especially anything that includes Ultralytics detailers (like bounding box/segmentation detection), you'll probably run into a nasty UnpicklingError or "weights only load failed" message.

    That’s not your fault — it's because PyTorch 2.6+ introduced a new weights_only=True default when loading model checkpoints to tighten security. But YOLO checkpoints require access to getattr, which isn't safe-listed by default.

    ComfyUI currently doesn’t automatically handle this, so if you’re trying to use UltralyticsDetectorProvider and YOLO checkpoints from HuggingFace or local sources — you gotta patch it manually.


    ❌ The Problem

    When loading a YOLOv8 or YOLOv10 model via the Impact Subpack, you might hit this:

    _pickle.UnpicklingError: Weights only load failed. GLOBAL getattr was not an allowed global by default.

    Even worse, ComfyUI may just ignore your model silently — especially if it's passed through the UltralyticsDetectorProvider.


    🔥 The Fix (Impact Subpack Patch)

    You'll need to edit the Python file that wraps torch.load() in the Impact Subpack. Here's how to patch it:

    1. Open your subcore.py or whatever file is wrapping YOLO loading logic in:

      ComfyUI/custom_nodes/comfyui-impact-subpack/modules/
    2. Find the torch_wrapper() function, or define it right before you load your model.

    3. Inject this precision patch into your Impact Subpack module to restore YOLO checkpoint compatibility:

      📎 Smart Torch Wrapper Patch

      Or go full beast mode with:

      📦 Fully Patched subcore.py

      ✅ Tested with: ComfyUI 0.3.27, Ultralytics v8/v10, PyTorch ≥ 2.6, MPS, xFormers, and remote/local YOLO checkpoints.

    1. Profit. You can now load models like:

    yolo_model = YOLO("path/to/your_model.pt")

    And they'll behave as intended... Plug it in. Power it up. Get back to the goddamn art.


    🧠 Why This Happens

    • PyTorch >2.6+ prioritizes security during deserialization.

    • Ultralytics YOLO uses getattr inside their checkpoint loading.

    • getattr is not considered safe by default (could lead to arbitrary code exec if abused).

    • ComfyUI doesn’t yet wrap this safely — so we fix it manually.


    ✅ Tested Setup

    • ComfyUI 0.3.27

    • Ultralytics YOLOv8/v10 checkpoints

    • Impact Pack & Subpack (latest)

    • PyTorch 2.8 dev branch

    • macOS with MPS and xformers enabled


    💬 Feedback & Support

    If you’d rather grab a pre‑patched module or run into any issues, open an issue on the Impact Pack repo or drop a note on my GitHub:

    Repo: https://github.com/1darkmatter/comfyui-app-ultralytics-fix


    This kind of patch shouldn’t be necessary forever — ideally ComfyUI or the Impact Pack will add internal support for secure global injection. But for now, this patch will unbreak your workflow and get your detectors running without compromising the security model of modern PyTorch.


    Feel free to comment if you want a pre-patched module or hotfix version.

    // Got Questions or Feedback?

    Feel free to reach out!


    Created by Magnabos.co | Creative Artist

    🔥 Stay modded, stay dangerous.