{"record":{"id":"cde4a6b973758064","repo":"ultralytics/yolov5","slug":"model-files-not-found-in-w-both-json-and-pdip","errorCode":null,"errorMessage":"Model files not found in {w}. Both .json and .pdiparams files are required.","messagePattern":"Model files not found in (.+?)\\. Both \\.json and \\.pdiparams files are required\\.","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"models/common.py","lineNumber":657,"sourceCode":"            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)\n            nhwc = model.runtime.startswith(\"tensorflow\")\n        else:\n            raise NotImplementedError(f\"ERROR: {w} is not a supported format\")","sourceCodeStart":639,"sourceCodeEnd":675,"githubUrl":"https://github.com/ultralytics/yolov5/blob/20d1d78a08277e365d57bfa3a2cce752772d9e59/models/common.py#L639-L675","documentation":"The PaddlePaddle branch raises FileNotFoundError when the candidate model.json / .pdiparams pair could not both be located and verified with is_file(). This is distinct from the ValueError case: the path shape was right (a directory, or a .pdiparams file) but the files inside/next to it are missing — e.g. an empty directory, an incomplete copy, or model.json named differently.","triggerScenarios":"Passing an export directory that lacks model.json (renamed, deleted, or never generated); passing a .pdiparams file whose sibling model.json is absent; rglob in a directory that contains .pdiparams but no .json at the top level searched.","commonSituations":"Incomplete rsync/docker COPY of the paddle export; exporting with an older export.py that produced different filenames; manual file reorganization breaking the required sibling relationship.","solutions":["Re-export with the repo's exporter: python export.py --weights yolov5s.pt --include paddle, then use the produced directory.","Verify both required files exist: the directory must contain a *.json and a *.pdiparams (or the .pdiparams must sit next to model.json).","If filenames were changed, rename them back to model.json / model.pdiparams."],"exampleFix":"# before\nmodel = DetectMultiBackend('paddle_out/')  # missing model.json\n\n# after\n# ensure: paddle_out/model.json and paddle_out/model.pdiparams both exist\nmodel = DetectMultiBackend('paddle_out/')","handlingStrategy":"validation","validationCode":"from pathlib import Path\n\ndef paddle_files_complete(w) -> bool:\n    p = Path(w)\n    if p.is_dir():\n        return any(p.rglob('*.json')) and any(p.rglob('*.pdiparams'))\n    if p.suffix == '.pdiparams':\n        return p.with_name('model.json').is_file()\n    return False","typeGuard":null,"tryCatchPattern":"try:\n    model = DetectMultiBackend(paddle_dir)\nexcept FileNotFoundError as e:\n    if 'Both .json and .pdiparams' in str(e):\n        reexport_paddle()  # python export.py --include paddle","preventionTips":["After copying paddle exports, assert both model.json and .pdiparams arrive together.","Use file-count checks in deploy scripts before starting the inference server."],"tags":["paddle","inference","missing-files","model-path"],"backgroundTag":null,"analyzedSha":"20d1d78a08277e365d57bfa3a2cce752772d9e59","analyzedAt":"2026-08-15T02:56:15.443Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}