Reputation: 145
I am using Keras 2.2.5
in the training phase. I have saved the model with ModelCheckpoint
function that is imported like this: from keras.callbacks import ModelCheckpoint
Then, in the test phase, when I want to load the model using the load_model
function (from keras.models import load_model
), I get the title error.
test script is as follow:
import numpy as np
import argparse
import keras.layers as KL
from keras.models import load_model
from keras.preprocessing import image
from keras.applications.resnet50 import preprocess_input as preprocess_input_resnet
if __name__ == "__main__":
# Define variables
parser = argparse.ArgumentParser()
parser.add_argument("--image_size", type=tuple, default=(500, 500))
parser.add_argument("--mask_size", type=tuple, default=(32,32))
parser.add_argument("--image_path", type=str, default="../DATA/resized_imgs/13056.png")
parser.add_argument("--mask_path", type=str, default="../DATA/resized_masks/13056.png")
parser.add_argument("--path_of_the_checkpoint", type=str, default="./RESULTS/2020_02_25_12_34_54/bestmodel/MultiLabel_PETA_weights.best.hdf5")
parser.add_argument("--Categories", type=list, default=["personalLess30", "personalLess45", "personalLess60", "personalLarger60"])
args = parser.parse_args()
# Load trained model
PAR_model = load_model (filepath=args.path_of_the_checkpoint, custom_objects={'BatchNorm':KL.BatchNormalization})
PAR_model.summary()
Upvotes: 1
Views: 1807
Reputation: 56377
You should not pass positional arguments as keyword arguments:
PAR_model = load_model (args.path_of_the_checkpoint, custom_objects={'BatchNorm':KL.BatchNormalization})
Upvotes: 2