diff --git a/mmdet/core/evaluation/eval_hooks.py b/mmdet/core/evaluation/eval_hooks.py index a20e2cff00b..7c1fbe968d2 100644 --- a/mmdet/core/evaluation/eval_hooks.py +++ b/mmdet/core/evaluation/eval_hooks.py @@ -56,7 +56,9 @@ def _do_evaluate(self, runner): results = single_gpu_test(runner.model, self.dataloader, show=False) runner.log_buffer.output['eval_iter_num'] = len(self.dataloader) key_score = self.evaluate(runner, results) - if self.save_best: + # the key_score may be `None` so it needs to skip the action to save + # the best checkpoint + if self.save_best and key_score: self._save_ckpt(runner, key_score) @@ -122,5 +124,7 @@ def _do_evaluate(self, runner): runner.log_buffer.output['eval_iter_num'] = len(self.dataloader) key_score = self.evaluate(runner, results) - if self.save_best: + # the key_score may be `None` so it needs to skip + # the action to save the best checkpoint + if self.save_best and key_score: self._save_ckpt(runner, key_score)