Commit d99428a1 authored by Yanghan Wang's avatar Yanghan Wang Committed by Facebook GitHub Bot
Browse files

only evaluate EMA model on non-predictor models

Summary:
EMA is only applicable when testing non-predictor based models, this diff simply add a check so it won't evaluate ema models.

Side note: `do_test` should probably just handle single model, in the case of EMA, we could let `do_train` to return two models with and without ema, and call `do_test` on each of them. Then the temporary fix in this diff is not needed at all.

Reviewed By: wrlife

Differential Revision: D31450572

fbshipit-source-id: 8696922a9fd194f91315d2f3480dc8bfd8f36a3d
parent 79ea94d5
...@@ -68,6 +68,7 @@ from detectron2.solver import ( ...@@ -68,6 +68,7 @@ from detectron2.solver import (
from detectron2.utils.events import CommonMetricPrinter, JSONWriter from detectron2.utils.events import CommonMetricPrinter, JSONWriter
from detectron2.utils.registry import Registry from detectron2.utils.registry import Registry
from mobile_cv.arch.quantization.observer import update_stat as observer_update_stat from mobile_cv.arch.quantization.observer import update_stat as observer_update_stat
from mobile_cv.predictor.api import PredictorWrapper
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
...@@ -414,7 +415,7 @@ class Detectron2GoRunner(BaseRunner): ...@@ -414,7 +415,7 @@ class Detectron2GoRunner(BaseRunner):
results.update(cur_results) results.update(cur_results)
# model with ema weights # model with ema weights
if cfg.MODEL_EMA.ENABLED: if cfg.MODEL_EMA.ENABLED and not isinstance(model, PredictorWrapper):
logger.info("Run evaluation with EMA.") logger.info("Run evaluation with EMA.")
with model_ema.apply_model_ema_and_restore(model): with model_ema.apply_model_ema_and_restore(model):
cur_results = self._do_test( cur_results = self._do_test(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment