kwcoco.demo.toypatterns
¶
Module Contents¶
Classes¶
Example |
|
Functions¶
|
Generates a star shaped structuring element. |
Attributes¶
- class kwcoco.demo.toypatterns.CategoryPatterns(categories=None, fg_scale=0.5, fg_intensity=0.9, rng=None)[source]¶
Bases:
object
Example
>>> from kwcoco.demo.toypatterns import * # NOQA >>> self = CategoryPatterns.coerce() >>> chip = np.zeros((100, 100, 3)) >>> offset = (20, 10) >>> dims = (160, 140) >>> info = self.random_category(chip, offset, dims) >>> print('info = {}'.format(ub.repr2(info, nl=1))) >>> # xdoctest: +REQUIRES(--show) >>> import kwplot >>> kwplot.autompl() >>> kwplot.imshow(info['data'], pnum=(1, 2, 1), fnum=1, title='chip-space') >>> kpts = kwimage.Points._from_coco(info['keypoints']) >>> kpts.translate(-np.array(offset)).draw(radius=3) >>> ##### >>> mask = kwimage.Mask.coerce(info['segmentation']) >>> kwplot.imshow(mask.to_c_mask().data, pnum=(1, 2, 2), fnum=1, title='img-space') >>> kpts.draw(radius=3) >>> kwplot.show_if_requested()
- classmethod coerce(CategoryPatterns, data=None, **kwargs)[source]¶
Construct category patterns from either defaults or only with specific categories. Can accept either an existig category pattern object, a list of known catnames, or mscoco category dictionaries.
Example
>>> data = ['superstar'] >>> self = CategoryPatterns.coerce(data)
- random_category(self, chip, xy_offset=None, dims=None, newstyle=True, size=None)[source]¶
Example
>>> from kwcoco.demo.toypatterns import * # NOQA >>> self = CategoryPatterns.coerce(['superstar']) >>> chip = np.random.rand(64, 64) >>> info = self.random_category(chip)
- render_category(self, cname, chip, xy_offset=None, dims=None, newstyle=True, size=None)[source]¶
Example
>>> from kwcoco.demo.toypatterns import * # NOQA >>> self = CategoryPatterns.coerce(['superstar']) >>> chip = np.random.rand(64, 64) >>> info = self.render_category('superstar', chip, newstyle=True) >>> print('info = {}'.format(ub.repr2(info, nl=-1))) >>> info = self.render_category('superstar', chip, newstyle=False) >>> print('info = {}'.format(ub.repr2(info, nl=-1)))
Example
>>> from kwcoco.demo.toypatterns import * # NOQA >>> self = CategoryPatterns.coerce(['superstar']) >>> chip = None >>> dims = (64, 64) >>> info = self.render_category('superstar', chip, newstyle=True, dims=dims, size=dims) >>> print('info = {}'.format(ub.repr2(info, nl=-1)))
- _todo_refactor_geometric_info(self, cname, xy_offset, dims)[source]¶
This function is used to populate kpts and sseg information in the autogenerated coco dataset before rendering. It is redundant with other functionality.
TODO: rectify with _from_elem
Example
>>> self = CategoryPatterns.coerce(['superstar']) >>> dims = (64, 64) >>> cname = 'superstar' >>> xy_offset = None >>> self._todo_refactor_geometric_info(cname, xy_offset, dims)