def to_labels(
        self,
        frame_size,
        label_types,
        seg_type,
        stream_infos,
        skeleton=None,
        skeleton_key=None,
    ):
        """Converts the stored :class:`OpenLABELObject` to FiftyOne labels.

        Args:
            frame_size: the size of the image frame in pixels (width, height)
            label_types: a list of label types to load
            seg_type: the :class:`SegmentationType` to use to store
                segmentations
            stream_infos: the :class:`OpenLABELStreamInfos` containing
                sample-level attributes to parse into labels
            skeleton (None): a
                :class:`fiftyone.core.odm.dataset.KeypointSkeleton` to use when
                loading keypoint annotations
            skeleton_key (None): the name of the field in the OpenLABEL
                annotations containing the labels of keypoints matching the
                labels of the given skeleton

        Returns:
            a dictionary of sample level fields and label objects and a
            dictionary of frame numbers to frame level fields and label objects
        """
        frame_dets = defaultdict(list)
        frame_kps = defaultdict(list)
        frame_segs = defaultdict(list)
        for obj in self.all_objects:
            if "detections" in label_types:
                for frame_number, dets in obj.to_detections(
                    frame_size
                ).items():
                    frame_dets[frame_number].extend(dets)

            if "keypoints" in label_types:
                for frame_number, kps in obj.to_keypoints(
                    frame_size, skeleton=skeleton, skeleton_key=skeleton_key
                ).items():
                    frame_kps[frame_number].extend(kps)

            if "segmentations" in label_types:
                for frame_number, segs in obj.to_polylines(frame_size).items():
                    if seg_type == SegmentationType.POLYLINE:
                        _segs = segs
                    elif seg_type == SegmentationType.INSTANCE:
                        _segs = []
                        for seg in segs:
                            _segs.append(
                                seg.to_detection(frame_size=frame_size)
                            )
                    else:
                        raise NotImplementedError(
                            "Loading semantic segmentations is not yet "
                            "supported"
                        )
                    frame_segs[frame_number].extend(_segs)

        sample_labels = stream_infos.get_stream_attributes()

        frame_labels = defaultdict(dict)
        for frame_number in stream_infos.frame_numbers:
            frame_labels[frame_number] = stream_infos.get_stream_attributes(
                frame_number=frame_number
            )

        for frame_number, dets in frame_dets.items():
            frame_labels[frame_number]["detections"] = fol.Detections(
                detections=dets
            )

        for frame_number, kps in frame_kps.items():
            frame_labels[frame_number]["keypoints"] = fol.Keypoints(
                keypoints=kps
            )

        for frame_number, segs in frame_segs.items():
            if seg_type == SegmentationType.POLYLINE:
                frame_labels[frame_number]["segmentations"] = fol.Polylines(
                    polylines=segs
                )
            elif seg_type == SegmentationType.INSTANCE:
                frame_labels[frame_number]["segmentations"] = fol.Detections(
                    detections=segs
                )
            else:
                raise NotImplementedError(
                    "Loading semantic segmentations is not yet supported"
                )

        sample_labels.update(frame_labels.pop(None, {}))

        return sample_labels, dict(frame_labels)
Converts the stored :class:`OpenLABELObject` to FiftyOne labels.

        Args:
            frame_size: the size of the image frame in pixels (width, height)
            label_types: a list of label types to load
            seg_type: the :class:`SegmentationType` to use to store
                segmentations
            stream_infos: the :class:`OpenLABELStreamInfos` containing
                sample-level attributes to parse into labels
            skeleton (None): a
                :class:`fiftyone.core.odm.dataset.KeypointSkeleton` to use when
                loading keypoint annotations
            skeleton_key (None): the name of the field in the OpenLABEL
                annotations containing the labels of keypoints matching the
                labels of the given skeleton

        Returns:
            a dictionary of sample level fields and label objects and a
            dictionary of frame numbers to frame level fields and label objects
        
fiftyone/utils/openlabel.py