Skip to content

Commit 014e369

Browse files
Vaghinak BasentsyanVaghinak Basentsyan
authored andcommitted
Fixed classId filling
1 parent e32b16d commit 014e369

File tree

11 files changed

+3345
-18
lines changed

11 files changed

+3345
-18
lines changed

src/superannotate/lib/app/interface/sdk_interface.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3650,8 +3650,9 @@ def validate_annotations(
36503650
):
36513651
"""Validates given annotation JSON.
36523652
3653-
:param project_type: project_type (str) – the project type Vector, Pixel, Video or Document
3653+
:param project_type: The project type Vector, Pixel, Video or Document
36543654
:type project_type: str
3655+
36553656
:param annotations_json: path to annotation JSON
36563657
:type annotations_json: Path-like (str or Path)
36573658

src/superannotate/lib/core/helpers.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,19 @@ def fill_annotation_ids(
6565
return
6666
unknown_classes = dict()
6767

68-
for annotation in [i for i in annotations["instances"] if "className" in i]:
68+
for annotation in annotations["instances"]:
6969
if "className" not in annotation:
70-
return
71-
annotation_class_name = annotation["className"]
72-
if annotation_class_name not in annotation_classes_name_maps.keys():
73-
if annotation_class_name not in unknown_classes:
74-
reporter.log_warning(f"Couldn't find class {annotation_class_name}")
75-
reporter.store_message("missing_classes", annotation_class_name)
76-
unknown_classes[annotation_class_name] = {
77-
"id": -(len(unknown_classes) + 1),
78-
"attribute_groups": {},
79-
}
70+
annotation["classId"] = -1
71+
else:
72+
annotation_class_name = annotation["className"]
73+
if annotation_class_name not in annotation_classes_name_maps.keys():
74+
if annotation_class_name not in unknown_classes:
75+
reporter.log_warning(f"Couldn't find class {annotation_class_name}")
76+
reporter.store_message("missing_classes", annotation_class_name)
77+
unknown_classes[annotation_class_name] = {
78+
"id": -(len(unknown_classes) + 1),
79+
"attribute_groups": {},
80+
}
8081
annotation_classes_name_maps.update(unknown_classes)
8182
template_name_id_map = {template["name"]: template["id"] for template in templates}
8283
for annotation in (

src/superannotate/lib/core/usecases/annotations.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -412,11 +412,6 @@ def prepare_annotations(
412412
annotations = convert_to_video_editor_json(
413413
annotations, annotation_classes_name_maps, reporter
414414
)
415-
if project_type == constances.ProjectType.DOCUMENT.value:
416-
fill_document_tags(
417-
annotations=annotations,
418-
annotation_classes=annotation_classes_name_maps,
419-
)
420415
handle_last_action(annotations, team)
421416
return annotations
422417

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[{"id":873208,"project_id":160158,"name":"vid","color":"#0fc1c9","count":0,"createdAt":"2021-10-22T10:40:03.000Z","updatedAt":"2021-10-22T10:40:03.000Z","attribute_groups":[{"id":347588,"class_id":873208,"name":"attr g","is_multiselect":0,"createdAt":"2021-10-22T10:40:03.000Z","updatedAt":"2021-10-22T10:40:03.000Z","attributes":[{"id":1203338,"group_id":347588,"project_id":160158,"name":"attr","count":0,"createdAt":"2021-10-22T10:40:03.000Z","updatedAt":"2021-10-22T10:40:03.000Z"}]}]}]
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"metadata": {
3+
"name": "text_file_example_1",
4+
"status": "Completed",
5+
"url": "https://sa-public-files.s3.us-west-2.amazonaws.com/Text+project/text_file_example_1.txt",
6+
"projectId": 160158,
7+
"annotatorEmail": null,
8+
"qaEmail": null,
9+
"lastAction": {
10+
"email": "shab.prog@gmail.com",
11+
"timestamp": 1634899229953
12+
}
13+
},
14+
"instances": [
15+
{
16+
"start": 253,
17+
"end": 593,
18+
"classId": 873208,
19+
"createdAt": "2021-10-22T10:40:26.151Z",
20+
"createdBy": {
21+
"email": "shab.prog@gmail.com",
22+
"role": "Admin"
23+
},
24+
"updatedAt": "2021-10-22T10:40:29.953Z",
25+
"updatedBy": {
26+
"email": "shab.prog@gmail.com",
27+
"role": "Admin"
28+
},
29+
"attributes": [],
30+
"creationType": "Manual"
31+
}
32+
],
33+
"tags": [
34+
"vid"
35+
],
36+
"freeText": ""
37+
}
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
[
2+
{
3+
"id": 55917,
4+
"project_id": 11979,
5+
"name": "Personal vehicle",
6+
"color": "#ecb65f",
7+
"count": 25,
8+
"createdAt": "2020-10-12T11:35:20.000Z",
9+
"updatedAt": "2020-10-12T11:48:19.000Z",
10+
"attribute_groups": [
11+
{
12+
"id": 17245,
13+
"class_id": 55917,
14+
"name": "Num doors",
15+
"is_multiselect": 0,
16+
"createdAt": "2020-10-12T11:35:20.000Z",
17+
"updatedAt": "2020-10-12T11:35:20.000Z",
18+
"attributes": [
19+
{
20+
"id": 62792,
21+
"group_id": 17245,
22+
"project_id": 11979,
23+
"name": "2",
24+
"count": 1,
25+
"createdAt": "2020-10-12T11:35:20.000Z",
26+
"updatedAt": "2020-10-12T11:46:28.000Z"
27+
},
28+
{
29+
"id": 62793,
30+
"group_id": 17245,
31+
"project_id": 11979,
32+
"name": "4",
33+
"count": 1,
34+
"createdAt": "2020-10-12T11:35:20.000Z",
35+
"updatedAt": "2020-10-12T11:35:20.000Z"
36+
}
37+
]
38+
}
39+
]
40+
},
41+
{
42+
"id": 55918,
43+
"project_id": 11979,
44+
"name": "Large vehicle",
45+
"color": "#737b28",
46+
"count": 1,
47+
"createdAt": "2020-10-12T11:35:20.000Z",
48+
"updatedAt": "2020-10-12T11:48:19.000Z",
49+
"attribute_groups": [
50+
{
51+
"id": 17246,
52+
"class_id": 55918,
53+
"name": "swedish",
54+
"is_multiselect": 0,
55+
"createdAt": "2020-10-12T11:35:20.000Z",
56+
"updatedAt": "2020-10-12T11:35:20.000Z",
57+
"attributes": [
58+
{
59+
"id": 62794,
60+
"group_id": 17246,
61+
"project_id": 11979,
62+
"name": "yes",
63+
"count": 0,
64+
"createdAt": "2020-10-12T11:35:20.000Z",
65+
"updatedAt": "2020-10-12T11:35:20.000Z"
66+
},
67+
{
68+
"id": 62795,
69+
"group_id": 17246,
70+
"project_id": 11979,
71+
"name": "no",
72+
"count": 1,
73+
"createdAt": "2020-10-12T11:35:20.000Z",
74+
"updatedAt": "2020-10-12T11:46:28.000Z"
75+
}
76+
]
77+
},
78+
{
79+
"id": 17247,
80+
"class_id": 55918,
81+
"name": "Num doors",
82+
"is_multiselect": 0,
83+
"createdAt": "2020-10-12T11:35:20.000Z",
84+
"updatedAt": "2020-10-12T11:35:20.000Z",
85+
"attributes": [
86+
{
87+
"id": 62796,
88+
"group_id": 17247,
89+
"project_id": 11979,
90+
"name": "2",
91+
"count": 0,
92+
"createdAt": "2020-10-12T11:35:20.000Z",
93+
"updatedAt": "2020-10-12T11:35:20.000Z"
94+
},
95+
{
96+
"id": 62797,
97+
"group_id": 17247,
98+
"project_id": 11979,
99+
"name": "4",
100+
"count": 1,
101+
"createdAt": "2020-10-12T11:35:20.000Z",
102+
"updatedAt": "2020-10-12T11:46:28.000Z"
103+
}
104+
]
105+
}
106+
]
107+
},
108+
{
109+
"id": 55919,
110+
"project_id": 11979,
111+
"name": "Human",
112+
"color": "#e4542b",
113+
"count": 9,
114+
"createdAt": "2020-10-12T11:35:20.000Z",
115+
"updatedAt": "2020-10-12T11:48:14.000Z",
116+
"attribute_groups": [
117+
{
118+
"id": 17248,
119+
"class_id": 55919,
120+
"name": "Height",
121+
"is_multiselect": 0,
122+
"createdAt": "2020-10-12T11:35:20.000Z",
123+
"updatedAt": "2020-10-12T11:35:20.000Z",
124+
"attributes": [
125+
{
126+
"id": 62798,
127+
"group_id": 17248,
128+
"project_id": 11979,
129+
"name": "Tall",
130+
"count": 0,
131+
"createdAt": "2020-10-12T11:35:20.000Z",
132+
"updatedAt": "2020-10-12T11:35:20.000Z"
133+
},
134+
{
135+
"id": 62799,
136+
"group_id": 17248,
137+
"project_id": 11979,
138+
"name": "Short",
139+
"count": 0,
140+
"createdAt": "2020-10-12T11:35:20.000Z",
141+
"updatedAt": "2020-10-12T11:35:20.000Z"
142+
}
143+
]
144+
}
145+
]
146+
},
147+
{
148+
"id": 55920,
149+
"project_id": 11979,
150+
"name": "Plant",
151+
"color": "#46ccb2",
152+
"count": 0,
153+
"createdAt": "2020-10-12T11:35:20.000Z",
154+
"updatedAt": "2020-10-12T11:35:20.000Z",
155+
"attribute_groups": []
156+
}
157+
]
209 KB
Loading
15.4 KB
Loading

0 commit comments

Comments
 (0)