ayooshkathuria / YOLO_v3_tutorial_from_scratch

Accompanying code for Paperspace tutorial series "How to Implement YOLO v3 Object Detector from Scratch"
https://blog.paperspace.com/how-to-implement-a-yolo-object-detector-in-pytorch/
2.32k stars 724 forks source link

What is the purpose of adding 1 while calculating the box area? #27

Open jayden199012 opened 5 years ago

jayden199012 commented 5 years ago

In the IoU function

#Intersection area inter_area = torch.clamp(inter_rect_x2 - inter_rect_x1 + 1, min=0) * torch.clamp(inter_rect_y2 - inter_rect_y1 + 1, min=0) inter_areaa = torch.clamp(inter_rect_x2 - inter_rect_x1, min=0) * torch.clamp(inter_rect_y2 - inter_rect_y1, min=0)

what is the reason for the + 1 while calculating the area?

Is it to avoid 0 division error for calculating IoU? But won't it affect the value by adding a constant to the area?

bot66 commented 4 years ago

It's about to avoid 0/0 situation.