From 221eaede2527c4b8ce573680f89762d85321cbec Mon Sep 17 00:00:00 2001 From: daichi Date: Fri, 20 May 2022 21:01:28 +0900 Subject: [PATCH 1/6] feat: add integrate audio task --- fastlabel/__init__.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/fastlabel/__init__.py b/fastlabel/__init__.py index c94be6b..d6faa18 100644 --- a/fastlabel/__init__.py +++ b/fastlabel/__init__.py @@ -1573,6 +1573,39 @@ def delete_task(self, task_id: str) -> None: endpoint = "tasks/" + task_id self.api.delete_request(endpoint) + # Integrate Task + + def integrate_audio_task_by_prefix( + self, + project: str, + prefix: str, + offset: int = None, + limit: int = 100, + ) -> list: + """ + Returns a list of integrate audio tasks. + Returns up to 10 at a time, to get more, set offset as the starting position + to fetch. + + project is slug of your project (Required). + prefix is a prefix of task name (Required). + offset is the starting position number to fetch (Optional). + limit is the max number to fetch (Optional). + """ + if limit > 1000: + raise FastLabelInvalidException( + "Limit must be less than or equal to 1000.", 422 + ) + endpoint = "tasks/integrate/audio" + params = {"project": project} + params["prefix"] = prefix + if offset: + params["offset"] = offset + if limit: + params["limit"] = limit + return self.api.get_request(endpoint, params=params) + + # Convert to Fastlabel def convert_coco_to_fastlabel(self, file_path: str) -> dict: From 94792129e8071d2be785d2f46140576d79f19b8b Mon Sep 17 00:00:00 2001 From: daichi Date: Thu, 26 May 2022 13:37:51 +0900 Subject: [PATCH 2/6] fix readme --- README.md | 50 +++++++++++++++++++++++++++++++++++++++++++ fastlabel/__init__.py | 24 +++++---------------- 2 files changed, 55 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 57a98ff..3d3ec33 100644 --- a/README.md +++ b/README.md @@ -1108,6 +1108,56 @@ Example of a single audio task object } ``` +#### Integrate Task + +Integration is possible only when tasks are registered from the objects divided by the dataset. + +In the case of a task divided under the following conditions. + +dataset slug: audio +object name: voice.mp3 +split count: 3 + +Objects are registered in the data set in the following form. + +- audio/voice/1.mp3 +- audio/voice/2.mp3 +- audio/voice/3.mp3 + +Annotations are combined when the end point specified in the annotation is the end time of the task and the start point of the next task is 0 seconds. + +In this case, SPLIT_AUDIO_TASK_NAME_PREFIX specifies `audio/voice`. + +```python +task = client.integrate_audio_task_by_prefix( + project="YOUR_PROJECT_SLUG", + prefix="SPLIT_AUDIO_TASK_NAME_PREFIX", +) +``` + +##### Response + +Example of a integrate audio task object + +```python +{ + 'groupId': 'eda3ba5b-082c-4813-ad6c-0479b72a27d5', + 'name': 'audio/voice.mp3', + "annotations": [ + { + "attributes": [], + "color": "#b36d18", + "start": 0.4, + "end": 0.5, + "title": "Bird", + "type": "segmentation", + "value": "bird" + } + ], +} +``` + + ### Audio Classification Supported following project types: diff --git a/fastlabel/__init__.py b/fastlabel/__init__.py index d6faa18..8706fb5 100644 --- a/fastlabel/__init__.py +++ b/fastlabel/__init__.py @@ -1579,30 +1579,16 @@ def integrate_audio_task_by_prefix( self, project: str, prefix: str, - offset: int = None, - limit: int = 100, - ) -> list: + ) -> dict: """ - Returns a list of integrate audio tasks. - Returns up to 10 at a time, to get more, set offset as the starting position - to fetch. + Returns a integrate audio task. project is slug of your project (Required). prefix is a prefix of task name (Required). - offset is the starting position number to fetch (Optional). - limit is the max number to fetch (Optional). """ - if limit > 1000: - raise FastLabelInvalidException( - "Limit must be less than or equal to 1000.", 422 - ) - endpoint = "tasks/integrate/audio" - params = {"project": project} - params["prefix"] = prefix - if offset: - params["offset"] = offset - if limit: - params["limit"] = limit + endpoint = "tasks/integrate/audios" + params = {"project": project, "prefix": prefix} + return self.api.get_request(endpoint, params=params) From af1a74c687bd40e95a18b6fb9a10c9f0ca8b5506 Mon Sep 17 00:00:00 2001 From: daichi Date: Thu, 26 May 2022 13:45:07 +0900 Subject: [PATCH 3/6] fix method name --- README.md | 2 +- fastlabel/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3d3ec33..f0a7a07 100644 --- a/README.md +++ b/README.md @@ -1129,7 +1129,7 @@ Annotations are combined when the end point specified in the annotation is the e In this case, SPLIT_AUDIO_TASK_NAME_PREFIX specifies `audio/voice`. ```python -task = client.integrate_audio_task_by_prefix( +task = client.find_integrated_audio_task_by_prefix( project="YOUR_PROJECT_SLUG", prefix="SPLIT_AUDIO_TASK_NAME_PREFIX", ) diff --git a/fastlabel/__init__.py b/fastlabel/__init__.py index 8706fb5..4eb6ed8 100644 --- a/fastlabel/__init__.py +++ b/fastlabel/__init__.py @@ -1575,7 +1575,7 @@ def delete_task(self, task_id: str) -> None: # Integrate Task - def integrate_audio_task_by_prefix( + def find_integrated_audio_task_by_prefix( self, project: str, prefix: str, From e4c0a11c60f30676029d28ab0fa897e808377aeb Mon Sep 17 00:00:00 2001 From: daichi Date: Mon, 30 May 2022 13:28:48 +0900 Subject: [PATCH 4/6] fix method name --- README.md | 2 +- fastlabel/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f0a7a07..238a522 100644 --- a/README.md +++ b/README.md @@ -1129,7 +1129,7 @@ Annotations are combined when the end point specified in the annotation is the e In this case, SPLIT_AUDIO_TASK_NAME_PREFIX specifies `audio/voice`. ```python -task = client.find_integrated_audio_task_by_prefix( +task = client.integrated_audio_task_by_prefix( project="YOUR_PROJECT_SLUG", prefix="SPLIT_AUDIO_TASK_NAME_PREFIX", ) diff --git a/fastlabel/__init__.py b/fastlabel/__init__.py index 4eb6ed8..5577f06 100644 --- a/fastlabel/__init__.py +++ b/fastlabel/__init__.py @@ -1575,7 +1575,7 @@ def delete_task(self, task_id: str) -> None: # Integrate Task - def find_integrated_audio_task_by_prefix( + def integrated_audio_task_by_prefix( self, project: str, prefix: str, From fa54d052d9baf4621dadb073b92fc998addf72a0 Mon Sep 17 00:00:00 2001 From: daichi Date: Mon, 30 May 2022 13:39:02 +0900 Subject: [PATCH 5/6] Revert "fix method name" This reverts commit e4c0a11c60f30676029d28ab0fa897e808377aeb. --- README.md | 2 +- fastlabel/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 238a522..f0a7a07 100644 --- a/README.md +++ b/README.md @@ -1129,7 +1129,7 @@ Annotations are combined when the end point specified in the annotation is the e In this case, SPLIT_AUDIO_TASK_NAME_PREFIX specifies `audio/voice`. ```python -task = client.integrated_audio_task_by_prefix( +task = client.find_integrated_audio_task_by_prefix( project="YOUR_PROJECT_SLUG", prefix="SPLIT_AUDIO_TASK_NAME_PREFIX", ) diff --git a/fastlabel/__init__.py b/fastlabel/__init__.py index 5577f06..4eb6ed8 100644 --- a/fastlabel/__init__.py +++ b/fastlabel/__init__.py @@ -1575,7 +1575,7 @@ def delete_task(self, task_id: str) -> None: # Integrate Task - def integrated_audio_task_by_prefix( + def find_integrated_audio_task_by_prefix( self, project: str, prefix: str, From 437f2bed76a658a763edd5d106f1a07f6be198e1 Mon Sep 17 00:00:00 2001 From: daichi Date: Mon, 30 May 2022 13:41:07 +0900 Subject: [PATCH 6/6] fix sentence --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f0a7a07..dea71d5 100644 --- a/README.md +++ b/README.md @@ -1137,7 +1137,7 @@ task = client.find_integrated_audio_task_by_prefix( ##### Response -Example of a integrate audio task object +Example of a integrated audio task object ```python {