in 04_detect_segment/utils_box.py [0:0]
def make_rois_relative_to_tiles(tiles, rois):
# roi coordinates relative to tile
tiles = tf.expand_dims(tiles, axis=1) # force broadcasting on correct axis
tile_x1, tile_y1, tile_x2, tile_y2 = tf.unstack(tiles, axis=2) # shape [n_tiles, 1]
roi_x1, roi_y1, roi_x2, roi_y2 = tf.unstack(rois, axis=2) # shape [n_tiles, max_per_tile]
roi_x1 = (roi_x1 - tile_x1) / (tile_x2-tile_x1) # shapes [n_tiles, max_per_tile] x [n_tiles] broadcast
roi_x2 = (roi_x2 - tile_x1) / (tile_x2-tile_x1)
roi_y1 = (roi_y1 - tile_y1) / (tile_y2-tile_y1)
roi_y2 = (roi_y2 - tile_y1) / (tile_y2-tile_y1)
rois = tf.stack([roi_x1, roi_y1, roi_x2, roi_y2], axis=-1) # shape [n_tiles, max_per_tile, 4]
return rois