class_docstr: Class for handling detection model predictions.
class_docstr_tok: ["Class","for","handling","detection","model","predictions","."]
docstr: Returns sahi.utils.coco.CocoPrediction representation of ObjectAnnotation.
docstr_tok: ["Returns","sahi.utils.coco.CocoPrediction","representation","of","ObjectAnnotation","."]
code: def to_coco_prediction(self, image_id=None):
      """
      Returns sahi.utils.coco.CocoPrediction representation of ObjectAnnotation.
      """
      if self.mask:
          coco_prediction = CocoPrediction.from_coco_segmentation(
              segmentation=self.mask.to_coco_segmentation(),
              category_id=self.category.id,
              category_name=self.category.name,
              score=self.score.value,
              image_id=image_id,
          )
      else:
          coco_prediction = CocoPrediction.from_coco_bbox(
              bbox=self.bbox.to_xywh(),
              category_id=self.category.id,
              category_name=self.category.name,
              score=self.score.value,
              image_id=image_id,
          )
      return coco_prediction
  
imports: import copy
  from typing import Dict, List, Optional, Union
  import numpy
  from PIL import Image
  from sahi.annotation import ObjectAnnotation
  from sahi.utils.coco import CocoAnnotation, CocoPrediction
  from sahi.utils.cv import read_image_as_pil, visualize_object_predictions
  from sahi.utils.file import Path
label_desc: Use image node_id 3 for calling the ObjectPrediction obj's underlying member method code with example usage: obj.to_coco_prediction(image_id) and returns: coco_prediction