Contents return some methods of image processing
Previous: depth articles - image processing methods (a) on three levels of image processing and selective search
Next: Depth articles - image processing methods (iii) elaborate HOG features and bag-of-word
In this section, elaborate and performance evaluation Giou IOU, and the next section HOG features elaborate bag-of-word
GIOU 论文地址:Generalized Intersection over Union: A Metric and A Loss for Bounding Box Regression
Performance Evaluation
Naturally, the object bounding boxes and comprising ground true (truth) is obtained by calculation window overlap more, then the better the performance.
三. IOU (Instersectiou Over Union, IOU)
1. IOU is a measure of a particular data set corresponding to the detection accuracy of a standard object.
2. IOU's formula:
: For each fixed to the of class C, each ground true (truth) is represented , wherein
: For each bounding box, which
In fact, the area ratio.
IOU's loss is:
3. IOU python code
#!/usr/bin/env python
# _*_ coding:utf-8 _*_
# ============================================
# @Time : 2020/02/01 16:04
# @Author : WanDaoYi
# @FileName : bbox_iou.py
# ============================================
import numpy as np
# IOU
def bboxes_iou(boxes1, boxes2):
boxes1 = np.array(boxes1)
boxes2 = np.array(boxes2)
# 计算 面积
boxes1_area = (boxes1[..., 2] - boxes1[..., 0]) * (boxes1[..., 3] - boxes1[..., 1])
boxes2_area = (boxes2[..., 2] - boxes2[..., 0]) * (boxes2[..., 3] - boxes2[..., 1])
# 交集的 左上角坐标
left_up = np.maximum(boxes1[..., :2], boxes2[..., :2])
# 交集的 右下角坐标
right_down = np.minimum(boxes1[..., 2:], boxes2[..., 2:])
# 计算交集矩形框的 high 和 width
inter_section = np.maximum(right_down - left_up, 0.0)
# 两个矩形框的 交集 面积
inter_area = inter_section[..., 0] * inter_section[..., 1]
# 两个矩形框的并集面积
union_area = boxes1_area + boxes2_area - inter_area
# 计算 iou
ious = np.maximum(1.0 * inter_area / union_area, np.finfo(np.float32).eps)
return ious
4. MABO (Mean Average Best Overlap, MABO) overlapping the highest average rate
In doing performance evaluation time, sometimes with MABO to assess its formula is as follows:
For performance evaluation in all categories, it is natural to assess performance in all categories, it is natural to use the average of all categories of ABO MABO evaluated.
5. single policy evaluation
You can change any of the diversity strategy, performance assessment MABO selective search. Policy papers taken are as follows:
(1) using the RGB color space (FIG based divided image may be an image with a different color area division)
(2) using the four kinds of combinations calculated similarity
(3) Set the threshold for image segmentation k = 50
Then, by changing one policy parameters, obtain MABO performance indicators.
6. Diversity strategy combination
Greedy search algorithm, the combination of a single strategy, will get a higher MABO, however, will result in increased computational cost.
四. GIOU (Generalized IOU, GIOU) 广义 IOU
1. For IOU has the following two drawbacks:
(1) When , that is bounding box with ground true when there is no intersection, can not know the bounding box of each other near the ground true is still very far away.
: Is predicted box, is the bounding box, the corresponding coordinates
: Is ground true, the corresponding coordinates
. (2) IOU alignment can not distinguish different ways, such as direction and inconsistent, as follows:
2. GIOU IOU optimized is calculated as follows:
: Is predicted box, is the bounding box, the corresponding coordinates
: Is ground true, the corresponding coordinates
(1) Calculation of the area
(2) Calculate the area (empathy) of
(3) computing the area
. (4) comprises a calculation and a minimum sealing area Box :
GIOU of loss as follows:
3. GIOU optimization of understanding
Calculated by:
(1) When the IOU = 0, IOU can not be optimized. The behavior:
When the time does not intersect, i.e. , this case reduces to:
Minimizing the need to maximize GIOU loss , which is an already normalized, i.e. , one which is required to maximize and minimize , maximize the same time , because , therefore , since the known and fixed, it is necessary to maximum technology , that is, minimize and maximize the same time , obviously, which makes tend to coincide.
(2) because when the time, GIOU still can be optimized, so, GIOU only to retain the original nature of the IOU, while weakening its weaknesses, so the paper can be considered as an IOU GIOU replacement.
4. GIOU python code:
#!/usr/bin/env python
# _*_ coding:utf-8 _*_
# ============================================
# @Time : 2020/02/01 16:04
# @Author : WanDaoYi
# @FileName : bbox_giou.py
# ============================================
import tensorflow as tf
def bbox_giou(boxes1, boxes2):
# 将 中心点 与 high 和 width 转为 左上 和 右下 坐标点
boxes1 = tf.concat([boxes1[..., :2] - boxes1[..., 2:] * 0.5,
boxes1[..., :2] + boxes1[..., 2:] * 0.5], axis=-1)
boxes2 = tf.concat([boxes2[..., :2] - boxes2[..., 2:] * 0.5,
boxes2[..., :2] + boxes2[..., 2:] * 0.5], axis=-1)
# 获取 框 的 左上角 和 右下角 的坐标值
boxes1 = tf.concat([tf.minimum(boxes1[..., :2], boxes1[..., 2:]),
tf.maximum(boxes1[..., :2], boxes1[..., 2:])], axis=-1)
boxes2 = tf.concat([tf.minimum(boxes2[..., :2], boxes2[..., 2:]),
tf.maximum(boxes2[..., :2], boxes2[..., 2:])], axis=-1)
# 计算 面积
boxes1_area = (boxes1[..., 2] - boxes1[..., 0]) * (boxes1[..., 3] - boxes1[..., 1])
boxes2_area = (boxes2[..., 2] - boxes2[..., 0]) * (boxes2[..., 3] - boxes2[..., 1])
# 计算交集的 左上角 和 右下角 坐标
left_up = tf.maximum(boxes1[..., :2], boxes2[..., :2])
right_down = tf.minimum(boxes1[..., 2:], boxes2[..., 2:])
# 计算 交集 的 high 和 width
inter_section = tf.maximum(right_down - left_up, 0.0)
# 计算 交集 的面积
inter_area = inter_section[..., 0] * inter_section[..., 1]
# 计算 并集 的面积
union_area = boxes1_area + boxes2_area - inter_area
# 计算 IOU
iou = inter_area / union_area
# 计算最小密封框 的 左上角 坐标
enclose_left_up = tf.minimum(boxes1[..., :2], boxes2[..., :2])
# 计算最小密封框 的 右下角 坐标
enclose_right_down = tf.maximum(boxes1[..., 2:], boxes2[..., 2:])
# 计算最小密封框 的 high 和 width
enclose = tf.maximum(enclose_right_down - enclose_left_up, 0.0)
# 计算最小密封框 的 面积
enclose_area = enclose[..., 0] * enclose[..., 1]
# 计算 GIOU
giou = iou - 1.0 * (enclose_area - union_area) / enclose_area
return giou
Contents return some methods of image processing
Previous: depth articles - image processing methods (a) on three levels of image processing and selective search
Next: Depth articles - image processing methods (iii) elaborate HOG features and bag-of-word