Skip to content

Commit d2d5ae7

Browse files
authored
raise error when checkpoint not exist (PaddlePaddle#2719)
1 parent 258bc64 commit d2d5ae7

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

PaddleCV/PaddleDetection/ppdet/utils/checkpoint.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ def load_pretrain(exe, prog, path):
5252
path = get_weights_path(path)
5353

5454
if not os.path.exists(path):
55-
logger.info('Model path {} does not exists.'.format(path))
55+
raise ValueError("Model pretrain path {} does not "
56+
"exists.".format(path))
5657

5758
logger.info('Loading pretrained model from {}...'.format(path))
5859

@@ -77,7 +78,8 @@ def load_checkpoint(exe, prog, path):
7778
path = get_weights_path(path)
7879

7980
if not os.path.exists(path):
80-
logger.info('Model path {} does not exists.'.format(path))
81+
raise ValueError("Model checkpoint path {} does not "
82+
"exists.".format(path))
8183

8284
logger.info('Loading checkpoint from {}...'.format(path))
8385
fluid.io.load_persistables(exe, path, prog)
@@ -127,6 +129,9 @@ def load_and_fusebn(exe, prog, path):
127129
if is_url(path):
128130
path = get_weights_path(path)
129131

132+
if not os.path.exists(path):
133+
raise ValueError("Model path {} does not exists.".format(path))
134+
130135
def _if_exist(var):
131136
b = os.path.exists(os.path.join(path, var.name))
132137
if b:

0 commit comments

Comments
 (0)