{"record":{"id":"5497937717bcbcb5","repo":"PaddlePaddle/PaddleOCR","slug":"neither-file-name-json-nor-file-name-pdmodel-w","errorCode":null,"errorMessage":"neither {file_name}.json nor {file_name}.pdmodel was found in {model_dir}.","messagePattern":"neither (.+?)\\.json nor (.+?)\\.pdmodel was found in (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"tools/infer/utility.py","lineNumber":257,"sourceCode":"            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:\n                precision = inference.PrecisionType.Half\n            elif args.precision == \"int8\":\n                precision = inference.PrecisionType.Int8\n            else:\n                precision = inference.PrecisionType.Float32\n        else:","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/tools/infer/utility.py#L239-L275","documentation":"Companion check to the .pdiparams gate: after finding a params file (model.* or inference.*), create_predictor requires the matching program file — either <name>.pdmodel or <name>.json (the new Paddle 3 serialized format) — in the same directory. Its absence raises this ValueError, meaning the model directory is half-populated (weights without the graph).","triggerScenarios":"A model dir containing inference.pdiparams but neither inference.pdmodel nor inference.json — e.g. weights copied without the program file, or an incomplete export.","commonSituations":"Manual copying between machines dropping the .pdmodel; export_model.py interrupted mid-write; mixing file naming (model.* vs inference.*) so params and program use different prefixes.","solutions":["Check the directory for the matching prefix: if inference.pdiparams exists, you need inference.pdmodel or inference.json","Re-export the inference model with tools/export_model.py","Keep the prefix consistent — do not rename model.pdiparams to inference.pdiparams without renaming the program file too"],"exampleFix":"# before\nls ./inference/rec\n# inference.pdiparams  inference.pdiparams.info   (no program file) -> ValueError\n\n# after\npython tools/export_model.py -c configs/rec/PP-OCRv4/rec_PP-OCRv4_mobile.yml \\\n  -o Global.pretrained_model=./pretrain_models/rec_mobile \\\n  Global.save_inference_dir=./inference/rec","handlingStrategy":"validation","validationCode":"import os\ndef valid_infer_dir(d):\n    for p in ('model', 'inference'):\n        if os.path.exists(f'{d}/{p}.pdiparams'):\n            return os.path.exists(f'{d}/{p}.pdmodel') or os.path.exists(f'{d}/{p}.json')\n    return False\nassert valid_infer_dir(model_dir), f'{model_dir} has params but no .pdmodel/.json program file'","typeGuard":null,"tryCatchPattern":"try:\n    utility.create_predictor(args, mode, logger)\nexcept ValueError as e:\n    if 'pdmodel' in str(e) or 'json' in str(e):\n        raise SystemExit(f'{model_dir}: re-export with tools/export_model.py — program file missing')\n    raise","preventionTips":["Always move model files as complete triples (program + params + info) using archive tools, never file-by-file","Keep the file prefix consistent within a model directory"],"tags":["paddle-inference","model-files","export","incomplete-model"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}