zero-mAP fix return .detach() to EMA (#9056)

Resolves https://github.com/ultralytics/hub/issues/82

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
Glenn Jocher authored and GitHub committed 2022-08-21 02:23:39 +02:00
1 parent 93f63ee33f
commit 841f312f93
1 file changed
+1 -1
+1 -1
View File
@@ -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')):