def perform_nms(
    sample_collection,
    in_field,
    out_field=None,
    iou_thresh=0.5,
    confidence_thresh=None,
    classwise=True,
    progress=None,
):
    """Performs non-maximum suppression (NMS) on the specified
    :class:`fiftyone.core.labels.Detections` field.

    NMS is a post-processing technique used in object detection to eliminate
    duplicate detections and select the most relevant detected objects. This
    helps reduce false positives.

    Args:
        sample_collection: a
            :class:`fiftyone.core.collections.SampleCollection`
        in_field: the name of the :class:`fiftyone.core.labels.Detections`
            field
        out_field (None): the name of the
            :class:`fiftyone.core.labels.Detections` field to populate. If not
            specified, the input field is updated in-place
        iou_thresh (0.5): an intersection over union (IoU) threshold to use.
            This determines the minimum overlap required between bounding boxes
            to be considered duplicates. Bounding boxes with IoU values greater
            than or equal to this threshold will be suppressed
        confidence_thresh (None): a minimum confidence score required for a
            detection to be considered valid. Detections with confidence scores
            lower than this threshold will be discarded
        classwise (True): whether to treat each class ``label`` separately
            (True) or suppress all detections jointly (False)
        progress (None): whether to render a progress bar (True/False), use the
            default value ``fiftyone.config.show_progress_bars`` (None), or a
            progress callback function to invoke instead
    """
    fov.validate_non_grouped_collection(sample_collection)
    fov.validate_collection_label_fields(
        sample_collection, in_field, fol.Detections
    )

    if out_field is None:
        out_field = in_field

    samples = sample_collection.select_fields(in_field)
    in_field, processing_frames = samples._handle_frame_field(in_field)
    out_field, _ = samples._handle_frame_field(out_field)

    for sample in samples.iter_samples(autosave=True, progress=progress):
        if processing_frames:
            images = sample.frames.values()
        else:
            images = [sample]

        for image in images:
            detections = image[in_field]
            if detections is not None:
                _detections = detections.detections.copy()
                nms_detections = _perform_nms(
                    _detections,
                    iou_thresh=iou_thresh,
                    confidence_thresh=confidence_thresh,
                    classwise=classwise,
                )
                image[out_field] = fol.Detections(detections=nms_detections)
Performs non-maximum suppression (NMS) on the specified
    :class:`fiftyone.core.labels.Detections` field.

    NMS is a post-processing technique used in object detection to eliminate
    duplicate detections and select the most relevant detected objects. This
    helps reduce false positives.

    Args:
        sample_collection: a
            :class:`fiftyone.core.collections.SampleCollection`
        in_field: the name of the :class:`fiftyone.core.labels.Detections`
            field
        out_field (None): the name of the
            :class:`fiftyone.core.labels.Detections` field to populate. If not
            specified, the input field is updated in-place
        iou_thresh (0.5): an intersection over union (IoU) threshold to use.
            This determines the minimum overlap required between bounding boxes
            to be considered duplicates. Bounding boxes with IoU values greater
            than or equal to this threshold will be suppressed
        confidence_thresh (None): a minimum confidence score required for a
            detection to be considered valid. Detections with confidence scores
            lower than this threshold will be discarded
        classwise (True): whether to treat each class ``label`` separately
            (True) or suppress all detections jointly (False)
        progress (None): whether to render a progress bar (True/False), use the
            default value ``fiftyone.config.show_progress_bars`` (None), or a
            progress callback function to invoke instead
    
fiftyone/utils/labels.py