code: def retinanet_bbox(
      model=None,
      nms=True,
      class_specific_filter=True,
      name="retinanet-bbox",
      anchor_params=None,
      pyramid_levels=None,
      nms_threshold=0.5,
      score_threshold=0.05,
      max_detections=300,
      parallel_iterations=32,
      **kwargs,
  ):
      """Construct a RetinaNet model on top of a backbone and adds convenience functions to output boxes directly.
  
      This model uses the minimum retinanet model and appends a few layers to compute boxes within the graph.
      These layers include applying the regression values to the anchors and performing NMS.
  
      Args
          model                 : RetinaNet model to append bbox layers to. If None, it will create a RetinaNet model using **kwargs.
          nms                   : Whether to use non-maximum suppression for the filtering step.
          class_specific_filter : Whether to use class specific filtering or filter for the best scoring class only.
          name                  : Name of the model.
          anchor_params         : Struct containing anchor parameters. If None, default values are used.
          pyramid_levels        : pyramid levels to use.
          nms_threshold         : Threshold for the IoU value to determine when a box should be suppressed.
          score_threshold       : Threshold used to prefilter the boxes with.
          max_detections        : Maximum number of detections to keep.
          parallel_iterations   : Number of batch items to process in parallel.
          **kwargs              : Additional kwargs to pass to the minimal retinanet model.
  
      Returns
          A keras.models.Model which takes an image as input and outputs the detections on the image.
  
          The order is defined as follows:
          ```
          [
              boxes, scores, labels, other[0], other[1], ...
          ]
          ```
      """
  
      # if no anchor parameters are passed, use default values
      if anchor_params is None:
          anchor_params = AnchorParameters.default
  
      # create RetinaNet model
      if model is None:
          model = retinanet(
              num_anchors=anchor_params.num_anchors(), **kwargs
          )
      else:
          assert_training_model(model)
  
      if pyramid_levels is None:
          pyramid_levels = [3, 4, 5, 6, 7]
  
      assert len(pyramid_levels) == len(
          anchor_params.sizes
      ), "number of pyramid levels {} should match number of anchor parameter sizes {}".format(
          len(pyramid_levels), len(anchor_params.sizes)
      )
  
      pyramid_layer_names = ["P{}".format(p) for p in pyramid_levels]
      # compute the anchors
      features = [
          model.get_layer(p_name).output
          for p_name in pyramid_layer_names
      ]
      anchors = __build_anchors(anchor_params, features)
  
      # we expect the anchors, regression and classification values as first output
      regression = model.outputs[0]
      classification = model.outputs[1]
  
      # "other" can be any additional output from custom submodels, by default this will be []
      other = model.outputs[2:]
  
      # apply predicted regression to anchors
      boxes = layers.RegressBoxes(name="boxes")([anchors, regression])
      boxes = layers.ClipBoxes(name="clipped_boxes")(
          [model.inputs[0], boxes]
      )
  
      # filter detections (apply NMS / score threshold / select top-k)
      detections = layers.FilterDetections(
          nms=nms,
          class_specific_filter=class_specific_filter,
          name="filtered_detections",
          nms_threshold=nms_threshold,
          score_threshold=score_threshold,
          max_detections=max_detections,
          parallel_iterations=parallel_iterations,
      )([boxes, classification] + other)
  
      # construct the model
      return keras.models.Model(
          inputs=model.inputs, outputs=detections, name=name
      )
  
file_path: ImageAI/imageai_tf_deprecated/Detection/keras_retinanet/models/retinanet.py
imports: from tensorflow import keras
  from ..None import initializers
  from ..None import layers
  from ..utils.anchors import AnchorParameters
  from .None import assert_training_model
label_desc: Use image node_id 9 for calling a global function with example usage: retinanet_bbox(model, nms, class_specific_filter, name, anchor_params, pyramid_levels, nms_threshold, score_threshold, max_detections, parallel_iterations) and returns: keras