class_docstr: Objects as Points. https://arxiv.org/abs/1904.07850v2
  
  Parameters
  ----------
  base_network : mxnet.gluon.nn.HybridBlock
      The base feature extraction network.
  heads : OrderedDict
      OrderedDict with specifications for each head.
      For example: OrderedDict([
          ('heatmap', {'num_output': len(classes), 'bias': -2.19}),
          ('wh', {'num_output': 2}),
          ('reg', {'num_output': 2})
          ])
  classes : list of str
      Category names.
  head_conv_channel : int, default is 0
      If > 0, will use an extra conv layer before each of the real heads.
  scale : float, default is 4.0
      The downsampling ratio of the entire network.
  topk : int, default is 100
      Number of outputs .
  flip_test : bool
      Whether apply flip test in inference (training mode not affected).
  nms_thresh : float, default is 0.
      Non-maximum suppression threshold. You can specify < 0 or > 1 to disable NMS.
      By default nms is disabled.
  nms_topk : int, default is 400
      Apply NMS to top k detection results, use -1 to disable so that every Detection
       result is used in NMS.
  post_nms : int, default is 100
      Only return top `post_nms` detection results, the rest is discarded. The number is
      based on COCO dataset which has maximum 100 objects per image. You can adjust this
      number if expecting more objects. You can use -1 to return all detections.
docstr: Reset class categories and class predictors.
  
  Parameters
  ----------
  classes : iterable of str
      The new categories. ['apple', 'orange'] for example.
  reuse_weights : dict
      A {new_integer : old_integer} or mapping dict or {new_name : old_name} mapping dict,
      or a list of [name0, name1,...] if class names don't change.
      This allows the new predictor to reuse the
      previously trained weights specified.
  
  Example
  -------
  >>> net = gluoncv.model_zoo.get_model('center_net_resnet50_v1b_voc', pretrained=True)
  >>> # use direct name to name mapping to reuse weights
  >>> net.reset_class(classes=['person'], reuse_weights={'person':'person'})
  >>> # or use interger mapping, person is the 14th category in VOC
  >>> net.reset_class(classes=['person'], reuse_weights={0:14})
  >>> # you can even mix them
  >>> net.reset_class(classes=['person'], reuse_weights={'person':14})
  >>> # or use a list of string if class name don't change
  >>> net.reset_class(classes=['person'], reuse_weights=['person'])
