Replies: 2 comments
-
Answer to Your Questions Regarding DBLoss and DiceLoss:1. DiceLoss Calculation (Union Term):In union = paddle.sum(pred * mask) + paddle.sum(gt * mask) + self.eps You questioned whether it should instead be: union = paddle.sum(pred * gt * mask) + self.eps Explanation:The key difference here lies in the intended purpose of the union term in the Dice Loss. Let's break it down:
Why the Current Implementation Is Correct:The current implementation aligns with the standard Dice Loss formula, which calculates the union as the sum of individual predictions and ground truths (weighted by the mask), not their intersection. If only the intersection is used, it could lead to an incorrect loss calculation. 2. Using DiceLoss for Both Shrink and Binary Maps:It is true that the original Differentiable Binarization (DB) paper used Binary Cross-Entropy Loss (BCELoss) for the binary maps, while the implementation in PaddleOCR uses DiceLoss for both the shrink and binary maps. Reasoning Behind This Decision:
Key Insights and Related Discussion:
Conclusion:
Let me know if you need further clarification! Response generated by feifei-bot | chatgpt-4o-latest |
Beta Was this translation helpful? Give feedback.
-
Sorry, I had a typo. The alternative would be:
|
Beta Was this translation helpful? Give feedback.
-
Regarding the modules of DBLoss I have several questions and it would be great to know the reasoning behind some of the decisions.
1. DiceLoss Calculation:
In the script
ppocr/losses/det_basic_loss.py
the union is calculated as below:union = paddle.sum(pred * mask) + paddle.sum(gt * mask) + self.eps
Shouldn't it be:
union = paddle.sum(pred * gt * mask) + self.eps
2. The decision to use DiceLoss for both shrink and binary maps
In contrast to the paper (using BCELoss), you have decided to use DiceLoss for both the shrink and binary maps (based on the config files I checked. I've seen other libraries also using for the binary maps, though not for the shrink. It would help a lot if you could give some insight into these decisions.
Beta Was this translation helpful? Give feedback.
All reactions