Detect
- class lib.infer.detect.Detect(plugin: str, rotation: str | None = None, min_size: int = 0, max_size: int = 0, compile_model: bool = False, config_file: str | None = None)
Bases:
ExtractHandlerResponsible for handling Detection plugins within the extract pipeline
- Parameters:
plugin (str) – The plugin that this runner is to use
None (rotation |) – The rotation arguments. Either a list of angles between 0 and 360 to rotate at or a single step size. Default:
None, no rotationsmin_size (int) – Minimum percentage of the frame’s shortest edge to accept as a successful detection along the detection’s longest edge Default: 0 (accept all detections)
max_size (int) – Maximum percentage of the frame’s shortest edge to accept as a successful detection along the detection’s longest edge Default: 0 (accept all detections)
compile_model (bool) –
Trueto compile any PyTorch modelsconfig_file (str | None) – Full path to a custom config file to load.
Nonefor default configrotation (str | None)
Attributes Summary
The batch size of the plugin
The processors which should have thread's launched for this handler
The runner that runs this handler
Methods Summary
__call__([input_plugin, profile])Build and start the plugin handler's runner
Load the model, compile it, if requested, and send a warmup batch through.
Output the counts of filtered items
post_process(batch)Perform detection post processing.
pre_process(batch)Perform pre-processing for detection plugins.
process(batch)Obtain the output from the plugin's model.
Attributes Documentation
- batch_size
The batch size of the plugin
- processors: tuple[Literal['pre_process', 'process', 'post_process'], ...] = ('pre_process', 'process', 'post_process')
The processors which should have thread’s launched for this handler
- runner
The runner that runs this handler
Methods Documentation
- __call__(input_plugin: ExtractHandler | ExtractRunner | None = None, profile: bool = False) ExtractRunner
Build and start the plugin handler’s runner
- Parameters:
input_plugin (ExtractHandler | ExtractRunner | None) – The input plugin handler or it’s runner that feeds this handler.
Noneif data is to be fed through the handler runner’s put method (ie, the first handler in an extraction chain). Default:Noneprofile (bool) –
Trueif the runner is to be profiled, indicating that threads will not be started. Default:False
- Return type:
The extract plugin handler’s runner for this handler
- init_model() None
Load the model, compile it, if requested, and send a warmup batch through. Called either from the main thread, if compiling, or from the inference thread if not.
- Return type:
None
- output_info() None
Output the counts of filtered items
- Return type:
None
- post_process(batch: ExtractBatch) None
Perform detection post processing.
If no rotations were requested, any plugin post-processing will be done here.
- Detection boxes are:
stacked into a single array
scaled back to frame dimensions,
filtered for faces which fall outside min/max thresholds
Added to the batch object along with frame to face mapping information.
- Parameters:
batch (ExtractBatch) – The incoming ExtractBatch to use for post-processing
- Return type:
None
- pre_process(batch: ExtractBatch) None
Perform pre-processing for detection plugins.
Gets the scale and padding to take the batch of images to model input size
Formats the image to the correct color order, dtype and scale for the plugin
Performs any plugin specific pre-processing
- Parameters:
batch (ExtractBatch) – The incoming ExtractBatch to use for pre-processing
- Return type:
None
- process(batch: ExtractBatch) None
Obtain the output from the plugin’s model.
Executes the plugin’s predict function and stores the output prior to post-processing.
If rotations have been selected, plugin post-processing is done as part of this process as the computed bounding boxes are required for re-feeding the model future rotations
- Parameters:
batch (ExtractBatch) – The incoming ExtractBatch to use for processing
- Return type:
None
- output_info() None
Output the counts of filtered items
- Return type:
None
- post_process(batch: ExtractBatch) None
Perform detection post processing.
If no rotations were requested, any plugin post-processing will be done here.
- Detection boxes are:
stacked into a single array
scaled back to frame dimensions,
filtered for faces which fall outside min/max thresholds
Added to the batch object along with frame to face mapping information.
- Parameters:
batch (ExtractBatch) – The incoming ExtractBatch to use for post-processing
- Return type:
None
- pre_process(batch: ExtractBatch) None
Perform pre-processing for detection plugins.
Gets the scale and padding to take the batch of images to model input size
Formats the image to the correct color order, dtype and scale for the plugin
Performs any plugin specific pre-processing
- Parameters:
batch (ExtractBatch) – The incoming ExtractBatch to use for pre-processing
- Return type:
None
- process(batch: ExtractBatch) None
Obtain the output from the plugin’s model.
Executes the plugin’s predict function and stores the output prior to post-processing.
If rotations have been selected, plugin post-processing is done as part of this process as the computed bounding boxes are required for re-feeding the model future rotations
- Parameters:
batch (ExtractBatch) – The incoming ExtractBatch to use for processing
- Return type:
None