cqylunlun / GLASS

[ECCV 2024] Official Implementation and Dataset Release for <A Unified Anomaly Synthesis Strategy with Gradient Ascent for Industrial Anomaly Detection and Localization>
MIT License
130 stars 17 forks source link

About Loss Function #12

Closed XRONHH closed 1 month ago

XRONHH commented 1 month ago

Thanks for your work, it inspires me a lot. But I have one question about the loss function in Section3.4, in order to filter crucial samples, you applied Online Hard Example Mining to L_las, I wonder how this is implemented in this project?

cqylunlun commented 1 month ago

Thank you for your recognition. In this project, the OHEM code is located in glass.py from L408 to L418. The argument --p is a parameter that controls the selection of hard samples. In our method, the default value is p=0.5, which means only those samples with an error degree (fake_dist) greater than or equal to d_hard are considered hard samples. In this case, d_hard is the median of fake_dist. Subsequently, these hard samples are used for the calculation of focal loss.