.. Copyright 2021 Graviti. Licensed under MIT License. ************** MultiPolygon ************** MultiPolygon is a type of label with several polygonal regions which contain same semantic information on an image. It's often used for CV tasks such as semantic segmentation. Each data can be assigned with multiple MultiPolygon labels. The structure of one MultiPolygon label is like:: { "multiPolygon": [ [ { "x": "y": }, ... ... ], ... ... ], "category": "attributes": { : ... ... } "instance": } To create a :class:`~tensorbay.label.label_polygon.LabeledMultiPolygon` label: >>> from tensorbay.label import LabeledMultiPolygon >>> multipolygon_label = LabeledMultiPolygon( ... [[(1.0, 2.0), (2.0, 3.0), (1.0, 3.0)], [(1.0, 4.0), (2.0, 3.0), (1.0, 8.0)]], ... category="", ... attributes={"": ""}, ... instance="" ... ) >>> multipolygon_label LabeledMultiPolygon [ Polygon [...], Polygon [...] ]( (category): '', (attributes): {...}, (instance): '>> LabeledMultiPolygon([[[1.0, 4.0], [2.0, 3.7], [7.0, 4.0]], ... [[5.0, 7.0], [6.0, 7.0], [9.0, 8.0]]]) LabeledMultiPolygon [ Polygon [...], Polygon [...] ]() MultiPolygon.category ===================== The category of the object inside polygonal regions. See :ref:`reference/label_format/CommonLabelProperties:category` for details. MultiPolygon.attributes ======================= Attributes are the additional information about this object, which are stored in key-value pairs. See :ref:`reference/label_format/CommonLabelProperties:attributes` for details. MultiPolygon.instance ===================== Instance is the unique id for the object inside of polygonal regions, which is mostly used for tracking tasks. See :ref:`reference/label_format/CommonLabelProperties:instance` for details. MultiPolygonSubcatalog ====================== Before adding the MultiPolygon labels to data, :class:`~tensorbay.label.label_polygon.MultiPolygonSubcatalog` should be defined. :class:`~tensorbay.label.label_polygon.MultiPolygonSubcatalog` has categories, attributes and tracking information, see :ref:`reference/label_format/CommonSubcatalogProperties:common category information`, :ref:`reference/label_format/CommonSubcatalogProperties:attributes information` and :ref:`reference/label_format/CommonSubcatalogProperties:tracking information` for details. The catalog with only MultiPolygon subcatalog is typically stored in a json file as follows:: { "MULTI_POLYGON": { * "description": ! -- Subcatalog description, (default: ""). "isTracking": ! -- Whether this type of label in the dataset contains tracking information, (default: false). "categoryDelimiter": -- The delimiter in category names indicating subcategories. Recommended delimiter is ".". There is no "categoryDelimiter" field by default which means the category is of one level. "categories": [ -- Category list, which contains all category information. { "name": * -- Category name. "description": ! -- Category description, (default: ""). }, ... ... ], "attributes": [ -- Attribute list, which contains all attribute information. { "name": * -- Attribute name. "enum": [...], -- All possible options for the attribute. "type": -- Type of the attribute including "boolean", "integer", "number", "string", "array" and "null". And it is not required when "enum" is provided. "minimum": -- Minimum value of the attribute when type is "number". "maximum": -- Maximum value of the attribute when type is "number". "items": { -- Used only if the attribute type is "array". "enum": [...], -- All possible options for elements in the attribute array. "type": -- Type of elements in the attribute array. "minimum": -- Minimum value of elements in the attribute array when type is "number". "maximum": -- Maximum value of elements in the attribute array when type is "number". }, "parentCategories": [...], -- Indicates the category to which the attribute belongs. Do not add this field if it is a global attribute. "description": ! -- Attribute description, (default: ""). }, ... ... ] } } .. note:: ``*`` indicates that the field is required. ``!`` indicates that the field has a default value. To add a :class:`~tensorbay.label.label_polygon.LabeledMultiPolygon` label to one data: >>> from tensorbay.dataset import Data >>> data = Data("") >>> data.label.multi_polygon = [] >>> data.label.multi_polygon.append(multipolygon_label) .. note:: One data may contain multiple MultiPolygon labels, so the :attr:`Data.label.multi_polygon` must be a list.