Created
April 30, 2020 05:11
-
-
Save pythonlessons/edc54a4bcdd56e1112d770c46cee4e8c to your computer and use it in GitHub Desktop.
Yolo_v3_bbox_giou
This file contains hidden or 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 bbox_giou (boxes1, boxes2): | |
| ... | |
| # Calculate the iou value between the two bounding boxes | |
| iou = inter_area / union_area | |
| # Calculate the coordinates of the upper left corner and the lower right corner of the smallest closed convex surface | |
| enclose_left_up = tf.minimum (boxes1 [..., :2], boxes2 [..., :2]) | |
| enclose_right_down = tf.maximum (boxes1 [..., 2:], boxes2 [..., 2:]) | |
| enclose = tf.maximum(enclose_right_down-enclose_left_up, 0.0 ) | |
| # Calculate the area of the smallest closed convex surface C | |
| enclose_area = enclose [..., 0 ] * enclose [..., 1 ] | |
| # Calculate the GIoU value according to the GioU formula | |
| giou = iou- 1.0 * (enclose_area-union_area) / enclose_area | |
| return giou |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment