ultralytics/yolov5 · error · NotImplementedError

ERROR: {w} is not a supported format

Error message

ERROR: {w} is not a supported format

What it means

DetectMultiBackend's final else branch raises NotImplementedError when the weight path's suffix matches none of the recognized backend formats (pt, torchscript, onnx, engine, tflite, pb, tfjs dir, pdiparams, triton URL, etc.). It is a format-dispatch failure: the file may exist and be perfectly valid, but this class has no loader for that extension.

Source

Thrown at models/common.py:675

                raise FileNotFoundError(f"Model files not found in {w}. Both .json and .pdiparams files are required.")

            config = pdi.Config(str(model_file), str(params_file))
            if cuda:
                config.enable_use_gpu(memory_pool_init_size_mb=2048, device_id=0)
            config.disable_mkldnn()  # disable MKL-DNN for PIR compatibility
            predictor = pdi.create_predictor(config)
            input_handle = predictor.get_input_handle(predictor.get_input_names()[0])
            output_names = predictor.get_output_names()

        elif triton:  # NVIDIA Triton Inference Server
            LOGGER.info(f"Using {w} as Triton Inference Server...")
            check_requirements("tritonclient[all]")
            from utils.triton import TritonRemoteModel

            model = TritonRemoteModel(url=w)
            nhwc = model.runtime.startswith("tensorflow")
        else:
            raise NotImplementedError(f"ERROR: {w} is not a supported format")

        # class names
        if "names" not in locals():
            names = yaml_load(data)["names"] if data else {i: f"class{i}" for i in range(999)}
        if names[0] == "n01440764" and len(names) == 1000:  # ImageNet
            names = yaml_load(ROOT / "data/ImageNet.yaml")["names"]  # human-readable names

        self.__dict__.update(locals())  # assign all variables to self

    def forward(self, im, augment=False):
        """Performs YOLOv5 inference on input images with optional augmentation."""
        _b, _ch, h, w = im.shape  # batch, channel, height, width
        if self.fp16 and im.dtype != torch.float16:
            im = im.half()  # to FP16
        if self.nhwc:
            im = im.permute(0, 2, 3, 1)  # torch BCHW to numpy BHWC shape(1,320,192,3)

        if self.pt:  # PyTorch

View on GitHub (pinned to 20d1d78a08)

Solutions

  1. Export to a supported format with export.py (onnx, tflite, engine, paddle, saved_model...) and pass that artifact.
  2. Fix the filename so its true suffix is recognized, e.g. strip accidental double extensions or rename back to .pt.
  3. For Triton, pass the full url or 'host:port/model' endpoint string, not a local file path.

Example fix

# before
model = DetectMultiBackend('yolov5s.onnx.zip')

# after
import zipfile; zipfile.extract('yolov5s.onnx.zip')
model = DetectMultiBackend('yolov5s.onnx')
Defensive patterns

Strategy: type-guard

Validate before calling

SUPPORTED = {'.pt', '.torchscript', '.onnx', '.engine', '.tflite', '.pb', '.pdiparams'}

def suffix_supported(w: str) -> bool:
    from pathlib import Path
    p = Path(w)
    return p.is_dir() or p.suffix in SUPPORTED or '://' in w or bool(w.count(':'))  # triton url

Type guard

from pathlib import Path

SUPPORTED_SUFFIXES = ('.pt', '.torchscript', '.onnx', '.engine', '.tflite', '.pb', '.pdiparams')

def is_supported_backend_path(w: str) -> bool:
    """True if DetectMultiBackend has a loader for this artifact."""
    p = Path(w)
    return p.is_dir() or p.suffix in SUPPORTED_SUFFIXES or bool(w.rsplit('/', 1)[-1].count(':'))  # triton

Try / catch

try:
    model = DetectMultiBackend(w)
except NotImplementedError:
    raise SystemExit(f'{w}: unsupported format; run export.py --include onnx|tflite|engine first')

Prevention

When it happens

Trigger: Passing 'yolov5s.onnx.tar.gz', 'model.uff', 'weights.h5', 'yolov5s.pt.bak', or any unsupported extension to DetectMultiBackend; pointing at an OpenVINO .xml/.bin pair; a path with a doubled suffix.

Common situations: Users converting YOLOv5 weights with third-party tools and feeding exotic artifacts back in; renaming files for versioning (model.pt-v2) which changes the suffix; expecting DetectMultiBackend to auto-decompress archives.

Related errors


AI-assisted analysis of ultralytics/yolov5@20d1d78a08 (2026-08-15). Data as JSON: /api/errors/d64ce5c378a41357. Report an issue: GitHub.