Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ output/
.venv/
.env
!tests/files/*
.idea
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2655,6 +2655,46 @@ client.download_dataset_objects(
)
```

### Update Dataset Object
```python
dataset_object = client.update_dataset_object(
dataset_id="YOUR_DATASET_ID",
object_name="brushwood_dog.jpg",
tags=["dog"], # max 5 tags per dataset object.
annotations=[
{
"keypoints": [
{
"value": [
102.59,
23.04,
1
],
"key": "head"
}
],
"attributes": [
{
"value": "Scottish field",
"key": "kind"
}
],
"confidenceScore": 0,
"rotation": 0,
"points": [
0
],
"value": "dog",
"type": "bbox" # type can be 'bbox', 'segmentation'.
}
],
custom_metadata={
"key": "value",
"metadata": "metadata-value"
}
)
```

### Delete Dataset Object

Delete a single dataset object.
Expand Down
12 changes: 12 additions & 0 deletions examples/update_dataset_object.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from pprint import pprint

import fastlabel

client = fastlabel.Client()

dataset_object = client.update_dataset_object(
dataset_id="YOUR_DATASET_ID",
object_name="OBJECT_NAME",
tags=["TAG1", "TAG2"],
)
pprint(dataset_object)
23 changes: 22 additions & 1 deletion fastlabel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4043,7 +4043,10 @@ def download_dataset_objects(
for _type, objects in object_map.items():
base_path = download_path / _type
with ThreadPoolExecutor(max_workers=4) as executor:
futures = [executor.submit(self.__download_dataset_object, base_path, obj) for obj in objects]
futures = [
executor.submit(self.__download_dataset_object, base_path, obj)
for obj in objects
]
wait(futures)

# check specification
Expand Down Expand Up @@ -4113,6 +4116,24 @@ def create_dataset_object(
payload["customMetadata"] = custom_metadata
return self.api.post_request(endpoint, payload=payload)

def update_dataset_object(
self,
dataset_id: str,
object_name: str,
tags: Optional[List[str]] = None,
annotations: Optional[List[dict]] = None,
custom_metadata: Optional[dict] = None,
) -> dict:
endpoint = "dataset-objects-v2"
payload = {"datasetId": dataset_id, "objectName": object_name}
if tags is not None:
payload["tags"] = tags
if annotations is not None:
payload["annotations"] = annotations
if custom_metadata is not None:
payload["customMetadata"] = custom_metadata
return self.api.put_request(endpoint, payload=payload)

def delete_dataset_object(self, dataset_id: str, object_name: str) -> None:
"""
Delete a dataset object.
Expand Down