diff --git a/py_sod_metrics/multiscale_iou.py b/py_sod_metrics/multiscale_iou.py index 374bf4a..614a6a3 100644 --- a/py_sod_metrics/multiscale_iou.py +++ b/py_sod_metrics/multiscale_iou.py @@ -7,16 +7,15 @@ class MSIoU: def __init__(self): """ - Multiscale Intersection over Union (MS-IoU) metric. + Multi-Scale Intersection over Union (MSIoU) metric. :: - @inproceedings{ahmadzadehMultiscaleIOUMetric2021, + @inproceedings{MSIoU, title = {Multiscale IOU: A Metric for Evaluation of Salient Object Detection with Fine Structures}, - booktitle = {2021 IEEE International Conference on Image Processing (ICIP)}, author = {Ahmadzadeh, Azim and Kempton, Dustin J. and Chen, Yang and Angryk, Rafal A.}, + booktitle = ICIP, year = {2021}, - doi = {10.1109/ICIP42928.2021.9506337} } """ # The values of this collection determines the resolutions based on which MIoU is computed. @@ -58,14 +57,6 @@ def shrink_by_grid(self, image: np.ndarray, cell_size: int) -> np.ndarray: return image def cal_msiou(self, pred: np.ndarray, gt: np.ndarray) -> float: - """ - Args: - pred (np.ndarray[bool]): - gt (np.ndarray[bool]): - - Returns: - float: - """ pred = self.get_edge(pred) gt = self.get_edge(gt) @@ -82,13 +73,6 @@ def cal_msiou(self, pred: np.ndarray, gt: np.ndarray) -> float: return msiou def step(self, pred: np.ndarray, gt: np.ndarray): - """ - computes the metric for the two given regions. Use 'miou/utils/mask_loader.py' - to properly load masks as binary arrays for `pred` and `gt`. - - :param pred: mask segmentation of the reference (ground-truth) object. - :param gt: mask segmentation of the target (detected) object. - """ gt = gt > 128 pred = pred > 128 @@ -97,7 +81,7 @@ def step(self, pred: np.ndarray, gt: np.ndarray): return msiou def get_results(self) -> dict: - """Return the results about MS-IoU. + """Return the results about MSIoU. :return: dict(msiou=msiou) """ diff --git a/readme.md b/readme.md index b65a1a7..6eda6f5 100644 --- a/readme.md +++ b/readme.md @@ -25,6 +25,29 @@ Your improvements and suggestions are welcome. - A Python-based salient object detection and video object segmentation evaluation toolbox. +### Supported Metrics + +| Metric | Sample-based | Whole-based | Related Class | +| ----------------------------------------- | --------------- | ----------- | ------------------------------------- | +| MAE | soft | | `MAE` | +| S-measure $S_{m}$ | soft | | `Smeasure` | +| weighted F-measure ($F^{\omega}_{\beta}$) | soft | | `WeightedFmeasure` | +| Multi-Scale IoU | bin | | `MSIoU` | +| E-measure ($E_{m}$) | max,avg,adp | | `Emeasure` | +| F-measure (old) ($F_{beta}$) | max,avg,adp | | `Fmeasure` | +| F-measure (old) ($F_{beta}$, $F_{1}$) | max,avg,adp,bin | bin | `FmeasureV2`+`FmeasureHandler` | +| BER | max,avg,adp,bin | bin | `FmeasureV2`+`BERHandler` | +| Dice | max,avg,adp,bin | bin | `FmeasureV2`+`DICEHandler` | +| FPR | max,avg,adp,bin | bin | `FmeasureV2`+`FPRHandler` | +| IoU | max,avg,adp,bin | bin | `FmeasureV2`+`IOUHandler` | +| Kappa | max,avg,adp,bin | bin | `FmeasureV2`+`KappaHandler` | +| Overall Accuracy | max,avg,adp,bin | bin | `FmeasureV2`+`OverallAccuracyHandler` | +| Precision | max,avg,adp,bin | bin | `FmeasureV2`+`PrecisionHandler` | +| Recall | max,avg,adp,bin | bin | `FmeasureV2`+`RecallHandler` | +| Sensitivity | max,avg,adp,bin | bin | `FmeasureV2`+`SensitivityHandler` | +| Specificity | max,avg,adp,bin | bin | `FmeasureV2`+`SpecificityHandler` | +| TNR | max,avg,adp,bin | bin | `FmeasureV2`+`TNRHandler` | +| TPR | max,avg,adp,bin | bin | `FmeasureV2`+`TPRHandler` | ## TODO List - [x] Speed up the calculation of Emeasure. @@ -46,20 +69,15 @@ matlab: Smeasure:0.903; wFmeasure:0.558; MAE:0.037; adpEm:0.941; meanEm:0.957; m ## Usage -### ~~Download the file as your script~~ (Not Recommended) - The core files are in the folder `py_sod_metrics`. -### Install it as a python package. (Recommended) - -```shell script -pip install pysodmetrics -``` +- **[Latest, but may be unstable]** Install from the source code: `pip install git+https://github.com/lartpang/PySODMetrics.git` +- **[More stable]** Install from PyPI: `pip install pysodmetrics` ### Examples -- -- +- [examples/test_metrics.py](./examples/test_metrics.py) +- [examples/metric_recorder.py](./examples/metric_recorder.py) ## Reference @@ -108,4 +126,11 @@ pip install pysodmetrics pages={248--255}, year={2014} } + +@inproceedings{MSIoU, + title = {Multiscale IOU: A Metric for Evaluation of Salient Object Detection with Fine Structures}, + author = {Ahmadzadeh, Azim and Kempton, Dustin J. and Chen, Yang and Angryk, Rafal A.}, + booktitle = ICIP, + year = {2021}, +} ``` diff --git a/readme_zh.md b/readme_zh.md index 3059899..960b0fd 100644 --- a/readme_zh.md +++ b/readme_zh.md @@ -25,6 +25,30 @@ - A Python-based salient object detection and video object segmentation evaluation toolbox. +### 支持的指标 + +| Metric | Sample-based | Whole-based | Related Class | +| ----------------------------------------- | --------------- | ----------- | ------------------------------------- | +| MAE | soft | | `MAE` | +| S-measure $S_{m}$ | soft | | `Smeasure` | +| weighted F-measure ($F^{\omega}_{\beta}$) | soft | | `WeightedFmeasure` | +| Multi-Scale IoU | bin | | `MSIoU` | +| E-measure ($E_{m}$) | max,avg,adp | | `Emeasure` | +| F-measure (old) ($F_{beta}$) | max,avg,adp | | `Fmeasure` | +| F-measure (old) ($F_{beta}$, $F_{1}$) | max,avg,adp,bin | bin | `FmeasureV2`+`FmeasureHandler` | +| BER | max,avg,adp,bin | bin | `FmeasureV2`+`BERHandler` | +| Dice | max,avg,adp,bin | bin | `FmeasureV2`+`DICEHandler` | +| FPR | max,avg,adp,bin | bin | `FmeasureV2`+`FPRHandler` | +| IoU | max,avg,adp,bin | bin | `FmeasureV2`+`IOUHandler` | +| Kappa | max,avg,adp,bin | bin | `FmeasureV2`+`KappaHandler` | +| Overall Accuracy | max,avg,adp,bin | bin | `FmeasureV2`+`OverallAccuracyHandler` | +| Precision | max,avg,adp,bin | bin | `FmeasureV2`+`PrecisionHandler` | +| Recall | max,avg,adp,bin | bin | `FmeasureV2`+`RecallHandler` | +| Sensitivity | max,avg,adp,bin | bin | `FmeasureV2`+`SensitivityHandler` | +| Specificity | max,avg,adp,bin | bin | `FmeasureV2`+`SpecificityHandler` | +| TNR | max,avg,adp,bin | bin | `FmeasureV2`+`TNRHandler` | +| TPR | max,avg,adp,bin | bin | `FmeasureV2`+`TPRHandler` | + ## 与[范的 Matlab 代码](https://github.com/DengPingFan/CODToolbox)的比较 在我们的测试中 (测试代码可见`test`文件夹下内容),结果与 Fan 的代码一致,如下: @@ -41,20 +65,15 @@ matlab: Smeasure:0.903; wFmeasure:0.558; MAE:0.037; adpEm:0.941; meanEm:0.957; m ## 使用 -### ~~下载文件为自己的脚本~~ - 核心文件在文件夹 `py_sod_metrics` 中。 -### 安装成一个包 - -```shell script -pip install pysodmetrics -``` +- **[新,但可能不稳定]** 从源代码安装:`pip install git+https://github.com/lartpang/PySODMetrics.git` +- **[更稳定一些]** 从 PyPI 安装:`pip install pysodmetrics` ### 示例 -- -- +- [examples/test_metrics.py](./examples/test_metrics.py) +- [examples/metric_recorder.py](./examples/metric_recorder.py) ## 参考 @@ -103,4 +122,11 @@ pip install pysodmetrics pages={248--255}, year={2014} } + +@inproceedings{MSIoU, + title = {Multiscale IOU: A Metric for Evaluation of Salient Object Detection with Fine Structures}, + author = {Ahmadzadeh, Azim and Kempton, Dustin J. and Chen, Yang and Angryk, Rafal A.}, + booktitle = ICIP, + year = {2021}, +} ```