darcyai.perceptor.object_detection_perceptor
ObjectDetectionPerceptor Objects
class ObjectDetectionPerceptor(MultiPlatformPerceptorBase)
ObjectDetectionPerceptor is a class that implements the Perceptor interface for object detection.
__init__
def __init__(processor_preference: dict,
threshold: float,
quantized: bool = True,
num_cpu_threads: int = 1)
Arguments
- processor_preference: A dictionary of processor preference. The key is the processor. Values are dictionaries of model paths and labels.
- threshold (
float
): The threshold for object detection. - quantized (
bool
): Whether the model is quantized (CPU). - num_cpu_threads (
int
): The number of threads to use for inference (CPU). Defaults to 1.
Example
from darcyai.perceptor.object_detection_perceptor import ObjectDetectionPerceptor
from darcyai.perceptor.processor import Processor
processor_preference = {
Processor.CORAL_EDGE_TPU: {
"model_path": "/path/to/model.tflite",
"labels_file": "/path/to/labels.txt",
},
Processor.CPU: {
"model_path": "/path/to/model.tflite",
"labels": {
"label_1": "label_1_name",
"label_2": "label_2_name",
},
},
}
object_detection_perceptor = ObjectDetectionPerceptor(
processor_preference=processor_preference,
threshold=0.5,
top_k=5)