Skip to content

作业答案有bug #10

@langziwuqing

Description

@langziwuqing

4 卷积神经网络/Week3 目标检测/4.3 目标检测/Car detection for Autonomous Driving/Autonomous driving application-Car detection-v1-answer.ipynb,计算iou的函数,此段代码有bug:
xi1 = max(box1[0], box2[0])
yi1 = max(box1[1], box2[1])
xi2 = min(box1[2], box2[2])
yi2 = min(box1[3], box2[3])
inter_area = (yi2 - yi1) * (xi2 - xi1)
当两个框没有重叠时,yi2 - yi1和xi2 - xi1的值都是负数,inter_area应该是0,所以应该这么写:
xi1 = max(box1[0], box2[0])
yi1 = max(box1[1], box2[1])
xi2 = min(box1[2], box2[2])
yi2 = min(box1[3], box2[3])
if (yi2 - yi1 < 0) or (xi2 - xi1 < 0):
inter_area = 0
else:
inter_area = (yi2 - yi1) * (xi2 - xi1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions