2022.1.15µÄ¼Ç¼ yolo3µÄËðʧº¯Êý½²½â yolov5µÄËðʧº¯ÊýµÄ¼¸µãÀí½â IOU¡¢GIOU¡¢CIOU¡¢DIOU NMS ·Ç³£¸Ðл·¢²¼ÉÏÃæÎÄÕµIJ©Ö÷,°ïÖúÌ«´óÁË¡£ ±¾µ±¤Ë¤¢¤ê¤¬¤È¤¦¤´¤¶¤¤¤Þ¤·¤¿?Öú¤«¤ê¤Þ¤·¤¿?
°´ÕÕÀÏʦÌṩµÄÂÛÎÄ,½«yolov5µÄNMSÖеÄIOU¸ÄΪDIOU,ÐÞ¸ÄÎļþΪgeneral.py¡£ËäÈ»¸ÄµÄ¶Ô²»¶Ô»¹²»È·¶¨😰¡£µÈºóÌìmatlabµÄ2wÕÅͼµÄѵÁ·¼¯Éú³É½áÊø¾ÍÊÔÊÔ¡£Éú³ÉÒ»¸ö¿ÉÒÔÓÃÀ´ÑµÁ·µÄͼƬ¼Ó¼ÆËã±êǩƽ¾ùÒª6.7s,Õ涥²»×¡,ÒÔºóÓÐʱ¼ä¿´Äܲ»ÄÜÓÅ»¯Ò»Ï´úÂë°É😓¡£
iou = box_iou(boxes[i], boxes) > iou_thres
¸ÄΪ
iou = My_Box_DIOU(boxes[i], boxes) > iou_thres
def My_Box_DIOU(box1, box2):
box2 = box2.T
b1_x1, b1_y1, b1_x2, b1_y2 = box1[0], box1[1], box1[2], box1[3]
b2_x1, b2_y1, b2_x2, b2_y2 = box2[0], box2[1], box2[2], box2[3]
inter = (torch.min(b1_x2, b2_x2) - torch.max(b1_x1, b2_x1)).clamp(0) * \
(torch.min(b1_y2, b2_y2) - torch.max(b1_y1, b2_y1)).clamp(0)
w1, h1 = b1_x2 - b1_x1, b1_y2 - b1_y1
w2, h2 = b2_x2 - b2_x1, b2_y2 - b2_y1
union = w1 * h1 + w2 * h2 - inter
iou = inter / union
cw = torch.max(b1_x2, b2_x2) - torch.min(b1_x1, b2_x1)
ch = torch.max(b1_y2, b2_y2) - torch.min(b1_y1, b2_y1)
c2 = cw ** 2 + ch ** 2
rho2 = ((b2_x1 + b2_x2 - b1_x1 - b1_x2) ** 2 +
(b2_y1 + b2_y2 - b1_y1 - b1_y2) ** 2) / 4
return iou - rho2 / c2
|