From 7919a9bb3505be3d9960fcfcf32bbc59c183ee37 Mon Sep 17 00:00:00 2001 From: dengkaipeng Date: Tue, 14 Apr 2020 14:45:50 +0000 Subject: [PATCH] enable load with postfix --- hapi/model.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hapi/model.py b/hapi/model.py index 3255e61..e2fa2d6 100644 --- a/hapi/model.py +++ b/hapi/model.py @@ -798,6 +798,13 @@ class Model(fluid.dygraph.Layer): format(key, list(state.shape), list(param.shape))) return param, state + def _strip_postfix(path): + path, ext = os.path.splitext(path) + assert ext in ['', '.pdparams', '.pdopt', '.pdmodel'], \ + "Unknown postfix {} from weights".format(ext) + return path + + path = _strip_postfix(path) param_state = _load_state_from_path(path + ".pdparams") assert param_state, "Failed to load parameters, please check path." -- GitLab