tianzhi0549 / FCOS

FCOS: Fully Convolutional One-Stage Object Detection (ICCV'19)
https://arxiv.org/abs/1904.01355
Other
3.28k stars 630 forks source link

box target? #36

Closed YongtaoGe closed 5 years ago

YongtaoGe commented 5 years ago

Does the network output the box offsets (l,r,t,b) normalized by image size? I tried to train fcos in another task and find the regression branch's output value is unstable.

tianzhi0549 commented 5 years ago

@yongtaoge No, we do not normalize it. I suggest that you make use of L1 loss instead of IOULoss in the code and compute the loss in a log scale. It should prevent the loss from diverging. Thank you very much!

YongtaoGe commented 5 years ago

@tianzhi0549 Thanks!

heiyuxiaokai commented 5 years ago

@tianzhi0549 Does it mean L1_loss(reg_scale)? reg_scale = log(reg_pre - reg_target), reg_pre = exp(x1box_conv_output) And the reg_target((l,r,t,b*) is not normalized.

tianzhi0549 commented 5 years ago

@heiyuxiaokai No. It means torch.abs(log(reg_target) - log(reg_pred)).mean().

heiyuxiaokai commented 5 years ago

@tianzhi0549 I know, thanks.

heiyuxiaokai commented 5 years ago

@tianzhi0549 In iou_loss, the loss weight is centerness_target. If I ues L1 loss, should I use centerness_target as loss weight?

tianzhi0549 commented 5 years ago

Yes.

heiyuxiaokai commented 5 years ago

@tianzhi0549 I'm trying fcos in mxnet. There are some questions about details. The reg_pred is (N, 4, hw). The centerness_target is (N, hw) l1 = abs(log1p(reg_target) - log1p(reg_pred)) (N, 4, hw) l1 = sum(l1, 1) (N, hw) l1_scale = l1 centerness_target / sum(centerness_target) (N, hw) (positive points are scaled by centerness_target, others are scale by 0 of centerness) final loss =sum(l1_scale) / where(centerness_target>0).size() (N, ) (where(centerness_target>0).size() is the positive number of each batch, sizeis (N, 1))

Is it right? The reg_loss reaches nan through several batches when it trains

tianzhi0549 commented 5 years ago

@heiyuxiaokai Why do you use log1p instead of log? Moreover, I think l1 = sum(l1, 1) should be l1 = mean(l1, 1).

heiyuxiaokai commented 5 years ago

@tianzhi0549 log(0) = nan, log1p(0) = log(0+1) = 0. I think log1p(x) ≈ log(x)? I will try l1 = mean(l1, 1). Thanks for your quick reply!

tianzhi0549 commented 5 years ago

@heiyuxiaokai reg_target should be always greater than 0.

heiyuxiaokai commented 5 years ago

@tianzhi0549 In reg_targets_flatten, there are always 22300(all points in p3,..,p7) box. Positive points' boxes > 0, and others' boxes = 0. reg_target[pos_inds] are the boxes which are greater than 0. I want caculate these boxes' loss and set other boxes' loss to 0.

tianzhi0549 commented 5 years ago

@heiyuxiaokai I see. But in case you get inferior performance, please try to make the code here the same as ours. Thank you.

heiyuxiaokai commented 5 years ago

@tianzhi0549 Ok, thanks a lot.

YilanWang commented 5 years ago

@heiyuxiaokai No. It means torch.abs(log(reg_target) - log(reg_pred)).mean().

in iou loss the reg_pred is across exp(), but log(exp(reg_pred)) == reg_pred. So should I only use

torch.abs(log(reg_target) - reg_pred).mean()