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

Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
pull/9436/head
Charles Ollion 8 months ago committed by GitHub
parent 30a867b8d7
commit 007f778b72
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      ultralytics/nn/autobackend.py

@ -543,7 +543,7 @@ class AutoBackend(nn.Module):
if integer: if integer:
scale, zero_point = output["quantization"] scale, zero_point = output["quantization"]
x = (x.astype(np.float32) - zero_point) * scale # re-scale 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 # 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 # xywh are normalized in TFLite/EdgeTPU to mitigate quantization error of integer models
x[:, [0, 2]] *= w x[:, [0, 2]] *= w

Loading…
Cancel
Save