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