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","."]
docstr: Update internal buffer with latest predictions.
  Note that the statistics are not available until you call self.get() to return
  the metrics.
  
  Parameters
  ----------
  pred_bboxes : mxnet.NDArray or numpy.ndarray
      Prediction bounding boxes with shape `B, N, 4`.
      Where B is the size of mini-batch, N is the number of bboxes.
  pred_labels : mxnet.NDArray or numpy.ndarray
      Prediction bounding boxes labels with shape `B, N`.
  pred_scores : mxnet.NDArray or numpy.ndarray
      Prediction bounding boxes scores with shape `B, N`.
  pred_masks: mxnet.NDArray or numpy.ndarray
      Prediction masks with *original* shape `H, W`.
docstr_tok: ["Update","internal","buffer","with","latest","predictions",".","Note","that","the","statistics","are","not","available","until","you","call","self.get","(",")","to","return","the","metrics",".","Parameters","--","--","--","--","--","pred_bboxes",":","mxnet.NDArray","or","numpy.ndarray","Prediction","bounding","boxes","with","shape","`","B",",","N",",","4","`",".","Where","B","is","the","size","of","mini-batch",",","N","is","the","number","of","bboxes",".","pred_labels",":","mxnet.NDArray","or","numpy.ndarray","Prediction","bounding","boxes","labels","with","shape","`","B",",","N","`",".","pred_scores",":","mxnet.NDArray","or","numpy.ndarray","Prediction","bounding","boxes","scores","with","shape","`","B",",","N","`",".","pred_masks",":","mxnet.NDArray","or","numpy.ndarray","Prediction","masks","with","*","original","*","shape","`","H",",","W","`","."]
code: def update(
      self,
      pred_bboxes,
      pred_labels,
      pred_scores,
      pred_masks,
      *args,
      **kwargs,
  ):
      """Update internal buffer with latest predictions.
      Note that the statistics are not available until you call self.get() to return
      the metrics.
  
      Parameters
      ----------
      pred_bboxes : mxnet.NDArray or numpy.ndarray
          Prediction bounding boxes with shape `B, N, 4`.
          Where B is the size of mini-batch, N is the number of bboxes.
      pred_labels : mxnet.NDArray or numpy.ndarray
          Prediction bounding boxes labels with shape `B, N`.
      pred_scores : mxnet.NDArray or numpy.ndarray
          Prediction bounding boxes scores with shape `B, N`.
      pred_masks: mxnet.NDArray or numpy.ndarray
          Prediction masks with *original* shape `H, W`.
  
      """
  
      def as_numpy(a):
          """Convert a (list of) mx.NDArray into numpy.ndarray"""
          if isinstance(a, mx.nd.NDArray):
              a = a.asnumpy()
          return a
  
      # mask must be the same as image shape, so no batch dimension is supported
      pred_bbox, pred_label, pred_score, pred_mask = [
          as_numpy(x)
          for x in [pred_bboxes, pred_labels, pred_scores, pred_masks]
      ]
      # filter out padded detection & low confidence detections
      valid_pred = np.where(
          (pred_label >= 0) & (pred_score >= self._score_thresh)
      )[0]
      pred_bbox = pred_bbox[valid_pred].astype("float32")
      pred_label = pred_label.flat[valid_pred].astype("int32")
      pred_score = pred_score.flat[valid_pred].astype("float32")
      pred_mask = pred_mask[valid_pred].astype("uint8")
      imgid = self._img_ids[int(self._current_id)]
      self._current_id += 1
      # for each bbox detection in each image
      for bbox, label, score, mask in zip(
          pred_bbox, pred_label, pred_score, pred_mask
      ):
          if label not in self.dataset.contiguous_id_to_json:
              # ignore non-exist class
              continue
          if score < self._score_thresh:
              continue
          category_id = self.dataset.contiguous_id_to_json[label]
          # convert [xmin, ymin, xmax, ymax]  to [xmin, ymin, w, h]
          bbox[2:4] -= bbox[:2]
          # coco format full image mask to rle
          rle = self._encode_mask(mask)
          if self._use_ext:
              self._bbox_result.append(
                  {
                      "image_id": int(imgid),
                      "category_id": category_id,
                      "bbox": list(
                          map(lambda x: float(round(x, 2)), bbox[:4])
                      ),
                      "score": float(round(score, 3)),
                  }
              )
              self._segm_result.append(
                  {
                      "image_id": int(imgid),
                      "category_id": category_id,
                      "segmentation": rle,
                      "score": float(round(score, 3)),
                  }
              )
  
          else:
              self._results.append(
                  {
                      "image_id": int(imgid),
                      "category_id": category_id,
                      "bbox": list(
                          map(lambda x: float(round(x, 2)), bbox[:4])
                      ),
                      "score": float(round(score, 3)),
                      "segmentation": rle,
                  }
              )
  
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 9 for calling the COCOInstanceMetric obj's underlying member method code with example usage: obj.update(pred_bboxes, pred_labels, pred_scores, pred_masks) and returns: a