| 69 | DEFAULT_VIDEO_END_TOKEN = "</vid>" |
| 70 | |
| 71 | def iou(box1, box2): |
| 72 | # 计算交集 |
| 73 | x1 = max(box1[0], box2[0]) |
| 74 | y1 = max(box1[1], box2[1]) |
| 75 | x2 = min(box1[2], box2[2]) |
| 76 | y2 = min(box1[3], box2[3]) |
| 77 | |
| 78 | intersection = max(0, x2 - x1) * max(0, y2 - y1) |
| 79 | box1_area = (box1[2] - box1[0]) * (box1[3] - box1[1]) |
| 80 | box2_area = (box2[2] - box2[0]) * (box2[3] - box2[1]) |
| 81 | union = box1_area + box2_area - intersection |
| 82 | |
| 83 | return intersection / union if union != 0 else 0 |
| 84 | |
| 85 | |
| 86 | def show_predictions(scores, boxes, classes): |