Skip to content

Commit

Permalink
Update the readme files.
Browse files Browse the repository at this point in the history
  • Loading branch information
lartpang committed Dec 16, 2023
1 parent 3baa40a commit c413a23
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 38 deletions.
24 changes: 4 additions & 20 deletions py_sod_metrics/multiscale_iou.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)

Expand All @@ -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

Expand All @@ -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)
"""
Expand Down
43 changes: 34 additions & 9 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,29 @@ Your improvements and suggestions are welcome.

- A Python-based salient object detection and video object segmentation evaluation toolbox. <https://github.com/lartpang/Py-SOD-VOS-EvalToolkit>

### 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.
Expand All @@ -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/metric_recorder.py>
- [examples/test_metrics.py](./examples/test_metrics.py)
- [examples/metric_recorder.py](./examples/metric_recorder.py)

## Reference

Expand Down Expand Up @@ -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},
}
```
44 changes: 35 additions & 9 deletions readme_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,30 @@

- A Python-based salient object detection and video object segmentation evaluation toolbox. <https://github.com/lartpang/Py-SOD-VOS-EvalToolkit>

### 支持的指标

| 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 的代码一致,如下:
Expand All @@ -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/metric_recorder.py>
- [examples/test_metrics.py](./examples/test_metrics.py)
- [examples/metric_recorder.py](./examples/metric_recorder.py)

## 参考

Expand Down Expand Up @@ -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},
}
```

0 comments on commit c413a23

Please sign in to comment.