From 3d1038210826d017245705dc1906a73aaeb1ae36 Mon Sep 17 00:00:00 2001 From: Kaipeng Deng Date: Thu, 4 Jul 2019 17:28:47 +0800 Subject: [PATCH] raise error when checkpoint not exist (#2719) --- ppdet/utils/checkpoint.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ppdet/utils/checkpoint.py b/ppdet/utils/checkpoint.py index b5bbc792c..4d600ee1c 100644 --- a/ppdet/utils/checkpoint.py +++ b/ppdet/utils/checkpoint.py @@ -52,7 +52,8 @@ def load_pretrain(exe, prog, path): path = get_weights_path(path) if not os.path.exists(path): - logger.info('Model path {} does not exists.'.format(path)) + raise ValueError("Model pretrain path {} does not " + "exists.".format(path)) logger.info('Loading pretrained model from {}...'.format(path)) @@ -77,7 +78,8 @@ def load_checkpoint(exe, prog, path): path = get_weights_path(path) if not os.path.exists(path): - logger.info('Model path {} does not exists.'.format(path)) + raise ValueError("Model checkpoint path {} does not " + "exists.".format(path)) logger.info('Loading checkpoint from {}...'.format(path)) fluid.io.load_persistables(exe, path, prog) @@ -127,6 +129,9 @@ def load_and_fusebn(exe, prog, path): if is_url(path): path = get_weights_path(path) + if not os.path.exists(path): + raise ValueError("Model path {} does not exists.".format(path)) + def _if_exist(var): b = os.path.exists(os.path.join(path, var.name)) if b: -- GitLab