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],...]
      """
  
      try:
          from pycocotools import mask as mask_utils
  
          can_decode_rle = True
      except ImportError:
          can_decode_rle = False
  
      original_predictions = self._original_predictions
      category_mapping = self.category_mapping
  
      # compatilibty for sahi v0.8.15
      shift_amount_list = fix_shift_amount_list(shift_amount_list)
      full_shape_list = fix_full_shape_list(full_shape_list)
  
      # parse boxes and masks from predictions
      object_prediction_list_per_image = []
      for image_ind, original_prediction in enumerate(
          original_predictions
      ):
          shift_amount = shift_amount_list[image_ind]
          full_shape = (
              None
              if full_shape_list is None
              else full_shape_list[image_ind]
          )
  
          boxes = original_prediction["bboxes"]
          scores = original_prediction["scores"]
          labels = original_prediction["labels"]
          if self.has_mask:
              masks = original_prediction["masks"]
  
          object_prediction_list = []
  
          n_detects = len(labels)
          # process predictions
          for i in range(n_detects):
              if self.has_mask:
                  mask = masks[i]
  
              bbox = boxes[i]
              score = scores[i]
              category_id = labels[i]
              category_name = category_mapping[str(category_id)]
  
              # ignore low scored predictions
              if score < self.confidence_threshold:
                  continue
  
              # parse prediction mask
              if self.has_mask:
                  if "counts" in mask:
                      if can_decode_rle:
                          bool_mask = mask_utils.decode(mask)
                      else:
                          raise ValueError(
                              "Can not decode rle mask. Please install pycocotools. ex: 'pip install pycocotools'"
                          )
                  else:
                      bool_mask = mask
  
                  # check if mask is valid
                  # https://github.com/obss/sahi/discussions/696
                  if get_bbox_from_bool_mask(bool_mask) is None:
                      continue
              else:
                  bool_mask = None
  
              # fix negative box coords
              bbox[0] = max(0, bbox[0])
              bbox[1] = max(0, bbox[1])
              bbox[2] = max(0, bbox[2])
              bbox[3] = max(0, bbox[3])
  
              # fix out of image box coords
              if full_shape is not None:
                  bbox[0] = min(full_shape[1], bbox[0])
                  bbox[1] = min(full_shape[0], bbox[1])
                  bbox[2] = min(full_shape[1], bbox[2])
                  bbox[3] = min(full_shape[0], bbox[3])
  
              # ignore invalid predictions
              if not (bbox[0] < bbox[2]) or not (bbox[1] < bbox[3]):
                  logger.warning(
                      f"ignoring invalid prediction with bbox: {bbox}"
                  )
                  continue
  
              object_prediction = ObjectPrediction(
                  bbox=bbox,
                  category_id=category_id,
                  score=score,
                  bool_mask=bool_mask,
                  category_name=category_name,
                  shift_amount=shift_amount,
                  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/mmdet.py
imports: import logging
  from typing import Any, Dict, List, Optional, Union
  import numpy
  from sahi.models.base import DetectionModel
  from sahi.prediction import ObjectPrediction
  from sahi.utils.compatibility import fix_full_shape_list, fix_shift_amount_list
  from sahi.utils.cv import get_bbox_from_bool_mask
  from sahi.utils.import_utils import check_requirements
label_desc: Use image node_id 9 for calling the MmdetDetectionModel 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