Fix TFLite Segment mask rows 1-4 normalization (#9405)

Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
Charles Ollion 2024-03-30 23:13:03 +01:00 committed by GitHub
parent 30a867b8d7
commit 007f778b72
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -543,7 +543,7 @@ class AutoBackend(nn.Module):
if integer:
scale, zero_point = output["quantization"]
x = (x.astype(np.float32) - zero_point) * scale # re-scale
if x.ndim > 2: # if task is not classification
if x.ndim == 3: # if task is not classification, excluding masks (ndim=4) as well
# Denormalize xywh by image size. See https://github.com/ultralytics/ultralytics/pull/1695
# xywh are normalized in TFLite/EdgeTPU to mitigate quantization error of integer models
x[:, [0, 2]] *= w