pred_minmax = [bbox_pred[0] - 0.5*bbox_pred[2], bbox_pred[1] - 0.5*bbox_pred[3],
bbox_pred[0] + 0.5*bbox_pred[2], bbox_pred[1] + 0.5*bbox_pred[3]]
true_minmax = [bbox_true[0] - 0.5*bbox_true[2], bbox_true[1] - 0.5*bbox_true[3],
bbox_true[0] + 0.5*bbox_true[2], bbox_true[1] + 0.5*bbox_true[3]]
inter_xy_min = tf.maximum(pred_minmax[:2], true_minmax[:2])
inter_xy_max = tf.minimum(pred_minmax[2:], true_minmax[2:])
inter_area = tf.maximum(0.0, inter_xy_max[0] - inter_xy_min[0]) * \
tf.maximum(0.0, inter_xy_max[1] - inter_xy_min[1])
union_area = pred_area + true_area - inter_area
return inter_area / union_area
iou_bbox1 = calculate_iou(bbox1_pred, bbox_true)
iou_bbox2 = calculate_iou(bbox2_pred, bbox_true)
responsible_bbox = bbox1_pred if iou_bbox1 > iou_bbox2 else bbox2_pred # ④