mirror of
https://github.com/clearml/clearml-docs
synced 2025-04-07 06:39:29 +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
|
||||
|
||||
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
|
||||
# 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'])
|
||||
```
|
||||
|
||||
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.
|
||||
|
||||
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
|
||||
complex polygon
|
||||
* `ellipse2d_xyrrt` - A List consisting of cx, cy, rx, ry, and theta for an ellipse
|
||||
* And more! See `SingleFrame.add_annotation` for further options.
|
||||
* `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.
|
||||
* `ellipse2d_xyrrt` - A List consisting of cx, cy, rx, ry, and theta for an ellipse.
|
||||
* And more! See [`SingleFrame.add_annotation`](../references/hyperdataset/singleframe.md#add_annotation) for further options.
|
||||
|
||||
### Adding a Frame Label
|
||||
|
||||
|
@ -30,7 +30,7 @@ frame.metadata['dangerous'] = 'no'
|
||||
|
||||
### 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.
|
||||
|
||||
```python
|
||||
|
@ -39,7 +39,8 @@ with an "Example" banner in the WebApp (UI).
|
||||
|
||||
### 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
|
||||
from allegroai import Dataset
|
||||
@ -47,7 +48,8 @@ from allegroai import Dataset
|
||||
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
|
||||
from allegroai import DatasetVersion
|
||||
@ -77,14 +79,17 @@ except ValueError:
|
||||
Additionally, create a Dataset with tags and a description.
|
||||
|
||||
```python
|
||||
myDataset = DatasetVersion.create_new_dataset(dataset_name='myDataset',
|
||||
tags=['One Tag', 'Another Tag', 'And one more tag'],
|
||||
description='some description text')
|
||||
myDataset = DatasetVersion.create_new_dataset(
|
||||
dataset_name='myDataset',
|
||||
tags=['One Tag', 'Another Tag', 'And one more tag'],
|
||||
description='some description text'
|
||||
)
|
||||
```
|
||||
|
||||
### 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
|
||||
myDataset = DatasetVersion.get_current(dataset_name='myDataset')
|
||||
@ -92,11 +97,11 @@ myDataset = DatasetVersion.get_current(dataset_name='myDataset')
|
||||
|
||||
### 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).
|
||||
|
||||
```python
|
||||
```python
|
||||
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`.
|
||||
|
||||
```python
|
||||
myDataset = DatasetVersion.create_snapshot(dataset_name='MyDataset',
|
||||
child_name='NewCurrentVersionName')
|
||||
myDataset = DatasetVersion.create_snapshot(
|
||||
dataset_name='MyDataset',
|
||||
child_name='NewCurrentVersionName'
|
||||
)
|
||||
```
|
||||
|
||||
#### Adding Metadata and Comments
|
||||
@ -198,17 +205,19 @@ Add a metadata dictionary and / or comment to a snapshot.
|
||||
For example:
|
||||
|
||||
```python
|
||||
myDataset = DatasetVersion.create_snapshot(dataset_name='MyDataset',
|
||||
child_metadata={'abc':'1234','def':'5678'},
|
||||
child_comment='some text comment')
|
||||
myDataset = DatasetVersion.create_snapshot(
|
||||
dataset_name='MyDataset',
|
||||
child_metadata={'abc':'1234','def':'5678'},
|
||||
child_comment='some text comment'
|
||||
)
|
||||
```
|
||||
|
||||
### Creating Child Versions
|
||||
|
||||
Create a new version from any version whose status is *Published*.
|
||||
|
||||
To create a new version, call the `DatasetVersion.create_version` method, and
|
||||
provide:
|
||||
To create a new version, call the [`DatasetVersion.create_version`](../references/hyperdataset/hyperdataset.md#datasetversioncreate_version)
|
||||
method, and provide:
|
||||
* Either the Dataset name or ID
|
||||
* The parent version name or ID from which the child inherits frames
|
||||
* 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.
|
||||
|
||||
```python
|
||||
myVersion = DatasetVersion.create_version(dataset_name='MyDataset',
|
||||
parent_version_names=['PublishedVersion'],
|
||||
version_name='NewChildVersion')
|
||||
myVersion = DatasetVersion.create_version(
|
||||
dataset_name='MyDataset',
|
||||
parent_version_names=['PublishedVersion'],
|
||||
version_name='NewChildVersion'
|
||||
)
|
||||
```
|
||||
|
||||
To raise a ValueError exception if `NewChildVersion` exists, set `raise_if_exists` to `True`.
|
||||
|
||||
```python
|
||||
myVersion = DatasetVersion.create_version(dataset_name='MyDataset',
|
||||
parent_version_names=['PublishedVersion'],
|
||||
version_name='NewChildVersion',
|
||||
raise_if_exists=True))
|
||||
myVersion = DatasetVersion.create_version(
|
||||
dataset_name='MyDataset',
|
||||
parent_version_names=['PublishedVersion'],
|
||||
version_name='NewChildVersion',
|
||||
raise_if_exists=True
|
||||
)
|
||||
```
|
||||
|
||||
### 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.
|
||||
|
||||
```python
|
||||
myDataset = DatasetVersion.create_version(dataset_name='MyDataset',
|
||||
version_name='NewRootVersion')
|
||||
myDataset = DatasetVersion.create_version(
|
||||
dataset_name='MyDataset',
|
||||
version_name='NewRootVersion'
|
||||
)
|
||||
```
|
||||
|
||||
### 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.
|
||||
|
||||
**Getting a list of all versions**
|
||||
@ -255,15 +271,19 @@ myDatasetversion = DatasetVersion.get_versions(dataset_name='MyDataset')
|
||||
**Getting a list of all _published_ versions**
|
||||
|
||||
```python
|
||||
myDatasetversion = DatasetVersion.get_versions(dataset_name='MyDataset',
|
||||
only_published=True)
|
||||
myDatasetversion = DatasetVersion.get_versions(
|
||||
dataset_name='MyDataset',
|
||||
only_published=True
|
||||
)
|
||||
```
|
||||
|
||||
**Getting a list of all _drafts_ versions**
|
||||
|
||||
```python
|
||||
myDatasetversion = DatasetVersion.get_versions(dataset_name='MyDataset',
|
||||
only_draft=True)
|
||||
myDatasetversion = DatasetVersion.get_versions(
|
||||
dataset_name='MyDataset',
|
||||
only_draft=True
|
||||
)
|
||||
```
|
||||
|
||||
**Getting the current version**
|
||||
@ -277,13 +297,16 @@ myDatasetversion = DatasetVersion.get_version(dataset_name='MyDataset')
|
||||
**Getting a specific version**
|
||||
|
||||
```python
|
||||
myDatasetversion = DatasetVersion.get_version(dataset_name='MyDataset',
|
||||
version_name='VersionName')
|
||||
myDatasetversion = DatasetVersion.get_version(
|
||||
dataset_name='MyDataset',
|
||||
version_name='VersionName'
|
||||
)
|
||||
```
|
||||
|
||||
### 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
|
||||
from allegroai import Dataset
|
||||
@ -295,12 +318,14 @@ myDataset.delete_version(version_name='VersionToDelete')
|
||||
|
||||
### 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
|
||||
the simple version structure.
|
||||
Publish (make read-only) versions which are status *Draft* using the [`DatasetVersion.publish_version`](../references/hyperdataset/hyperdatasetversion.md#publish_version)
|
||||
method. This includes the current version, if the Dataset is in the simple version structure.
|
||||
|
||||
```python
|
||||
myVersion = DatasetVersion.get_version(dataset_name='MyDataset',
|
||||
version_name='VersionToPublish')
|
||||
myVersion = DatasetVersion.get_version(
|
||||
dataset_name='MyDataset',
|
||||
version_name='VersionToPublish'
|
||||
)
|
||||
|
||||
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
|
||||
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.
|
||||
To define the DatasetVersion level mask-label mapping, use the [`DatasetVersion.set_masks_labels`](../references/hyperdataset/hyperdatasetversion.md#set_masks_labels)
|
||||
method, and input a dictionary of RGB-value tuple keys and label-list values.
|
||||
|
||||
```python
|
||||
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.
|
||||
|
||||
```python
|
||||
mappping = myDatasetversion.get_metadata()['mask_labels']
|
||||
mapping = myDatasetversion.get_metadata()['mask_labels']
|
||||
|
||||
print(mapping)
|
||||
```
|
||||
|
@ -143,8 +143,8 @@ myDataView = DataView(iteration_order=IterationOrder.random, iteration_infinite=
|
||||
|
||||
### Adding Queries
|
||||
|
||||
To add a query to a DataView, use the `DataView.add_query` method and specify Dataset versions,
|
||||
ROI and / or frame queries, and other criteria.
|
||||
To add a query to a DataView, use the [`DataView.add_query`](../references/hyperdataset/dataview.md#add_query) method
|
||||
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
|
||||
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)
|
||||
|
||||
# Add a query for a Dataset version
|
||||
myDataView.add_query(dataset_name='myDataset',
|
||||
version_name='myVersion', roi_query='cat')
|
||||
myDataView.add_query(
|
||||
dataset_name='myDataset',
|
||||
version_name='myVersion',
|
||||
roi_query='cat'
|
||||
)
|
||||
```
|
||||
|
||||
* 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
|
||||
# Add a query for a Dataset version
|
||||
myDataView.add_query(dataset_name='myDataset', version_name='myVersion',
|
||||
roi_query='cat')
|
||||
myDataView.add_query(
|
||||
dataset_name='myDataset',
|
||||
version_name='myVersion',
|
||||
roi_query='cat'
|
||||
)
|
||||
|
||||
myDataView.add_query(dataset_name='myDataset', version_name='myVersion',
|
||||
roi_query='dog')
|
||||
myDataView.add_query(
|
||||
dataset_name='myDataset',
|
||||
version_name='myVersion',
|
||||
roi_query='dog'
|
||||
)
|
||||
```
|
||||
|
||||
* 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
|
||||
# Add a query for a Dataset version
|
||||
myDataView.add_query(dataset_name='myDataset', version_name='training',
|
||||
roi_query=['Car','partly_occluded'])
|
||||
myDataView.add_query(
|
||||
dataset_name='myDataset',
|
||||
version_name='training',
|
||||
roi_query=['Car','partly_occluded'])
|
||||
```
|
||||
|
||||
* 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
|
||||
# "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
|
||||
myDataView.add_query(dataset_name='myDataset', version_name='training',
|
||||
roi_query='label.keyword:\"Car\" AND NOT label.keyword:\"partly_occluded\"')
|
||||
myDataView.add_query(
|
||||
dataset_name='myDataset',
|
||||
version_name='training',
|
||||
roi_query='label.keyword:\"Car\" AND NOT label.keyword:\"partly_occluded\"'
|
||||
)
|
||||
```
|
||||
|
||||
#### Querying Multiple Datasets and Versions
|
||||
@ -215,23 +229,28 @@ from two versions of one Dataset, and one version of another Dataset.
|
||||
# Add queries:
|
||||
|
||||
# The 1st Dataset version
|
||||
myDataView.add_query(dataset_name='dataset_1',
|
||||
version_name='version_1',
|
||||
roi_query='label.keyword:\"car\" OR label.keyword:\"truck\" OR '
|
||||
'label.keyword:\"bicycle\"')
|
||||
myDataView.add_query(
|
||||
dataset_name='dataset_1',
|
||||
version_name='version_1',
|
||||
roi_query='label.keyword:\"car\" OR label.keyword:\"truck\" OR '
|
||||
'label.keyword:\"bicycle\"'
|
||||
)
|
||||
|
||||
# The 1st Dataset, but a different version
|
||||
myDataView.add_query(dataset_name='dataset_1',
|
||||
version_name='version_2',
|
||||
roi_query='label.keyword:\"car\" OR label.keyword:\"truck\" OR '
|
||||
'label.keyword:\"bicycle\"')
|
||||
myDataView.add_query(
|
||||
dataset_name='dataset_1',
|
||||
version_name='version_2',
|
||||
roi_query='label.keyword:\"car\" OR label.keyword:\"truck\" OR '
|
||||
'label.keyword:\"bicycle\"'
|
||||
)
|
||||
|
||||
# A 2nd Dataset (version)
|
||||
myDataView.add_query(dataset_name='dataset_2',
|
||||
version_name='some_version',
|
||||
roi_query='label.keyword:\"car\" OR label.keyword:\"truck\" OR '
|
||||
'label.keyword:\"bicycle\"')
|
||||
|
||||
myDataView.add_query(
|
||||
dataset_name='dataset_2',
|
||||
version_name='some_version',
|
||||
roi_query='label.keyword:\"car\" OR label.keyword:\"truck\" OR '
|
||||
'label.keyword:\"bicycle\"'
|
||||
)
|
||||
```
|
||||
|
||||
#### Frame Queries
|
||||
@ -246,16 +265,18 @@ This example demonstrates a frame query filtering for frames containing the meta
|
||||
|
||||
```python
|
||||
# Add a frame query for frames with the meta key "city" value of "bremen"
|
||||
myDataView.add_query(dataset_name='myDataset',
|
||||
version_name='version',
|
||||
frame_query='meta.city:"bremen"')
|
||||
myDataView.add_query(
|
||||
dataset_name='myDataset',
|
||||
version_name='version',
|
||||
frame_query='meta.city:"bremen"'
|
||||
)
|
||||
```
|
||||
|
||||
|
||||
### Controlling Query Iteration
|
||||
|
||||
Use `DataView.set_iteration_parameters` to manage the order, number, timing, and reproducibility of frames
|
||||
for training.
|
||||
Use [`DataView.set_iteration_parameters`](../references/hyperdataset/dataview.md#set_iteration_parameters) to manage the
|
||||
order, number, timing, and reproducibility of frames for training.
|
||||
|
||||
|
||||
#### 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
|
||||
myDataView.set_iteration_parameters(
|
||||
order=IterationOrder.random, infinite=False)
|
||||
order=IterationOrder.random,
|
||||
infinite=False
|
||||
)
|
||||
|
||||
# Add a query for a Dataset version
|
||||
myDataView.add_query(dataset_name='myDataset',
|
||||
version_name='myVersion', roi_query='cat')
|
||||
myDataView.add_query(
|
||||
dataset_name='myDataset',
|
||||
version_name='myVersion',
|
||||
roi_query='cat'
|
||||
)
|
||||
```
|
||||
|
||||
#### 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
|
||||
myDataView.set_iteration_parameters(
|
||||
order=IterationOrder.random, infinite=False,
|
||||
maximum_number_of_frames=5000)
|
||||
order=IterationOrder.random,
|
||||
infinite=False,
|
||||
maximum_number_of_frames=5000
|
||||
)
|
||||
```
|
||||
|
||||
### Debiasing Input Data
|
||||
|
||||
Debias input data using the `DataView.add_query` method's `weight` 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.
|
||||
Debias input data using the [`DataView.add_query`](../references/hyperdataset/dataview.md#add_query) method's `weight`
|
||||
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`
|
||||
(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)
|
||||
|
||||
# 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"
|
||||
myDataView.add_query(dataset_name='dataset_2', version_name='aVersion',
|
||||
roi_query='car')
|
||||
myDataView.add_query(
|
||||
dataset_name='dataset_2',
|
||||
version_name='aVersion',
|
||||
roi_query='car'
|
||||
)
|
||||
|
||||
# A 3rd Dataset (version) - "Car" with uppercase "C"
|
||||
myDataView.add_query(dataset_name='dataset_3', version_name='training',
|
||||
roi_query='Car')
|
||||
myDataView.add_query(
|
||||
dataset_name='dataset_3',
|
||||
version_name='training',
|
||||
roi_query='Car'
|
||||
)
|
||||
|
||||
# Use a mapping rule to translate "Car" (uppercase) to "car" (lowercase)
|
||||
myDataView.add_mapping_rule(dataset_name='dataset_3',
|
||||
version_name='training',
|
||||
from_labels=['Car'],
|
||||
to_label='car')
|
||||
myDataView.add_mapping_rule(
|
||||
dataset_name='dataset_3',
|
||||
version_name='training',
|
||||
from_labels=['Car'],
|
||||
to_label='car'
|
||||
)
|
||||
```
|
||||
|
||||
### 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)
|
||||
|
||||
# Add a query for a Dataset version
|
||||
myDataView.add_query(dataset_name='myDataset', version_name='myVersion',
|
||||
roi_query='cat')
|
||||
myDataView.add_query(
|
||||
dataset_name='myDataset',
|
||||
version_name='myVersion',
|
||||
roi_query='cat'
|
||||
)
|
||||
|
||||
myDataView.add_query(dataset_name='myDataset', version_name='myVersion',
|
||||
roi_query='dog')
|
||||
myDataView.add_query(
|
||||
dataset_name='myDataset',
|
||||
version_name='myVersion',
|
||||
roi_query='dog'
|
||||
)
|
||||
|
||||
myDataView.add_query(dataset_name='myDataset', version_name='myVersion',
|
||||
roi_query='bird')
|
||||
myDataView.add_query(
|
||||
dataset_name='myDataset',
|
||||
version_name='myVersion',
|
||||
roi_query='bird'
|
||||
)
|
||||
|
||||
myDataView.add_query(dataset_name='myDataset', version_name='myVersion',
|
||||
roi_query='sheep')
|
||||
myDataView.add_query(
|
||||
dataset_name='myDataset',
|
||||
version_name='myVersion',
|
||||
roi_query='sheep'
|
||||
)
|
||||
|
||||
myDataView.add_query(dataset_name='myDataset', version_name='myVersion',
|
||||
roi_query='cow')
|
||||
myDataView.add_query(
|
||||
dataset_name='myDataset',
|
||||
version_name='myVersion',
|
||||
roi_query='cow'
|
||||
)
|
||||
|
||||
# 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()
|
||||
|
||||
# Create a SingleFrame
|
||||
frame = SingleFrame(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')
|
||||
frame = SingleFrame(
|
||||
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.
|
||||
frame_group['FrameOne'] = frame
|
||||
@ -54,7 +57,9 @@ To add FrameGroups to a Dataset Version:
|
||||
frame_group = FrameGroup()
|
||||
|
||||
# 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.
|
||||
frame_group['FrameOne'] = single_frame
|
||||
@ -74,9 +79,11 @@ To access a FrameGroup, use the `DatasetVersion.get_single_frame` method, just l
|
||||
|
||||
```python
|
||||
# Get the FrameGroup
|
||||
frame_group = DatasetVersion.get_single_frame(frame_id='f3ed0e09bf23fc947f426a0d254c652c',
|
||||
dataset_name='MyDataset',
|
||||
version_name='FrameGroup')
|
||||
frame_group = DatasetVersion.get_single_frame(
|
||||
frame_id='f3ed0e09bf23fc947f426a0d254c652c',
|
||||
dataset_name='MyDataset',
|
||||
version_name='FrameGroup'
|
||||
)
|
||||
```
|
||||
|
||||
### Updating FrameGroups
|
||||
@ -88,8 +95,11 @@ SingleFrame needs to be referenced using its name as the key in the FrameGroup.
|
||||
frames = []
|
||||
|
||||
# Get the FrameGroup
|
||||
frame_group = DatasetVersion.get_single_frame(frame_id='f3ed0e09bf23fc947f426a0d254c652c',
|
||||
dataset_name='MyDataset', version_name='FrameGroup')
|
||||
frame_group = DatasetVersion.get_single_frame(
|
||||
frame_id='f3ed0e09bf23fc947f426a0d254c652c',
|
||||
dataset_name='MyDataset',
|
||||
version_name='FrameGroup'
|
||||
)
|
||||
|
||||
# Add metadata by referencing the name of the SingleFrame in the FrameGroup
|
||||
frame_group['FrameOne'].metadata['new_key'] = 'new_value'
|
||||
@ -102,15 +112,18 @@ myVersion.update_frames(frames)
|
||||
|
||||
### Deleting Frames
|
||||
|
||||
To delete a FrameGroup, use the `DatasetVersion.delete_frames` method, just like when deleting a
|
||||
SingleFrame, except that a FrameGroup is being referenced.
|
||||
To delete a FrameGroup, use the [`DatasetVersion.delete_frames`](../references/hyperdataset/hyperdatasetversion.md#delete_frames)
|
||||
method, just like when deleting a SingleFrame, except that a FrameGroup is being referenced.
|
||||
|
||||
```python
|
||||
frames = []
|
||||
|
||||
# Get the FrameGroup
|
||||
frame_group = DatasetVersion.get_single_frame(frame_id='f3ed0e09bf23fc947f426a0d254c652c',
|
||||
dataset_name='MyDataset', version_name='FrameGroup')
|
||||
frame_group = DatasetVersion.get_single_frame(
|
||||
frame_id='f3ed0e09bf23fc947f426a0d254c652c',
|
||||
dataset_name='MyDataset',
|
||||
version_name='FrameGroup'
|
||||
)
|
||||
|
||||
# Delete the FrameGroup
|
||||
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
|
||||
|
||||
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
|
||||
To add a mask annotation to a frame, use the [`SingleFrame.add_annotation`](../references/hyperdataset/singleframe.md#add_annotation).
|
||||
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
|
||||
|
@ -194,7 +194,7 @@ For more information about using Frames in the WebApp, see [Working with Frames]
|
||||
|
||||
### 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
|
||||
* 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
|
||||
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
|
||||
from allegroai import DatasetVersion
|
||||
frame = DatasetVersion.get_single_frame(frame_id='dcd81d094ab44e37875c13f2014530ae',
|
||||
dataset_name='MyDataset', # OR dataset_id='80ccb3ae11a74b91b1c6f25f98539039'
|
||||
version_name='SingleFrame' # OR version_id='b07b626e3b6f4be7be170a2f39e14bfb'
|
||||
)
|
||||
frame = DatasetVersion.get_single_frame(
|
||||
frame_id='dcd81d094ab44e37875c13f2014530ae',
|
||||
dataset_name='MyDataset', # OR dataset_id='80ccb3ae11a74b91b1c6f25f98539039'
|
||||
version_name='SingleFrame' # OR version_id='b07b626e3b6f4be7be170a2f39e14bfb'
|
||||
)
|
||||
```
|
||||
|
||||
To access a SingleFrame, the following must be specified:
|
||||
@ -266,23 +268,30 @@ To access a SingleFrame, the following must be specified:
|
||||
### Updating SingleFrames
|
||||
|
||||
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
|
||||
* 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
|
||||
frames = []
|
||||
|
||||
# get the SingleFrame
|
||||
frame = DatasetVersion.get_single_frame(frame_id='dcd81d094ab44e37875c13f2014530ae',
|
||||
dataset_name='MyDataset',
|
||||
version_name='SingleFrame')
|
||||
frame = DatasetVersion.get_single_frame(
|
||||
frame_id='dcd81d094ab44e37875c13f2014530ae',
|
||||
dataset_name='MyDataset',
|
||||
version_name='SingleFrame'
|
||||
)
|
||||
|
||||
# make changes to the frame
|
||||
## add a new annotation
|
||||
frame.add_annotation(poly2d_xy=[154, 343, 209, 343, 209, 423, 154, 423],
|
||||
labels=['tire'], metadata={'alive': 'no'},
|
||||
confidence=0.5)
|
||||
frame.add_annotation(
|
||||
poly2d_xy=[154, 343, 209, 343, 209, 423, 154, 423],
|
||||
labels=['tire'],
|
||||
metadata={'alive': 'no'},
|
||||
confidence=0.5
|
||||
)
|
||||
|
||||
## add metadata
|
||||
frame.meta['road_hazard'] = 'yes'
|
||||
@ -296,14 +305,18 @@ myDatasetVersion.update_frames(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
|
||||
frames = []
|
||||
|
||||
# get the SingleFrame
|
||||
frame = DatasetVersion.get_single_frame(frame_id='f3ed0e09bf23fc947f426a0d254c652c',
|
||||
dataset_name='MyDataset', version_name='FrameGroup')
|
||||
frame = DatasetVersion.get_single_frame(
|
||||
frame_id='f3ed0e09bf23fc947f426a0d254c652c',
|
||||
dataset_name='MyDataset',
|
||||
version_name='FrameGroup'
|
||||
)
|
||||
|
||||
# delete the SingleFrame
|
||||
frames.append(frame)
|
||||
|
Loading…
Reference in New Issue
Block a user