Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more coco dataset examples #83

Merged
merged 2 commits into from
Jan 13, 2021
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
14 changes: 10 additions & 4 deletions datumaro/plugins/coco_format/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import datumaro.util.mask_tools as mask_tools
from datumaro.components.converter import Converter
from datumaro.components.extractor import (_COORDINATE_ROUNDING_DIGITS,
DEFAULT_SUBSET_NAME, AnnotationType, Points)
AnnotationType, Points)
from datumaro.util import cast, find, str_to_bool

from .format import CocoPath, CocoTask
Expand Down Expand Up @@ -144,7 +144,9 @@ def save_annotations(self, item):
log.warning("Item '%s', ann #%s: failed to convert "
"attribute 'score': %e" % (item.id, ann_idx, e))
if self._context._allow_attributes:
elem['attributes'] = self._convert_attributes(ann)
attrs = self._convert_attributes(ann)
if attrs:
elem['attributes'] = attrs

self.annotations.append(elem)

Expand Down Expand Up @@ -317,7 +319,9 @@ def convert_instance(self, instance, item):
log.warning("Item '%s': failed to convert attribute "
"'score': %e" % (item.id, e))
if self._context._allow_attributes:
elem['attributes'] = self._convert_attributes(ann)
attrs = self._convert_attributes(ann)
if attrs:
elem['attributes'] = attrs

return elem

Expand Down Expand Up @@ -434,7 +438,9 @@ def save_annotations(self, item):
log.warning("Item '%s': failed to convert attribute "
"'score': %e" % (item.id, e))
if self._context._allow_attributes:
elem['attributes'] = self._convert_attributes(ann)
attrs = self._convert_attributes(ann)
if attrs:
elem['attributes'] = attrs

self.annotations.append(elem)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"licenses": [{
"name": "",
"id": 0,
"url": ""
}],
"info": {
"contributor": "",
"date_created": "",
"description": "",
"url": "",
"version": "",
"year": ""
},
"categories": [],
"images": [{
"id": 1,
"width": 0,
"height": 0,
"file_name": "1.jpg",
"license": 0,
"flickr_url": "",
"coco_url": "",
"date_captured": 0
}, {
"id": 2,
"width": 0,
"height": 0,
"file_name": "2.jpg",
"license": 0,
"flickr_url": "",
"coco_url": "",
"date_captured": 0
}],
"annotations": [{
"id": 1,
"image_id": 1,
"category_id": 0,
"caption": "hello",
"attributes": {}
}, {
"id": 2,
"image_id": 1,
"category_id": 0,
"caption": "world",
"attributes": {}
}, {
"id": 3,
"image_id": 2,
"category_id": 0,
"caption": "test",
"attributes": {}
}]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"licenses": [{
"name": "",
"id": 0,
"url": ""
}],
"info": {
"contributor": "",
"date_created": "",
"description": "",
"url": "",
"version": "",
"year": ""
},
"categories": [],
"images": [{
"id": 1,
"width": 0,
"height": 0,
"file_name": "3.jpg",
"license": 0,
"flickr_url": "",
"coco_url": "",
"date_captured": 0
}],
"annotations": [{
"id": 1,
"image_id": 1,
"category_id": 0,
"caption": "word",
"attributes": {}
}]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"licenses": [{
"name": "",
"id": 0,
"url": ""
}],
"info": {
"contributor": "",
"date_created": "",
"description": "",
"url": "",
"version": "",
"year": ""
},
"categories": [],
"images": [{
"id": 1,
"width": 15,
"height": 10,
"file_name": "1.jpg",
"license": 0,
"flickr_url": "",
"coco_url": "",
"date_captured": 0
}],
"annotations": []
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@
"segmentation": [[0, 0, 1, 0, 1, 2, 0, 2]],
"area": 2,
"bbox": [0, 0, 1, 2],
"iscrowd": 0
"iscrowd": 0,
"attributes": {
"x": 1, "y": "hello"
}
},
{
"id": 2,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"licenses": [{
"name": "",
"id": 0,
"url": ""
}],
"info": {
"contributor": "",
"date_created": "",
"description": "",
"url": "",
"version": "",
"year": ""
},
"categories": [{
"id": 1,
"name": "a",
"supercategory": ""
}, {
"id": 2,
"name": "b",
"supercategory": ""
}],
"images": [{
"id": 1,
"width": 0,
"height": 0,
"file_name": "1.jpg",
"license": 0,
"flickr_url": "",
"coco_url": "",
"date_captured": 0
}],
"annotations": [{
"id": 1,
"image_id": 1,
"category_id": 2
}, {
"id": 2,
"image_id": 1,
"category_id": 1,
"attributes": {}
}]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{
"licenses": [{
"name": "",
"id": 0,
"url": ""
}],
"info": {
"contributor": "",
"date_created": "",
"description": "",
"url": "",
"version": "",
"year": ""
},
"categories": [{
"id": 1,
"name": "a",
"supercategory": "",
"keypoints": [],
"skeleton": [
[0, 1],
[1, 2]
]
}, {
"id": 2,
"name": "b",
"supercategory": "",
"keypoints": [],
"skeleton": [
[0, 1],
[1, 2]
]
}],
"images": [{
"id": 1,
"width": 5,
"height": 5,
"file_name": "1.jpg",
"license": 0,
"flickr_url": "",
"coco_url": "",
"date_captured": 0
}],
"annotations": [{
"id": 3,
"image_id": 1,
"category_id": 1,
"segmentation": [],
"area": 4.0,
"bbox": [0.0, 1.0, 4.0, 1.0],
"iscrowd": 0,
"keypoints": [1, 2, 2, 0, 2, 2, 4, 1, 2],
"num_keypoints": 3
}, {
"id": 5,
"image_id": 1,
"category_id": 0,
"segmentation": [],
"area": 4.0,
"bbox": [1.0, 2.0, 2.0, 2.0],
"iscrowd": 0,
"keypoints": [0, 0, 0, 1, 2, 1, 3, 4, 2],
"num_keypoints": 2
}, {
"id": 1,
"image_id": 1,
"category_id": 2,
"segmentation": [
[0.0, 0.0, 4.0, 0.0, 4.0, 4.0]
],
"area": 6.0,
"bbox": [0.0, 0.0, 4.0, 4.0],
"iscrowd": 0,
"keypoints": [0, 0, 0, 0, 2, 1, 4, 1, 2],
"num_keypoints": 2
}, {
"id": 2,
"image_id": 1,
"category_id": 0,
"segmentation": [],
"area": 4.0,
"bbox": [1.0, 2.0, 2.0, 2.0],
"iscrowd": 0,
"keypoints": [1, 2, 2, 3, 4, 2, 2, 3, 2],
"num_keypoints": 3
}]
}
Loading