如何从上次获得的最佳权重继续训练?

How to Continue Training from the last acquired best weights?

Keras implementation of YOLOv4

在 YOLOv4 的这个 Keras 实现中,是否有可能以某种方式从上次保存的最佳权重继续训练?类似于以下内容:

model_checkpoint_callback = tf.keras.callbacks.ModelCheckpoint(
    filepath=checkpoint_filepath,
    monitor='val_binary_accuracy',
    mode='max',
    save_best_only=True)

model.load_weights(checkpoint_filepath)

根据these lines,存储库会自动处理您路径上的权重;所以要加载一个 pre-trained 权重(.h5 检查点或 .weights 进行迁移学习,其余的请遵循训练笔记本;

model = Yolov4(weight_path='mytraining.weights', 
               class_name_path=class_name_path)

更新:(来自OP的评论)

Pre-trained 权重可以通过将“.h5”检查点文件的路径传递给 weight_path 参数来加载以进行迁移学习,并在 models.py 中进行以下修改:替换 line 75:

if load_pretrained and self.weight_path and self.weight_path.endswith('.weights'):

与:

if load_pretrained and self.weight_path and (self.weight_path.endswith('.weights') or self.weight_path.endswith('.h5')):

此问题已在 PR 中得到解决。