YOLOv3_TensorFlow
YOLOv3_TensorFlow copied to clipboard
focal loss 和论文不同??
您好:
focal_mask = alpha * tf.pow(tf.abs(object_mask - tf.sigmoid(pred_conf_logits)), gamma)
1*(label - logits)^2
是不是少计算了一个取对数log?
On the original paper, it was mentioned it did not help, it seems Yolo is not sensible to unbalanced classes.
@nobody-cheng No, it's consistent with the original paper. Note that the formula you cited is a mask array. The log part is in the conf_loss part and conf_loss *= focal_mask. I didn't include the alpha in my implementation. To be exactly the same with the paper, the codes need to be:
alpha_weight = tf.where(tf.equal(object_mask, 1), alpha, 1 - alpha)
focal_weight = tf.pow(object_mask - tf.nn.sigmoid(pred_conf_logits), gamma)
focal_mask = alpha_weight * focal_weight
conf_loss = conf_loss * focal_mask
@fariquelme I don't think YOLO is not sensible to unbalanced classes. Otherwise the author would not design the ignore_mask in the loss function. I've said that in readme file "These are all good strategies but it does not mean they will definitely improve the performance". To make focal loss really work, alpha_weight and gamma needs to be tuned(see my comments above). In my own experiments (on my private dataset), focal loss is useful.
Nice, maybe they implemented it wrong ? they explicitly say it dropped their mAP by 2 points. Btw, thanks for your implementation, it helped me a lot!
@fariquelme Yes, I guess the author implemented it wrong or did not tune to a better parameter. In my experiments, alpha is more important than gamma and alpha needs to be carefully tuned. (The current version does not include the alpha parameter and I will update my repo tomorrow). Actually many people found that focal loss did help in their experiments. Check https://www.zhihu.com/question/293369755/answer/488355189 (In Chinese. You can google translate it)
Are you going to implement the focal loss in this repository?? It would help me a lot 😅
Focal loss is already in the code. Specifically, the log part has been implemented beforehand in line 282 and 283 of model.py.
I want to use yolov3 to predict the number of real-time person from the rtsp stream with suited interval,anyone has the right python file?