Skip to content

Commit 42c5637

Browse files
authored
[Datumaro] Fix mask to polygons warning (#1581)
* Fix message, add test * update changelog
1 parent 2d1b73c commit 42c5637

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4747
- Fixed full COCO dataset import error with conflicting labels in keypoints and detection (https://github.com/opencv/cvat/pull/1548)
4848
- Fixed COCO keypoints skeleton parsing and saving (https://github.com/opencv/cvat/issues/1539)
4949
- `tf.placeholder() is not compatible with eager execution` exception for auto_segmentation (https://github.com/opencv/cvat/pull/1562)
50+
- Fixed a problem with mask to polygons conversion when polygons are too small (https://github.com/opencv/cvat/pull/1581)
5051

5152
### Security
5253
-

datumaro/datumaro/plugins/transforms.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def transform_item(self, item):
216216
log.debug("[%s]: item %s: "
217217
"Mask conversion to polygons resulted in too "
218218
"small polygons, which were discarded" % \
219-
(self.NAME, item.id))
219+
(self._get_name(__class__), item.id))
220220
annotations.extend(polygons)
221221
else:
222222
annotations.append(ann)

datumaro/tests/test_transforms.py

+28
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import logging as log
12
import numpy as np
23

34
from unittest import TestCase
@@ -65,6 +66,33 @@ def __iter__(self):
6566
actual = transforms.MasksToPolygons(SrcExtractor())
6667
compare_datasets(self, DstExtractor(), actual)
6768

69+
def test_mask_to_polygons_small_polygons_message(self):
70+
class SrcExtractor(Extractor):
71+
def __iter__(self):
72+
items = [
73+
DatasetItem(id=1, image=np.zeros((5, 10, 3)),
74+
annotations=[
75+
Mask(np.array([
76+
[0, 0, 0],
77+
[0, 1, 0],
78+
[0, 0, 0],
79+
]),
80+
),
81+
]
82+
),
83+
]
84+
return iter(items)
85+
86+
class DstExtractor(Extractor):
87+
def __iter__(self):
88+
return iter([ DatasetItem(id=1, image=np.zeros((5, 10, 3))), ])
89+
90+
with self.assertLogs(level=log.DEBUG) as logs:
91+
actual = transforms.MasksToPolygons(SrcExtractor())
92+
93+
compare_datasets(self, DstExtractor(), actual)
94+
self.assertRegex('\n'.join(logs.output), 'too small polygons')
95+
6896
def test_polygons_to_masks(self):
6997
class SrcExtractor(Extractor):
7098
def __iter__(self):

0 commit comments

Comments
 (0)