From 2edc1a5808a3833dc663c71f2f1a7e259bbddecb Mon Sep 17 00:00:00 2001 From: GT-Zhang <46156734+GT-ZhangAcer@users.noreply.github.com> Date: Fri, 5 Nov 2021 18:00:07 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=AC=A1=E5=BA=8F=EF=BC=8C?= =?UTF-8?q?=E5=85=BC=E5=AE=B9=E4=BD=8E=E7=89=88=E6=9C=ACPython?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ppqi/inference.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ppqi/inference.py b/ppqi/inference.py index 75dbb6c..63d3170 100644 --- a/ppqi/inference.py +++ b/ppqi/inference.py @@ -64,8 +64,10 @@ def load_config(self, modelpath, use_gpu, gpu_id, use_mkldnn, cpu_threads): print( '''Error! Unable to use GPU. Please set the environment variables "CUDA_VISIBLE_DEVICES=GPU_id" to use GPU. Now switch to CPU to continue...''') use_gpu = False - - if os.path.isdir(modelpath): + + if isinstance(modelpath, Config): + config = modelpath + elif os.path.isdir(modelpath): if os.path.exists(os.path.join(modelpath, "__params__")): # __model__ + __params__ model = os.path.join(modelpath, "__model__") @@ -87,8 +89,6 @@ def load_config(self, modelpath, use_gpu, gpu_id, use_mkldnn, cpu_threads): model = modelpath + ".pdmodel" params = modelpath + ".pdiparams" config = Config(model, params) - elif isinstance(modelpath, Config): - config = modelpath else: raise Exception( "Error! Can\'t find the model in: %s. Please check your model path." % os.path.abspath(modelpath))