Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

指标计算问题 #10

Open
yzw-xax opened this issue Dec 8, 2024 · 1 comment
Open

指标计算问题 #10

yzw-xax opened this issue Dec 8, 2024 · 1 comment

Comments

@yzw-xax
Copy link

yzw-xax commented Dec 8, 2024

您好,感谢您提供这个很棒的库。
但在使用对指标计算中的一些细节有些疑惑,比如fm这个指标,他有max,avg,adp,bin这几种。其中max,avg是对0-255个阈值计算,adp是采用公式得出阈值,那么这个bin二值图的方式是如何进行计算的呢。
另外一个问题是Sample-based , Whole-based这两个列具体是什么意思。

另外,我在做二分类医学图像分割的相关研究,在将概率图转换为二值图进行对比效果时,应选取什么样的阈值,作者有什么建议吗

@lartpang
Copy link
Owner

lartpang commented Dec 9, 2024

@yzw-xax

指标计算

几种指标的计算综合可以参考这部分代码:

for handler_name, handler in self._metric_handlers.items():
if handler.dynamic_results is not None:
if dynamical_tpfptnfn is None:
dynamical_tpfptnfn = self.dynamically_binarizing(
pred=pred, gt=gt, FG=FG, BG=BG
)
handler.dynamic_results.append(handler(**dynamical_tpfptnfn))
if handler.adaptive_results is not None:
if adaptive_tpfptnfn is None:
adaptive_tpfptnfn = self.adaptively_binarizing(pred=pred, gt=gt, FG=FG, BG=BG)
handler.adaptive_results.append(handler(**adaptive_tpfptnfn))
if handler.binary_results is not None:
if binary_tpfptnfn is None:
# `pred > 0.5`: Simulating the effect of the `argmax` function.
binary_tpfptnfn = self.get_statistics(binary=pred > 0.5, gt=gt, FG=FG, BG=BG)
if handler.sample_based:
handler.binary_results.append(handler(**binary_tpfptnfn))
else:
handler.binary_results["tp"] += binary_tpfptnfn["tp"]
handler.binary_results["fp"] += binary_tpfptnfn["fp"]
handler.binary_results["tn"] += binary_tpfptnfn["tn"]
handler.binary_results["fn"] += binary_tpfptnfn["fn"]

所以对于bin的计算中,需要先对归一化后的样本使用0.5阈值进行二值化,之后再统计tp、fp、tn、fn。

sample_based

sample-based和whole-based从这里的注释中应该可以理解,差异就是先是完整计算每个样本的指标在计算均值,还是整体统计完内部的统计量之后再统一计算指标(只有bin的设定下会存在这种情况)。

sample_based (bool, optional): Whether to average the metric of each sample or calculate
the metric of the dataset. Defaults to True.

阈值的选择

这本身是一个独立的后处理增强的技巧,所以在显著/伪装目标检测这类任务并不预先二值化。这样可以通过基于灰度值的指标来更全面的反映出预测结果。
在一些二值分割的任务中,可能会在验证集通过利用阈值和对应指标的曲线,通过选择平均性能最好的阈值来进行最终的二值化。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants