YOLOV4 中断恢复训练 --resume

在用YOLOV4-WongKinYiu时训练时,不小心训练中断了,在恢复训练时遇到这个问题

Traceback (most recent call last):
  File "train.py", line 538, in 
    train(hyp, opt, device, tb_writer, wandb)
  File "train.py", line 81, in train
    model = Darknet(opt.cfg).to(device)  # create
  File "/root/autodl-tmp/yolov4-wky/models/models.py", line 451, in __init__
    self.module_defs = parse_model_cfg(cfg)
  File "/root/autodl-tmp/yolov4-wky/utils/parse_config.py", line 13, in parse_model_cfg
    with open(path, 'r') as f:
FileNotFoundError: [Errno 2] No such file or directory: '.cfg'

解决方案:

在train.py的第537行之前加入该行代码

opt.cfg, opt.weights, opt.resume = './cfg/crowd.cfg',ckpt, True  # 中断恢复训练

修改后的代码:

 # Train
    logger.info(opt)
    if not opt.evolve:
        tb_writer = None  # init loggers
        if opt.global_rank in [-1, 0]:
            logger.info(f'Start Tensorboard with "tensorboard --logdir {opt.project}", view at http://localhost:6006/')
            tb_writer = SummaryWriter(opt.save_dir)  # Tensorboard
        opt.cfg, opt.weights, opt.resume = './cfg/crowd.cfg',ckpt, True  # 中断恢复训练
        train(hyp, opt, device, tb_writer, wandb)

顺利解决!

注:恢复中断训练完成之后,应该是需要把这行代码注释掉!

你可能感兴趣的:(问题解决,YOLO,人工智能,深度学习)