Chris-hughes10 / Yolov7-training

A clean, modular implementation of the Yolov7 model family, which uses the official pretrained weights, with utilities for training the model on custom (non-COCO) tasks.
GNU General Public License v3.0
116 stars 35 forks source link

Hi, How do you resume from best_model.pt? #19

Open ross-Hr opened 1 year ago

ross-Hr commented 1 year ago

Hello,

For some reason my machine lost power during training. Is it possible to resume the previous training from best_model.pt ?

I realized https://github.com/Chris-hughes10/Yolov7-training/issues/13#issue-1624702887 didn't solve the problem complete...

My rough code:

   if RESUME_LOCAL_PATH is not None:
        ckpoint = torch.load(RESUME_LOCAL_PATH)
        optimizer.state_dict().update(ckpoint['optimizer_state_dict'])

   ......

   state_dict = torch.load(RESUME_LOCAL_PATH )
   state_dict = intersect_dicts(
                state_dict,
                model.state_dict(),
                exclude=["anchor"],
            )

   model.load_state_dict(state_dict, strict=False)

I'm not sure if I'll be able to get back to my previous training.