ExtractHandler
- class lib.infer.handler.ExtractHandler(plugin: str, compile_model: bool = False, config_file: str | None = None)
Bases:
ABCHandles the execution of a plugin’s pre_process, process and post_process actions
- Parameters:
plugin (str) – The name of the plugin that this handler is to use
compile_model (bool) –
Trueto compile any PyTorch modelsconfig_file (str | None) – Full path to a custom config file to load.
Nonefor default config
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.
Called after the final item is put to the out queue.
post_process(batch)Perform post-processing on the given batch object, ready for exit from the plugin.
pre_process(batch)Override to perform plugin type specific behavior for pre-processing on the given batch object, ready for inference.
process(batch)Override to plugin type specific processing to get results from the plugin's inference for the given batch.
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
Called after the final item is put to the out queue. Override for plugin runner specific output
- Return type:
None
- abstractmethod post_process(batch: ExtractBatch) None
Perform post-processing on the given batch object, ready for exit from the plugin. Override for plugin type specific behavior
- Parameters:
batch (ExtractBatch) – The incoming ExtractBatch to use for post-processing
- Return type:
None
- abstractmethod pre_process(batch: ExtractBatch) None
Override to perform plugin type specific behavior for pre-processing on the given batch object, ready for inference.
- Parameters:
batch (ExtractBatch) – The incoming ExtractBatch to use for pre-processing
- Return type:
None
- abstractmethod process(batch: ExtractBatch) None
Override to plugin type specific processing to get results from the plugin’s inference for the given batch.
- Parameters:
batch (ExtractBatch) – The incoming ExtractBatch to use for processing
- Return type:
None
- __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
- property batch_size: int
The batch size of the plugin
- do_compile
Trueif any managed Torch modules are to be compiled
- 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
Called after the final item is put to the out queue. Override for plugin runner specific output
- Return type:
None
- plugin
The extraction plugin that this handler manages
- plugin_name
The name of the plugin that is being handled
- plugin_type: Literal['detect', 'align', 'mask', 'identity', 'file']
The type of plugin that this handler manages
- abstractmethod post_process(batch: ExtractBatch) None
Perform post-processing on the given batch object, ready for exit from the plugin. Override for plugin type specific behavior
- Parameters:
batch (ExtractBatch) – The incoming ExtractBatch to use for post-processing
- Return type:
None
- abstractmethod pre_process(batch: ExtractBatch) None
Override to perform plugin type specific behavior for pre-processing on the given batch object, ready for inference.
- Parameters:
batch (ExtractBatch) – The incoming ExtractBatch to use for pre-processing
- Return type:
None
- abstractmethod process(batch: ExtractBatch) None
Override to plugin type specific processing to get results from the plugin’s inference for the given batch.
- Parameters:
batch (ExtractBatch) – The incoming ExtractBatch to use for processing
- Return type:
None
- processors: tuple[Literal['pre_process', 'process', 'post_process'], ...] = ('pre_process', 'process', 'post_process')
The processors which should have thread’s launched for this handler
- property runner: ExtractRunner
The runner that runs this handler