darcyai.perceptor.image_classification_perceptor
ImageClassificationPerceptor Objects
class ImageClassificationPerceptor(MultiPlatformPerceptorBase)
ImageClassificationPerceptor is a class that implements the Perceptor interface for image classification.
__init__
def __init__(processor_preference: dict,
threshold: float,
top_k: int = None,
mean: float = 128.0,
std: float = 128.0,
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. - top_k (
int
): The number of top predictions to return. - mean (
float
): The mean of the image (Coral Edge TPU). - std (
float
): The standard deviation of the image (Coral Edge TPU). - 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.image_classification_perceptor import ImageClassificationPerceptor
from darcyai.perceptor.processor import Processor
processor_preference = {
Processor.CORAL_EDGE_TPU: {
"model_path": "/path/to/model.tflite",
"labels_file": "/path/to/labels.txt", // The path to the labels file.
},
Processor.CPU: {
"model_path": "/path/to/model.tflite",
"labels": { // A dictionary of labels.
"label_1": "label_1_name",
"label_2": "label_2_name",
},
},
}
image_classification_perceptor = ImageClassificationPerceptor(
processor_preference=processor_preference, threshold=0.5, top_k=5)