tensorflow常用函数库

归一化函数:

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)
posted @ 2019-04-22 16:04  水木清扬  阅读(804)  评论(0编辑  收藏  举报