in 04_detect_segment/utils_box.py [0:0]
def compute_safe_IOU(target_rois, detected_rois, detected_rois_overflow, tile_size):
"""Computes the Intersection Over Union (IOU) of a batch of detected boxes
against a batch of target boxes. Logs a message if a problem occurs."""
iou_accuracy = IOUCalculator.batch_intersection_over_union(detected_rois * tile_size, target_rois * tile_size, tile_size=tile_size)
iou_accuracy_overflow = tf.greater(tf.reduce_sum(detected_rois_overflow), 0)
# check that we are not overflowing the tensor size. Issue a warning if we are. This should only happen at
# the beginning of the training with a completely uninitialized network.
iou_accuracy = tf.cond(iou_accuracy_overflow,
lambda: tf.Print(iou_accuracy, [detected_rois_overflow],
summarize=250, message="ROI tensor overflow in IOU computation. "
"The computed IOU is not correct and will "
"be reported as 0. This can be normal in initial "
"training iteration when all weights are random. "
"Increase MAX_DETECTED_ROIS_PER_TILE to avoid."),
lambda: tf.identity(iou_accuracy))
iou_accuracy = IOUCalculator.batch_mean(iou_accuracy)
# set iou_accuracy to 0 if there has been any overflow in its computation
iou_accuracy = tf.where(iou_accuracy_overflow, tf.zeros_like(iou_accuracy), iou_accuracy)
return iou_accuracy