bubbliiiing / centernet-keras

这是一个centernet-keras的源码,可以用于训练自己的模型。
MIT License
63 stars 15 forks source link

load_model报错 tensorflow-gpu=1.13.2,keras=2.1.5 #8

Open xxwwkk opened 2 years ago

xxwwkk commented 2 years ago

1.将模型存储

model.save('my_model.h5')

2.加载模型报错

from nets.centernet_training import focal_loss, reg_l1_loss from keras.models import load_model model = load_model('my_model.h5', compile=False, custom_objects={'focal_loss': focal_loss, 'reg_l1_loss': reg_l1_loss}) 报错信息如下: Traceback (most recent call last): File "load_model_error.py", line 21, in model = load_model('my_model.h5', compile=False, custom_objects={'focal_loss': focal_loss, 'reg_l1_loss': reg_l1_loss}) File "/home/wisdom/anaconda3/envs/lvbangxwk/lib/python3.6/site-packages/keras/models.py", line 243, in load_model model = model_from_config(model_config, custom_objects=custom_objects) File "/home/wisdom/anaconda3/envs/lvbangxwk/lib/python3.6/site-packages/keras/models.py", line 317, in model_from_config return layer_module.deserialize(config, custom_objects=custom_objects) File "/home/wisdom/anaconda3/envs/lvbangxwk/lib/python3.6/site-packages/keras/layers/init.py", line 55, in deserialize printable_module_name='layer') File "/home/wisdom/anaconda3/envs/lvbangxwk/lib/python3.6/site-packages/keras/utils/generic_utils.py", line 144, in deserialize_keras_object list(custom_objects.items()))) File "/home/wisdom/anaconda3/envs/lvbangxwk/lib/python3.6/site-packages/keras/engine/topology.py", line 2524, in from_config process_node(layer, node_data) File "/home/wisdom/anaconda3/envs/lvbangxwk/lib/python3.6/site-packages/keras/engine/topology.py", line 2481, in process_node layer(input_tensors[0], kwargs) File "/home/wisdom/anaconda3/envs/lvbangxwk/lib/python3.6/site-packages/keras/engine/topology.py", line 619, in call output = self.call(inputs, kwargs) File "/home/wisdom/anaconda3/envs/lvbangxwk/lib/python3.6/site-packages/keras/layers/core.py", line 663, in call return self.function(inputs, **arguments) File "C:\Users\wisdom\Anaconda3\envs\keras-centernet\lib\site-packages\tensorflow\python\ops\math_ops.py", line 1530, in reduce_mean_v1 NameError: name 'deprecation' is not defined

bubbliiiing commented 2 years ago

预测的时候整个一起保存吧

xxwwkk commented 2 years ago

已解决,3q~