[Datumaro] Fix mask to polygons warning (#1581)

* Fix message, add test
* update changelog
main
zhiltsov-max 6 years ago committed by GitHub
parent 2d1b73c2ab
commit 42c5637ddd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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

@ -216,7 +216,7 @@ class MasksToPolygons(Transform, CliPlugin):
log.debug("[%s]: item %s: "
"Mask conversion to polygons resulted in too "
"small polygons, which were discarded" % \
(self.NAME, item.id))
(self._get_name(__class__), item.id))
annotations.extend(polygons)
else:
annotations.append(ann)

@ -1,3 +1,4 @@
import logging as log
import numpy as np
from unittest import TestCase
@ -65,6 +66,33 @@ class TransformsTest(TestCase):
actual = transforms.MasksToPolygons(SrcExtractor())
compare_datasets(self, DstExtractor(), actual)
def test_mask_to_polygons_small_polygons_message(self):
class SrcExtractor(Extractor):
def __iter__(self):
items = [
DatasetItem(id=1, image=np.zeros((5, 10, 3)),
annotations=[
Mask(np.array([
[0, 0, 0],
[0, 1, 0],
[0, 0, 0],
]),
),
]
),
]
return iter(items)
class DstExtractor(Extractor):
def __iter__(self):
return iter([ DatasetItem(id=1, image=np.zeros((5, 10, 3))), ])
with self.assertLogs(level=log.DEBUG) as logs:
actual = transforms.MasksToPolygons(SrcExtractor())
compare_datasets(self, DstExtractor(), actual)
self.assertRegex('\n'.join(logs.output), 'too small polygons')
def test_polygons_to_masks(self):
class SrcExtractor(Extractor):
def __iter__(self):

Loading…
Cancel
Save