class_docstr: CenterNet network using Hourglass from https://arxiv.org/abs/1904.07850S.
class_docstr_tok: ["CenterNet","network","using","Hourglass","from","https",":","\/\/arxiv.org\/abs\/1904.07850S","."]
docstr: Transform and group detections.
docstr_tok: ["Transform","and","group","detections","."]
code: def transform_and_group_detections_per_class(
      detections, metadata, num_classes
  ):
      """Transform and group detections."""
      c, s = metadata["center"], metadata["side_size"]
      w, h = metadata["output_w"], metadata["output_h"]
      detections = detections.numpy()
      ret = []
      for i in range(detections.shape[0]):
          top_preds = {}
          detections[i, :, :2] = image_utils.transform_predictions(
              detections[i, :, 0:2], c, s, (w, h)
          )
          detections[i, :, 2:4] = image_utils.transform_predictions(
              detections[i, :, 2:4], c, s, (w, h)
          )
          classes = detections[i, :, -1]
          for j in range(num_classes):
              inds = classes == j
              top_preds[j + 1] = np.concatenate(
                  [
                      detections[i, inds, :4].astype(np.float32),
                      detections[i, inds, 4:5].astype(np.float32),
                  ],
                  axis=1,
              )
          ret.append(top_preds)
      return ret
  
imports: import collections
  import os
  import random
  import string
  import time
  from absl import logging
  import numpy
  import tensorflow
  from tensorflow_graphics.projects.points_to_3Dobjects.models import centernet_utils
  from tensorflow_graphics.projects.points_to_3Dobjects.networks import hourglass
  from tensorflow_graphics.projects.points_to_3Dobjects.transforms import transforms
  from tensorflow_graphics.projects.points_to_3Dobjects.utils import image
  from google3.pyglib import gfile
label_desc: Use image node_id 17 for calling the CenterNetVID obj's underlying member method code with example usage: obj.transform_and_group_detections_per_class(detections, metadata, num_classes) and returns: ret