FinalEvaluator#
- class FinalEvaluator(test_last=False)[source]#
Bases:
HookBaseRun the configured tester once after training, usually on model_best.
On
after_train(and only whencfg.evaluateis true), builds the tester named bycfg.test.typefrom theTESTERSregistry and runs its fulltest()pass. By default it loadsmodel_best.pth(the best checkpoint selected during training) into the tester before testing; settest_last=Trueto instead test the in-memorymodel_lastweights. This hook computes no metric of its own and does not set the checkpoint-selectioncomm_infokeys — it delegates all metric computation to the tester. Registered asFinalEvaluator(use astypein ahooks=[...]entry).- Parameters:
test_last (bool) – Test the current
model_lastweights instead of loadingmodel_best.pth. Defaults toFalse.
Note
Runs exactly once, after training exits. When
test_lastisFalsethe best checkpoint is loaded withstrict=True, so the tester model architecture must match the saved state dict.Example
Add to
cfg.hooks; once inafter_trainit runs the configured tester on the best checkpoint:hooks = [dict(type="FinalEvaluator", test_last=False)] # → after training, builds cfg.test.type from the TESTERS registry, # loads <save_path>/model/model_best.pth (strict=True) into it, and # runs tester.test(); computes no metric of its own