Add DatasetVersion usage and model column (#92)

This commit is contained in:
pollfly 2021-10-21 11:42:38 +03:00 committed by GitHub
parent 6d54c6baaa
commit 29a2553dd6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 62 additions and 2 deletions

View File

@ -17,6 +17,8 @@ metadata and data.
These parent-child version relationships can be represented as version trees with a root-level parent. A Dataset These parent-child version relationships can be represented as version trees with a root-level parent. A Dataset
can contain one or more trees. can contain one or more trees.
Mask-labels can be defined globally, for a DatasetVersion, which will be applied to all masks in that version.
## Dataset Version State ## Dataset Version State
Dataset versions can have either **Draft** or **Published** status. Dataset versions can have either **Draft** or **Published** status.
@ -130,7 +132,7 @@ version at the root level), or the last child in the Dataset versions tree is *P
Creating a version in a simple version structure may convert it to an advanced structure. This happens when creating Creating a version in a simple version structure may convert it to an advanced structure. This happens when creating
a Dataset version that yields a parent with two children, or when publishing the last child version. a Dataset version that yields a parent with two children, or when publishing the last child version.
## Versioning Usage ## DatasetVersion Usage
Manage Dataset versioning using the DatasetVersion class in the ClearML Enterprise SDK. Manage Dataset versioning using the DatasetVersion class in the ClearML Enterprise SDK.
@ -303,3 +305,45 @@ myVersion = DatasetVersion.get_version(dataset_name='MyDataset',
myVersion.publish_version() myVersion.publish_version()
``` ```
### Managing Version Mask-labels
#### Setting Version Mask-label Mapping
In order to visualize masks in a dataset version, the mask values need to be mapped to their labels. Mask-label
mapping is stored in a version's metadata.
To define the DatasetVersion level mask-label mapping, use the `set_masks_labels` method of the [DatasetVersion](dataset.md#dataset-versioning)
class, and input a dictionary of RGB-value tuple keys and label-list values.
```python
from allegroai import DatasetVersion
# Getting a version
myDatasetversion = DatasetVersion.get_version(dataset_name='MyDataset',
version_name='VersionName')
# Mapping out colors and labels of masks
myDatasetversion.set_masks_labels(
{
(0, 0, 0): ["background"],
(1, 1, 1): ["person", "sitting"],
(2, 2, 2): ["cat"],
}
)
```
#### Accessing Version Mask-label Mapping
The mask values and labels are stored as a property in a dataset version's metadata.
```python
mappping = myDatasetversion.get_metadata()['mask_labels']
print(mapping)
```
This should return a dictionary of the version's masks and labels, which should look something like this:
```python
{'_all_': [{'value': [0, 0, 0], 'labels': ['background']}, {'value': [1, 1, 1], 'labels': ['person', 'sitting']}, {'value': [2, 2, 2], 'labels': ['cat']}]}
```

View File

@ -239,3 +239,19 @@ This example shows two masks for video from a camera. The masks label cars and t
* Each ROI has a label of `right_lane` indicating the ROI object. * Each ROI has a label of `right_lane` indicating the ROI object.
* Each `mask` has an `id` (`car`, `person`) and a unique RGB `value` (color-coding). * Each `mask` has an `id` (`car`, `person`) and a unique RGB `value` (color-coding).
## Usage
### Adding mask annotations
To add a mask annotation to a frame, use the `add_annotation` method of the [SingleFrame](single_frames.md) class. This
method is generally used to add ROI annotations, but it can also be used to add frame specific mask labels. Input the
mask value as a list with the RGB values in the `mask_rgb` parameter, and a list of labels in the `labels` parameter.
```python
frame = SingleFrame(
source='/home/user/woof_meow.jpg',
preview_uri='https://storage.googleapis.com/kaggle-competitions/kaggle/3362/media/woof_meow.jpg',
frame.add_annotation(mask_rgb=[0, 0, 0], labels=['cat'])
```

Binary file not shown.

Before

Width:  |  Height:  |  Size: 151 KiB

After

Width:  |  Height:  |  Size: 225 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 201 KiB

After

Width:  |  Height:  |  Size: 240 KiB

View File

@ -20,7 +20,7 @@ The models table contains the following columns:
| **PROJECT** | The project with which the model is associated.| Default | | **PROJECT** | The project with which the model is associated.| Default |
| **USER** | The user who ran the experiment that created the model, or the user who imported the model.| Default | | **USER** | The user who ran the experiment that created the model, or the user who imported the model.| Default |
| **TASK** | The experiment (Task) name that created the model. | Default | | **TASK** | The experiment (Task) name that created the model. | Default |
| **CREATED** | Elapsed time since the model creation. Hover over the elapsed time to view the date and time.| Default | | **UPDATED** | Elapsed time since the model was updated. Hover over the elapsed time to view the date and time.| Default |
| **DESCRIPTION** | The model description. | Default (hidden) | | **DESCRIPTION** | The model description. | Default (hidden) |