Created
July 7, 2020 01:41
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_conf_mask(best_ious, true_box_conf, true_box_conf_IOU,LAMBDA_NO_OBJECT, LAMBDA_OBJECT): | |
''' | |
== input == | |
best_ious : tensor of shape (Nbatch, N grid h, N grid w, N anchor) | |
true_box_conf : tensor of shape (Nbatch, N grid h, N grid w, N anchor) | |
true_box_conf_IOU : tensor of shape (Nbatch, N grid h, N grid w, N anchor) | |
LAMBDA_NO_OBJECT : 1.0 | |
LAMBDA_OBJECT : 5.0 | |
== output == | |
conf_mask : tensor of shape (Nbatch, N grid h, N grid w, N anchor) | |
conf_mask[iframe, igridy, igridx, ianchor] = 0 | |
when there is no object assigned in (grid cell, anchor) pair and the region seems useless i.e. | |
y_true[iframe,igridx,igridy,4] = 0 "and" the predicted region has no object that has IoU > 0.6 | |
conf_mask[iframe, igridy, igridx, ianchor] = NO_OBJECT_SCALE | |
when there is no object assigned in (grid cell, anchor) pair but region seems to include some object | |
y_true[iframe,igridx,igridy,4] = 0 "and" the predicted region has some object that has IoU > 0.6 | |
conf_mask[iframe, igridy, igridx, ianchor] = OBJECT_SCALE | |
when there is an object in (grid cell, anchor) pair | |
''' | |
conf_mask = tf.cast(best_ious < 0.6, tf.float32) * (1 - true_box_conf) * LAMBDA_NO_OBJECT | |
# penalize the confidence of the boxes, which are reponsible for corresponding ground truth box | |
conf_mask = conf_mask + true_box_conf_IOU * LAMBDA_OBJECT | |
return(conf_mask) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment