faster-coco-eval 1.5.1__tar.gz → 1.5.2__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.
Files changed (33) hide show
  1. {faster_coco_eval-1.5.1/faster_coco_eval.egg-info → faster_coco_eval-1.5.2}/PKG-INFO +8 -14
  2. {faster_coco_eval-1.5.1 → faster_coco_eval-1.5.2}/README.md +7 -13
  3. {faster_coco_eval-1.5.1 → faster_coco_eval-1.5.2}/faster_coco_eval/extra/draw.py +3 -0
  4. {faster_coco_eval-1.5.1 → faster_coco_eval-1.5.2}/faster_coco_eval/extra/extra.py +27 -0
  5. faster_coco_eval-1.5.2/faster_coco_eval/extra/utils.py +86 -0
  6. {faster_coco_eval-1.5.1 → faster_coco_eval-1.5.2}/faster_coco_eval/version.py +1 -1
  7. {faster_coco_eval-1.5.1 → faster_coco_eval-1.5.2/faster_coco_eval.egg-info}/PKG-INFO +8 -14
  8. {faster_coco_eval-1.5.1 → faster_coco_eval-1.5.2}/faster_coco_eval.egg-info/SOURCES.txt +2 -0
  9. faster_coco_eval-1.5.2/requirements/extra.txt +1 -0
  10. {faster_coco_eval-1.5.1 → faster_coco_eval-1.5.2}/LICENSE +0 -0
  11. {faster_coco_eval-1.5.1 → faster_coco_eval-1.5.2}/MANIFEST.in +0 -0
  12. {faster_coco_eval-1.5.1 → faster_coco_eval-1.5.2}/csrc/faster_eval_api/coco_eval/cocoeval.cpp +0 -0
  13. {faster_coco_eval-1.5.1 → faster_coco_eval-1.5.2}/csrc/faster_eval_api/coco_eval/cocoeval.h +0 -0
  14. {faster_coco_eval-1.5.1 → faster_coco_eval-1.5.2}/csrc/faster_eval_api/faster_eval_api.cpp +0 -0
  15. {faster_coco_eval-1.5.1 → faster_coco_eval-1.5.2}/csrc/mask/common/maskApi.c +0 -0
  16. {faster_coco_eval-1.5.1 → faster_coco_eval-1.5.2}/csrc/mask/common/maskApi.h +0 -0
  17. {faster_coco_eval-1.5.1 → faster_coco_eval-1.5.2}/csrc/mask/pycocotools/_mask.pyx +0 -0
  18. {faster_coco_eval-1.5.1 → faster_coco_eval-1.5.2}/faster_coco_eval/__init__.py +0 -0
  19. {faster_coco_eval-1.5.1 → faster_coco_eval-1.5.2}/faster_coco_eval/core/__init__.py +0 -0
  20. {faster_coco_eval-1.5.1 → faster_coco_eval-1.5.2}/faster_coco_eval/core/coco.py +0 -0
  21. {faster_coco_eval-1.5.1 → faster_coco_eval-1.5.2}/faster_coco_eval/core/cocoeval.py +0 -0
  22. {faster_coco_eval-1.5.1 → faster_coco_eval-1.5.2}/faster_coco_eval/core/faster_eval_api.py +0 -0
  23. {faster_coco_eval-1.5.1 → faster_coco_eval-1.5.2}/faster_coco_eval/core/mask.py +0 -0
  24. {faster_coco_eval-1.5.1 → faster_coco_eval-1.5.2}/faster_coco_eval/extra/__init__.py +0 -0
  25. {faster_coco_eval-1.5.1 → faster_coco_eval-1.5.2}/faster_coco_eval/extra/curves.py +0 -0
  26. {faster_coco_eval-1.5.1 → faster_coco_eval-1.5.2}/faster_coco_eval/extra/display.py +0 -0
  27. {faster_coco_eval-1.5.1 → faster_coco_eval-1.5.2}/faster_coco_eval.egg-info/dependency_links.txt +0 -0
  28. {faster_coco_eval-1.5.1 → faster_coco_eval-1.5.2}/faster_coco_eval.egg-info/requires.txt +0 -0
  29. {faster_coco_eval-1.5.1 → faster_coco_eval-1.5.2}/faster_coco_eval.egg-info/top_level.txt +0 -0
  30. {faster_coco_eval-1.5.1 → faster_coco_eval-1.5.2}/pyproject.toml +0 -0
  31. {faster_coco_eval-1.5.1 → faster_coco_eval-1.5.2}/requirements/runtime.txt +0 -0
  32. {faster_coco_eval-1.5.1 → faster_coco_eval-1.5.2}/setup.cfg +0 -0
  33. {faster_coco_eval-1.5.1 → faster_coco_eval-1.5.2}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: faster-coco-eval
