-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basic fix for merged dataset annotations
Fixes how the merged datasets get annotations for all the task types. Probably, need to change it further to use the original GT, as excluded GT annotations will be missing from the result now.
- Loading branch information
1 parent
ba9228f
commit 16c67b0
Showing
4 changed files
with
100 additions
and
14 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
packages/examples/cvat/recording-oracle/src/core/tasks/points.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import os | ||
from pathlib import Path | ||
from tempfile import TemporaryDirectory | ||
|
||
import datumaro as dm | ||
|
||
# These details are relevant for image_points tasks | ||
|
||
|
||
class TaskMetaLayout: | ||
GT_FILENAME = "gt.json" | ||
|
||
|
||
class TaskMetaSerializer: | ||
GT_DATASET_FORMAT = "datumaro" | ||
|
||
def serialize_gt_annotations(self, gt_dataset: dm.Dataset) -> bytes: | ||
with TemporaryDirectory() as temp_dir: | ||
gt_dataset_dir = os.path.join(temp_dir, "gt_dataset") | ||
gt_dataset.export(gt_dataset_dir, self.GT_DATASET_FORMAT) | ||
return (Path(gt_dataset_dir) / "annotations" / "default.json").read_bytes() | ||
|
||
def parse_gt_annotations(self, gt_dataset_data: bytes) -> dm.Dataset: | ||
with TemporaryDirectory() as temp_dir: | ||
annotations_dir = os.path.join(temp_dir, "annotations") | ||
os.makedirs(annotations_dir) | ||
|
||
annotations_filename = os.path.join(annotations_dir, "default.json") | ||
with open(annotations_filename, "wb") as f: | ||
f.write(gt_dataset_data) | ||
|
||
dataset = dm.Dataset.import_from(temp_dir, format=self.GT_DATASET_FORMAT) | ||
dataset.init_cache() | ||
return dataset |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 28 additions & 2 deletions
30
packages/examples/cvat/recording-oracle/src/utils/annotations.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters