PaddlePaddle/PaddleOCR · error · ValueError
not find model file path {}
Error message
not find model file path {} What it means
In utility.create_predictor, when --use_onnx is set, the model path must point to an actual .onnx file (not a directory of Paddle inference files). This ValueError fires when the given path does not exist on disk. Note the separate branch above it: if model_dir itself is None the code logs and sys.exit(0)s instead — so this error specifically means 'a path was given but nothing is there'.
Source
Thrown at tools/infer/utility.py:205
model_dir = args.ser_model_dir
elif mode == "re":
model_dir = args.re_model_dir
elif mode == "sr":
model_dir = args.sr_model_dir
elif mode == "layout":
model_dir = args.layout_model_dir
else:
model_dir = args.e2e_model_dir
if model_dir is None:
logger.info("not find {} model file path {}".format(mode, model_dir))
sys.exit(0)
if args.use_onnx:
import onnxruntime as ort
model_file_path = model_dir
if not os.path.exists(model_file_path):
raise ValueError("not find model file path {}".format(model_file_path))
sess_options = args.onnx_sess_options or None
if args.onnx_providers and len(args.onnx_providers) > 0:
sess = ort.InferenceSession(
model_file_path,
providers=args.onnx_providers,
sess_options=sess_options,
)
elif args.use_gpu:
sess = ort.InferenceSession(
model_file_path,
providers=[
(
"CUDAExecutionProvider",
{
"device_id": args.gpu_id,
"cudnn_conv_algo_search": "HEURISTIC",View on GitHub (pinned to 2661c7c0ef)
Solutions
- Verify the file exists and is an .onnx file: ls -la <path>
- Convert a Paddle model first: paddle2onnx --model_dir inference/det --model_filename inference.pdmodel --params_filename inference.pdiparams --save_file det.onnx
- Pass the full file path (dir/model.onnx), not the directory, when use_onnx is enabled
Example fix
# before --use_onnx --det_model_dir=./inference/det_ppocrv3 # directory, not .onnx -> ValueError # after paddle2onnx --model_dir ./inference/det_ppocrv3 \ --model_filename inference.pdmodel --params_filename inference.pdiparams \ --save_file ./inference/det.onnx --use_onnx --det_model_dir=./inference/det.onnx
Defensive patterns
Strategy: validation
Validate before calling
import os
assert args.use_onnx is False or (args.det_model_dir and os.path.isfile(args.det_model_dir) and args.det_model_dir.endswith('.onnx')), \
'with --use_onnx the model path must be an existing .onnx file' Try / catch
try:
utility.create_predictor(args, 'det', logger)
except ValueError as e:
if 'not find model file path' in str(e):
raise SystemExit(f'ONNX model missing: {args.det_model_dir} — convert with paddle2onnx first')
raise Prevention
- Verify ONNX artifacts exist as part of your build step, right after paddle2onnx
- Keep a manifest mapping each pipeline stage to its concrete model file and check it at startup
When it happens
Trigger: Running with --use_onnx and a model path that doesn't exist: typo, wrong extension, passing a directory when an .onnx file path is required, or not having converted/downloaded the ONNX model.
Common situations: Converting workflow to ONNX but forgetting to run paddle2onnx; passing the Paddle model directory (containing .pdmodel) unchanged to the ONNX path; downloading models to a different folder than referenced.
Related errors
- degenerate text crop (zero width/height)
- File not found: '{file_path}'
- {file_path}
- {} does not exist!
- {} does not exist!
AI-assisted analysis of PaddlePaddle/PaddleOCR@2661c7c0ef (2026-08-14).
Data as JSON: /api/errors/a81b172ba847129c.
Report an issue: GitHub.