Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add categoryId in the three mask chapters of "label_format.rst" #961

Merged
merged 1 commit into from
Aug 23, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 50 additions & 23 deletions docs/source/reference/label_format.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ and the unique ones will be explained under the corresponding type of label.
Take a :ref:`2D box label <reference/label_format:Box2D>` as an example:

>>> from tensorbay.label import LabeledBox2D
>>> label = LabeledBox2D(
>>> box2d_label = LabeledBox2D(
... 10, 20, 30, 40,
... category="category",
... attributes={"attribute_name": "attribute_value"},
... instance="instance_ID"
... )
>>> label
>>> box2d_label
LabeledBox2D(10, 20, 30, 40)(
(category): 'category',
(attributes): {...},
Expand All @@ -63,7 +63,7 @@ category

Category is a string indicating the class of the labeled object.

>>> label.category
>>> box2d_label.category
'data_category'

attributes
Expand All @@ -74,7 +74,7 @@ and there is no limit on the number of attributes.

The attribute names and values are stored in key-value pairs.

>>> label.attributes
>>> box2d_label.attributes
{'attribute_name': 'attribute_value'}


Expand All @@ -84,7 +84,7 @@ instance
Instance is the unique id for the object inside of the label,
which is mostly used for tracking tasks.

>>> label.instance
>>> box2d_label.instance
"instance_ID"

******************************
Expand Down Expand Up @@ -121,13 +121,16 @@ or set the ``is_tracking`` attr after initialization.
category information
====================

common category information
---------------------------

If the label of this type in the dataset has category,
then the subcatalog should contain all the optional categories.

Each :ref:`reference/label_format:category` of a label
appeared in the dataset should be within the categories of the subcatalog.

Category information can be added to the subcatalog.
Common category information can be added to the most subcatalogs except for mask subcatalogs.

>>> box2d_subcatalog.add_category(name="cat", description="The Flerken")
>>> box2d_subcatalog.categories
Expand All @@ -139,6 +142,26 @@ Category information can be added to the subcatalog.
a :ref:`reference/label_format:category`.
See details in :class:`~tensorbay.label.supports.CategoryInfo`.

mask category information
-------------------------

If the mask label in the dataset has category information,
then the subcatalog should contain all the optional mask categories.

graczhual marked this conversation as resolved.
Show resolved Hide resolved
MaskCategory information can be added to the mask subcatalog.

Different from common category, mask category information must have ``category_id`` which
is the pixel value of this category in all mask images.

>>> semantic_mask_subcatalog.add_category(name="cat", category_id=1, description="Ragdoll")
>>> semantic_mask_subcatalog.categories
NameList [
MaskCategoryInfo("cat")(...)
graczhual marked this conversation as resolved.
Show resolved Hide resolved
]

:class:`~tensorbay.label.supports.MaskCategoryInfo` is used to describe the category information of pixels in the mask image.
See details in :class:`~tensorbay.label.supports.MaskCategoryInfo`.

attributes information
======================

Expand Down Expand Up @@ -233,7 +256,7 @@ Before adding the classification label to data,

:class:`~tensorbay.label.label_classification.ClassificationSubcatalog`
has categories and attributes information,
see :ref:`reference/label_format:category information` and
see :ref:`reference/label_format:common category information` and
:ref:`reference/label_format:attributes information` for details.

To add a :class:`~tensorbay.label.label_classification.Classification` label to one data:
Expand Down Expand Up @@ -348,7 +371,7 @@ Before adding the Box2D labels to data,

:class:`~tensorbay.label.label_box.Box2DSubcatalog`
has categories, attributes and tracking information,
see :ref:`reference/label_format:category information`,
see :ref:`reference/label_format:common category information`,
:ref:`reference/label_format:attributes information` and
:ref:`reference/label_format:tracking information` for details.

Expand Down Expand Up @@ -500,7 +523,7 @@ Before adding the Box3D labels to data,

:class:`~tensorbay.label.label_box.Box3DSubcatalog`
has categories, attributes and tracking information,
see :ref:`reference/label_format:category information`,
see :ref:`reference/label_format:common category information`,
:ref:`reference/label_format:attributes information` and
:ref:`reference/label_format:tracking information` for details.

Expand Down Expand Up @@ -623,7 +646,7 @@ Before adding 2D keypoints labels to the dataset,
:class:`~tensorbay.label.label_keypoints.Keypoints2DSubcatalog` should be defined.

Besides :ref:`reference/label_format:attributes information`,
:ref:`reference/label_format:category information`,
:ref:`reference/label_format:common category information`,
:ref:`reference/label_format:tracking information` in
:class:`~tensorbay.label.label_keypoints.Keypoints2DSubcatalog`,
it also has :attr:`~tensorbay.label.label_keypoints.Keypoints2DSubcatalog.keypoints`
Expand Down Expand Up @@ -781,7 +804,7 @@ Before adding the Polygon labels to data,

:class:`~tensorbay.label.label_polygon.PolygonSubcatalog`
has categories, attributes and tracking information,
see :ref:`reference/label_format:category information`,
see :ref:`reference/label_format:common category information`,
:ref:`reference/label_format:attributes information` and
:ref:`reference/label_format:tracking information` for details.

Expand Down Expand Up @@ -891,7 +914,7 @@ Before adding the MultiPolygon labels to data,

:class:`~tensorbay.label.label_polygon.MultiPolygonSubcatalog`
has categories, attributes and tracking information,
see :ref:`reference/label_format:category information`,
see :ref:`reference/label_format:common category information`,
:ref:`reference/label_format:attributes information` and
:ref:`reference/label_format:tracking information` for details.

Expand Down Expand Up @@ -995,7 +1018,7 @@ Before adding the RLE labels to data,

:class:`~tensorbay.label.label_polygon.RLESubcatalog`
has categories, attributes and tracking information,
see :ref:`reference/label_format:category information`,
see :ref:`reference/label_format:common category information`,
:ref:`reference/label_format:attributes information` and
:ref:`reference/label_format:tracking information` for details.

Expand Down Expand Up @@ -1111,7 +1134,7 @@ Before adding the Polyline2D labels to data,

:class:`~tensorbay.label.label_polyline.Polyline2DSubcatalog`
has categories, attributes and tracking information,
see :ref:`reference/label_format:category information`,
see :ref:`reference/label_format:common category information`,
:ref:`reference/label_format:attributes information` and
:ref:`reference/label_format:tracking information` for details.

Expand Down Expand Up @@ -1221,7 +1244,7 @@ Before adding the MultiPolyline2D labels to data,

:class:`~tensorbay.label.label_polyline.MultiPolyline2DSubcatalog`
has categories, attributes and tracking information,
see :ref:`reference/label_format:category information`,
see :ref:`reference/label_format:common category information`,
:ref:`reference/label_format:attributes information` and
:ref:`reference/label_format:tracking information` for details.

Expand Down Expand Up @@ -1467,7 +1490,7 @@ In TensorBay, the structure of SemanticMask label is unified as follows::
``local_path`` is the storage path of the mask image. TensorBay only supports single-channel, gray-scale png images.
If the number of categories exceeds 256, the color depth of this image should be 16 bits, otherwise it is 8 bits.

The gray-scale value of the pixel corresponds to the index of the ``categories`` within the :class:`~tensorbay.label.label_mask.SemanticMaskSubcatalog`.
The gray-scale value of the pixel corresponds to the category id of the ``categories`` within the :class:`~tensorbay.label.label_mask.SemanticMaskSubcatalog`.

Each data can only be assigned with one :class:`~tensorbay.label.label_mask.SemanticMask` label.

Expand Down Expand Up @@ -1509,8 +1532,8 @@ SemanticMaskSubcatalog
Before adding the SemanticMask labels to data,
:class:`~tensorbay.label.label_mask.SemanticMaskSubcatalog` should be defined.

:class:`~tensorbay.label.label_mask.SemanticMaskSubcatalog` has categories and attributes,
see :ref:`reference/label_format:category information` and
:class:`~tensorbay.label.label_mask.SemanticMaskSubcatalog` has mask categories and attributes,
see :ref:`reference/label_format:mask category information` and
:ref:`reference/label_format:attributes information` for details.

To add a :class:`~tensorbay.label.label_mask.SemanticMask` label to one data:
Expand Down Expand Up @@ -1551,6 +1574,9 @@ In TensorBay, the structure of InstanceMask label is unified as follows::
``local_path`` is the storage path of the mask image. TensorBay only supports single-channel, gray-scale png images.
If the number of categories exceeds 256, the color depth of this image should be 16 bits, otherwise it is 8 bits.

There are pixels in the InstanceMask that do not represent the instance, such as backgrounds or borders. This information is written to the
``categories`` within the :class:`~tensorbay.label.label_mask.InstanceMaskSubcatalog`.

Each data can only be assigned with one :class:`~tensorbay.label.label_mask.InstanceMask` label.

To create a :class:`~tensorbay.label.label_mask.InstanceMask` label:
Expand Down Expand Up @@ -1591,8 +1617,9 @@ InstanceMaskSubcatalog
Before adding the InstanceMask labels to data,
:class:`~tensorbay.label.label_mask.InstanceMaskSubcatalog` should be defined.

:class:`~tensorbay.label.label_mask.InstanceMaskSubcatalog` has attributes,
see :ref:`reference/label_format:attributes information` for details.
:class:`~tensorbay.label.label_mask.InstanceMaskSubcatalog` has mask categories and attributes,
see :ref:`reference/label_format:mask category information` and
:ref:`reference/label_format:attributes information` for details.

To add a :class:`~tensorbay.label.label_mask.InstanceMask` label to one data:

Expand Down Expand Up @@ -1633,7 +1660,7 @@ In TensorBay, the structure of PanopticMask label is unified as follows::
``local_path`` is the storage path of the mask image. TensorBay only supports single-channel, gray-scale png images.
If the number of categories exceeds 256, the color depth of this image should be 16 bits, otherwise it is 8 bits.

The gray-scale value of the pixel corresponds to the index of the ``categories`` within the :class:`~tensorbay.label.label_mask.PanopticMaskSubcatalog`.
The gray-scale value of the pixel corresponds to the category id of the ``categories`` within the :class:`~tensorbay.label.label_mask.PanopticMaskSubcatalog`.

Each data can only be assigned with one :class:`~tensorbay.label.label_mask.PanopticMask` label.

Expand Down Expand Up @@ -1689,8 +1716,8 @@ PanopticMaskSubcatalog
Before adding the PanopticMask labels to data,
:class:`~tensorbay.label.label_mask.PanopticMaskSubcatalog` should be defined.

:class:`~tensorbay.label.label_mask.PanopticMaskSubcatalog` has categories and attributes,
see :ref:`reference/label_format:category information` and
:class:`~tensorbay.label.label_mask.PanopticMaskSubcatalog` has mask categories and attributes,
see :ref:`reference/label_format:mask category information` and
:ref:`reference/label_format:attributes information` for details.

To add a :class:`~tensorbay.label.label_mask.PanopticMask` label to one data:
Expand Down