归一化函数:

def norm_boxes(boxes, shape):
"""Converts boxes from pixel coordinates to normalized coordinates.
boxes: [N, (y1, x1, y2, x2)] in pixel coordinates
shape: [..., (height, width)] in pixels

Note: In pixel coordinates (y2, x2) is outside the box. But in normalized
coordinates it's inside the box.

Returns:
[N, (y1, x1, y2, x2)] in normalized coordinates
"""
h, w = shape
scale = np.array([h - 1, w - 1, h - 1, w - 1])
shift = np.array([0, 0, 1, 1])
return np.divide((boxes - shift), scale).astype(np.float32)

相关文章:

  • 2022-01-11
  • 2021-09-13
  • 2021-05-29
  • 2022-12-23
  • 2019-07-14
  • 2022-12-23
  • 2021-08-03
猜你喜欢
  • 2021-06-22
  • 2021-06-04
  • 2021-11-20
  • 2021-07-08
  • 2021-08-25
  • 2021-06-09
相关资源
相似解决方案