code: def record_to_fo_detections(
      record, undo_bbox_tfms
  ) -> Iterable[Detection]:
      if hasattr(record, "detection"):
          if hasattr(record.detection, "bboxes"):
              if hasattr(record.detection, "scores"):
                  detections = [
                      Detection(
                          label=label,
                          bounding_box=undo_bbox_tfms(bbox),
                          confidence=score,
                      )
                      for label, bbox, score in zip(
                          record.detection.labels,
                          record.detection.bboxes,
                          record.detection.scores,
                      )
                  ]
              else:
                  detections = [
                      Detection(
                          label=label, bounding_box=undo_bbox_tfms(bbox)
                      )
                      for label, bbox in zip(
                          record.detection.labels,
                          record.detection.bboxes,
                      )
                  ]
          else:
              raise NotImplementedError(
                  "Fiftyone export support only bboxes yet"
              )
      else:
          raise ValueError(
              f"Provided record does not contain a detection attribute"
          )
  
      return detections
  
file_path: icevision/icevision/data/convert_records_to_fo.py
imports: from PIL import Image
  from warnings import warn
  from pathlib import Path
  from icevision import tfms
  from icevision.core.bbox import BBox
  from icevision.data.prediction import Prediction
  from icevision.models.inference import postprocess_bbox
  from icevision.soft_dependencies import SoftDependencies
  from icevision.utils.imageio import get_img_size
  from typing import Any, Callable, Union, Iterable, List, Tuple
label_desc: Use image node_id 2 for calling a global function with example usage: record_to_fo_detections(record, undo_bbox_tfms) and returns: detections