code: def bbox_transform(anchors, gt_boxes, mean=None, std=None):
      """Compute bounding-box regression targets for an image."""
  
      # The Mean and std are calculated from COCO dataset.
      # Bounding box normalization was firstly introduced in the Fast R-CNN paper.
      # See https://github.com/fizyr/keras-retinanet/issues/1273#issuecomment-585828825  for more details
      if mean is None:
          mean = np.array([0, 0, 0, 0])
      if std is None:
          std = np.array([0.2, 0.2, 0.2, 0.2])
  
      if isinstance(mean, (list, tuple)):
          mean = np.array(mean)
      elif not isinstance(mean, np.ndarray):
          raise ValueError(
              "Expected mean to be a np.ndarray, list or tuple. Received: {}".format(
                  type(mean)
              )
          )
  
      if isinstance(std, (list, tuple)):
          std = np.array(std)
      elif not isinstance(std, np.ndarray):
          raise ValueError(
              "Expected std to be a np.ndarray, list or tuple. Received: {}".format(
                  type(std)
              )
          )
  
      anchor_widths = anchors[:, 2] - anchors[:, 0]
      anchor_heights = anchors[:, 3] - anchors[:, 1]
  
      # According to the information provided by a keras-retinanet author, they got marginally better results using
      # the following way of bounding box parametrization.
      # See https://github.com/fizyr/keras-retinanet/issues/1273#issuecomment-585828825 for more details
      targets_dx1 = (gt_boxes[:, 0] - anchors[:, 0]) / anchor_widths
      targets_dy1 = (gt_boxes[:, 1] - anchors[:, 1]) / anchor_heights
      targets_dx2 = (gt_boxes[:, 2] - anchors[:, 2]) / anchor_widths
      targets_dy2 = (gt_boxes[:, 3] - anchors[:, 3]) / anchor_heights
  
      targets = np.stack(
          (targets_dx1, targets_dy1, targets_dx2, targets_dy2)
      )
      targets = targets.T
  
      targets = (targets - mean) / std
  
      return targets
  
file_path: ImageAI/imageai_tf_deprecated/Detection/keras_retinanet/utils/anchors.py
imports: import numpy
  from tensorflow import keras
label_desc: Use image node_id 8 for calling a global function with example usage: bbox_transform(anchors, gt_boxes, mean, std) and returns: targets