yjh0410 / CenterNet-plus

A Simple Baseline for Object Detection
55 stars 11 forks source link

IOU Loss and Heatmap Visualization #14

Closed YashRunwal closed 3 years ago

YashRunwal commented 3 years ago

@yjh0410

  1. How do we visualize the heatmap (output), I would like to inspect the peaks and make some changes if need be.
  2. Why is the IOU loss used here? IOU is supposed to be used for anchor-based Object Detection, right? Also, I have several bounding boxes overlapping each other for an object. How can we use NonMaxSuprresion (NMS) for this task?
YashRunwal commented 3 years ago

@yjh0410 Hi! I think I can plot the heatmaps. Number of heatmaps == Number of classes the model has been trained for. Right? However, I don't understand why IOU Loss is used. Could you explain it a bit?

yjh0410 commented 3 years ago

@YashRunwal Yes, the Number of heatmaps == Number of classes. IoU loss is an common loss function for bbox regression. It doesn't matter whether you use anchor box.

YashRunwal commented 3 years ago

@yjh0410 But in the "Objects as Points" paper, they have mentioned that by using the anchorless method, there is no need of using IOU loss. Also, in the loss_basefunction, the IOU loss function has been set to zero. Can you also please take a look at this issue? I am on some sort of deadline. The functionality I want to add would improve this repo as well, I think.

yjh0410 commented 3 years ago

There is no relation between IoU loss and anchor box. For example, Fcos, a famous anchor free detector, uses IoU loss to regress bounding box. IoU loss is just an common loss function for bbox regression. In addition, The loss_base in my project is build for my baseline model to do ablation studies which you can just ignore.

YashRunwal commented 3 years ago

I understand. But in this model, for what purpose is the IOU loss used? From what I can understand, it is used for bounding box regression. The pred_iouis calculated using the decode_boxes function and the pred_iou detection head. Then the iou_predis calculated using the iou_scorefunction. In the loss then, there is the following:

gt_box_scale_weight = label[:, :, :, num_classes + 4]
gt_mask = (gt_box_scale_weight > 0.).float()
gt_iou = gt_mask.clone()

Here, we can see that there is groundtruth_iou. This is calculated using a weightwhich is assigned during creating a target using gt_creator. weight = 2.0 - (box_w / w) * (box_h / h).

How did you come up with this formula for weight? And what does it do exactly?

yjh0410 commented 3 years ago

In general, IoU loss can improve the performance of a detector, so I add this loss to my model.

The formula of weight refers to YOLOv3 to balance the loss between large and small objects.

YashRunwal commented 3 years ago

Right, so the IOU loss improves the bounding box detection performance. So this model is a hybrid between YOLOv3 and CenterNet. IOU loss is taken from YOLOv3 and the rest of the part is an improvement of CenterNet. I would perhaps try training my network without using IOU loss and check the performance. I will let you know on this thread.

YashRunwal commented 3 years ago

Meanwhile, can you pleasee help me with this (https://github.com/yjh0410/CenterNet-plus/issues/15) issue?