-
前端反复模型调用时出错
TypeError: Cannot interpret feed_dict key as Tensor: Tensor Tensor(“Placeholder_1:0”, shape=(32,), dtype=float32) is not an element of this graph.
解决方法:
在每次模型调用时执行: 添加下面第二行代码即可。
tf.logging.info(“模型加载中…”)
keras.backend.clear_session()
model = load_model(model_path)
np.set_printoptions(precision=2, suppress=True) -
raise TypeError(repr(o) + " is not JSON serializable")
TypeError: array([[ 0, 43, 0],
[ 0, 643, 0],
[ 0, 38, 0]]) is not JSON serializable
只需要在结果后面添加 '.tolist()'转成list即可 -
return imagenet_utils.preprocess_input(x, mode=‘tf’) NameError: name ‘imagenet_utils’ is not define
使用如下方式加载成功:
from keras.applications import imagenet_utils
model = load_model(model_path, custom_objects={‘imagenet_utils’: imagenet_utils})
- 后续持续更新