{"record":{"id":"02537c78c6613813","repo":"PaddlePaddle/PaddleOCR","slug":"not-find-file-name-pdiparams-in-model-dir","errorCode":null,"errorMessage":"not find {file_name}.pdiparams in {model_dir}","messagePattern":"not find (.+?)\\.pdiparams in (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"tools/infer/utility.py","lineNumber":251,"sourceCode":"                sess_options=sess_options,\n            )\n        inputs = sess.get_inputs()\n        return (\n            sess,\n            inputs[0] if len(inputs) == 1 else [vo.name for vo in inputs],\n            None,\n            None,\n        )\n\n    else:\n        file_names = [\"model\", \"inference\"]\n        for file_name in file_names:\n            params_file_path = f\"{model_dir}/{file_name}.pdiparams\"\n            if os.path.exists(params_file_path):\n                break\n\n        if not os.path.exists(params_file_path):\n            raise ValueError(f\"not find {file_name}.pdiparams in {model_dir}\")\n\n        if not (\n            os.path.exists(f\"{model_dir}/{file_name}.pdmodel\")\n            or os.path.exists(f\"{model_dir}/{file_name}.json\")\n        ):\n            raise ValueError(\n                f\"neither {file_name}.json nor {file_name}.pdmodel was found in {model_dir}.\"\n            )\n\n        if os.path.exists(f\"{model_dir}/{file_name}.json\"):\n            model_file_path = f\"{model_dir}/{file_name}.json\"\n        else:\n            model_file_path = f\"{model_dir}/{file_name}.pdmodel\"\n\n        config = inference.Config(model_file_path, params_file_path)\n\n        if hasattr(args, \"precision\"):\n            if args.precision == \"fp16\" and args.use_tensorrt:","sourceCodeStart":233,"sourceCodeEnd":269,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/tools/infer/utility.py#L233-L269","documentation":"In the non-ONNX branch of create_predictor, Paddle Inference requires both a program file and a parameters file. The code searches model_dir for model.pdiparams or inference.pdiparams; if neither exists it raises this ValueError naming the last candidate checked. Note the message uses the loop variable file_name, so it can misleadingly report 'inference.pdiparams' as missing when model.pdiparams was the intended file. It usually means the model download was incomplete or the directory contains only ONNX/other files.","triggerScenarios":"Passing --det_model_dir/--rec_model_dir (etc.) pointing at a directory lacking both model.pdiparams and inference.pdiparams — empty dir, partial extraction, or a dir holding only .onnx/.pdmodel files.","commonSituations":"Interrupted or partial tar extraction of a model package; pointing at the parent of the actual model dir (nested extraction like det_infer/det_infer/...); downloading only weights without params; mistakenly using a dir of saved checkpoints (best_accuracy.*) instead of exported inference models.","solutions":["List the directory: ls <model_dir> — confirm either model.pdiparams or inference.pdiparams is present","Re-download and fully extract the model tar ball; point --*_model_dir at the directory that directly contains the .pdmodel/.pdiparams pair","If you only have checkpoints, export an inference model first using tools/export_model.py"],"exampleFix":"# before\n--det_model_dir=./inference  # contains det_db_infer/ subdir only\n\n# after\ntar -xf det_mv3_db.tar -C ./inference  # fully extracted\n--det_model_dir=./inference/det_db_infer  # holds inference.pdmodel + inference.pdiparams","handlingStrategy":"validation","validationCode":"import os\ndef has_params(d):\n    return os.path.exists(os.path.join(d, 'model.pdiparams')) or os.path.exists(os.path.join(d, 'inference.pdiparams'))\nassert has_params(model_dir), f'{model_dir} lacks model.pdiparams / inference.pdiparams'","typeGuard":null,"tryCatchPattern":"try:\n    utility.create_predictor(args, mode, logger)\nexcept ValueError as e:\n    if '.pdiparams' in str(e):\n        raise SystemExit(f'incomplete model dir {model_dir}: re-download or re-export the inference model')\n    raise","preventionTips":["Validate model dirs (params + program file) at service startup, not on first request","Verify tar ball checksums/sizes after download before extraction"],"tags":["paddle-inference","model-files","download-incomplete","export"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}