Keras gradCAM
#######a 加载有权重的模型 model = resnet_18_res2net(input_shape=(256, 256, 1), nclass=2)print(model.summary())model.compile(keras.optimizers.Adam(lr=0.0001), loss='categorical_crossentropy', metrics=['accuracy'])model_path = "train_weights/"model.load_weights(os.path.join(model_path, "resnet_18_res2net.h5"))#resnet18_se#####输入图像 image = np.array(Image.open('C:/Users/xian/Desktop/grad_CAM/2.bmp').convert("L"))#RGBimage = np.expand_dims(image, axis=0)image = np.expand_dims(image, axis=-1)image = image.astype('float32') / 255print(image.shape)###调用函数 cam,heatmap=grad_cam(model,image,1,'concatenate_5')#