|
|
|
@ -587,14 +587,21 @@ class AutoBackend(nn.Module): |
|
|
|
|
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 |
|
|
|
|
x[:, [1, 3]] *= h |
|
|
|
|
if x.shape[-1] == 6: # end-to-end model |
|
|
|
|
x[:, :, [0, 2]] *= w |
|
|
|
|
x[:, :, [1, 3]] *= h |
|
|
|
|
else: |
|
|
|
|
x[:, [0, 2]] *= w |
|
|
|
|
x[:, [1, 3]] *= h |
|
|
|
|
y.append(x) |
|
|
|
|
# TF segment fixes: export is reversed vs ONNX export and protos are transposed |
|
|
|
|
if len(y) == 2: # segment with (det, proto) output order reversed |
|
|
|
|
if len(y[1].shape) != 4: |
|
|
|
|
y = list(reversed(y)) # should be y = (1, 116, 8400), (1, 160, 160, 32) |
|
|
|
|
y[1] = np.transpose(y[1], (0, 3, 1, 2)) # should be y = (1, 116, 8400), (1, 32, 160, 160) |
|
|
|
|
if y[1].shape[-1] == 6: # end-to-end model |
|
|
|
|
y = [y[1]] |
|
|
|
|
else: |
|
|
|
|
y[1] = np.transpose(y[1], (0, 3, 1, 2)) # should be y = (1, 116, 8400), (1, 32, 160, 160) |
|
|
|
|
y = [x if isinstance(x, np.ndarray) else x.numpy() for x in y] |
|
|
|
|
|
|
|
|
|
# for x in y: |
|
|
|
|