DynAIkonTrap.filtering.animal#
This module provides a generic interface to an animal detector. The system is fairly agnostic of the specific animal detection mechanism beings used, as the input to the AnimalFilter
is a JPEG, RGB or RGBA image and the output a confidence in the image containing an animal.
The animal detection model may be chosen from a range of pre-trained detector networks, configurable via AnimalFilterSettings
. Choices currently range between: a SSDLite MobileNet v2 model trained on WCS data, int32 quantised, a SSDLite MobileNet v2 model trained on human and WCS data, int32 quantised and a YOLOv4-tiny model trained on WCS data
The function, AnimalFilter.run()
produces a tuple result, the first result indicates animal presence; the second result human presence. If the model used is trained on WCS data only, the second result will always be False
Classes
|
Animal filter stage to indicate if a frame contains an animal |
|
Class to store supported compressed image formats |
A class to hold data for neural network input buffer sizes. |
- class AnimalFilter(settings: AnimalFilterSettings)#
Animal filter stage to indicate if a frame contains an animal
- Parameters
settings (AnimalFilterSettings) – Settings for the filter
- run(image: bytes, img_format: Union[RawImageFormat, CompressedImageFormat] = CompressedImageFormat.JPEG) Tuple[bool, bool] #
The same as
run_raw()
, but with a threshold applied. This function outputs a boolean to indicate if the confidences are at least as large as the threshold- Parameters
image (bytes) – The image frame to be analysed, can be in JPEG compressed format or RGBA, RGB raw format
img_format (Union[RawImageFormat, CompressedImageFormat], optional) – Enum indicating which image format has been passed. Defaults to CompressedImageFormat.JPEG.
- Returns
Each element is True if the confidence is at least the threshold, otherwise False. Elements represent detections for animal and human class.
- Return type
Tuple(bool, bool)
- run_raw(image: bytes, img_format: Union[RawImageFormat, CompressedImageFormat] = CompressedImageFormat.JPEG) Tuple[float, float] #
Run the animal filter on the image to give a confidence that the image frame contains an animal and/or a human. For configurations where an animal-only detector is initialised, human confidence will always equal 0.0.
- Parameters
image (bytes) – The image frame to be analysed, can be in JPEG compressed format or RGBA, RGB raw format
img_format (Union[RawImageFormat, CompressedImageFormat], optional) – Enum indicating which image format has been passed. Defaults to CompressedImageFormat.JPEG.
- Returns
Confidences in the output containing an animal and a human as a decimal fraction
- Return type
Tuple(float, float)