@@ -707,7 +707,7 @@ def _append_video_scenes(
707707 return response
708708
709709 def iloc (self , i : int ) -> dict :
710- """Retrieves dataset item by absolute numerical index.
710+ """Retrieves dataset item and associated annotations by absolute numerical index.
711711
712712 Parameters:
713713 i: Absolute numerical index of the dataset item within the dataset.
@@ -735,7 +735,7 @@ def iloc(self, i: int) -> dict:
735735
736736 @sanitize_string_args
737737 def refloc (self , reference_id : str ) -> dict :
738- """Retrieves a dataset item by reference ID.
738+ """Retrieves a dataset item and associated annotations by reference ID.
739739
740740 Parameters:
741741 reference_id: User-defined reference ID of the dataset item.
@@ -762,7 +762,7 @@ def refloc(self, reference_id: str) -> dict:
762762 return format_dataset_item_response (response )
763763
764764 def loc (self , dataset_item_id : str ) -> dict :
765- """Retrieves a dataset item by Nucleus-generated ID.
765+ """Retrieves a dataset item and associated annotations by Nucleus-generated ID.
766766
767767 Parameters:
768768 dataset_item_id: Nucleus-generated dataset item ID (starts with ``di_``).
@@ -1178,9 +1178,9 @@ def items_and_annotations(
11781178 "cuboid": Optional[List[CuboidAnnotation]],
11791179 "line": Optional[List[LineAnnotation]],
11801180 "polygon": Optional[List[PolygonAnnotation]],
1181- "keypoints": Optional[List[KeypointsAnnotation]],
11821181 "segmentation": Optional[List[SegmentationAnnotation]],
11831182 "category": Optional[List[CategoryAnnotation]],
1183+ "keypoints": Optional[List[KeypointsAnnotation]],
11841184 }
11851185 }]
11861186 """
@@ -1191,6 +1191,32 @@ def items_and_annotations(
11911191 )
11921192 return convert_export_payload (api_payload [EXPORTED_ROWS ])
11931193
1194+ def items_and_annotation_generator (
1195+ self ,
1196+ ) -> Iterable [Dict [str , Union [DatasetItem , Dict [str , List [Annotation ]]]]]:
1197+ """Provides a generator of all DatasetItems and Annotations in the dataset.
1198+
1199+ Returns:
1200+ Generator where each element is a dict containing the DatasetItem
1201+ and all of its associated Annotations, grouped by type.
1202+ ::
1203+
1204+ Iterable[{
1205+ "item": DatasetItem,
1206+ "annotations": {
1207+ "box": List[BoxAnnotation],
1208+ "polygon": List[PolygonAnnotation],
1209+ "cuboid": List[CuboidAnnotation],
1210+ "line": Optional[List[LineAnnotation]],
1211+ "segmentation": List[SegmentationAnnotation],
1212+ "category": List[CategoryAnnotation],
1213+ "keypoints": List[KeypointsAnnotation],
1214+ }
1215+ }]
1216+ """
1217+ for item in self .items_generator ():
1218+ yield self .refloc (reference_id = item .reference_id )
1219+
11941220 def export_embeddings (
11951221 self ,
11961222 ) -> List [Dict [str , Union [str , List [float ]]]]:
0 commit comments