View Source YOLO.Models.YOLOX (YOLO v0.2.0)

YOLOX model implementation for preprocessing input images and postprocessing detections using non-maximum suppression (NMS).

Supports YOLOX models found at https://github.com/Megvii-BaseDetection/YOLOX

If using a YOLOX model that was exported with --decode_in_inference, you can set decode_head: false in the YOLO.detect/3 options.

YOLOX-Tiny and YOLOX-Nano models use 416x416, while other models use 640x640.

Summary

Functions

Calculates the detection score for each prediction as the product of the maximum class probability and the objectness score.

Post-processes the model's raw output to produce a filtered list of detected objects.

YOLOX input doesn't need to be normalized, so we resize and convert the image to a {batch_size, channels, height, width} tensor.

Functions

calculate_max_prob_score_per_prediction(predictions)

Calculates the detection score for each prediction as the product of the maximum class probability and the objectness score.

Adaptation of YOLO.NMS.filter_predictions/2, but calculates the correct score based on the product of the maximum class probability and the objectness score which differs from Ultralytics

Removes prob_threshold filtering so that we can use Nx.Defn compilation for performance.

default_nms(model_output_nx, prob_threshold, nms_threshold)

generate_grids_and_expanded_strides(arg, p6 \\ false)

postprocess(model, model_output, scaling_config, opts)

Post-processes the model's raw output to produce a filtered list of detected objects.

Options:

  • decode_head - If true, decode the output head to map predictions to input image space. Defaults to true. Can be set to false if using a YOLOX model that was exported with --decode_in_inference
  • nms_fun - Optional custom NMS function. Must calculate detection scores as the product of the maximum class probability and the objectness score.
  • prob_threshold - Minimum probability threshold for detections
  • iou_threshold - IoU threshold for non-maximum suppression

preprocess(model, image, options)

YOLOX input doesn't need to be normalized, so we resize and convert the image to a {batch_size, channels, height, width} tensor.

Tiny and Nano models use 416x416, while other models use 640x640.

process_bboxes(model_output, grids, expanded_strides)