class_docstr: All about an annotation such as Mask, Category, BoundingBox.
class_docstr_tok: ["All","about","an","annotation","such","as","Mask",",","Category",",","BoundingBox","."]
docstr: Returns imantics.annotation.Annotation representation of ObjectAnnotation.
docstr_tok: ["Returns","imantics.annotation.Annotation","representation","of","ObjectAnnotation","."]
code: def to_imantics_annotation(self):
      """
      Returns imantics.annotation.Annotation representation of ObjectAnnotation.
      """
      try:
          import imantics
      except ImportError:
          raise ImportError(
              'Please run "pip install -U imantics" '
              "to install imantics first for imantics conversion."
          )
  
      imantics_category = imantics.Category(
          id=self.category.id, name=self.category.name
      )
      if self.mask is not None:
          imantics_mask = imantics.Mask.create(self.mask.bool_mask)
          imantics_annotation = (
              imantics.annotation.Annotation.from_mask(
                  mask=imantics_mask, category=imantics_category
              )
          )
      else:
          imantics_bbox = imantics.BBox.create(self.bbox.to_xyxy())
          imantics_annotation = (
              imantics.annotation.Annotation.from_bbox(
                  bbox=imantics_bbox, category=imantics_category
              )
          )
      return imantics_annotation
  
imports: import copy
  from typing import Dict, List, Optional
  import numpy
  from sahi.utils.coco import CocoAnnotation, CocoPrediction
  from sahi.utils.cv import get_bbox_from_bool_mask, get_bool_mask_from_coco_segmentation, get_coco_segmentation_from_bool_mask
  from sahi.utils.shapely import ShapelyAnnotation
label_desc: Use image node_id 11 for calling the ObjectAnnotation obj's underlying member method code with example usage: obj.to_imantics_annotation() and returns: imantics_annotation