From e0f3bcb49481bfb1ec47d24fdea3314967e3548c Mon Sep 17 00:00:00 2001 From: "shaohua.zhang" Date: Mon, 3 Aug 2020 14:07:20 +0800 Subject: [PATCH 1/2] add a necessary check for checkpoints add a necessary check for checkpoints, if you miss the file prefix and it will not execute the checkpoints codes --- ppocr/utils/save_load.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ppocr/utils/save_load.py b/ppocr/utils/save_load.py index 74a200f..47950a6 100755 --- a/ppocr/utils/save_load.py +++ b/ppocr/utils/save_load.py @@ -109,9 +109,14 @@ def init_model(config, program, exe): """ checkpoints = config['Global'].get('checkpoints') if checkpoints: - path = checkpoints - fluid.load(program, path, exe) - logger.info("Finish initing model from {}".format(path)) + if os.path.exists(checkpoints + '.pdparams'): + path = checkpoints + fluid.load(program, path, exe) + logger.info("Finish initing model from {}".format(path)) + else: + raise ValueError( + "Model checkpoints {} does not exists," + "check if you lost the file prefix .".format(checkpoints + '.pdparams')) pretrain_weights = config['Global'].get('pretrain_weights') if pretrain_weights: From a4abf1322cb51e3bf5ce7a78b28f947d9c957aa3 Mon Sep 17 00:00:00 2001 From: "shaohua.zhang" Date: Mon, 3 Aug 2020 21:54:09 +0800 Subject: [PATCH 2/2] Update save_load.py --- ppocr/utils/save_load.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ppocr/utils/save_load.py b/ppocr/utils/save_load.py index 47950a6..80f64dc 100755 --- a/ppocr/utils/save_load.py +++ b/ppocr/utils/save_load.py @@ -115,8 +115,8 @@ def init_model(config, program, exe): logger.info("Finish initing model from {}".format(path)) else: raise ValueError( - "Model checkpoints {} does not exists," - "check if you lost the file prefix .".format(checkpoints + '.pdparams')) + "Model checkpoints {} does not exists," + "check if you lost the file prefix.".format(checkpoints + '.pdparams')) pretrain_weights = config['Global'].get('pretrain_weights') if pretrain_weights: