Closed aliencaocao closed 3 years ago
Resuming training from checkpoints is not implemented yet, I will implement it soon. a temporary solution:
elif args.model_type == "p5": model = Yolov4(args, training=True) if args.use_pretrain: if len(os.listdir(os.path.dirname(args.p5_coco_pretrained_weights)))!=0: try: model.load_weights(args.p5_coco_pretrained_weights).expect_partial() print("Load {} checkpoints successfully!".format(args.model_type)) except: cur_num_classes = int(args.num_classes) args.num_classes = 80 pretrain_model = Yolov4(args, training=True) pretrain_model.load_weights(args.p5_coco_pretrained_weights).expect_partial() for layer in model.layers: if not layer.get_weights(): continue if 'yolov3_head' in layer.name: continue layer.set_weights(pretrain_model.get_layer(layer.name).get_weights()) args.num_classes = cur_num_classes print("Load {} weight successfully!".format(args.model_type)) else: raise ValueError("pretrained_weights directory is empty!")
Resuming training from checkpoints is supported now.
Okay thanks a lot!
I assumed that the way to load a saved checkpoint is the same as loading pretrained weight. However, when I try to load my own saved checkpoint and train again with the exact same data and exact same command, I got this error:
The command I'm using:
python train.py --epochs 200 --batch-size 4 --start-eval-epoch 0 --model-type p5 --use-pretrain True --dataset-type coco --dataset dataset/CV1/ --num-classes 5 --class-names CV1.names --coco-train-set train --coco-valid-set val --augment ssd_random_crop --p5-coco-pretrained-weights checkpoints/best_weight_p5_27_0.872
Let me know if you need the weight files to test. I can share