docstr_tok: ["Reset","class","categories","and","class","predictors",".","Parameters","--","--","--","--","--","classes",":","iterable","of","str","The","new","categories",".","[","'apple","'",",","'orange","'","]","for","example",".","reuse_weights",":","dict","A","{","new_integer",":","old_integer","}","or","mapping","dict","or","{","new_name",":","old_name","}","mapping","dict",",","or","a","list","of","[","name0",",","name1",",","...","]","if","class","names","do","n't","change",".","This","allows","the","new","predictor","to","reuse","the","previously","trained","weights","specified",".","Example","--","--","--","-",">",">",">","net","=","gluoncv.model_zoo.get_model","(","'center_net_resnet50_v1b_voc","'",",","pretrained=True",")",">",">",">","#","use","direct","name","to","name","mapping","to","reuse","weights",">",">",">","net.reset_class","(","classes=","[","'person","'","]",",","reuse_weights=","{","'person","'",":","'person","'","}",")",">",">",">","#","or","use","interger","mapping",",","person","is","the","14th","category","in","VOC",">",">",">","net.reset_class","(","classes=","[","'person","'","]",",","reuse_weights=","{","0:14","}",")",">",">",">","#","you","can","even","mix","them",">",">",">","net.reset_class","(","classes=","[","'person","'","]",",","reuse_weights=","{","'person':14","}",")",">",">",">","#","or","use","a","list","of","string","if","class","name","do","n't","change",">",">",">","net.reset_class","(","classes=","[","'person","'","]",",","reuse_weights=","[","'person","'","]",")"]
code: def reset_class(self, classes, reuse_weights=None):
      """Reset class categories and class predictors.
  
      Parameters
      ----------
      classes : iterable of str
          The new categories. ['apple', 'orange'] for example.
      reuse_weights : dict
          A {new_integer : old_integer} or mapping dict or {new_name : old_name} mapping dict,
          or a list of [name0, name1,...] if class names don't change.
          This allows the new predictor to reuse the
          previously trained weights specified.
  
      Example
      -------
      >>> net = gluoncv.model_zoo.get_model('center_net_resnet50_v1b_voc', pretrained=True)
      >>> # use direct name to name mapping to reuse weights
      >>> net.reset_class(classes=['person'], reuse_weights={'person':'person'})
      >>> # or use interger mapping, person is the 14th category in VOC
      >>> net.reset_class(classes=['person'], reuse_weights={0:14})
      >>> # you can even mix them
      >>> net.reset_class(classes=['person'], reuse_weights={'person':14})
      >>> # or use a list of string if class name don't change
      >>> net.reset_class(classes=['person'], reuse_weights=['person'])
  
      """
      self._clear_cached_op()
      old_classes = self.classes
      self.classes = classes
      # trying to reuse weights by mapping old and new classes
      if isinstance(reuse_weights, (dict, list)):
          if isinstance(reuse_weights, dict):
              # trying to replace str with indices
              new_keys = []
              new_vals = []
              for k, v in reuse_weights.items():
                  if isinstance(v, str):
                      try:
                          new_vals.append(
                              old_classes.index(v)
                          )  # raise ValueError if not found
                      except ValueError:
                          raise ValueError(
                              "{} not found in old class names {}".format(
                                  v, old_classes
                              )
                          )
                  else:
                      if v < 0 or v >= len(old_classes):
                          raise ValueError(
                              "Index {} out of bounds for old class names".format(
                                  v
                              )
                          )
                      new_vals.append(v)
                  if isinstance(k, str):
                      try:
                          new_keys.append(
                              self.classes.index(k)
                          )  # raise ValueError if not found
                      except ValueError:
                          raise ValueError(
                              "{} not found in new class names {}".format(
                                  k, self.classes
                              )
                          )
                  else:
                      if k < 0 or k >= len(self.classes):
                          raise ValueError(
                              "Index {} out of bounds for new class names".format(
                                  k
                              )
                          )
                      new_keys.append(k)
              reuse_weights = dict(zip(new_keys, new_vals))
          else:
              new_map = {}
              for x in reuse_weights:
                  try:
                      new_idx = self.classes.index(x)
                      old_idx = old_classes.index(x)
                      new_map[new_idx] = old_idx
                  except ValueError:
                      warnings.warn(
                          "{} not found in old: {} or new class names: {}".format(
                              x, old_classes, self.classes
                          )
                      )
              reuse_weights = new_map
      # replace class predictors
      with self.name_scope():
          hm_head = nn.HybridSequential("heatmap")
          orig_head = self.heads
          orig_hm = self.heads[0]
          for i in range(len(orig_hm) - 1):
              hm_head.add(orig_hm[i])
          num_output = len(classes)
          bias = self._head_setups["heatmap"].get("bias", 0.0)
          weight_initializer = (
              mx.init.Normal(0.001) if bias == 0 else mx.init.Xavier()
          )
          # to avoid deferred init, number of in_channels must be defined
          in_channels = list(orig_hm[0].params.values())[0].shape[1]
          hm_head.add(
              nn.Conv2D(
                  num_output,
                  kernel_size=1,
                  strides=1,
                  padding=0,
                  use_bias=True,
                  weight_initializer=weight_initializer,
                  bias_initializer=mx.init.Constant(bias),
                  in_channels=in_channels,
              )
          )
          with warnings.catch_warnings(record=True) as _:
              warnings.simplefilter("always")
              ctx = list(orig_hm[0].params.values())[0].list_ctx()
              hm_head.initialize(ctx=ctx)
          if reuse_weights:
              assert isinstance(reuse_weights, dict)
              for old_params, new_params in zip(
                  orig_hm[2].params.values(), hm_head[2].params.values()
              ):
                  old_data = old_params.data()
                  new_data = new_params.data()
  
                  for k, v in reuse_weights.items():
                      if k > len(self.classes) or v > len(old_classes):
                          warnings.warn(
                              "reuse mapping {}/{} -> {}/{} out of range".format(
                                  k, self.classes, v, old_classes
                              )
                          )
                          continue
                      new_data[k :: len(self.classes)] = old_data[
                          v :: len(old_classes)
                      ]
                  # set data to new conv layers
                  new_params.set_data(new_data)
          old_heads = self.heads
          self.heads = nn.HybridSequential("heads")
          self.heads.add(hm_head)
          self.heads.add(orig_head[1])
          self.heads.add(orig_head[2])
  
imports: from __future__ import absolute_import
  import os
  import warnings
  from collections import OrderedDict
  import mxnet
  from mxnet.gluon import nn
  from mxnet import autograd
  from ...nn.coder import CenterNetDecoder
label_desc: Use image node_id 4 for calling the CenterNet obj's underlying member method code with example usage: obj.reset_class(classes, reuse_weights) without return types