(boxA, boxB)
| 30 | |
| 31 | |
| 32 | def box_iou(boxA, boxB): |
| 33 | boxA = [int(x) for x in boxA] |
| 34 | boxB = [int(x) for x in boxB] |
| 35 | |
| 36 | xA = max(boxA[0], boxB[0]) |
| 37 | xB = min(boxA[2], boxB[2]) |
| 38 | yA = max(boxA[1], boxB[1]) |
| 39 | yB = min(boxA[3], boxB[3]) |
| 40 | |
| 41 | interArea = max(0, xB - xA + 1) * max(0, yB - yA + 1) |
| 42 | |
| 43 | boxAArea = (boxA[2] - boxA[0] + 1) * (boxA[3] - boxA[1] + 1) |
| 44 | boxBArea = (boxB[2] - boxB[0] + 1) * (boxB[3] - boxB[1] + 1) |
| 45 | |
| 46 | iou = interArea / float(boxAArea + boxBArea - interArea) |
| 47 | |
| 48 | return iou |
| 49 | def clean_string(s): |
| 50 | while s and (s[0] in ":[]()' ."): |
| 51 | s = s[1:] |
no outgoing calls
no test coverage detected