|  | 
| 22 | 22 | 
 | 
| 23 | 23 | 
 | 
| 24 | 24 | class AnomalyDetection(ImageModel): | 
|  | 25 | +    """Anomaly Detection model. | 
|  | 26 | +
 | 
|  | 27 | +    Generic anomaly detection model that acts as an inference wrapper for all the exported models from | 
|  | 28 | +    Anomalib. | 
|  | 29 | +
 | 
|  | 30 | +    Args: | 
|  | 31 | +        inference_adapter (InferenceAdapter): Inference adapter | 
|  | 32 | +        configuration (dict, optional): Configuration parameters. Defaults to {}. | 
|  | 33 | +        preload (bool, optional): Whether to preload the model. Defaults to False. | 
|  | 34 | +
 | 
|  | 35 | +    Example: | 
|  | 36 | +        >>> from model_api.models import AnomalyDetection | 
|  | 37 | +        >>> import cv2 | 
|  | 38 | +        >>> model = AnomalyDetection.create_model("./path_to_model.xml") | 
|  | 39 | +        >>> image = cv2.imread("path_to_image.jpg") | 
|  | 40 | +        >>> result = model.predict(image) | 
|  | 41 | +            AnomalyResult(anomaly_map=array([[150, 150, 150, ..., 138, 138, 138], | 
|  | 42 | +                [150, 150, 150, ..., 138, 138, 138], | 
|  | 43 | +                [150, 150, 150, ..., 138, 138, 138], | 
|  | 44 | +                ..., | 
|  | 45 | +                [134, 134, 134, ..., 138, 138, 138], | 
|  | 46 | +                [134, 134, 134, ..., 138, 138, 138], | 
|  | 47 | +                [134, 134, 134, ..., 138, 138, 138]], dtype=uint8), | 
|  | 48 | +                pred_boxes=None, pred_label='Anomaly', | 
|  | 49 | +                pred_mask=array([[1, 1, 1, ..., 1, 1, 1], | 
|  | 50 | +                    [1, 1, 1, ..., 1, 1, 1], | 
|  | 51 | +                    [1, 1, 1, ..., 1, 1, 1], | 
|  | 52 | +                    ..., | 
|  | 53 | +                    [1, 1, 1, ..., 1, 1, 1], | 
|  | 54 | +                    [1, 1, 1, ..., 1, 1, 1], | 
|  | 55 | +                    [1, 1, 1, ..., 1, 1, 1]], dtype=uint8), | 
|  | 56 | +                    pred_score=0.8536462108391619) | 
|  | 57 | +    """ | 
|  | 58 | + | 
| 25 | 59 |     __model__ = "AnomalyDetection" | 
| 26 | 60 | 
 | 
| 27 | 61 |     def __init__( | 
|  | 
0 commit comments