code: def convert_raw_prediction(
      sample,
      raw_pred: dict,
      record: BaseRecord,
      detection_threshold: float,
      keep_image: bool = False,
  ):
      above_threshold = raw_pred["scores"] >= detection_threshold
  
      # convert predictions
      labels = raw_pred["labels"][above_threshold]
      labels = labels.detach().cpu().numpy()
  
      scores = raw_pred["scores"][above_threshold]
      scores = scores.detach().cpu().numpy()
  
      boxes = raw_pred["boxes"][above_threshold]
      bboxes = []
      for box_tensor in boxes:
          xyxy = box_tensor.cpu().numpy()
          bbox = BBox.from_xyxy(*xyxy)
          bboxes.append(bbox)
  
      # build prediction
      pred = BaseRecord(
          (
              ScoresRecordComponent(),
              ImageRecordComponent(),
              InstancesLabelsRecordComponent(),
              BBoxesRecordComponent(),
          )
      )
      pred.detection.set_class_map(record.detection.class_map)
      pred.detection.set_scores(scores)
      pred.detection.set_labels_by_id(labels)
      pred.detection.set_bboxes(bboxes)
      pred.detection.above_threshold = above_threshold
  
      if keep_image:
          tensor_image, *_ = sample
          record.set_img(tensor_to_image(tensor_image))
  
      return Prediction(pred=pred, ground_truth=record)
  
file_path: icevision/icevision/models/torchvision/faster_rcnn/prediction.py
imports: from icevision.imports import *
  from icevision.utils import *
  from icevision.core import *
  from icevision.models.utils import _predict_from_dl
  from icevision.data import *
  from icevision.models.torchvision.dataloaders import *
  from icevision.models.inference import *
label_desc: Use image node_id 5 for calling a global function with example usage: convert_raw_prediction(sample, raw_pred, record, detection_threshold, keep_image) and returns: Prediction