morpheus.modules.filter_detections
Functions
|
Filter message by a classification threshold. |
- filter_detections(builder)[source]
Filter message by a classification threshold.
The FilterDetections is used to filter rows from a dataframe based on values in a tensor using a specified criteria. Rows in the
meta
dataframe are excluded if their associated value in theprobs
array is less than or equal tothreshold
.This module can operate in two different modes set by the
copy
argument. When thecopy
argument isTrue
(default), rows that meet the filter criteria are copied into a new dataframe. WhenFalse
sliced views are used instead.Setting
copy=True
should be used when the number of matching records is expected to be both high and in non-adjacent rows. In this mode, the stage will generate only one output message for each incoming message, regardless of the size of the input and the number of matching records. However this comes at the cost of needing to allocate additional memory and perform the copy. Note: In most other stages, messages emitted contain a reference to the originalMessageMeta
emitted into the pipeline by the source stage. When using copy mode this won’t be the case and could cause the originalMessageMeta
to be deallocated after this stage.Setting
copy=False
should be used when either the number of matching records is expected to be very low or are likely to be contained in adjacent rows. In this mode, slices of contiguous blocks of rows are emitted in multiple output messages. Performing a slice is relatively low-cost, however for each incoming message the number of emitted messages could be high (in the worst case scenario as high as half the number of records in the incoming message). Depending on the downstream stages, this can cause performance issues, especially if those stages need to acquire the Python GIL.- Parameters
- buildermrc.Builder
An mrc Builder object.
Notes
- Configurable Parameters:
copy (bool): Whether to copy the rows or slice them; Example: true; Default: true
field_name (str): Name of the field to filter on; Example:
probs
; Default: probsfilter_source (str): Source of the filter field; Example:
AUTO
; Default: AUTOschema (dict): Schema configuration; See Below; Default: -
threshold (float): Threshold value to filter on; Example: 0.5; Default: 0.5
- schema:
encoding (str): Encoding; Example: “latin1”; Default: “latin1”
input_message_type (str): Pickled message type; Example:
pickle_message_type
; Default:[Required]
schema_str (str): Schema string; Example: “string”; Default:
[Required]