From 841f312f9384d3ab8f2ff2ae287441ecfba03740 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sun, 21 Aug 2022 02:23:39 +0200 Subject: [PATCH] zero-mAP fix return `.detach()` to EMA (#9056) Resolves https://github.com/ultralytics/hub/issues/82 Signed-off-by: Glenn Jocher Signed-off-by: Glenn Jocher --- utils/torch_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/torch_utils.py b/utils/torch_utils.py index 88108906b..b934248de 100644 --- a/utils/torch_utils.py +++ b/utils/torch_utils.py @@ -422,7 +422,7 @@ class ModelEMA: for k, v in self.ema.state_dict().items(): if v.dtype.is_floating_point: # true for FP16 and FP32 v *= d - v += (1 - d) * msd[k] + v += (1 - d) * msd[k].detach() assert v.dtype == msd[k].dtype == torch.float32, f'EMA {v.dtype} and model {msd[k]} must be updated in FP32' def update_attr(self, model, include=(), exclude=('process_group', 'reducer')):