From 4bdd0696506e7ffec8fd83c3bb49a7835353d425 Mon Sep 17 00:00:00 2001 From: Jim Martens Date: Tue, 9 Jul 2019 12:13:41 +0200 Subject: [PATCH] Added custom objects to recover saved model Signed-off-by: Jim Martens --- src/twomartens/masterthesis/cli.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/twomartens/masterthesis/cli.py b/src/twomartens/masterthesis/cli.py index 8469034..4672d57 100644 --- a/src/twomartens/masterthesis/cli.py +++ b/src/twomartens/masterthesis/cli.py @@ -307,6 +307,9 @@ def _ssd_test(args: argparse.Namespace) -> None: from twomartens.masterthesis import data from twomartens.masterthesis import ssd + from twomartens.masterthesis.ssd_keras.keras_layers import keras_layer_AnchorBoxes + from twomartens.masterthesis.ssd_keras.keras_layers import keras_layer_L2Normalization + config = tf.ConfigProto() config.log_device_placement = False @@ -334,7 +337,10 @@ def _ssd_test(args: argparse.Namespace) -> None: instances = pickle.load(file) # model - ssd_model = tf.keras.models.load_model(model_file) + ssd_model = tf.keras.models.load_model(model_file, custom_objects={ + "L2Normalization": keras_layer_L2Normalization.L2Normalization, + "AnchorBoxes": keras_layer_AnchorBoxes.AnchorBoxes + }) test_generator, length_dataset = \ data.load_scenenet_data(file_names_photos, instances, coco_path,