3
- Version: 1.5.1
3
+ Version: 1.5.2
4
4
  Summary: Faster interpretation of the original COCOEval
5
5
  Home-page: https://github.com/MiXaiLL76/faster_coco_eval
6
6
  Author: MiXaiLL76
@@ -49,22 +49,16 @@ for coco's AP metrics, especially when dealing with a high number of instances i
49
49
  For our use case with a test dataset of 5000 images from the coco val dataset.
50
50
  Testing was carried out using the mmdetection framework and the eval_metric.py script. The indicators are presented below.
51
51
 
52
- Visualization of testing **comparison.ipynb** available in directory [examples/comparison](https://github.com/MiXaiLL76/faster_coco_eval/blob/main/examples/comparison/mmdet/comparison.ipynb)
53
- Tested with yolo3 model (bbox eval) and yoloact model (segm eval)
52
+ Visualization of testing **colab_example.ipynb** available in directory [examples/comparison](https://github.com/MiXaiLL76/faster_coco_eval/blob/main/examples/comparison/mmdet/colab_example.ipynb)
53
+ [colab_example.ipynb in google collab](https://drive.google.com/file/d/13raC0nRsil797ITJSv3FTRvUvfEK9SD-/view?usp=sharing)
54
+ Tested with rtmdet model bbox + segm
54
55
 
55
56
  ### Summary for 5000 imgs
56
57
 
57
- | Type | COCOeval | COCOeval_faster | Profit |
58
- | ---- | ----------- | --------------- | ------------ |
59
- | bbox | 18.477 sec. | 7.345 sec. | ~2.5x faster |
60
- | segm | 29.819 sec. | 15.840 sec. | ~1.7x faster |
61
-
62
- ## Summary for 500 imgs
63
-
64
- | Type | COCOeval | COCOeval_faster | Profit |
65
- | ---- | --------- | --------------- | ------------ |
66
- | bbox | 3.57 sec. | 2.03 sec. | ~1.7x faster |
67
- | segm | 4.16 sec. | 2.41 sec. | ~1.7x faster |
58
+ | Type | faster-coco-eval | pycocotools | Profit |
59
+ | :--- | ---------------: | ----------: | -----: |
60
+ | bbox | 5.812 | 22.72 | 3.909 |
61
+ | segm | 7.413 | 24.434 | 3.296 |
68
62
 
69
63
  ## Feautures
70
64
 
@@ -24,22 +24,16 @@ for coco's AP metrics, especially when dealing with a high number of instances i
24
24
  For our use case with a test dataset of 5000 images from the coco val dataset.
25
25
  Testing was carried out using the mmdetection framework and the eval_metric.py script. The indicators are presented below.
26
26
 
27
- Visualization of testing **comparison.ipynb** available in directory [examples/comparison](https://github.com/MiXaiLL76/faster_coco_eval/blob/main/examples/comparison/mmdet/comparison.ipynb)
28
- Tested with yolo3 model (bbox eval) and yoloact model (segm eval)
27
+ Visualization of testing **colab_example.ipynb** available in directory [examples/comparison](https://github.com/MiXaiLL76/faster_coco_eval/blob/main/examples/comparison/mmdet/colab_example.ipynb)
28
+ [colab_example.ipynb in google collab](https://drive.google.com/file/d/13raC0nRsil797ITJSv3FTRvUvfEK9SD-/view?usp=sharing)
29
+ Tested with rtmdet model bbox + segm
29
30
 
30
31
  ### Summary for 5000 imgs
31
32
 
32
- | Type | COCOeval | COCOeval_faster | Profit |
33
- | ---- | ----------- | --------------- | ------------ |
34
- | bbox | 18.477 sec. | 7.345 sec. | ~2.5x faster |
35
- | segm | 29.819 sec. | 15.840 sec. | ~1.7x faster |
36
-
37
- ## Summary for 500 imgs
38
-
39
- | Type | COCOeval | COCOeval_faster | Profit |
40
- | ---- | --------- | --------------- | ------------ |
41
- | bbox | 3.57 sec. | 2.03 sec. | ~1.7x faster |
42
- | segm | 4.16 sec. | 2.41 sec. | ~1.7x faster |
33
+ | Type | faster-coco-eval | pycocotools | Profit |
34
+ | :--- | ---------------: | ----------: | -----: |
35
+ | bbox | 5.812 | 22.72 | 3.909 |
36
+ | segm | 7.413 | 24.434 | 3.296 |
43
37
 
44
38
  ## Feautures
45
39
 
@@ -8,6 +8,7 @@ import plotly.graph_objs as go
8
8
  from PIL import Image
9
9
 
10
10
  from ..core import COCO
11
+ from .utils import convert_ann_rle_to_poly
11
12
 
12
13
  logger = logging.getLogger(__name__)
13
14
 
@@ -34,6 +35,8 @@ def generate_ann_polygon(
34
35
  all_x = [x1, x1 + w, x1 + w, x1, x1, None]
35
36
  all_y = [y1, y1, y1 + h, y1 + h, y1, None]
36
37
  else:
38
+ ann = convert_ann_rle_to_poly(ann)
39
+
37
40
  for poly in ann["segmentation"]:
38
41
  if len(poly) > 3:
39
42
  poly += poly[:2]
@@ -31,6 +31,7 @@ class ExtraEval:
31
31
  assert self.cocoGt is not None, "cocoGt is empty"
32
32
 
33
33
  if (self.cocoGt is not None) and (self.cocoDt is not None):
34
+ self.drop_cocodt_by_score(min_score=min_score)
34
35
  self.evaluate()
35
36
 
36
37
  def evaluate(self):
@@ -54,3 +55,29 @@ class ExtraEval:
54
55
  cocoEval.accumulate()
55
56
 
56
57
  self.eval = cocoEval.eval
58
+
59
+ def drop_cocodt_by_score(self, min_score: float):
60
+ assert self.cocoDt is not None, "cocoDt is empty"
61
+
62
+ if min_score > 0:
63
+ bad_keys = {}
64
+ bad_images_keys = []
65
+
66
+ for key, ann in self.cocoDt.anns.items():
67
+ if ann["score"] < min_score:
68
+ if bad_keys.get(ann["image_id"]) is None:
69
+ bad_keys[ann["image_id"]] = {}
70
+
71
+ bad_keys[ann["image_id"]][key] = True
72
+
73
+ bad_images_keys.append(ann["image_id"])
74
+
75
+ for image_id in set(bad_images_keys):
76
+ self.cocoDt.imgToAnns[image_id] = [
77
+ ann
78
+ for ann in self.cocoDt.imgToAnns[image_id]
79
+ if bad_keys.get(image_id, {}).get(ann["id"]) is None
80
+ ]
81
+
82
+ for ann_id in bad_keys.get(image_id, {}).keys():
83
+ del self.cocoDt.anns[ann_id]
@@ -0,0 +1,86 @@
1
+ try:
2
+ import cv2
3
+
4
+ opencv_available = True
5
+ except ImportError:
6
+ opencv_available = False
7
+
8
+ import numpy as np
9
+
10
+ import faster_coco_eval.core.mask as mask_util
11
+
12
+
13
+ def conver_mask_to_poly(mask: np.ndarray, bbox: list, boxes_margin=0.1) -> list:
14
+ """Convert mask (uint8) to list of poly as coco style.
15
+
16
+ :param mask (np.ndarray): numpy array in uint8 0-255
17
+ :param bbox (list): x,y,w,h of this ann
18
+ :param boxes_margin (float): margin for increase bbox
19
+ :return: list of poly as coco style
20
+
21
+ """
22
+ x1, y1, w, h = bbox
23
+ x2 = x1 + w
24
+ y2 = y1 + h
25
+
26
+ m_w, m_h = int(w * boxes_margin), int(h * boxes_margin)
27
+ x1 -= m_w
28
+ if x1 < 0:
29
+ x1 = 0
30
+
31
+ y1 -= m_h
32
+ if y1 < 0:
33
+ y1 = 0
34
+
35
+ x2 += m_w
36
+ y2 += m_h
37
+
38
+ coords, _ = cv2.findContours(
39
+ mask[int(y1) : int(y2), int(x1) : int(x2)].astype(np.uint8),
40
+ cv2.RETR_TREE,
41
+ cv2.CHAIN_APPROX_SIMPLE,
42
+ )
43
+
44
+ coords = list(coords)
45
+ if len(coords) > 0:
46
+ for cnt_idx, cnt in enumerate(coords):
47
+ coords[cnt_idx] = cnt + [x1, y1]
48
+
49
+ coords = [
50
+ _cnt.ravel().tolist() for _cnt in coords if _cnt.shape[0] >= 6
51
+ ]
52
+
53
+ return coords
54
+
55
+
56
+ def convert_rle_to_poly(rle: dict, bbox: list):
57
+ """Convert rle (dict) to list of poly as coco style.
58
+
59
+ :param rle (dict): rle of mask image
60
+ :param bbox (list): x,y,w,h of this ann
61
+ :return: list of poly as coco style
62
+
63
+ """
64
+ mask = mask_util.decode(rle) * 255
65
+ return conver_mask_to_poly(mask, bbox)
66
+
67
+
68
+ def convert_ann_rle_to_poly(ann: dict):
69
+ """Convert ann segm from rle to poly style; Save rle in *count* var;
70
+
71
+ :param ann (dict): ann row
72
+ :return: ann
73
+
74
+ """
75
+ if type(ann["segmentation"]) is dict:
76
+ if not opencv_available:
77
+ raise Exception(
78
+ "Your dataset needs to be converted to polygons. Install"
79
+ " **opencv-python** for this."
80
+ )
81
+
82
+ ann["counts"] = ann["segmentation"]
83
+ ann["segmentation"] = convert_rle_to_poly(
84
+ ann["segmentation"], ann["bbox"]
85
+ )
86
+ return ann
@@ -1,2 +1,2 @@
1
- __version__ = "1.5.1"
1
+ __version__ = "1.5.2"
2
2
  __author__ = "MiXaiLL76"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: faster-coco-eval
3
- Version: 1.5.1
3
+ Version: 1.5.2
4
4
  Summary: Faster interpretation of the original COCOEval
5
5
  Home-page: https://github.com/MiXaiLL76/faster_coco_eval
6
6
  Author: MiXaiLL76
@@ -49,22 +49,16 @@ for coco's AP metrics, especially when dealing with a high number of instances i
49
49
  For our use case with a test dataset of 5000 images from the coco val dataset.
50
50
  Testing was carried out using the mmdetection framework and the eval_metric.py script. The indicators are presented below.
51
51
 
52
- Visualization of testing **comparison.ipynb** available in directory [examples/comparison](https://github.com/MiXaiLL76/faster_coco_eval/blob/main/examples/comparison/mmdet/comparison.ipynb)
53
- Tested with yolo3 model (bbox eval) and yoloact model (segm eval)
52
+ Visualization of testing **colab_example.ipynb** available in directory [examples/comparison](https://github.com/MiXaiLL76/faster_coco_eval/blob/main/examples/comparison/mmdet/colab_example.ipynb)
53
+ [colab_example.ipynb in google collab](https://drive.google.com/file/d/13raC0nRsil797ITJSv3FTRvUvfEK9SD-/view?usp=sharing)
54
+ Tested with rtmdet model bbox + segm
54
55
 
55
56
  ### Summary for 5000 imgs
56
57
 
57
- | Type | COCOeval | COCOeval_faster | Profit |
58
- | ---- | ----------- | --------------- | ------------ |
59
- | bbox | 18.477 sec. | 7.345 sec. | ~2.5x faster |
60
- | segm | 29.819 sec. | 15.840 sec. | ~1.7x faster |
61
-
62
- ## Summary for 500 imgs
63
-
64
- | Type | COCOeval | COCOeval_faster | Profit |
65
- | ---- | --------- | --------------- | ------------ |
66
- | bbox | 3.57 sec. | 2.03 sec. | ~1.7x faster |
67
- | segm | 4.16 sec. | 2.41 sec. | ~1.7x faster |
58
+ | Type | faster-coco-eval | pycocotools | Profit |
59
+ | :--- | ---------------: | ----------: | -----: |
60
+ | bbox | 5.812 | 22.72 | 3.909 |
61
+ | segm | 7.413 | 24.434 | 3.296 |
68
62
 
69
63
  ## Feautures
70
64
 
@@ -26,4 +26,6 @@ faster_coco_eval/extra/curves.py
26
26
  faster_coco_eval/extra/display.py
27
27
  faster_coco_eval/extra/draw.py
28
28
  faster_coco_eval/extra/extra.py
29
+ faster_coco_eval/extra/utils.py
30
+ requirements/extra.txt
29
31
  requirements/runtime.txt
@@ -0,0 +1 @@
1
+ opencv-python-headless