Main Content

efficientADAnomalyDetector

Detect anomalies using EfficientAD network

Since R2024b

    Description

    The efficientADAnomalyDetector object detects images of anomalies using an EfficientAD anomaly detector network. Train the detector using the trainEfficientADAnomalyDetector function. To detect anomalous images, pass the trained detector to the classify function.

    Note

    This functionality requires Deep Learning Toolbox™ and the Automated Visual Inspection Library for Computer Vision Toolbox™. You can install the Automated Visual Inspection Library for Computer Vision Toolbox from Add-On Explorer. For more information about installing add-ons, see Get and Manage Add-Ons.

    Creation

    Description

    detector = efficientADAnomalyDetector creates an EfficientAD anomaly detector from a base patch description network (PDN).

    detector = efficientADAnomalyDetector(Name=Value) specifies options for the EfficientAD anomaly detector creation using one or more name-value arguments.

    example

    Input Arguments

    expand all

    Name-Value Arguments

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Example: efficientADAnomalyDetector(PDNnet="pdn-small") specifies the patch description network as "pdn-small".

    Name of the patch description network (PDN), a convolutional network that serves as the base feature extraction network, specified as one of these values:

    • "pdn-small" — PDN of reduced depth that has a teacher and student network architecture.

    • "pdn-medium" — PDN that uses twice as many filters in the middle layers of both its teacher and student networks. This network has a higher capacity to extract and learn detailed and nuanced features from image patches, at the expense of more computation time.

    For images of variable size, the PDN generates all feature vectors in a single forward pass.

    Data Types: char | string

    Global anomaly map autoencoder toggle for tile-based training, specified as a numeric or logical 1 (true) or 0 (false). If you specify UseGlobalAnomalyMap as false, the efficientADAnomalyDetector object creates an EfficientAD anomaly detector that uses the student-teacher model to generate the local anomaly map, and turns off the autoencoder, which primarily detects global anomalies. To perform inference on full-size images after tile-based training on patches of images, turn off the autoencoder by specifying UseGlobalAnomalyMap as false.

    Tip

    When you perform tile-based training and GPU memory is limited, reduce the mini-batch size using the MiniBatchSize (Deep Learning Toolbox) argument of the trainingOptions (Deep Learning Toolbox) function, at the expense of slower computation speed.

    Properties

    expand all

    Anomaly threshold, stored as a numeric scalar. You must set the value of the threshold before calling the classify function. You can calculate a threshold using the anomalyThreshold function.

    This property is read-only.

    Image size of images used for training and inference, stored as a three-element numeric row vector. The trainEfficientADAnomalyDetector function sets the ImageSize property during training, which indicates the size of the training images. The image size can be different from the input layer size of the base feature extraction PDN.

    Note

    When using the detector, the image size at inference must match the image size used during training.

    Object Functions

    predictPredict unnormalized anomaly scores
    classifyClassify image as normal or anomalous
    anomalyMapPredict per-pixel anomaly score map

    Examples

    collapse all

    Create an efficientADAnomalyDetector object from a medium-sized base patch description network (PDN).

    detector = efficientADAnomalyDetector(Network="pdn-medium")
    detector = 
      efficientADAnomalyDetector with properties:
    
        Threshold: []
        ImageSize: []
    
    

    More About

    expand all

    References

    [1] Batzner, Kilian, Lars Heckler, and Rebecca König. “EfficientAD: Accurate Visual Anomaly Detection at Millisecond-Level Latencies.” arXiv, February 8, 2024. https://doi.org/10.48550/arXiv.2303.14535.

    Extended Capabilities

    Version History

    Introduced in R2024b