mirror of
https://github.com/clearml/clearml-docs
synced 2025-04-07 14:44:52 +00:00
Add hyperdataset links and reformat code snippets (#116)
This commit is contained in:
parent
81b0a2322a
commit
ceaa4c5445
@ -27,21 +27,22 @@ Frame labels are applied to an entire frame, not a region in a frame.
|
|||||||
|
|
||||||
### Adding a Frame Object
|
### Adding a Frame Object
|
||||||
|
|
||||||
To add a frame object annotation to a SingleFrame, use the `SingleFrame.add_annotation` method.
|
To add a frame object annotation to a SingleFrame, use the [`SingleFrame.add_annotation`](../references/hyperdataset/singleframe.md#add_annotation)
|
||||||
|
method.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
# a bounding box labeled "test" at x=10,y=10 with width of 30px and height of 20px
|
# a bounding box labeled "test" at x=10,y=10 with width of 30px and height of 20px
|
||||||
frame.add_annotation(box2d_xywh=(10, 10, 30, 20), labels=['test'])
|
frame.add_annotation(box2d_xywh=(10, 10, 30, 20), labels=['test'])
|
||||||
```
|
```
|
||||||
|
|
||||||
The argument `box2d_xywh` specifies the coordinates of the annotation's bounding box, and the argument `labels` specifies
|
The `box2d_xywh` argument specifies the coordinates of the annotation's bounding box, and the `labels` argument specifies
|
||||||
a list of labels for the annotation.
|
a list of labels for the annotation.
|
||||||
|
|
||||||
When adding an annotation there are a few options for entering the annotation's boundaries, including:
|
When adding an annotation there are a few options for entering the annotation's boundaries, including:
|
||||||
* `poly2d_xy` - A list of floating points (x,y) to create for single polygon, or a list of Floating points lists for a
|
* `poly2d_xy` - A list of floating points (x,y) to create for single polygon, or a list of floating points lists for a
|
||||||
complex polygon
|
complex polygon.
|
||||||
* `ellipse2d_xyrrt` - A List consisting of cx, cy, rx, ry, and theta for an ellipse
|
* `ellipse2d_xyrrt` - A List consisting of cx, cy, rx, ry, and theta for an ellipse.
|
||||||
* And more! See `SingleFrame.add_annotation` for further options.
|
* And more! See [`SingleFrame.add_annotation`](../references/hyperdataset/singleframe.md#add_annotation) for further options.
|
||||||
|
|
||||||
### Adding a Frame Label
|
### Adding a Frame Label
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ frame.metadata['dangerous'] = 'no'
|
|||||||
|
|
||||||
### Adding ROI Metadata
|
### Adding ROI Metadata
|
||||||
|
|
||||||
Metadata can be added to individual ROIs when adding an annotation to a `frame`, using the `add_annotation`
|
Metadata can be added to individual ROIs when adding an annotation to a `frame`, using the [`SingleFrame.add_annotation`](../references/hyperdataset/singleframe.md#add_annotation)
|
||||||
method.
|
method.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
@ -39,7 +39,8 @@ with an "Example" banner in the WebApp (UI).
|
|||||||
|
|
||||||
### Creating Datasets
|
### Creating Datasets
|
||||||
|
|
||||||
Use the `Dataset.create` method to create a Dataset. It will contain an empty version named `Current`.
|
Use the [`Dataset.create`](../references/hyperdataset/hyperdataset.md#datasetcreate) method to create a Dataset. It will
|
||||||
|
contain an empty version named `Current`.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from allegroai import Dataset
|
from allegroai import Dataset
|
||||||
@ -47,7 +48,8 @@ from allegroai import Dataset
|
|||||||
myDataset = Dataset.create(dataset_name='myDataset')
|
myDataset = Dataset.create(dataset_name='myDataset')
|
||||||
```
|
```
|
||||||
|
|
||||||
Or, use the `DatasetVersion.create_new_dataset` method.
|
Or, use the [`DatasetVersion.create_new_dataset`](../references/hyperdataset/hyperdatasetversion.md#datasetversioncreate_new_dataset)
|
||||||
|
method.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from allegroai import DatasetVersion
|
from allegroai import DatasetVersion
|
||||||
@ -77,14 +79,17 @@ except ValueError:
|
|||||||
Additionally, create a Dataset with tags and a description.
|
Additionally, create a Dataset with tags and a description.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
myDataset = DatasetVersion.create_new_dataset(dataset_name='myDataset',
|
myDataset = DatasetVersion.create_new_dataset(
|
||||||
tags=['One Tag', 'Another Tag', 'And one more tag'],
|
dataset_name='myDataset',
|
||||||
description='some description text')
|
tags=['One Tag', 'Another Tag', 'And one more tag'],
|
||||||
|
description='some description text'
|
||||||
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
### Accessing Current Dataset
|
### Accessing Current Dataset
|
||||||
|
|
||||||
To get the current Dataset, use the `DatasetVersion.get_current` method.
|
To get the current Dataset, use the [`DatasetVersion.get_current`](../references/hyperdataset/hyperdatasetversion.md#datasetversionget_current)
|
||||||
|
method.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
myDataset = DatasetVersion.get_current(dataset_name='myDataset')
|
myDataset = DatasetVersion.get_current(dataset_name='myDataset')
|
||||||
@ -92,11 +97,11 @@ myDataset = DatasetVersion.get_current(dataset_name='myDataset')
|
|||||||
|
|
||||||
### Deleting Datasets
|
### Deleting Datasets
|
||||||
|
|
||||||
Use the `Dataset.delete` method to delete a Dataset.
|
Use the [`Dataset.delete`](../references/hyperdataset/hyperdataset.md#datasetdelete) method to delete a Dataset.
|
||||||
|
|
||||||
Delete an empty Dataset (no versions).
|
Delete an empty Dataset (no versions).
|
||||||
|
|
||||||
```python
|
```python
|
||||||
Dataset.delete(dataset_name='MyDataset', delete_all_versions=False, force=False)
|
Dataset.delete(dataset_name='MyDataset', delete_all_versions=False, force=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -187,8 +192,10 @@ a snapshot named `snapshot` with the timestamp appended.
|
|||||||
The newly created version (with a new version ID) is the current version, and its name is `NewCurrentVersionName`.
|
The newly created version (with a new version ID) is the current version, and its name is `NewCurrentVersionName`.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
myDataset = DatasetVersion.create_snapshot(dataset_name='MyDataset',
|
myDataset = DatasetVersion.create_snapshot(
|
||||||
child_name='NewCurrentVersionName')
|
dataset_name='MyDataset',
|
||||||
|
child_name='NewCurrentVersionName'
|
||||||
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Adding Metadata and Comments
|
#### Adding Metadata and Comments
|
||||||
@ -198,17 +205,19 @@ Add a metadata dictionary and / or comment to a snapshot.
|
|||||||
For example:
|
For example:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
myDataset = DatasetVersion.create_snapshot(dataset_name='MyDataset',
|
myDataset = DatasetVersion.create_snapshot(
|
||||||
child_metadata={'abc':'1234','def':'5678'},
|
dataset_name='MyDataset',
|
||||||
child_comment='some text comment')
|
child_metadata={'abc':'1234','def':'5678'},
|
||||||
|
child_comment='some text comment'
|
||||||
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
### Creating Child Versions
|
### Creating Child Versions
|
||||||
|
|
||||||
Create a new version from any version whose status is *Published*.
|
Create a new version from any version whose status is *Published*.
|
||||||
|
|
||||||
To create a new version, call the `DatasetVersion.create_version` method, and
|
To create a new version, call the [`DatasetVersion.create_version`](../references/hyperdataset/hyperdataset.md#datasetversioncreate_version)
|
||||||
provide:
|
method, and provide:
|
||||||
* Either the Dataset name or ID
|
* Either the Dataset name or ID
|
||||||
* The parent version name or ID from which the child inherits frames
|
* The parent version name or ID from which the child inherits frames
|
||||||
* The new version's name.
|
* The new version's name.
|
||||||
@ -218,18 +227,22 @@ where the new version inherits the frames of the existing version. If `NewChildV
|
|||||||
it is returned.
|
it is returned.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
myVersion = DatasetVersion.create_version(dataset_name='MyDataset',
|
myVersion = DatasetVersion.create_version(
|
||||||
parent_version_names=['PublishedVersion'],
|
dataset_name='MyDataset',
|
||||||
version_name='NewChildVersion')
|
parent_version_names=['PublishedVersion'],
|
||||||
|
version_name='NewChildVersion'
|
||||||
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
To raise a ValueError exception if `NewChildVersion` exists, set `raise_if_exists` to `True`.
|
To raise a ValueError exception if `NewChildVersion` exists, set `raise_if_exists` to `True`.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
myVersion = DatasetVersion.create_version(dataset_name='MyDataset',
|
myVersion = DatasetVersion.create_version(
|
||||||
parent_version_names=['PublishedVersion'],
|
dataset_name='MyDataset',
|
||||||
version_name='NewChildVersion',
|
parent_version_names=['PublishedVersion'],
|
||||||
raise_if_exists=True))
|
version_name='NewChildVersion',
|
||||||
|
raise_if_exists=True
|
||||||
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
### Creating Root-level Parent Versions
|
### Creating Root-level Parent Versions
|
||||||
@ -237,13 +250,16 @@ myVersion = DatasetVersion.create_version(dataset_name='MyDataset',
|
|||||||
Create a new version at the root-level. This is a version without a parent, and it contains no frames.
|
Create a new version at the root-level. This is a version without a parent, and it contains no frames.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
myDataset = DatasetVersion.create_version(dataset_name='MyDataset',
|
myDataset = DatasetVersion.create_version(
|
||||||
version_name='NewRootVersion')
|
dataset_name='MyDataset',
|
||||||
|
version_name='NewRootVersion'
|
||||||
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
### Getting Versions
|
### Getting Versions
|
||||||
|
|
||||||
To get a version or versions, use the `DatasetVersion.get_version` and `DatasetVersion.get_versions`
|
To get a version or versions, use the [`DatasetVersion.get_version`](../references/hyperdataset/hyperdatasetversion.md#datasetversionget_version)
|
||||||
|
and [`DatasetVersion.get_versions`](../references/hyperdataset/hyperdatasetversion.md#datasetversionget_versions)
|
||||||
methods, respectively.
|
methods, respectively.
|
||||||
|
|
||||||
**Getting a list of all versions**
|
**Getting a list of all versions**
|
||||||
@ -255,15 +271,19 @@ myDatasetversion = DatasetVersion.get_versions(dataset_name='MyDataset')
|
|||||||
**Getting a list of all _published_ versions**
|
**Getting a list of all _published_ versions**
|
||||||
|
|
||||||
```python
|
```python
|
||||||
myDatasetversion = DatasetVersion.get_versions(dataset_name='MyDataset',
|
myDatasetversion = DatasetVersion.get_versions(
|
||||||
only_published=True)
|
dataset_name='MyDataset',
|
||||||
|
only_published=True
|
||||||
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
**Getting a list of all _drafts_ versions**
|
**Getting a list of all _drafts_ versions**
|
||||||
|
|
||||||
```python
|
```python
|
||||||
myDatasetversion = DatasetVersion.get_versions(dataset_name='MyDataset',
|
myDatasetversion = DatasetVersion.get_versions(
|
||||||
only_draft=True)
|
dataset_name='MyDataset',
|
||||||
|
only_draft=True
|
||||||
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
**Getting the current version**
|
**Getting the current version**
|
||||||
@ -277,13 +297,16 @@ myDatasetversion = DatasetVersion.get_version(dataset_name='MyDataset')
|
|||||||
**Getting a specific version**
|
**Getting a specific version**
|
||||||
|
|
||||||
```python
|
```python
|
||||||
myDatasetversion = DatasetVersion.get_version(dataset_name='MyDataset',
|
myDatasetversion = DatasetVersion.get_version(
|
||||||
version_name='VersionName')
|
dataset_name='MyDataset',
|
||||||
|
version_name='VersionName'
|
||||||
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
### Deleting Versions
|
### Deleting Versions
|
||||||
|
|
||||||
Delete versions which are status *Draft* using the `Dataset.delete_version` method.
|
Delete versions which are status *Draft* using the [`Dataset.delete_version`](../references/hyperdataset/hyperdataset.md#delete_version)
|
||||||
|
method.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from allegroai import Dataset
|
from allegroai import Dataset
|
||||||
@ -295,12 +318,14 @@ myDataset.delete_version(version_name='VersionToDelete')
|
|||||||
|
|
||||||
### Publishing Versions
|
### Publishing Versions
|
||||||
|
|
||||||
Publish (make read-only) versions which are status *Draft* using the `Dataset.publish_version` method. This includes the current version, if the Dataset is in
|
Publish (make read-only) versions which are status *Draft* using the [`DatasetVersion.publish_version`](../references/hyperdataset/hyperdatasetversion.md#publish_version)
|
||||||
the simple version structure.
|
method. This includes the current version, if the Dataset is in the simple version structure.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
myVersion = DatasetVersion.get_version(dataset_name='MyDataset',
|
myVersion = DatasetVersion.get_version(
|
||||||
version_name='VersionToPublish')
|
dataset_name='MyDataset',
|
||||||
|
version_name='VersionToPublish'
|
||||||
|
)
|
||||||
|
|
||||||
myVersion.publish_version()
|
myVersion.publish_version()
|
||||||
```
|
```
|
||||||
@ -312,8 +337,8 @@ myVersion.publish_version()
|
|||||||
In order to visualize masks in a dataset version, the mask values need to be mapped to their labels. Mask-label
|
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.
|
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)
|
To define the DatasetVersion level mask-label mapping, use the [`DatasetVersion.set_masks_labels`](../references/hyperdataset/hyperdatasetversion.md#set_masks_labels)
|
||||||
class, and input a dictionary of RGB-value tuple keys and label-list values.
|
method, and input a dictionary of RGB-value tuple keys and label-list values.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from allegroai import DatasetVersion
|
from allegroai import DatasetVersion
|
||||||
@ -337,7 +362,7 @@ myDatasetversion.set_masks_labels(
|
|||||||
The mask values and labels are stored as a property in a dataset version's metadata.
|
The mask values and labels are stored as a property in a dataset version's metadata.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
mappping = myDatasetversion.get_metadata()['mask_labels']
|
mapping = myDatasetversion.get_metadata()['mask_labels']
|
||||||
|
|
||||||
print(mapping)
|
print(mapping)
|
||||||
```
|
```
|
||||||
|
@ -143,8 +143,8 @@ myDataView = DataView(iteration_order=IterationOrder.random, iteration_infinite=
|
|||||||
|
|
||||||
### Adding Queries
|
### Adding Queries
|
||||||
|
|
||||||
To add a query to a DataView, use the `DataView.add_query` method and specify Dataset versions,
|
To add a query to a DataView, use the [`DataView.add_query`](../references/hyperdataset/dataview.md#add_query) method
|
||||||
ROI and / or frame queries, and other criteria.
|
and specify Dataset versions, ROI and / or frame queries, and other criteria.
|
||||||
|
|
||||||
The `dataset_name` and `version_name` arguments specify the Dataset Version. The `roi_query` and `frame_query` arguments
|
The `dataset_name` and `version_name` arguments specify the Dataset Version. The `roi_query` and `frame_query` arguments
|
||||||
specify the queries.
|
specify the queries.
|
||||||
@ -165,8 +165,11 @@ This example is an ROI query filtering for frames containing at least one ROI wi
|
|||||||
myDataView = DataView(iteration_order=IterationOrder.random, iteration_infinite=True)
|
myDataView = DataView(iteration_order=IterationOrder.random, iteration_infinite=True)
|
||||||
|
|
||||||
# Add a query for a Dataset version
|
# Add a query for a Dataset version
|
||||||
myDataView.add_query(dataset_name='myDataset',
|
myDataView.add_query(
|
||||||
version_name='myVersion', roi_query='cat')
|
dataset_name='myDataset',
|
||||||
|
version_name='myVersion',
|
||||||
|
roi_query='cat'
|
||||||
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
* ROI query for one label OR another
|
* ROI query for one label OR another
|
||||||
@ -175,11 +178,17 @@ This example is an ROI query filtering for frames containing at least one ROI wi
|
|||||||
|
|
||||||
```python
|
```python
|
||||||
# Add a query for a Dataset version
|
# Add a query for a Dataset version
|
||||||
myDataView.add_query(dataset_name='myDataset', version_name='myVersion',
|
myDataView.add_query(
|
||||||
roi_query='cat')
|
dataset_name='myDataset',
|
||||||
|
version_name='myVersion',
|
||||||
|
roi_query='cat'
|
||||||
|
)
|
||||||
|
|
||||||
myDataView.add_query(dataset_name='myDataset', version_name='myVersion',
|
myDataView.add_query(
|
||||||
roi_query='dog')
|
dataset_name='myDataset',
|
||||||
|
version_name='myVersion',
|
||||||
|
roi_query='dog'
|
||||||
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
* ROI query for one label AND another label
|
* ROI query for one label AND another label
|
||||||
@ -188,8 +197,10 @@ This example is an ROI query filtering for frames containing at least one ROI wi
|
|||||||
|
|
||||||
```python
|
```python
|
||||||
# Add a query for a Dataset version
|
# Add a query for a Dataset version
|
||||||
myDataView.add_query(dataset_name='myDataset', version_name='training',
|
myDataView.add_query(
|
||||||
roi_query=['Car','partly_occluded'])
|
dataset_name='myDataset',
|
||||||
|
version_name='training',
|
||||||
|
roi_query=['Car','partly_occluded'])
|
||||||
```
|
```
|
||||||
|
|
||||||
* ROI query for one label AND NOT another (Lucene query).
|
* ROI query for one label AND NOT another (Lucene query).
|
||||||
@ -202,8 +213,11 @@ This example is an ROI query filtering for frames containing at least one ROI wi
|
|||||||
# Use a Lucene Query
|
# Use a Lucene Query
|
||||||
# "label" is a key in the rois dictionary of a frame
|
# "label" is a key in the rois dictionary of a frame
|
||||||
# In this Lucene Query, specify two values for the label key and use a Logical AND NOT
|
# In this Lucene Query, specify two values for the label key and use a Logical AND NOT
|
||||||
myDataView.add_query(dataset_name='myDataset', version_name='training',
|
myDataView.add_query(
|
||||||
roi_query='label.keyword:\"Car\" AND NOT label.keyword:\"partly_occluded\"')
|
dataset_name='myDataset',
|
||||||
|
version_name='training',
|
||||||
|
roi_query='label.keyword:\"Car\" AND NOT label.keyword:\"partly_occluded\"'
|
||||||
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Querying Multiple Datasets and Versions
|
#### Querying Multiple Datasets and Versions
|
||||||
@ -215,23 +229,28 @@ from two versions of one Dataset, and one version of another Dataset.
|
|||||||
# Add queries:
|
# Add queries:
|
||||||
|
|
||||||
# The 1st Dataset version
|
# The 1st Dataset version
|
||||||
myDataView.add_query(dataset_name='dataset_1',
|
myDataView.add_query(
|
||||||
version_name='version_1',
|
dataset_name='dataset_1',
|
||||||
roi_query='label.keyword:\"car\" OR label.keyword:\"truck\" OR '
|
version_name='version_1',
|
||||||
'label.keyword:\"bicycle\"')
|
roi_query='label.keyword:\"car\" OR label.keyword:\"truck\" OR '
|
||||||
|
'label.keyword:\"bicycle\"'
|
||||||
|
)
|
||||||
|
|
||||||
# The 1st Dataset, but a different version
|
# The 1st Dataset, but a different version
|
||||||
myDataView.add_query(dataset_name='dataset_1',
|
myDataView.add_query(
|
||||||
version_name='version_2',
|
dataset_name='dataset_1',
|
||||||
roi_query='label.keyword:\"car\" OR label.keyword:\"truck\" OR '
|
version_name='version_2',
|
||||||
'label.keyword:\"bicycle\"')
|
roi_query='label.keyword:\"car\" OR label.keyword:\"truck\" OR '
|
||||||
|
'label.keyword:\"bicycle\"'
|
||||||
|
)
|
||||||
|
|
||||||
# A 2nd Dataset (version)
|
# A 2nd Dataset (version)
|
||||||
myDataView.add_query(dataset_name='dataset_2',
|
myDataView.add_query(
|
||||||
version_name='some_version',
|
dataset_name='dataset_2',
|
||||||
roi_query='label.keyword:\"car\" OR label.keyword:\"truck\" OR '
|
version_name='some_version',
|
||||||
'label.keyword:\"bicycle\"')
|
roi_query='label.keyword:\"car\" OR label.keyword:\"truck\" OR '
|
||||||
|
'label.keyword:\"bicycle\"'
|
||||||
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Frame Queries
|
#### Frame Queries
|
||||||
@ -246,16 +265,18 @@ This example demonstrates a frame query filtering for frames containing the meta
|
|||||||
|
|
||||||
```python
|
```python
|
||||||
# Add a frame query for frames with the meta key "city" value of "bremen"
|
# Add a frame query for frames with the meta key "city" value of "bremen"
|
||||||
myDataView.add_query(dataset_name='myDataset',
|
myDataView.add_query(
|
||||||
version_name='version',
|
dataset_name='myDataset',
|
||||||
frame_query='meta.city:"bremen"')
|
version_name='version',
|
||||||
|
frame_query='meta.city:"bremen"'
|
||||||
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### Controlling Query Iteration
|
### Controlling Query Iteration
|
||||||
|
|
||||||
Use `DataView.set_iteration_parameters` to manage the order, number, timing, and reproducibility of frames
|
Use [`DataView.set_iteration_parameters`](../references/hyperdataset/dataview.md#set_iteration_parameters) to manage the
|
||||||
for training.
|
order, number, timing, and reproducibility of frames for training.
|
||||||
|
|
||||||
|
|
||||||
#### Iterate Frames Infinitely
|
#### Iterate Frames Infinitely
|
||||||
@ -280,11 +301,16 @@ myDataView = DataView(iteration_order=IterationOrder.random, iteration_infinite=
|
|||||||
|
|
||||||
# Set Iteration Parameters (overrides parameters in constructing the DataView object
|
# Set Iteration Parameters (overrides parameters in constructing the DataView object
|
||||||
myDataView.set_iteration_parameters(
|
myDataView.set_iteration_parameters(
|
||||||
order=IterationOrder.random, infinite=False)
|
order=IterationOrder.random,
|
||||||
|
infinite=False
|
||||||
|
)
|
||||||
|
|
||||||
# Add a query for a Dataset version
|
# Add a query for a Dataset version
|
||||||
myDataView.add_query(dataset_name='myDataset',
|
myDataView.add_query(
|
||||||
version_name='myVersion', roi_query='cat')
|
dataset_name='myDataset',
|
||||||
|
version_name='myVersion',
|
||||||
|
roi_query='cat'
|
||||||
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Iterate a Maximum Number of Frames
|
#### Iterate a Maximum Number of Frames
|
||||||
@ -297,14 +323,17 @@ myDataView = DataView(iteration_order=IterationOrder.random, iteration_infinite=
|
|||||||
|
|
||||||
# Set Iteration Parameters (overrides parameters in constructing the DataView object
|
# Set Iteration Parameters (overrides parameters in constructing the DataView object
|
||||||
myDataView.set_iteration_parameters(
|
myDataView.set_iteration_parameters(
|
||||||
order=IterationOrder.random, infinite=False,
|
order=IterationOrder.random,
|
||||||
maximum_number_of_frames=5000)
|
infinite=False,
|
||||||
|
maximum_number_of_frames=5000
|
||||||
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
### Debiasing Input Data
|
### Debiasing Input Data
|
||||||
|
|
||||||
Debias input data using the `DataView.add_query` method's `weight` argument to add weights. This
|
Debias input data using the [`DataView.add_query`](../references/hyperdataset/dataview.md#add_query) method's `weight`
|
||||||
is the same `DataView.add_query` that can be used to specify Dataset versions, and ROI queries and frame queries.
|
argument to add weights. This is the same `DataView.add_query` that can be used to specify Dataset versions, and ROI
|
||||||
|
queries and frame queries.
|
||||||
|
|
||||||
This example adjusts an imbalance in the input data to improve training for `Car` ROIs that are also `largely occluded`
|
This example adjusts an imbalance in the input data to improve training for `Car` ROIs that are also `largely occluded`
|
||||||
(obstructed). For every frame containing at least one ROI labeled `Car`, approximately five frames containing at least
|
(obstructed). For every frame containing at least one ROI labeled `Car`, approximately five frames containing at least
|
||||||
@ -334,21 +363,33 @@ The example maps `Car` (upper case "C") to `car` (lower case "c").
|
|||||||
myDataView = DataView(iteration_order=IterationOrder.random, iteration_infinite=True)
|
myDataView = DataView(iteration_order=IterationOrder.random, iteration_infinite=True)
|
||||||
|
|
||||||
# The 1st Dataset (version) - "car" with lowercase "c"
|
# The 1st Dataset (version) - "car" with lowercase "c"
|
||||||
myDataView.add_query(dataset_name='myDataset', version_name='myVersion' roi_query='car')
|
myDataView.add_query(
|
||||||
|
dataset_name='myDataset',
|
||||||
|
version_name='myVersion',
|
||||||
|
roi_query='car'
|
||||||
|
)
|
||||||
|
|
||||||
# The 2nd Dataset (version) - "car" with lowercase "c"
|
# The 2nd Dataset (version) - "car" with lowercase "c"
|
||||||
myDataView.add_query(dataset_name='dataset_2', version_name='aVersion',
|
myDataView.add_query(
|
||||||
roi_query='car')
|
dataset_name='dataset_2',
|
||||||
|
version_name='aVersion',
|
||||||
|
roi_query='car'
|
||||||
|
)
|
||||||
|
|
||||||
# A 3rd Dataset (version) - "Car" with uppercase "C"
|
# A 3rd Dataset (version) - "Car" with uppercase "C"
|
||||||
myDataView.add_query(dataset_name='dataset_3', version_name='training',
|
myDataView.add_query(
|
||||||
roi_query='Car')
|
dataset_name='dataset_3',
|
||||||
|
version_name='training',
|
||||||
|
roi_query='Car'
|
||||||
|
)
|
||||||
|
|
||||||
# Use a mapping rule to translate "Car" (uppercase) to "car" (lowercase)
|
# Use a mapping rule to translate "Car" (uppercase) to "car" (lowercase)
|
||||||
myDataView.add_mapping_rule(dataset_name='dataset_3',
|
myDataView.add_mapping_rule(
|
||||||
version_name='training',
|
dataset_name='dataset_3',
|
||||||
from_labels=['Car'],
|
version_name='training',
|
||||||
to_label='car')
|
from_labels=['Car'],
|
||||||
|
to_label='car'
|
||||||
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
### Setting Label Enumeration Values
|
### Setting Label Enumeration Values
|
||||||
@ -369,21 +410,38 @@ For example, if the labels `truck`, `van`, and `car` are mapped **to** `vehicle`
|
|||||||
myDataView = DataView(iteration_order=IterationOrder.random, iteration_infinite=True)
|
myDataView = DataView(iteration_order=IterationOrder.random, iteration_infinite=True)
|
||||||
|
|
||||||
# Add a query for a Dataset version
|
# Add a query for a Dataset version
|
||||||
myDataView.add_query(dataset_name='myDataset', version_name='myVersion',
|
myDataView.add_query(
|
||||||
roi_query='cat')
|
dataset_name='myDataset',
|
||||||
|
version_name='myVersion',
|
||||||
|
roi_query='cat'
|
||||||
|
)
|
||||||
|
|
||||||
myDataView.add_query(dataset_name='myDataset', version_name='myVersion',
|
myDataView.add_query(
|
||||||
roi_query='dog')
|
dataset_name='myDataset',
|
||||||
|
version_name='myVersion',
|
||||||
|
roi_query='dog'
|
||||||
|
)
|
||||||
|
|
||||||
myDataView.add_query(dataset_name='myDataset', version_name='myVersion',
|
myDataView.add_query(
|
||||||
roi_query='bird')
|
dataset_name='myDataset',
|
||||||
|
version_name='myVersion',
|
||||||
|
roi_query='bird'
|
||||||
|
)
|
||||||
|
|
||||||
myDataView.add_query(dataset_name='myDataset', version_name='myVersion',
|
myDataView.add_query(
|
||||||
roi_query='sheep')
|
dataset_name='myDataset',
|
||||||
|
version_name='myVersion',
|
||||||
|
roi_query='sheep'
|
||||||
|
)
|
||||||
|
|
||||||
myDataView.add_query(dataset_name='myDataset', version_name='myVersion',
|
myDataView.add_query(
|
||||||
roi_query='cow')
|
dataset_name='myDataset',
|
||||||
|
version_name='myVersion',
|
||||||
|
roi_query='cow'
|
||||||
|
)
|
||||||
|
|
||||||
# Set the enumeration label values
|
# Set the enumeration label values
|
||||||
myDataView.set_labels({"cat": 1, "dog": 2, "bird": 3, "sheep": 4, "cow": 5, "ignore": -1,})
|
myDataView.set_labels(
|
||||||
|
{"cat": 1, "dog": 2, "bird": 3, "sheep": 4, "cow": 5, "ignore": -1,}
|
||||||
|
)
|
||||||
```
|
```
|
||||||
|
@ -31,8 +31,11 @@ from allegroai import FrameGroup, SingleFrame
|
|||||||
frame_group = FrameGroup()
|
frame_group = FrameGroup()
|
||||||
|
|
||||||
# Create a SingleFrame
|
# Create a SingleFrame
|
||||||
frame = SingleFrame(source='https://allegro-datasets.s3.amazonaws.com/tutorials/000012.jpg',
|
frame = SingleFrame(
|
||||||
width=512, height=512, preview_uri='https://allegro-datasets.s3.amazonaws.com/tutorials/000012.jpg')
|
source='https://allegro-datasets.s3.amazonaws.com/tutorials/000012.jpg',
|
||||||
|
width=512, height=512,
|
||||||
|
preview_uri='https://allegro-datasets.s3.amazonaws.com/tutorials/000012.jpg'
|
||||||
|
)
|
||||||
|
|
||||||
# Add the first SingleFrame to the FrameGroup.
|
# Add the first SingleFrame to the FrameGroup.
|
||||||
frame_group['FrameOne'] = frame
|
frame_group['FrameOne'] = frame
|
||||||
@ -54,7 +57,9 @@ To add FrameGroups to a Dataset Version:
|
|||||||
frame_group = FrameGroup()
|
frame_group = FrameGroup()
|
||||||
|
|
||||||
# Create SingleFrame
|
# Create SingleFrame
|
||||||
single_frame = SingleFrame(source='https://allegro-datasets.s3.amazonaws.com/tutorials/000012.jpg')
|
single_frame = SingleFrame(
|
||||||
|
source='https://allegro-datasets.s3.amazonaws.com/tutorials/000012.jpg'
|
||||||
|
)
|
||||||
|
|
||||||
# Add the first SingleFrame to the FrameGroup.
|
# Add the first SingleFrame to the FrameGroup.
|
||||||
frame_group['FrameOne'] = single_frame
|
frame_group['FrameOne'] = single_frame
|
||||||
@ -74,9 +79,11 @@ To access a FrameGroup, use the `DatasetVersion.get_single_frame` method, just l
|
|||||||
|
|
||||||
```python
|
```python
|
||||||
# Get the FrameGroup
|
# Get the FrameGroup
|
||||||
frame_group = DatasetVersion.get_single_frame(frame_id='f3ed0e09bf23fc947f426a0d254c652c',
|
frame_group = DatasetVersion.get_single_frame(
|
||||||
dataset_name='MyDataset',
|
frame_id='f3ed0e09bf23fc947f426a0d254c652c',
|
||||||
version_name='FrameGroup')
|
dataset_name='MyDataset',
|
||||||
|
version_name='FrameGroup'
|
||||||
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
### Updating FrameGroups
|
### Updating FrameGroups
|
||||||
@ -88,8 +95,11 @@ SingleFrame needs to be referenced using its name as the key in the FrameGroup.
|
|||||||
frames = []
|
frames = []
|
||||||
|
|
||||||
# Get the FrameGroup
|
# Get the FrameGroup
|
||||||
frame_group = DatasetVersion.get_single_frame(frame_id='f3ed0e09bf23fc947f426a0d254c652c',
|
frame_group = DatasetVersion.get_single_frame(
|
||||||
dataset_name='MyDataset', version_name='FrameGroup')
|
frame_id='f3ed0e09bf23fc947f426a0d254c652c',
|
||||||
|
dataset_name='MyDataset',
|
||||||
|
version_name='FrameGroup'
|
||||||
|
)
|
||||||
|
|
||||||
# Add metadata by referencing the name of the SingleFrame in the FrameGroup
|
# Add metadata by referencing the name of the SingleFrame in the FrameGroup
|
||||||
frame_group['FrameOne'].metadata['new_key'] = 'new_value'
|
frame_group['FrameOne'].metadata['new_key'] = 'new_value'
|
||||||
@ -102,15 +112,18 @@ myVersion.update_frames(frames)
|
|||||||
|
|
||||||
### Deleting Frames
|
### Deleting Frames
|
||||||
|
|
||||||
To delete a FrameGroup, use the `DatasetVersion.delete_frames` method, just like when deleting a
|
To delete a FrameGroup, use the [`DatasetVersion.delete_frames`](../references/hyperdataset/hyperdatasetversion.md#delete_frames)
|
||||||
SingleFrame, except that a FrameGroup is being referenced.
|
method, just like when deleting a SingleFrame, except that a FrameGroup is being referenced.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
frames = []
|
frames = []
|
||||||
|
|
||||||
# Get the FrameGroup
|
# Get the FrameGroup
|
||||||
frame_group = DatasetVersion.get_single_frame(frame_id='f3ed0e09bf23fc947f426a0d254c652c',
|
frame_group = DatasetVersion.get_single_frame(
|
||||||
dataset_name='MyDataset', version_name='FrameGroup')
|
frame_id='f3ed0e09bf23fc947f426a0d254c652c',
|
||||||
|
dataset_name='MyDataset',
|
||||||
|
version_name='FrameGroup'
|
||||||
|
)
|
||||||
|
|
||||||
# Delete the FrameGroup
|
# Delete the FrameGroup
|
||||||
frames.append(frame_group)
|
frames.append(frame_group)
|
||||||
|
@ -243,8 +243,8 @@ This example shows two masks for video from a camera. The masks label cars and t
|
|||||||
|
|
||||||
### Adding Mask Annotations
|
### Adding Mask Annotations
|
||||||
|
|
||||||
To add a mask annotation to a frame, use the `add_annotation` method of the [SingleFrame](single_frames.md) class. This
|
To add a mask annotation to a frame, use the [`SingleFrame.add_annotation`](../references/hyperdataset/singleframe.md#add_annotation).
|
||||||
method is generally used to add ROI annotations, but it can also be used to add frame specific mask labels. Input the
|
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.
|
mask value as a list with the RGB values in the `mask_rgb` parameter, and a list of labels in the `labels` parameter.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
@ -194,7 +194,7 @@ For more information about using Frames in the WebApp, see [Working with Frames]
|
|||||||
|
|
||||||
### Creating a SingleFrame
|
### Creating a SingleFrame
|
||||||
|
|
||||||
To create a `SingleFrame`, instantiate a `SingleFrame` class and populate it with:
|
To create a [`SingleFrame`](../references/hyperdataset/singleframe.md), instantiate a `SingleFrame` class and populate it with:
|
||||||
* The URI link to the source file of the data frame
|
* The URI link to the source file of the data frame
|
||||||
* A preview URI that is accessible by browser, so you will be able to visualize the data frame in the web UI
|
* A preview URI that is accessible by browser, so you will be able to visualize the data frame in the web UI
|
||||||
|
|
||||||
@ -248,14 +248,16 @@ myDatasetversion.add_frames(frames)
|
|||||||
|
|
||||||
|
|
||||||
### Accessing SingleFrames
|
### Accessing SingleFrames
|
||||||
To access a SingleFrame, use the `DatasetVersion.get_single_frame` method.
|
To access a SingleFrame, use the [`DatasetVersion.get_single_frame`](../references/hyperdataset/hyperdatasetversion.md#datasetversionget_single_frame)
|
||||||
|
method.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from allegroai import DatasetVersion
|
from allegroai import DatasetVersion
|
||||||
frame = DatasetVersion.get_single_frame(frame_id='dcd81d094ab44e37875c13f2014530ae',
|
frame = DatasetVersion.get_single_frame(
|
||||||
dataset_name='MyDataset', # OR dataset_id='80ccb3ae11a74b91b1c6f25f98539039'
|
frame_id='dcd81d094ab44e37875c13f2014530ae',
|
||||||
version_name='SingleFrame' # OR version_id='b07b626e3b6f4be7be170a2f39e14bfb'
|
dataset_name='MyDataset', # OR dataset_id='80ccb3ae11a74b91b1c6f25f98539039'
|
||||||
)
|
version_name='SingleFrame' # OR version_id='b07b626e3b6f4be7be170a2f39e14bfb'
|
||||||
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
To access a SingleFrame, the following must be specified:
|
To access a SingleFrame, the following must be specified:
|
||||||
@ -266,23 +268,30 @@ To access a SingleFrame, the following must be specified:
|
|||||||
### Updating SingleFrames
|
### Updating SingleFrames
|
||||||
|
|
||||||
To update a SingleFrame:
|
To update a SingleFrame:
|
||||||
* Access the SingleFrame by calling the `DatasetVersion.get_single_frame` method,
|
* Access the SingleFrame by calling the [`DatasetVersion.get_single_frame`](../references/hyperdataset/hyperdatasetversion.md#datasetversionget_single_frame)
|
||||||
|
method
|
||||||
* Make changes to the frame
|
* Make changes to the frame
|
||||||
* Update the frame in a DatasetVersion using the `DatasetVersion.update_frames` method.
|
* Update the frame in a DatasetVersion using the [`DatasetVersion.update_frames`](../references/hyperdataset/hyperdatasetversion.md##update_frames)
|
||||||
|
method.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
frames = []
|
frames = []
|
||||||
|
|
||||||
# get the SingleFrame
|
# get the SingleFrame
|
||||||
frame = DatasetVersion.get_single_frame(frame_id='dcd81d094ab44e37875c13f2014530ae',
|
frame = DatasetVersion.get_single_frame(
|
||||||
dataset_name='MyDataset',
|
frame_id='dcd81d094ab44e37875c13f2014530ae',
|
||||||
version_name='SingleFrame')
|
dataset_name='MyDataset',
|
||||||
|
version_name='SingleFrame'
|
||||||
|
)
|
||||||
|
|
||||||
# make changes to the frame
|
# make changes to the frame
|
||||||
## add a new annotation
|
## add a new annotation
|
||||||
frame.add_annotation(poly2d_xy=[154, 343, 209, 343, 209, 423, 154, 423],
|
frame.add_annotation(
|
||||||
labels=['tire'], metadata={'alive': 'no'},
|
poly2d_xy=[154, 343, 209, 343, 209, 423, 154, 423],
|
||||||
confidence=0.5)
|
labels=['tire'],
|
||||||
|
metadata={'alive': 'no'},
|
||||||
|
confidence=0.5
|
||||||
|
)
|
||||||
|
|
||||||
## add metadata
|
## add metadata
|
||||||
frame.meta['road_hazard'] = 'yes'
|
frame.meta['road_hazard'] = 'yes'
|
||||||
@ -296,14 +305,18 @@ myDatasetVersion.update_frames(frames)
|
|||||||
|
|
||||||
### Deleting Frames
|
### Deleting Frames
|
||||||
|
|
||||||
To delete a SingleFrame, use the `DatasetVersion.delete_frames` method.
|
To delete a SingleFrame, use the [`DatasetVersion.delete_frames`](../references/hyperdataset/hyperdatasetversion.md#delete_frames)
|
||||||
|
method.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
frames = []
|
frames = []
|
||||||
|
|
||||||
# get the SingleFrame
|
# get the SingleFrame
|
||||||
frame = DatasetVersion.get_single_frame(frame_id='f3ed0e09bf23fc947f426a0d254c652c',
|
frame = DatasetVersion.get_single_frame(
|
||||||
dataset_name='MyDataset', version_name='FrameGroup')
|
frame_id='f3ed0e09bf23fc947f426a0d254c652c',
|
||||||
|
dataset_name='MyDataset',
|
||||||
|
version_name='FrameGroup'
|
||||||
|
)
|
||||||
|
|
||||||
# delete the SingleFrame
|
# delete the SingleFrame
|
||||||
frames.append(frame)
|
frames.append(frame)
|
||||||
|
Loading…
Reference in New Issue
Block a user