@@ -65,11 +65,7 @@ def from_common(
65
65
cls , data : LabelCollection
66
66
) -> Generator ["NDLabel" , None , None ]:
67
67
for label in data :
68
- if all (
69
- isinstance (model , RelationshipAnnotation )
70
- for model in label .annotations
71
- ):
72
- yield from cls ._create_relationship_annotations (label )
68
+ yield from cls ._create_relationship_annotations (label )
73
69
yield from cls ._create_non_video_annotations (label )
74
70
yield from cls ._create_video_annotations (label )
75
71
@@ -195,24 +191,20 @@ def _create_non_video_annotations(cls, label: Label):
195
191
)
196
192
197
193
def _create_relationship_annotations (cls , label : Label ):
198
- relationship_annotations = [
199
- annotation
200
- for annotation in label .annotations
201
- if isinstance (annotation , RelationshipAnnotation )
202
- ]
203
- for relationship_annotation in relationship_annotations :
204
- uuid1 = uuid4 ()
205
- uuid2 = uuid4 ()
206
- source = copy .copy (relationship_annotation .value .source )
207
- target = copy .copy (relationship_annotation .value .target )
208
- if not isinstance (source , ObjectAnnotation ) or not isinstance (
209
- target , ObjectAnnotation
210
- ):
211
- raise TypeError (
212
- f"Unable to create relationship with non ObjectAnnotations. `Source: { type (source )} Target: { type (target )} `"
213
- )
214
- if not source ._uuid :
215
- source ._uuid = uuid1
216
- if not target ._uuid :
217
- target ._uuid = uuid2
218
- yield relationship_annotation
194
+ for annotation in label .annotations :
195
+ if isinstance (annotation , RelationshipAnnotation ):
196
+ uuid1 = uuid4 ()
197
+ uuid2 = uuid4 ()
198
+ source = copy .copy (annotation .value .source )
199
+ target = copy .copy (annotation .value .target )
200
+ if not isinstance (source , ObjectAnnotation ) or not isinstance (
201
+ target , ObjectAnnotation
202
+ ):
203
+ raise TypeError (
204
+ f"Unable to create relationship with non ObjectAnnotations. `Source: { type (source )} Target: { type (target )} `"
205
+ )
206
+ if not source ._uuid :
207
+ source ._uuid = uuid1
208
+ if not target ._uuid :
209
+ target ._uuid = uuid2
210
+ yield annotation
0 commit comments