faster-coco-eval 1.6.3__tar.gz → 1.6.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- faster_coco_eval-1.6.4/MANIFEST.in +1 -0
- {faster_coco_eval-1.6.3/faster_coco_eval.egg-info → faster_coco_eval-1.6.4}/PKG-INFO +13 -9
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.4}/README.md +118 -117
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.4}/csrc/faster_eval_api/coco_eval/cocoeval.cpp +1 -1
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.4}/csrc/faster_eval_api/coco_eval/cocoeval.h +1 -1
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.4}/csrc/faster_eval_api/faster_eval_api.cpp +3 -3
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.4}/csrc/mask_api/mask_api.cpp +4 -4
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.4}/csrc/mask_api/src/mask.cpp +38 -35
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.4}/csrc/mask_api/src/mask.h +2 -1
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.4}/csrc/mask_api/src/rle.cpp +34 -14
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.4}/faster_coco_eval/core/coco.py +23 -76
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.4}/faster_coco_eval/core/cocoeval.py +74 -187
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.4}/faster_coco_eval/core/faster_eval_api.py +15 -34
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.4}/faster_coco_eval/core/mask.py +3 -20
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.4}/faster_coco_eval/extra/curves.py +10 -36
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.4}/faster_coco_eval/extra/display.py +6 -21
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.4}/faster_coco_eval/extra/draw.py +44 -91
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.4}/faster_coco_eval/extra/extra.py +1 -3
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.4}/faster_coco_eval/extra/utils.py +3 -13
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.4}/faster_coco_eval/version.py +1 -1
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.4/faster_coco_eval.egg-info}/PKG-INFO +13 -9
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.4}/faster_coco_eval.egg-info/requires.txt +3 -3
- faster_coco_eval-1.6.4/pyproject.toml +35 -0
- faster_coco_eval-1.6.4/requirements/extra.txt +1 -0
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.4}/requirements/runtime.txt +2 -2
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.4}/requirements/tests.txt +2 -2
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.4}/setup.py +24 -37
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.4}/tests/test_basic.py +16 -26
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.4}/tests/test_boundary.py +12 -26
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.4}/tests/test_coco_metric.py +10 -23
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.4}/tests/test_init_pycocotools.py +2 -6
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.4}/tests/test_keypoints.py +6 -7
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.4}/tests/test_lvis_metric.py +15 -50
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.4}/tests/test_mask_api.py +25 -59
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.4}/tests/test_torchmetrics.py +4 -13
- faster_coco_eval-1.6.3/MANIFEST.in +0 -1
- faster_coco_eval-1.6.3/pyproject.toml +0 -10
- faster_coco_eval-1.6.3/requirements/extra.txt +0 -1
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.4}/LICENSE +0 -0
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.4}/faster_coco_eval/__init__.py +0 -0
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.4}/faster_coco_eval/core/__init__.py +0 -0
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.4}/faster_coco_eval/extra/__init__.py +0 -0
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.4}/faster_coco_eval.egg-info/SOURCES.txt +0 -0
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.4}/faster_coco_eval.egg-info/dependency_links.txt +0 -0
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.4}/faster_coco_eval.egg-info/top_level.txt +0 -0
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.4}/setup.cfg +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
graft csrc
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: faster-coco-eval
|
|
3
|
-
Version: 1.6.
|
|
3
|
+
Version: 1.6.4
|
|
4
4
|
Summary: Faster interpretation of the original COCOEval
|
|
5
5
|
Home-page: https://github.com/MiXaiLL76/faster_coco_eval
|
|
6
6
|
Author: MiXaiLL76
|
|
@@ -13,26 +13,29 @@ Classifier: Programming Language :: Python :: 3.7
|
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.8
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.9
|
|
15
15
|
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
19
|
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
17
20
|
Requires-Python: >=3.7
|
|
18
21
|
Description-Content-Type: text/markdown
|
|
19
22
|
License-File: LICENSE
|
|
20
|
-
Requires-Dist: numpy
|
|
23
|
+
Requires-Dist: numpy
|
|
21
24
|
Requires-Dist: plotly
|
|
22
25
|
Requires-Dist: pandas
|
|
23
26
|
Requires-Dist: Pillow
|
|
24
27
|
Provides-Extra: extra
|
|
25
|
-
Requires-Dist: numpy
|
|
28
|
+
Requires-Dist: numpy; extra == "extra"
|
|
26
29
|
Requires-Dist: plotly; extra == "extra"
|
|
27
30
|
Requires-Dist: pandas; extra == "extra"
|
|
28
31
|
Requires-Dist: Pillow; extra == "extra"
|
|
29
32
|
Requires-Dist: opencv-python-headless; extra == "extra"
|
|
30
33
|
Provides-Extra: tests
|
|
31
|
-
Requires-Dist: numpy
|
|
34
|
+
Requires-Dist: numpy; extra == "tests"
|
|
32
35
|
Requires-Dist: plotly; extra == "tests"
|
|
33
36
|
Requires-Dist: pandas; extra == "tests"
|
|
34
37
|
Requires-Dist: Pillow; extra == "tests"
|
|
35
|
-
Requires-Dist: numpy
|
|
38
|
+
Requires-Dist: numpy; extra == "tests"
|
|
36
39
|
Requires-Dist: pycocotools; extra == "tests"
|
|
37
40
|
Requires-Dist: pytest; extra == "tests"
|
|
38
41
|
Requires-Dist: pytest-cov; extra == "tests"
|
|
@@ -41,13 +44,13 @@ Requires-Dist: parameterized; extra == "tests"
|
|
|
41
44
|
# Faster-COCO-Eval
|
|
42
45
|
|
|
43
46
|
[](https://pypi.org/project/faster-coco-eval)
|
|
44
|
-
[](
|
|
45
|
-
https://pypi.org/project/faster-coco-eval/)
|
|
47
|
+
[](https://pypi.org/project/faster-coco-eval/)
|
|
46
48
|
|
|
47
49
|
[](https://github.com/MiXaiLL76/faster_coco_eval/wiki)
|
|
48
50
|
[](https://github.com/MiXaiLL76/faster_coco_eval/blob/main/LICENSE)
|
|
49
51
|
|
|
50
52
|
[](https://github.com/MiXaiLL76/faster_coco_eval/actions/workflows/unittest.yml)
|
|
53
|
+
|
|
51
54
|
<!-- [](https://codecov.io/gh/MiXaiLL76/faster_coco_eval) -->
|
|
52
55
|
|
|
53
56
|
## Disclaimer
|
|
@@ -65,7 +68,7 @@ pip install faster-coco-eval
|
|
|
65
68
|
|
|
66
69
|
### Additional visualization options
|
|
67
70
|
|
|
68
|
-
> Only 1 additional package needed opencv-python-headless
|
|
71
|
+
> Only 1 additional package needed opencv-python-headless
|
|
69
72
|
|
|
70
73
|
```bash
|
|
71
74
|
pip install faster-coco-eval[extra]
|
|
@@ -105,6 +108,7 @@ For our use case with a test dataset of 5000 images from the coco val dataset.
|
|
|
105
108
|
Testing was carried out using the mmdetection framework and the eval_metric.py script. The indicators are presented below.
|
|
106
109
|
|
|
107
110
|
Visualization of testing **colab_example.ipynb** available in directory [examples/comparison](https://nbviewer.org/github/MiXaiLL76/faster_coco_eval/blob/main/examples/comparison)
|
|
111
|
+
|
|
108
112
|
- [mmdet example](https://nbviewer.org/github/MiXaiLL76/faster_coco_eval/blob/main/examples/comparison/mmdet/colab_example.ipynb)
|
|
109
113
|
- [ultralytics example](https://nbviewer.org/github/MiXaiLL76/faster_coco_eval/blob/main/examples/comparison/ultralytics/colab_example.ipynb)
|
|
110
114
|
|
|
@@ -117,7 +121,7 @@ Visualization of testing **colab_example.ipynb** available in directory [example
|
|
|
117
121
|
|
|
118
122
|
## Feautures
|
|
119
123
|
|
|
120
|
-
This library provides not only validation functions, but also error visualization functions. Including visualization of errors in the image.
|
|
124
|
+
This library provides not only validation functions, but also error visualization functions. Including visualization of errors in the image.
|
|
121
125
|
You can study in more detail in the [examples](https://github.com/MiXaiLL76/faster_coco_eval/blob/main/examples) and [Wiki](https://github.com/MiXaiLL76/faster_coco_eval/wiki).
|
|
122
126
|
|
|
123
127
|
## Usage
|
|
@@ -1,117 +1,118 @@
|
|
|
1
|
-
# Faster-COCO-Eval
|
|
2
|
-
|
|
3
|
-
[](https://pypi.org/project/faster-coco-eval)
|
|
4
|
-
[](
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
[](https://codecov.io/gh/MiXaiLL76/faster_coco_eval) -->
|
|
12
|
-
|
|
13
|
-
## Disclaimer
|
|
14
|
-
|
|
15
|
-
I often use this project, but I saw it abandoned and without a public repository on github.
|
|
16
|
-
Also, part of the project remained unfinished for a long time. I implemented some of the author's ideas and decided to make the results publicly available.
|
|
17
|
-
|
|
18
|
-
## Install
|
|
19
|
-
|
|
20
|
-
### Basic implementation identical to pycocotools
|
|
21
|
-
|
|
22
|
-
```bash
|
|
23
|
-
pip install faster-coco-eval
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
### Additional visualization options
|
|
27
|
-
|
|
28
|
-
> Only 1 additional package needed opencv-python-headless
|
|
29
|
-
|
|
30
|
-
```bash
|
|
31
|
-
pip install faster-coco-eval[extra]
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
### Basic usage
|
|
35
|
-
|
|
36
|
-
```py
|
|
37
|
-
import faster_coco_eval
|
|
38
|
-
|
|
39
|
-
# Replace pycocotools with faster_coco_eval
|
|
40
|
-
faster_coco_eval.init_as_pycocotools()
|
|
41
|
-
|
|
42
|
-
from pycocotools.coco import COCO
|
|
43
|
-
from pycocotools.cocoeval import COCOeval
|
|
44
|
-
|
|
45
|
-
anno = COCO(str(anno_json)) # init annotations api
|
|
46
|
-
pred = anno.loadRes(str(pred_json)) # init predictions api (must pass string, not Path)
|
|
47
|
-
|
|
48
|
-
val = COCOeval(anno, pred, "bbox")
|
|
49
|
-
val.evaluate()
|
|
50
|
-
val.accumulate()
|
|
51
|
-
val.summarize()
|
|
52
|
-
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
## Faster-COCO-Eval base
|
|
56
|
-
|
|
57
|
-
This package wraps a facebook C++ implementation of COCO-eval operations found in the
|
|
58
|
-
[pycocotools](https://github.com/cocodataset/cocoapi/tree/master/PythonAPI/pycocotools) package.
|
|
59
|
-
This implementation greatly speeds up the evaluation time
|
|
60
|
-
for coco's AP metrics, especially when dealing with a high number of instances in an image.
|
|
61
|
-
|
|
62
|
-
## Comparison
|
|
63
|
-
|
|
64
|
-
For our use case with a test dataset of 5000 images from the coco val dataset.
|
|
65
|
-
Testing was carried out using the mmdetection framework and the eval_metric.py script. The indicators are presented below.
|
|
66
|
-
|
|
67
|
-
Visualization of testing **colab_example.ipynb** available in directory [examples/comparison](https://nbviewer.org/github/MiXaiLL76/faster_coco_eval/blob/main/examples/comparison)
|
|
68
|
-
|
|
69
|
-
- [
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
|
75
|
-
|
|
|
76
|
-
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
- [
|
|
91
|
-
- [
|
|
92
|
-
- [
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
|
|
1
|
+
# Faster-COCO-Eval
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/faster-coco-eval)
|
|
4
|
+
[](https://pypi.org/project/faster-coco-eval/)
|
|
5
|
+
|
|
6
|
+
[](https://github.com/MiXaiLL76/faster_coco_eval/wiki)
|
|
7
|
+
[](https://github.com/MiXaiLL76/faster_coco_eval/blob/main/LICENSE)
|
|
8
|
+
|
|
9
|
+
[](https://github.com/MiXaiLL76/faster_coco_eval/actions/workflows/unittest.yml)
|
|
10
|
+
|
|
11
|
+
<!-- [](https://codecov.io/gh/MiXaiLL76/faster_coco_eval) -->
|
|
12
|
+
|
|
13
|
+
## Disclaimer
|
|
14
|
+
|
|
15
|
+
I often use this project, but I saw it abandoned and without a public repository on github.
|
|
16
|
+
Also, part of the project remained unfinished for a long time. I implemented some of the author's ideas and decided to make the results publicly available.
|
|
17
|
+
|
|
18
|
+
## Install
|
|
19
|
+
|
|
20
|
+
### Basic implementation identical to pycocotools
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pip install faster-coco-eval
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Additional visualization options
|
|
27
|
+
|
|
28
|
+
> Only 1 additional package needed opencv-python-headless
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pip install faster-coco-eval[extra]
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Basic usage
|
|
35
|
+
|
|
36
|
+
```py
|
|
37
|
+
import faster_coco_eval
|
|
38
|
+
|
|
39
|
+
# Replace pycocotools with faster_coco_eval
|
|
40
|
+
faster_coco_eval.init_as_pycocotools()
|
|
41
|
+
|
|
42
|
+
from pycocotools.coco import COCO
|
|
43
|
+
from pycocotools.cocoeval import COCOeval
|
|
44
|
+
|
|
45
|
+
anno = COCO(str(anno_json)) # init annotations api
|
|
46
|
+
pred = anno.loadRes(str(pred_json)) # init predictions api (must pass string, not Path)
|
|
47
|
+
|
|
48
|
+
val = COCOeval(anno, pred, "bbox")
|
|
49
|
+
val.evaluate()
|
|
50
|
+
val.accumulate()
|
|
51
|
+
val.summarize()
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Faster-COCO-Eval base
|
|
56
|
+
|
|
57
|
+
This package wraps a facebook C++ implementation of COCO-eval operations found in the
|
|
58
|
+
[pycocotools](https://github.com/cocodataset/cocoapi/tree/master/PythonAPI/pycocotools) package.
|
|
59
|
+
This implementation greatly speeds up the evaluation time
|
|
60
|
+
for coco's AP metrics, especially when dealing with a high number of instances in an image.
|
|
61
|
+
|
|
62
|
+
## Comparison
|
|
63
|
+
|
|
64
|
+
For our use case with a test dataset of 5000 images from the coco val dataset.
|
|
65
|
+
Testing was carried out using the mmdetection framework and the eval_metric.py script. The indicators are presented below.
|
|
66
|
+
|
|
67
|
+
Visualization of testing **colab_example.ipynb** available in directory [examples/comparison](https://nbviewer.org/github/MiXaiLL76/faster_coco_eval/blob/main/examples/comparison)
|
|
68
|
+
|
|
69
|
+
- [mmdet example](https://nbviewer.org/github/MiXaiLL76/faster_coco_eval/blob/main/examples/comparison/mmdet/colab_example.ipynb)
|
|
70
|
+
- [ultralytics example](https://nbviewer.org/github/MiXaiLL76/faster_coco_eval/blob/main/examples/comparison/ultralytics/colab_example.ipynb)
|
|
71
|
+
|
|
72
|
+
### Summary for 5000 imgs
|
|
73
|
+
|
|
74
|
+
| Type | faster-coco-eval | pycocotools | Profit |
|
|
75
|
+
| :--- | ---------------: | ----------: | -----: |
|
|
76
|
+
| bbox | 5.812 | 22.72 | 3.909 |
|
|
77
|
+
| segm | 7.413 | 24.434 | 3.296 |
|
|
78
|
+
|
|
79
|
+
## Feautures
|
|
80
|
+
|
|
81
|
+
This library provides not only validation functions, but also error visualization functions. Including visualization of errors in the image.
|
|
82
|
+
You can study in more detail in the [examples](https://github.com/MiXaiLL76/faster_coco_eval/blob/main/examples) and [Wiki](https://github.com/MiXaiLL76/faster_coco_eval/wiki).
|
|
83
|
+
|
|
84
|
+
## Usage
|
|
85
|
+
|
|
86
|
+
Code examples for using the library are available on the [Wiki](https://github.com/MiXaiLL76/faster_coco_eval/wiki)
|
|
87
|
+
|
|
88
|
+
### Examples
|
|
89
|
+
|
|
90
|
+
- [Eval example](https://nbviewer.org/github/MiXaiLL76/faster_coco_eval/blob/main/examples/eval_example.ipynb)
|
|
91
|
+
- [Curve example](https://nbviewer.org/github/MiXaiLL76/faster_coco_eval/blob/main/examples/curve_example.ipynb)
|
|
92
|
+
- [CED Keypoint example](https://nbviewer.org/github/MiXaiLL76/faster_coco_eval/blob/main/examples/ced_example.ipynb)
|
|
93
|
+
- [LVIS example](https://nbviewer.org/github/MiXaiLL76/faster_coco_eval/blob/main/examples/lvis_example.ipynb)
|
|
94
|
+
|
|
95
|
+
## Update history
|
|
96
|
+
|
|
97
|
+
Available via link [history.md](https://github.com/MiXaiLL76/faster_coco_eval/blob/main/history.md)
|
|
98
|
+
|
|
99
|
+
## Star History
|
|
100
|
+
|
|
101
|
+
[](https://star-history.com/#MiXaiLL76/faster_coco_eval&Date)
|
|
102
|
+
|
|
103
|
+
## License
|
|
104
|
+
|
|
105
|
+
The original module was licensed with apache 2, I will continue with the same license.
|
|
106
|
+
Distributed under the apache version 2.0 license, see [license](LICENSE) for more information.
|
|
107
|
+
|
|
108
|
+
## Citation
|
|
109
|
+
|
|
110
|
+
If you use this benchmark in your research, please cite this project.
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
@article{faster-coco-eval,
|
|
114
|
+
title = {{Faster-COCO-Eval}: Faster interpretation of the original COCOEval},
|
|
115
|
+
author = {MiXaiLL76},
|
|
116
|
+
year = {2024}
|
|
117
|
+
}
|
|
118
|
+
```
|
|
@@ -157,4 +157,4 @@ namespace coco_eval
|
|
|
157
157
|
long double calc_auc(const std::vector<long double> &recall_list, const std::vector<long double> &precision_list);
|
|
158
158
|
long double _summarize(const int &ap, const double &iouThr, const std::string &areaRng, const int &maxDet, const std::vector<int> &catIds, const py::object ¶ms, const std::vector<size_t> &counts, const py::object &nums_array);
|
|
159
159
|
} // namespace COCOeval
|
|
160
|
-
} // namespace coco_eval
|
|
160
|
+
} // namespace coco_eval
|
|
@@ -49,7 +49,7 @@ namespace coco_eval
|
|
|
49
49
|
m.def("COCOevalAccumulate", &COCOeval::Accumulate, "COCOeval::Accumulate");
|
|
50
50
|
m.def("COCOevalEvaluateImages", &COCOeval::EvaluateImages, "COCOeval::EvaluateImages");
|
|
51
51
|
m.def("COCOevalEvaluateAccumulate", &COCOeval::EvaluateAccumulate, "COCOeval::EvaluateAccumulate");
|
|
52
|
-
|
|
52
|
+
|
|
53
53
|
// slow!
|
|
54
54
|
m.def("_summarize", &COCOeval::_summarize, "COCOeval::_summarize");
|
|
55
55
|
m.def("calc_auc", &COCOeval::calc_auc, "COCOeval::calc_auc");
|
|
@@ -58,7 +58,7 @@ namespace coco_eval
|
|
|
58
58
|
.def(pybind11::init<uint64_t, double, double, bool, bool, bool>());
|
|
59
59
|
|
|
60
60
|
pybind11::class_<COCOeval::ImageEvaluation>(m, "ImageEvaluation").def(pybind11::init<>());
|
|
61
|
-
|
|
61
|
+
|
|
62
62
|
pybind11::class_<COCOeval::Dataset>(m, "Dataset").def(pybind11::init<>())
|
|
63
63
|
.def("append", &COCOeval::Dataset::append)
|
|
64
64
|
.def("get", &COCOeval::Dataset::get)
|
|
@@ -73,4 +73,4 @@ namespace coco_eval
|
|
|
73
73
|
#endif
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
} // namespace coco_eval
|
|
76
|
+
} // namespace coco_eval
|
|
@@ -71,9 +71,9 @@ namespace mask_api
|
|
|
71
71
|
|
|
72
72
|
/* Create a new C++ instance */
|
|
73
73
|
Mask::RLE p = Mask::RLE(
|
|
74
|
-
t[0].cast<std::uint64_t>(),
|
|
75
|
-
t[1].cast<std::uint64_t>(),
|
|
76
|
-
t[2].cast<std::uint64_t>(),
|
|
74
|
+
t[0].cast<std::uint64_t>(),
|
|
75
|
+
t[1].cast<std::uint64_t>(),
|
|
76
|
+
t[2].cast<std::uint64_t>(),
|
|
77
77
|
t[3].cast<std::vector<uint>>()
|
|
78
78
|
);
|
|
79
79
|
|
|
@@ -129,4 +129,4 @@ namespace mask_api
|
|
|
129
129
|
#endif
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
} // namespace coco_eval
|
|
132
|
+
} // namespace coco_eval
|
|
@@ -142,7 +142,7 @@ namespace mask_api
|
|
|
142
142
|
if (n > 0)
|
|
143
143
|
{
|
|
144
144
|
uint64_t h = (R[0].h), w = (R[0].w);
|
|
145
|
-
|
|
145
|
+
|
|
146
146
|
py::array_t<uint8_t, py::array::f_style> M({(size_t)h, (size_t)w, (size_t)n});
|
|
147
147
|
auto mask = M.mutable_unchecked();
|
|
148
148
|
uint64_t s = h * w * n;
|
|
@@ -155,14 +155,17 @@ namespace mask_api
|
|
|
155
155
|
{
|
|
156
156
|
for (uint64_t k = 0; k < R[i].cnts[j]; k++)
|
|
157
157
|
{
|
|
158
|
-
mask(y, x, i) = v;
|
|
159
158
|
c += 1;
|
|
160
159
|
if (c > s)
|
|
161
160
|
{
|
|
162
|
-
|
|
161
|
+
std::stringstream ss;
|
|
162
|
+
ss << "Invalid RLE mask representation; out of range HxW=[0;0]->[" << h - 1 << ";" << w - 1 << "] x=" << x << "; y=" << y;
|
|
163
|
+
throw std::range_error(ss.str());
|
|
163
164
|
}
|
|
164
|
-
y += 1;
|
|
165
165
|
|
|
166
|
+
mask(y, x, i) = v;
|
|
167
|
+
|
|
168
|
+
y += 1;
|
|
166
169
|
if (y >= h)
|
|
167
170
|
{
|
|
168
171
|
y = 0;
|
|
@@ -597,17 +600,17 @@ namespace mask_api
|
|
|
597
600
|
py::gil_scoped_release release;
|
|
598
601
|
std::vector<std::tuple<uint64_t, uint64_t, std::string>> result(rles.size());
|
|
599
602
|
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
+
// Windows not support async
|
|
604
|
+
#ifndef _WIN32
|
|
605
|
+
auto process = [&rles, &result](size_t s, size_t e, double d) mutable
|
|
606
|
+
{
|
|
607
|
+
for (size_t i = s; i < e; ++i)
|
|
603
608
|
{
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
};
|
|
610
|
-
#endif
|
|
609
|
+
result[i] = rles[i].toBoundary(d).toTuple();
|
|
610
|
+
}
|
|
611
|
+
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
|
612
|
+
};
|
|
613
|
+
#endif
|
|
611
614
|
|
|
612
615
|
size_t start = 0;
|
|
613
616
|
size_t step = 1000;
|
|
@@ -620,21 +623,21 @@ namespace mask_api
|
|
|
620
623
|
|
|
621
624
|
while (start < rles.size())
|
|
622
625
|
{
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
+
#ifndef _WIN32
|
|
627
|
+
std::vector<std::future<void>> rle_futures(cpu_count);
|
|
628
|
+
#endif
|
|
626
629
|
|
|
627
630
|
size_t thread = 0;
|
|
628
631
|
for (thread = 0; thread < cpu_count; thread++)
|
|
629
632
|
{
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
633
|
+
#ifdef _WIN32
|
|
634
|
+
for (size_t i = start; i < end; ++i)
|
|
635
|
+
{
|
|
636
|
+
result[i] = rles[i].toBoundary(dilation_ratio).toTuple();
|
|
637
|
+
}
|
|
638
|
+
#else
|
|
639
|
+
rle_futures[thread] = std::async(std::launch::async, process, start, end, dilation_ratio);
|
|
640
|
+
#endif
|
|
638
641
|
|
|
639
642
|
start += step;
|
|
640
643
|
end += step;
|
|
@@ -649,15 +652,15 @@ namespace mask_api
|
|
|
649
652
|
break;
|
|
650
653
|
}
|
|
651
654
|
}
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
655
|
+
|
|
656
|
+
#ifndef _WIN32
|
|
657
|
+
for (size_t i = 0; i < thread; i++)
|
|
658
|
+
{
|
|
659
|
+
rle_futures[i].wait();
|
|
660
|
+
}
|
|
661
|
+
rle_futures.clear();
|
|
662
|
+
rle_futures.shrink_to_fit();
|
|
663
|
+
#endif
|
|
661
664
|
}
|
|
662
665
|
|
|
663
666
|
py::gil_scoped_acquire acquire;
|
|
@@ -715,4 +718,4 @@ namespace mask_api
|
|
|
715
718
|
|
|
716
719
|
} // namespace Mask
|
|
717
720
|
|
|
718
|
-
}
|
|
721
|
+
}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
#include <pybind11/stl_bind.h>
|
|
8
8
|
#include <pybind11/embed.h>
|
|
9
9
|
#include <vector>
|
|
10
|
+
#include <cmath>
|
|
10
11
|
|
|
11
12
|
namespace py = pybind11;
|
|
12
13
|
|
|
@@ -104,4 +105,4 @@ namespace mask_api
|
|
|
104
105
|
const double &dilation_ratio,
|
|
105
106
|
const size_t &cpu_count);
|
|
106
107
|
} // namespace Mask
|
|
107
|
-
} // namespace mask_api
|
|
108
|
+
} // namespace mask_api
|
|
@@ -9,6 +9,24 @@
|
|
|
9
9
|
|
|
10
10
|
using namespace pybind11::literals;
|
|
11
11
|
|
|
12
|
+
template <typename T>
|
|
13
|
+
static bool AreEqual(T f1, T f2)
|
|
14
|
+
{
|
|
15
|
+
return (std::fabs(f1 - f2) <= std::numeric_limits<T>::epsilon() * std::fmax(std::fabs(f1), std::fabs(f2)));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
template <typename T>
|
|
19
|
+
void prinf_vector(const std::vector<T> vec, const std::string s)
|
|
20
|
+
{
|
|
21
|
+
std::cout << "name: " << s << std::endl;
|
|
22
|
+
std::cout << "size: " << vec.size() << std::endl;
|
|
23
|
+
|
|
24
|
+
for (const auto &v : vec)
|
|
25
|
+
std::cout << "\t" << v << std::endl;
|
|
26
|
+
|
|
27
|
+
std::cout << std::endl;
|
|
28
|
+
}
|
|
29
|
+
|
|
12
30
|
namespace mask_api
|
|
13
31
|
{
|
|
14
32
|
namespace Mask
|
|
@@ -66,7 +84,7 @@ namespace mask_api
|
|
|
66
84
|
c = s[i] - 48;
|
|
67
85
|
x |= (c & 0x1f) << 5 * k;
|
|
68
86
|
more = c & 0x20;
|
|
69
|
-
|
|
87
|
+
|
|
70
88
|
i += 1;
|
|
71
89
|
k += 1;
|
|
72
90
|
|
|
@@ -201,8 +219,10 @@ namespace mask_api
|
|
|
201
219
|
{
|
|
202
220
|
xd = (double)(u[j] < u[j - 1] ? u[j] : u[j] - 1);
|
|
203
221
|
xd = (xd + .5) / scale - .5;
|
|
204
|
-
if (floor(xd)
|
|
222
|
+
if ((!AreEqual(std::floor(xd), xd)) || xd < 0 || xd > w - 1)
|
|
223
|
+
{
|
|
205
224
|
continue;
|
|
225
|
+
}
|
|
206
226
|
yd = (double)(v[j] < v[j - 1] ? v[j] : v[j - 1]);
|
|
207
227
|
yd = (yd + .5) / scale - .5;
|
|
208
228
|
if (yd < 0)
|
|
@@ -210,7 +230,7 @@ namespace mask_api
|
|
|
210
230
|
else if (yd > h)
|
|
211
231
|
yd = (double)h;
|
|
212
232
|
|
|
213
|
-
yd = ceil(yd);
|
|
233
|
+
yd = std::ceil(yd);
|
|
214
234
|
x.emplace_back((int)xd);
|
|
215
235
|
y.emplace_back((int)yd);
|
|
216
236
|
}
|
|
@@ -251,8 +271,8 @@ namespace mask_api
|
|
|
251
271
|
|
|
252
272
|
RLE RLE::frBbox(const std::vector<double> &bb, const uint64_t &h, const uint64_t &w)
|
|
253
273
|
{
|
|
254
|
-
double xs = bb[0], xe =
|
|
255
|
-
double ys = bb[1], ye =
|
|
274
|
+
double xs = bb[0], xe = bb[0] + bb[2];
|
|
275
|
+
double ys = bb[1], ye = bb[1] + bb[3];
|
|
256
276
|
return RLE::frPoly({xs, ys, xs, ye, xe, ye, xe, ys}, h, w);
|
|
257
277
|
}
|
|
258
278
|
|
|
@@ -264,11 +284,11 @@ namespace mask_api
|
|
|
264
284
|
std::vector<bool>::iterator ptr = _counts.begin();
|
|
265
285
|
std::for_each(this->cnts.begin(), this->cnts.end(), [&v, &ptr](uint count)
|
|
266
286
|
{
|
|
267
|
-
|
|
287
|
+
|
|
268
288
|
if(v){
|
|
269
289
|
std::fill_n(ptr, count, v);
|
|
270
290
|
}
|
|
271
|
-
|
|
291
|
+
|
|
272
292
|
v = !v;
|
|
273
293
|
ptr += count; });
|
|
274
294
|
|
|
@@ -326,8 +346,8 @@ namespace mask_api
|
|
|
326
346
|
{
|
|
327
347
|
long test_ptr = c + o;
|
|
328
348
|
return (
|
|
329
|
-
(test_ptr >= 0) &&
|
|
330
|
-
(test_ptr < max_len) && _counts[test_ptr] &&
|
|
349
|
+
(test_ptr >= 0) &&
|
|
350
|
+
(test_ptr < max_len) && _counts[test_ptr] &&
|
|
331
351
|
(std::abs((test_ptr % rle_h) - x) <= dilation )
|
|
332
352
|
); });
|
|
333
353
|
}
|
|
@@ -337,10 +357,10 @@ namespace mask_api
|
|
|
337
357
|
{
|
|
338
358
|
long test_ptr = c + o;
|
|
339
359
|
long _test_ptr = c - o;
|
|
340
|
-
|
|
360
|
+
|
|
341
361
|
return (
|
|
342
|
-
(_test_ptr >= 0) && _counts[_test_ptr] &&
|
|
343
|
-
(test_ptr < max_len) && _counts[test_ptr] &&
|
|
362
|
+
(_test_ptr >= 0) && _counts[_test_ptr] &&
|
|
363
|
+
(test_ptr < max_len) && _counts[test_ptr] &&
|
|
344
364
|
(std::abs((test_ptr % rle_h) - x) <= dilation )
|
|
345
365
|
); });
|
|
346
366
|
}
|
|
@@ -431,7 +451,7 @@ namespace mask_api
|
|
|
431
451
|
if(v){
|
|
432
452
|
std::fill_n(ptr, count, 1);
|
|
433
453
|
}
|
|
434
|
-
|
|
454
|
+
|
|
435
455
|
v = !v;
|
|
436
456
|
ptr += count; });
|
|
437
457
|
|
|
@@ -556,4 +576,4 @@ namespace mask_api
|
|
|
556
576
|
}
|
|
557
577
|
} // namespace Mask
|
|
558
578
|
|
|
559
|
-
}
|
|
579
|
+
}
|