faster-coco-eval 1.6.3__tar.gz → 1.6.5__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.5/MANIFEST.in +1 -0
- {faster_coco_eval-1.6.3/faster_coco_eval.egg-info → faster_coco_eval-1.6.5}/PKG-INFO +13 -9
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.5}/README.md +118 -117
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.5}/csrc/faster_eval_api/coco_eval/cocoeval.cpp +29 -1
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.5}/csrc/faster_eval_api/coco_eval/cocoeval.h +7 -1
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.5}/csrc/faster_eval_api/faster_eval_api.cpp +43 -5
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.5}/csrc/mask_api/mask_api.cpp +4 -4
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.5}/csrc/mask_api/src/mask.cpp +38 -35
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.5}/csrc/mask_api/src/mask.h +2 -1
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.5}/csrc/mask_api/src/rle.cpp +34 -14
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.5}/faster_coco_eval/core/coco.py +48 -100
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.5}/faster_coco_eval/core/cocoeval.py +157 -216
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.5}/faster_coco_eval/core/faster_eval_api.py +59 -62
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.5}/faster_coco_eval/core/mask.py +3 -20
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.5}/faster_coco_eval/extra/curves.py +10 -36
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.5}/faster_coco_eval/extra/display.py +6 -21
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.5}/faster_coco_eval/extra/draw.py +44 -91
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.5}/faster_coco_eval/extra/extra.py +1 -3
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.5}/faster_coco_eval/extra/utils.py +3 -13
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.5}/faster_coco_eval/version.py +1 -1
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.5/faster_coco_eval.egg-info}/PKG-INFO +13 -9
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.5}/faster_coco_eval.egg-info/SOURCES.txt +3 -1
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.5}/faster_coco_eval.egg-info/requires.txt +3 -3
- faster_coco_eval-1.6.5/pyproject.toml +36 -0
- faster_coco_eval-1.6.5/requirements/extra.txt +1 -0
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.5}/requirements/runtime.txt +2 -2
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.5}/requirements/tests.txt +2 -2
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.5}/setup.py +24 -37
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.5}/tests/test_basic.py +23 -33
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.5}/tests/test_boundary.py +15 -29
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.5}/tests/test_coco_metric.py +10 -23
- faster_coco_eval-1.6.5/tests/test_crowdpose.py +53 -0
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.5}/tests/test_init_pycocotools.py +2 -6
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.5}/tests/test_keypoints.py +6 -7
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.5}/tests/test_lvis_metric.py +15 -50
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.5}/tests/test_mask_api.py +25 -59
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.5}/tests/test_torchmetrics.py +4 -13
- faster_coco_eval-1.6.5/tests/test_world_evalutor.py +139 -0
- 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.5}/LICENSE +0 -0
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.5}/faster_coco_eval/__init__.py +0 -0
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.5}/faster_coco_eval/core/__init__.py +0 -0
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.5}/faster_coco_eval/extra/__init__.py +0 -0
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.5}/faster_coco_eval.egg-info/dependency_links.txt +0 -0
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.5}/faster_coco_eval.egg-info/top_level.txt +0 -0
- {faster_coco_eval-1.6.3 → faster_coco_eval-1.6.5}/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.5
|
|
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
|
+
```
|
{faster_coco_eval-1.6.3 → faster_coco_eval-1.6.5}/csrc/faster_eval_api/coco_eval/cocoeval.cpp
RENAMED
|
@@ -629,6 +629,34 @@ namespace coco_eval
|
|
|
629
629
|
{
|
|
630
630
|
this->data[{img_id, cat_id}].emplace_back(ann);
|
|
631
631
|
}
|
|
632
|
+
|
|
633
|
+
void Dataset::clean(){
|
|
634
|
+
this->data.clear();
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
py::tuple Dataset::make_tuple() const {
|
|
638
|
+
std::vector<std::pair<int64_t, int64_t>> keys;
|
|
639
|
+
std::vector<std::vector<py::dict>> values;
|
|
640
|
+
|
|
641
|
+
for (const auto& [key, value] : this->data) {
|
|
642
|
+
keys.push_back(key);
|
|
643
|
+
values.push_back(value);
|
|
644
|
+
}
|
|
645
|
+
return py::make_tuple(keys, values);
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
void Dataset::load_tuple(py::tuple data){
|
|
649
|
+
if (data.size() != 2)
|
|
650
|
+
throw std::runtime_error("Invalid state!");
|
|
651
|
+
|
|
652
|
+
std::vector<std::pair<int64_t, int64_t>> keys = data[0].cast<std::vector<std::pair<int64_t, int64_t>>>();
|
|
653
|
+
std::vector<std::vector<py::dict>> values = data[1].cast<std::vector<std::vector<py::dict>>>();
|
|
654
|
+
|
|
655
|
+
for (size_t i = 0; i < keys.size(); i++) {
|
|
656
|
+
this->data[keys[i]] = values[i];
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
|
|
632
660
|
std::vector<py::dict> Dataset::get(const int64_t &img_id, const int64_t &cat_id)
|
|
633
661
|
{
|
|
634
662
|
std::pair<int64_t, int64_t> key(img_id, cat_id);
|
|
@@ -864,4 +892,4 @@ namespace coco_eval
|
|
|
864
892
|
|
|
865
893
|
} // namespace COCOeval
|
|
866
894
|
|
|
867
|
-
} // namespace coco_eval
|
|
895
|
+
} // namespace coco_eval
|
|
@@ -97,6 +97,12 @@ namespace coco_eval
|
|
|
97
97
|
// this->data.max_load_factor(0.25); // DECREASING MAX_LOAD_FACTOR
|
|
98
98
|
}
|
|
99
99
|
void append(int64_t img_id, int64_t cat_id, py::dict ann);
|
|
100
|
+
void clean();
|
|
101
|
+
|
|
102
|
+
// pickle
|
|
103
|
+
py::tuple make_tuple() const ;
|
|
104
|
+
void load_tuple(py::tuple data);
|
|
105
|
+
|
|
100
106
|
std::vector<py::dict> get(const int64_t &img_id, const int64_t &cat_id);
|
|
101
107
|
std::vector<InstanceAnnotation> get_cpp_annotations(
|
|
102
108
|
const int64_t &img_id, const int64_t &cat_id);
|
|
@@ -157,4 +163,4 @@ namespace coco_eval
|
|
|
157
163
|
long double calc_auc(const std::vector<long double> &recall_list, const std::vector<long double> &precision_list);
|
|
158
164
|
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
165
|
} // namespace COCOeval
|
|
160
|
-
} // namespace coco_eval
|
|
166
|
+
} // 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");
|
|
@@ -57,14 +57,52 @@ namespace coco_eval
|
|
|
57
57
|
pybind11::class_<COCOeval::InstanceAnnotation>(m, "InstanceAnnotation")
|
|
58
58
|
.def(pybind11::init<uint64_t, double, double, bool, bool, bool>());
|
|
59
59
|
|
|
60
|
-
pybind11::class_<COCOeval::ImageEvaluation>(m, "ImageEvaluation").def(pybind11::init<>())
|
|
61
|
-
|
|
60
|
+
pybind11::class_<COCOeval::ImageEvaluation>(m, "ImageEvaluation").def(pybind11::init<>())
|
|
61
|
+
.def(py::pickle(
|
|
62
|
+
[](const COCOeval::ImageEvaluation &p) {
|
|
63
|
+
|
|
64
|
+
std::vector<std::tuple<uint64_t, uint64_t, double>> matched_annotations;
|
|
65
|
+
for (size_t i = 0; i < p.matched_annotations.size(); i++) {
|
|
66
|
+
matched_annotations.push_back(std::make_tuple(p.matched_annotations[i].dt_id, p.matched_annotations[i].gt_id, p.matched_annotations[i].iou));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return py::make_tuple(p.detection_matches, p.ground_truth_matches, p.detection_scores, p.ground_truth_ignores, p.detection_ignores, matched_annotations);
|
|
70
|
+
},
|
|
71
|
+
[](py::tuple t) { // __setstate__
|
|
72
|
+
if (t.size() != 6)
|
|
73
|
+
throw std::runtime_error("Invalid state!");
|
|
74
|
+
|
|
75
|
+
COCOeval::ImageEvaluation p;
|
|
76
|
+
p.detection_matches = t[0].cast<std::vector<int64_t>>();
|
|
77
|
+
p.ground_truth_matches = t[1].cast<std::vector<int64_t>>();
|
|
78
|
+
p.detection_scores = t[2].cast<std::vector<double>>();
|
|
79
|
+
p.ground_truth_ignores = t[3].cast<std::vector<bool>>();
|
|
80
|
+
p.detection_ignores = t[4].cast<std::vector<bool>>();
|
|
81
|
+
std::vector<std::tuple<uint64_t, uint64_t, double>> matched_annotations = t[5].cast<std::vector<std::tuple<uint64_t, uint64_t, double>>>();
|
|
82
|
+
for (size_t i = 0; i < matched_annotations.size(); i++) {
|
|
83
|
+
p.matched_annotations.emplace_back(std::get<0>(matched_annotations[i]), std::get<1>(matched_annotations[i]), std::get<2>(matched_annotations[i]));
|
|
84
|
+
}
|
|
85
|
+
return p;
|
|
86
|
+
}
|
|
87
|
+
));
|
|
88
|
+
|
|
62
89
|
pybind11::class_<COCOeval::Dataset>(m, "Dataset").def(pybind11::init<>())
|
|
63
90
|
.def("append", &COCOeval::Dataset::append)
|
|
91
|
+
.def("clean", &COCOeval::Dataset::clean)
|
|
64
92
|
.def("get", &COCOeval::Dataset::get)
|
|
65
93
|
.def("get_instances", &COCOeval::Dataset::get_instances)
|
|
66
94
|
.def("get_cpp_annotations", &COCOeval::Dataset::get_cpp_annotations)
|
|
67
|
-
.def("get_cpp_instances", &COCOeval::Dataset::get_cpp_instances)
|
|
95
|
+
.def("get_cpp_instances", &COCOeval::Dataset::get_cpp_instances)
|
|
96
|
+
.def(py::pickle(
|
|
97
|
+
[](const COCOeval::Dataset &p) {
|
|
98
|
+
return p.make_tuple();
|
|
99
|
+
},
|
|
100
|
+
[](py::tuple t) { // __setstate__
|
|
101
|
+
COCOeval::Dataset p;
|
|
102
|
+
p.load_tuple(t);
|
|
103
|
+
return p;
|
|
104
|
+
}
|
|
105
|
+
));
|
|
68
106
|
|
|
69
107
|
#ifdef VERSION_INFO
|
|
70
108
|
m.attr("__version__") = MACRO_STRINGIFY(VERSION_INFO);
|
|
@@ -73,4 +111,4 @@ namespace coco_eval
|
|
|
73
111
|
#endif
|
|
74
112
|
}
|
|
75
113
|
|
|
76
|
-
} // namespace coco_eval
|
|
114
|
+
} // 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
|