Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Laughing-q committed Apr 1, 2024
1 parent 6869af4 commit 97a2478
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions ultralytics/engine/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,7 @@ def _setup_train(self, world_size):
# Scheduler
self._setup_scheduler()
self.stopper, self.stop = EarlyStopping(patience=self.args.patience), False
if self.args.resume:
self.resume_training(ckpt)
self.resume_training(ckpt)
self.scheduler.last_epoch = self.start_epoch - 1 # do not move
self.run_callbacks("on_pretrain_routine_end")

Expand Down Expand Up @@ -649,7 +648,7 @@ def check_resume(self, overrides):

resume = True
self.args = get_cfg(ckpt_args)
self.args.model = str(last) # reinstate model
self.args.model = self.args.resume = str(last) # reinstate model
for k in "imgsz", "batch", "device": # allow arg updates to reduce memory or update device on resume
if k in overrides:
setattr(self.args, k, overrides[k])
Expand All @@ -663,7 +662,7 @@ def check_resume(self, overrides):

def resume_training(self, ckpt):
"""Resume YOLO training from given epoch and best fitness."""
if ckpt is None:
if ckpt is None or not self.resume:
return
best_fitness = 0.0
start_epoch = ckpt.get("epoch", -1) + 1
Expand Down

0 comments on commit 97a2478

Please sign in to comment.