docstr: self._original_predictions is converted to a list of prediction.ObjectPrediction and set to
  self._object_prediction_list_per_image.
  Args:
      shift_amount_list: list of list
          To shift the box and mask predictions from sliced image to full sized image, should
          be in the form of List[[shift_x, shift_y],[shift_x, shift_y],...]
      full_shape_list: list of list
          Size of the full image after shifting, should be in the form of
          List[[height, width],[height, width],...]
docstr_tok: ["self._original_predictions","is","converted","to","a","list","of","prediction.ObjectPrediction","and","set","to","self._object_prediction_list_per_image",".","Args",":","shift_amount_list",":","list","of","list","To","shift","the","box","and","mask","predictions","from","sliced","image","to","full","sized","image",",","should","be","in","the","form","of","List","[","[","shift_x",",","shift_y","]",",","[","shift_x",",","shift_y","]",",","...","]","full_shape_list",":","list","of","list","Size","of","the","full","image","after","shifting",",","should","be","in","the","form","of","List","[","[","height",",","width","]",",","[","height",",","width","]",",","...","]"]
code: def _create_object_prediction_list_from_original_predictions(
      self,
      shift_amount_list: Optional[List[List[int]]] = [[0, 0]],
      full_shape_list: Optional[List[List[int]]] = None,
  ):
      """
      self._original_predictions is converted to a list of prediction.ObjectPrediction and set to
      self._object_prediction_list_per_image.
      Args:
          shift_amount_list: list of list
              To shift the box and mask predictions from sliced image to full sized image, should
              be in the form of List[[shift_x, shift_y],[shift_x, shift_y],...]
          full_shape_list: list of list
              Size of the full image after shifting, should be in the form of
              List[[height, width],[height, width],...]
      """
  
      original_predictions = self._original_predictions
  
      # compatilibty for sahi v0.8.15
      if isinstance(shift_amount_list[0], int):
          shift_amount_list = [shift_amount_list]
      if full_shape_list is not None and isinstance(
          full_shape_list[0], int
      ):
          full_shape_list = [full_shape_list]
  
      # detectron2 DefaultPredictor supports single image
      shift_amount = shift_amount_list[0]
      full_shape = (
          None if full_shape_list is None else full_shape_list[0]
      )
  
      # parse boxes, masks, scores, category_ids from predictions
      boxes = original_predictions["instances"].pred_boxes.tensor
      scores = original_predictions["instances"].scores
      category_ids = original_predictions["instances"].pred_classes
  
      # check if predictions contain mask
      try:
          masks = original_predictions["instances"].pred_masks
      except AttributeError:
          masks = None
  
      # filter predictions with low confidence
      high_confidence_mask = scores >= self.confidence_threshold
      boxes = boxes[high_confidence_mask]
      scores = scores[high_confidence_mask]
      category_ids = category_ids[high_confidence_mask]
      if masks is not None:
          masks = masks[high_confidence_mask]
  
      if masks is not None:
          object_prediction_list = [
              ObjectPrediction(
                  bbox=box.tolist() if mask is None else None,
                  bool_mask=mask.detach().cpu().numpy()
                  if mask is not None
                  else None,
                  category_id=category_id.item(),
                  category_name=self.category_mapping[
                      str(category_id.item())
                  ],
                  shift_amount=shift_amount,
                  score=score.item(),
                  full_shape=full_shape,
              )
              for box, score, category_id, mask in zip(
                  boxes, scores, category_ids, masks
              )
              if mask is None
              or get_bbox_from_bool_mask(mask.detach().cpu().numpy())
              is not None
          ]
      else:
          object_prediction_list = [
              ObjectPrediction(
                  bbox=box.tolist(),
                  bool_mask=None,
                  category_id=category_id.item(),
                  category_name=self.category_mapping[
                      str(category_id.item())
                  ],
                  shift_amount=shift_amount,
                  score=score.item(),
                  full_shape=full_shape,
              )
              for box, score, category_id in zip(
                  boxes, scores, category_ids
              )
          ]
  
      # detectron2 DefaultPredictor supports single image
      object_prediction_list_per_image = [object_prediction_list]
  
      self._object_prediction_list_per_image = (
          object_prediction_list_per_image
      )
  
file_path: sahi/sahi/models/detectron2.py
imports: import logging
  from typing import List, Optional
  import numpy
  from sahi.models.base import DetectionModel
  from sahi.prediction import ObjectPrediction
  from sahi.utils.cv import get_bbox_from_bool_mask
  from sahi.utils.import_utils import check_requirements
label_desc: Use image node_id 5 for calling the Detectron2DetectionModel obj's underlying member method code with example usage: obj._create_object_prediction_list_from_original_predictions(shift_amount_list, full_shape_list) without return types