@@ -65,11 +65,7 @@ def from_common(
6565 cls , data : LabelCollection
6666 ) -> Generator ["NDLabel" , None , None ]:
6767 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 )
7369 yield from cls ._create_non_video_annotations (label )
7470 yield from cls ._create_video_annotations (label )
7571
@@ -195,24 +191,20 @@ def _create_non_video_annotations(cls, label: Label):
195191 )
196192
197193 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