code: def yolo_detections_to_norfair_detections(
      yolo_detections: torch.tensor,
      track_points: str = "centroid",  # bbox or centroid
  ) -> List[Detection]:
      """convert detections_as_xywh to norfair detections"""
      norfair_detections: List[Detection] = []
  
      if track_points == "centroid":
          detections_as_xywh = yolo_detections.xywh[0]
          for detection_as_xywh in detections_as_xywh:
              centroid = np.array(
                  [
                      [
                          detection_as_xywh[0].item(),
                          detection_as_xywh[1].item(),
                      ],
                      [
                          detection_as_xywh[0].item(),
                          detection_as_xywh[1].item(),
                      ],
                  ]
              )
              scores = np.array(
                  [
                      detection_as_xywh[4].item(),
                      detection_as_xywh[4].item(),
                  ]
              )
              norfair_detections.append(
                  Detection(points=centroid, scores=scores)
              )
      elif track_points == "bbox":
          detections_as_xyxy = yolo_detections.xyxy[0]
          for detection_as_xyxy in detections_as_xyxy:
              bbox = np.array(
                  [
                      [
                          detection_as_xyxy[0].item(),
                          detection_as_xyxy[1].item(),
                      ],
                      [
                          detection_as_xyxy[2].item(),
                          detection_as_xyxy[3].item(),
                      ],
                  ]
              )
              scores = np.array(
                  [
                      detection_as_xyxy[4].item(),
                      detection_as_xyxy[4].item(),
                  ]
              )
              norfair_detections.append(
                  Detection(points=bbox, scores=scores)
              )
  
      return norfair_detections
  
file_path: norfair/demos/colab/yolo.py
imports: import os
  from typing import List, Optional, Union
  import numpy
  import torch
  from norfair import Detection
label_desc: Use image node_id 1 for calling a global function with example usage: yolo_detections_to_norfair_detections(yolo_detections, track_points) and returns: norfair_detections