class_docstr: Detection metric for COCO bbox task.
  
  Parameters
  ----------
  dataset : instance of gluoncv.data.COCODetection
      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``.
  in_vis_thresh : float
      Detection results with confident scores smaller than ``in_vis_thresh`` will
      be discarded before saving to results.
  data_shape : tuple of int, default is None
      If `data_shape` is provided as (height, width), we will rescale bounding boxes when
      saving the predictions.
      This is helpful when SSD/YOLO box predictions cannot be rescaled conveniently. Note that
      the data_shape must be fixed for all validation images.
class_docstr_tok: ["Detection","metric","for","COCO","bbox","task",".","Parameters","--","--","--","--","--","dataset",":","instance","of","gluoncv.data.COCODetection","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","``",".","in_vis_thresh",":","float","Detection","results","with","confident","scores","smaller","than","``","in_vis_thresh","``","will","be","discarded","before","saving","to","results",".","data_shape",":","tuple","of","int",",","default","is","None","If","`","data_shape","`","is","provided","as","(","height",",","width",")",",","we","will","rescale","bounding","boxes","when","saving","the","predictions",".","This","is","helpful","when","SSD\/YOLO","box","predictions","can","not","be","rescaled","conveniently",".","Note","that","the","data_shape","must","be","fixed","for","all","validation","images","."]
code: def __init__(
      self,
      dataset,
      save_prefix,
      use_time=True,
      cleanup=False,
      in_vis_thresh=0.2,
      data_shape=None,
  ):
      super(COCOKeyPointsMetric, self).__init__("COCOMeanAP")
      self.dataset = dataset
      self._img_ids = sorted(dataset.coco.getImgIds())
      self._recorded_ids = {}
      self._cleanup = cleanup
      self._results = []
      self._in_vis_thresh = in_vis_thresh
      if isinstance(data_shape, (tuple, list)):
          assert (
              len(data_shape) == 2
          ), "Data shape must be (height, width)"
      elif not data_shape:
          data_shape = None
      else:
          raise ValueError(
              "data_shape must be None or tuple of int as (height, width)"
          )
      self._data_shape = data_shape
  
      if use_time:
          import datetime
  
          t = datetime.datetime.now().strftime("_%Y_%m_%d_%H_%M_%S")
      else:
          t = ""
      self._filename = osp.abspath(
          osp.expanduser(save_prefix) + t + ".json"
      )
      try:
          f = open(self._filename, "w")
      except IOError as e:
          raise RuntimeError(
              "Unable to open json file to dump. What(): {}".format(
                  str(e)
              )
          )
      else:
          f.close()
  
file_path: gluon-cv/gluoncv/utils/metrics/coco_keypoints.py
imports: from __future__ import absolute_import
  import os
  from os import path
  from collections import OrderedDict
  import warnings
label_desc: Use image node_id 1 to create a new COCOKeyPointsMetric object from inherited base classes: EvalMetric with example: obj = COCOKeyPointsMetric(dataset, save_prefix, use_time, cleanup, in_vis_thresh, data_shape)