From 2d8e421f81c667ba0c1f6d7fe85c97d345af9d3d Mon Sep 17 00:00:00 2001 From: akrilio <1711062485@qq.com> Date: Sat, 15 Mar 2025 18:57:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9=E6=80=A7=E8=B0=83=E6=95=B4?= =?UTF-8?q?=EF=BC=9Apaddlepaddle-gpu=3D=3D3.0.0rc1=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E6=8E=A8=E7=90=86=E6=A8=A1=E5=9E=8B=E4=B8=BA.json=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=EF=BC=8C=E6=97=A9=E6=9C=9F=E7=89=88=E6=9C=AC=E4=B8=BA?= =?UTF-8?q?.pdmodel,.pdiparams=E6=A0=BC=E5=BC=8F=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=BB=A3=E7=A0=81=E5=85=81=E8=AE=B8=E8=AF=BB=E5=8F=96?= =?UTF-8?q?.json=E6=A0=BC=E5=BC=8F=E7=9A=84=E6=A8=A1=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/infer/utility.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/infer/utility.py b/tools/infer/utility.py index 57b585601fe..78406dc0a18 100644 --- a/tools/infer/utility.py +++ b/tools/infer/utility.py @@ -225,11 +225,13 @@ def create_predictor(args, mode, logger): else: file_names = ["model", "inference"] + model_formats = ["pdmodel", "json"] for file_name in file_names: - model_file_path = "{}/{}.pdmodel".format(model_dir, file_name) params_file_path = "{}/{}.pdiparams".format(model_dir, file_name) - if os.path.exists(model_file_path) and os.path.exists(params_file_path): - break + for model_format in model_formats: + model_file_path = "{}/{}.{}".format(model_dir, file_name, model_format) + if os.path.exists(model_file_path) and os.path.exists(params_file_path): + break if not os.path.exists(model_file_path): raise ValueError( "not find model.pdmodel or inference.pdmodel in {}".format(model_dir)