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.20
      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]
  
      for image_predictions in original_predictions:
          object_prediction_list_per_image = []
  
          # get indices of boxes with score > confidence_threshold
          scores = image_predictions["scores"].cpu().detach().numpy()
          selected_indices = np.where(
              scores > self.confidence_threshold
          )[0]
  
          # parse boxes, masks, scores, category_ids from predictions
          category_ids = list(
              image_predictions["labels"][selected_indices]
              .cpu()
              .detach()
              .numpy()
          )
          boxes = list(
              image_predictions["boxes"][selected_indices]
              .cpu()
              .detach()
              .numpy()
          )
          scores = scores[selected_indices]
  
          # check if predictions contain mask
          masks = image_predictions.get("masks", None)
          if masks is not None:
              masks = list(
                  image_predictions["masks"][selected_indices]
                  .cpu()
                  .detach()
                  .numpy()
              )
          else:
              masks = None
  
          # create object_prediction_list
          object_prediction_list = []
  
          shift_amount = shift_amount_list[0]
          full_shape = (
              None if full_shape_list is None else full_shape_list[0]
          )
  
          for ind in range(len(boxes)):
              if masks is not None:
                  mask = np.array(masks[ind])
              else:
                  mask = None
  
              object_prediction = ObjectPrediction(
                  bbox=boxes[ind],
                  bool_mask=mask,
                  category_id=int(category_ids[ind]),
                  category_name=self.category_mapping[
                      str(int(category_ids[ind]))
                  ],
                  shift_amount=shift_amount,
                  score=scores[ind],
                  full_shape=full_shape,
              )
              object_prediction_list.append(object_prediction)
          object_prediction_list_per_image.append(
              object_prediction_list
          )
  
      self._object_prediction_list_per_image = (
          object_prediction_list_per_image
      )
  
file_path: sahi/sahi/models/torchvision.py
imports: import logging
  from typing import Any, Dict, List, Optional
  import numpy
  from sahi.models.base import DetectionModel
  from sahi.prediction import ObjectPrediction
  from sahi.utils.import_utils import check_requirements
label_desc: Use image node_id 8 for calling the TorchVisionDetectionModel 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