Skip to content

Commit 076f4bb

Browse files
committed
Fix converter for old jsons
1 parent 2426228 commit 076f4bb

File tree

6 files changed

+65
-2
lines changed

6 files changed

+65
-2
lines changed

superannotate/input_converters/converters/coco_converters/coco_converter.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
class CocoBaseStrategy(baseStrategy):
2020
project_type_to_json_ending = {
21+
'Pixel': '___pixel.json',
22+
'Vector': '___objects.json',
2123
'pixel': '___pixel.json',
2224
'vector': '___objects.json'
2325
}
@@ -169,11 +171,10 @@ def _parse_json_into_common_format(self, sa_annotation_json, fpath):
169171

170172
if 'name' not in sa_annotation_json[
171173
'metadata'] or sa_annotation_json['metadata']['name'] is None:
172-
fname = fpath.split('/')[-1]
174+
fname = fpath.name
173175
fname = fname[:-len(
174176
self.project_type_to_json_ending[self.project_type]
175177
)]
176-
177178
sa_annotation_json['metadata']['name'] = fname
178179
sa_annotation_json['metadata']['image_path'] = str(
179180
Path(fpath).parent / sa_annotation_json['metadata']['name']
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[{"id":599064,"project_id":76203,"name":"some","color":"#c444de","count":0,"createdAt":"2021-05-04T07:26:32.000Z","updatedAt":"2021-05-04T07:26:32.000Z","attribute_groups":[]}]
110 KB
Loading
10.8 KB
Loading
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"metadata": {
3+
"lastAction": {
4+
"email": "",
5+
"timestamp": 1621320107809
6+
},
7+
"width": 1234,
8+
"height": 1540,
9+
"projectId": 76203,
10+
"isPredicted": false,
11+
"status": "Completed",
12+
"pinned": false,
13+
"annotatorEmail": null,
14+
"qaEmail": null
15+
},
16+
"comments": [],
17+
"tags": [],
18+
"instances": [
19+
{
20+
"type": "bbox",
21+
"classId": 599064,
22+
"probability": 100,
23+
"points": {
24+
"x1": 312.52,
25+
"x2": 1053.63,
26+
"y1": 291.08,
27+
"y2": 1405.83
28+
},
29+
"groupId": 0,
30+
"pointLabels": {},
31+
"locked": false,
32+
"visible": true,
33+
"attributes": [],
34+
"trackingId": null,
35+
"error": null,
36+
"createdAt": "2021-05-18T06:41:55.965Z",
37+
"createdBy": {
38+
"email": "",
39+
"role": "Admin"
40+
},
41+
"creationType": "Manual",
42+
"updatedAt": "2021-05-18T06:42:30.415Z",
43+
"updatedBy": {
44+
"email": "",
45+
"role": "Admin"
46+
},
47+
"className": "some"
48+
}
49+
]
50+
}

tests/converter_test/test_conversion.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,14 @@ def test_instance_segmentation_sa2coco_vector_empty_array(tmpdir):
113113
with open(truth_path, 'r') as f:
114114
truth = json.loads(f.read())
115115
assert truth == data
116+
117+
118+
def test_instance_segmentation_sa2coco_vector_empty_name(tmpdir):
119+
input_dir = Path(
120+
"tests"
121+
) / "converter_test" / "COCO" / "input" / "fromSuperAnnotate" / "vector_no_name"
122+
out_path = Path("sssss1") / "fromSuperAnnotate" / "instance_test_vector"
123+
sa.export_annotation(
124+
input_dir, out_path, "COCO", "instance_test_vector", "Vector",
125+
"instance_segmentation"
126+
)

0 commit comments

Comments
 (0)