class_docstr: Instance segmentation metric for COCO bbox and segm task.
  Will return box summary, box metric, seg summary and seg metric.
  
  Parameters
  ----------
  dataset : instance of gluoncv.data.COCOInstance
      The validation dataset.
  save_prefix : str
      Prefix for the saved JSON results.
  use_time : bool
      Append unique datetime string to created JSON file name if ``True``.
  cleanup : bool
      Remove created JSON file if ``True``. When cleanup is True, we do not output json to save
      computation.
  use_ext : bool
      Whether to use external module built by NVIDIA, which is significantly faster.
      Make sure NVIDIA MSCOCO API is installed!
  starting_id : int, default is 0
      If using distributed evaluation, it need to be set to the start of each shard.
  score_thresh : float
      Detection results with confident scores smaller than ``score_thresh`` will
      be discarded before saving to results.
class_docstr_tok: ["Instance","segmentation","metric","for","COCO","bbox","and","segm","task",".","Will","return","box","summary",",","box","metric",",","seg","summary","and","seg","metric",".","Parameters","--","--","--","--","--","dataset",":","instance","of","gluoncv.data.COCOInstance","The","validation","dataset",".","save_prefix",":","str","Prefix","for","the","saved","JSON","results",".","use_time",":","bool","Append","unique","datetime","string","to","created","JSON","file","name","if","``","True","``",".","cleanup",":","bool","Remove","created","JSON","file","if","``","True","``",".","When","cleanup","is","True",",","we","do","not","output","json","to","save","computation",".","use_ext",":","bool","Whether","to","use","external","module","built","by","NVIDIA",",","which","is","significantly","faster",".","Make","sure","NVIDIA","MSCOCO","API","is","installed","!","starting_id",":","int",",","default","is","0","If","using","distributed","evaluation",",","it","need","to","be","set","to","the","start","of","each","shard",".","score_thresh",":","float","Detection","results","with","confident","scores","smaller","than","``","score_thresh","``","will","be","discarded","before","saving","to","results","."]
code: def __init__(
      self,
      dataset,
      save_prefix,
      use_time=True,
      cleanup=False,
      use_ext=False,
      starting_id=0,
      score_thresh=1e-3,
  ):
      self._starting_id = starting_id
      self._use_ext = use_ext
      super(COCOInstanceMetric, self).__init__("COCOInstance")
      self.dataset = dataset
      self._dump_to_file = not cleanup
      if use_time:
          import datetime
  
          t = datetime.datetime.now().strftime("_%Y_%m_%d_%H_%M_%S")
      else:
          t = ""
      self._img_ids = sorted(dataset.coco.getImgIds())
      self._current_id = starting_id
      self._results = []
      self._score_thresh = score_thresh
      from ...data.mscoco.utils import try_import_pycocotools
  
      try_import_pycocotools()
      import pycocotools.mask as cocomask
  
      self._cocomask = cocomask
      self._filename = osp.abspath(
          osp.expanduser(save_prefix) + t + ".json"
      )
      if use_ext:
          from pycocotools import coco
  
          if not hasattr(coco, "ext"):
              raise AttributeError(
                  "external module is not support by the COCO API installed. "
                  "Consider install NVIDIA MSCOCO API here "
                  "https://github.com/NVIDIA/cocoapi.git"
              )
          self.dataset.coco.createIndex(use_ext=use_ext)
          self._bbox_result = []
          self._segm_result = []
          self._bbox_filename = osp.abspath(
              osp.expanduser(save_prefix) + t + "_bbox.json"
          )
          self._segm_filename = osp.abspath(
              osp.expanduser(save_prefix) + t + "_segm.json"
          )
          if not self._dump_to_file:
              warnings.warn(
                  "When using external module, eval json is always dumped."
              )
  
file_path: gluon-cv/gluoncv/utils/metrics/coco_instance.py
imports: from __future__ import absolute_import
  import io
  import sys
  import warnings
  from os import path
  import numpy
  import mxnet
label_desc: Use image node_id 1 to create a new COCOInstanceMetric object from inherited base classes: EvalMetric with example: obj = COCOInstanceMetric(dataset, save_prefix, use_time, cleanup, use_ext, starting_id, score_thresh)