@@ -66,10 +66,12 @@ def annotations(self) -> List[Annotation]:
66
66
detection_annotation = Annotation (
67
67
shape = rectangle ,
68
68
labels = [ScoredLabel (label = labels [0 ])],
69
+ id = ID ("detection_annotation_1" ),
69
70
)
70
71
segmentation_annotation = Annotation (
71
72
shape = other_rectangle ,
72
73
labels = [ScoredLabel (label = labels [1 ])],
74
+ id = ID ("segmentation_annotation_1" ),
73
75
)
74
76
return [detection_annotation , segmentation_annotation ]
75
77
@@ -107,6 +109,7 @@ def roi(self):
107
109
modification_date = datetime .datetime (year = 2021 , month = 12 , day = 9 ),
108
110
),
109
111
labels = self .roi_scored_labels (),
112
+ id = ID ("roi_annotation" ),
110
113
)
111
114
return roi
112
115
@@ -158,6 +161,7 @@ def compare_denormalized_annotations(
158
161
expected_annotation = expected_annotations [index ]
159
162
# Redefining id and modification_date required because of new Annotation objects created after shape
160
163
# denormalize
164
+ actual_annotation .id_ = expected_annotation .id_
161
165
actual_annotation .shape .modification_date = (
162
166
expected_annotation .shape .modification_date
163
167
)
@@ -187,10 +191,12 @@ def annotations_to_add(self) -> List[Annotation]:
187
191
annotation_to_add = Annotation (
188
192
shape = Rectangle (x1 = 0.1 , y1 = 0.1 , x2 = 0.7 , y2 = 0.8 ),
189
193
labels = [ScoredLabel (label = labels_to_add [0 ])],
194
+ id = ID ("added_annotation_1" ),
190
195
)
191
196
other_annotation_to_add = Annotation (
192
197
shape = Rectangle (x1 = 0.2 , y1 = 0.3 , x2 = 0.8 , y2 = 0.9 ),
193
198
labels = [ScoredLabel (label = labels_to_add [1 ])],
199
+ id = ID ("added_annotation_2" ),
194
200
)
195
201
return [annotation_to_add , other_annotation_to_add ]
196
202
@@ -393,6 +399,7 @@ def test_dataset_item_roi_numpy(self):
393
399
rectangle_roi = Annotation (
394
400
Rectangle (x1 = 0.2 , y1 = 0.1 , x2 = 0.8 , y2 = 0.9 ),
395
401
[ScoredLabel (roi_label )],
402
+ ID ("rectangle_roi" ),
396
403
)
397
404
assert np .array_equal (
398
405
dataset_item .roi_numpy (rectangle_roi ), media .numpy [1 :9 , 3 :13 ]
@@ -401,6 +408,7 @@ def test_dataset_item_roi_numpy(self):
401
408
ellipse_roi = Annotation (
402
409
Ellipse (x1 = 0.1 , y1 = 0.0 , x2 = 0.9 , y2 = 0.8 ),
403
410
[ScoredLabel (roi_label )],
411
+ ID ("ellipse_roi" ),
404
412
)
405
413
assert np .array_equal (
406
414
dataset_item .roi_numpy (ellipse_roi ), media .numpy [0 :8 , 2 :14 ]
@@ -417,6 +425,7 @@ def test_dataset_item_roi_numpy(self):
417
425
]
418
426
),
419
427
labels = [],
428
+ id = ID ("polygon_roi" ),
420
429
)
421
430
assert np .array_equal (
422
431
dataset_item .roi_numpy (polygon_roi ), media .numpy [4 :8 , 5 :13 ]
@@ -616,6 +625,8 @@ def test_dataset_item_append_annotations(self):
616
625
)
617
626
dataset_item .append_annotations (annotations_to_add )
618
627
# Random id is generated for normalized annotations
628
+ normalized_annotations [0 ].id_ = dataset_item .annotation_scene .annotations [2 ].id_
629
+ normalized_annotations [1 ].id_ = dataset_item .annotation_scene .annotations [3 ].id_
619
630
assert (
620
631
dataset_item .annotation_scene .annotations
621
632
== full_box_annotations + normalized_annotations
@@ -633,6 +644,7 @@ def test_dataset_item_append_annotations(self):
633
644
incorrect_shape_annotation = Annotation (
634
645
shape = incorrect_polygon ,
635
646
labels = [ScoredLabel (incorrect_shape_label )],
647
+ id = ID ("incorrect_shape_annotation" ),
636
648
)
637
649
dataset_item .append_annotations ([incorrect_shape_annotation ])
638
650
assert (
0 commit comments