{"record":{"id":"71579545726e5c00","repo":"ultralytics/yolov5","slug":"invalid-model-path-w-provide-model-directory-or","errorCode":null,"errorMessage":"Invalid model path {w}. Provide model directory or a .pdiparams file.","messagePattern":"Invalid model path (.+?)\\. Provide model directory or a \\.pdiparams file\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"models/common.py","lineNumber":654,"sourceCode":"                meta = ast.literal_eval(model.read(meta_file).decode(\"utf-8\"))\n                stride, names = int(meta[\"stride\"]), meta[\"names\"]\n        elif tfjs:  # TF.js\n            raise NotImplementedError(\"ERROR: YOLOv5 TF.js inference is not supported\")\n        # PaddlePaddle\n        elif paddle:\n            LOGGER.info(f\"Loading {w} for PaddlePaddle inference...\")\n            check_requirements(\"paddlepaddle-gpu\" if cuda else \"paddlepaddle>=3.0.0\")\n            import paddle.inference as pdi\n\n            w = Path(w)\n            if w.is_dir():\n                model_file = next(w.rglob(\"*.json\"), None)\n                params_file = next(w.rglob(\"*.pdiparams\"), None)\n            elif w.suffix == \".pdiparams\":\n                model_file = w.with_name(\"model.json\")\n                params_file = w\n            else:\n                raise ValueError(f\"Invalid model path {w}. Provide model directory or a .pdiparams file.\")\n\n            if not (model_file and params_file and model_file.is_file() and params_file.is_file()):\n                raise FileNotFoundError(f\"Model files not found in {w}. Both .json and .pdiparams files are required.\")\n\n            config = pdi.Config(str(model_file), str(params_file))\n            if cuda:\n                config.enable_use_gpu(memory_pool_init_size_mb=2048, device_id=0)\n            config.disable_mkldnn()  # disable MKL-DNN for PIR compatibility\n            predictor = pdi.create_predictor(config)\n            input_handle = predictor.get_input_handle(predictor.get_input_names()[0])\n            output_names = predictor.get_output_names()\n\n        elif triton:  # NVIDIA Triton Inference Server\n            LOGGER.info(f\"Using {w} as Triton Inference Server...\")\n            check_requirements(\"tritonclient[all]\")\n            from utils.triton import TritonRemoteModel\n\n            model = TritonRemoteModel(url=w)","sourceCodeStart":636,"sourceCodeEnd":672,"githubUrl":"https://github.com/ultralytics/yolov5/blob/20d1d78a08277e365d57bfa3a2cce752772d9e59/models/common.py#L636-L672","documentation":"In the PaddlePaddle branch of DetectMultiBackend, ValueError is raised when the weight path is neither a directory nor a file with the .pdiparams suffix. The loader expects either the export directory containing model.json + *.pdiparams, or the .pdiparams file itself (it then looks for a sibling model.json). Any other shape (e.g. a bare .json, a .pdmodel, or a random file) hits this branch.","triggerScenarios":"Passing DetectMultiBackend('model.json') or a .pdmodel file; passing the directory of a Paddle *training* checkpoint rather than a Paddle Inference export; a typo'd path with a wrong extension.","commonSituations":"Converting models with paddle tools and handing DetectMultiBackend the wrong artifact of the set; copying only some files out of the export directory and renaming them.","solutions":["Point at the export directory produced by export.py --include paddle, which contains model.json and model.pdiparams.","Or point directly at the .pdiparams file; the loader pairs it with a sibling model.json automatically.","Do not pass .pdmodel or .json paths; they are not accepted inputs."],"exampleFix":"# before\nmodel = DetectMultiBackend('model.json')\n\n# after\nmodel = DetectMultiBackend('yolov5s_paddle_model/')  # dir with model.json + model.pdiparams","handlingStrategy":"type-guard","validationCode":"from pathlib import Path\n\ndef valid_paddle_path(w) -> bool:\n    p = Path(w)\n    return p.is_dir() or p.suffix == '.pdiparams'","typeGuard":"from pathlib import Path\n\ndef is_paddle_loadable(w: str) -> bool:\n    \"\"\"True if DetectMultiBackend's paddle branch accepts this path shape.\"\"\"\n    p = Path(w)\n    return p.is_dir() or p.suffix == \".pdiparams\"","tryCatchPattern":null,"preventionTips":["Always pass the export.py --include paddle output directory untouched.","Never rename .pdiparams/model.json files individually."],"tags":["paddle","inference","model-path","unsupported-format"],"backgroundTag":null,"analyzedSha":"20d1d78a08277e365d57bfa3a2cce752772d9e59","analyzedAt":"2026-08-15T02:56:15.443Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}