fastFlowAnomalyDetector - Detect anomalies using FastFlow network - MATLAB (original) (raw)
Detect anomalies using FastFlow network
Since R2023a
Description
The fastFlowAnomalyDetector
object detects images of anomalies using a FastFlow anomaly detector network. Train the detector using the trainFastFlowAnomalyDetector function. To detect anomalous images, pass the trained detector to the classify function.
Note
This functionality requires Deep Learning Toolbox™. This functionality also requires the Deep Learning Toolbox Model for ResNet-18 Network and the Automated Visual Inspection Library for Computer Vision Toolbox™, which you can install from Add-On Explorer. For more information about installing add-ons, see Get and Manage Add-Ons.
Creation
Syntax
Description
detector = fastFlowAnomalyDetector
creates a FastFlow anomaly detector from a ResNet-18 backbone network.
detector = fastFlowAnomalyDetector(`Name=Value`)
specifies the Backbone,NumFlowSteps and FlowModelChannelRatio properties of the FastFlow anomaly detector using name-value arguments.
For example, NumFlowSteps=10
sets the number of steps in the flow network of the FastFlow detector to 10.
Properties
This property is read-only.
Pretrained backbone network that serves as the base feature extraction network, specified as a dlnetwork (Deep Learning Toolbox) object. The network must accept a single input and produce one or more outputs. If you do not specify theBackbone
property, fastFlowAnomalyDetector
uses a ResNet-18 network as the backbone feature extraction network.
To set the value of this property, you must specify it at object creation.
Data Types: dlnetwork
This property is read-only.
Number of steps in the flow network of the FastFlow detector, specified as a positive integer. Increase the number of flow network steps to obtain more trainable parameters at the possible expense of increasing memory cost and using more computing resources.
To set the value of this property, you must specify it at object creation.
This property is read-only.
Ratio of input channels to hidden channels used in the input and output subnet layers after the channels are split in the flow network, specified as a positive numeric scalar. Increase the value of FlowModelChannelRatio
to improve detection metrics at the possible expense of increasing memory cost and using more computing resources.
To set the value of this property, you must specify it at object creation.
Anomaly threshold, specified 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.
Network layers, specified as an array of Layer
objects.
This property is read-only.
Network input layer names, specified as a cell array of character vectors.
This property is read-only.
Network output layer names, specified as a cell array of character vectors.
This property is read-only.
Network state, specified as a table with three columns.
Layer
— Layer name, specified as a string scalarParameter
— State parameter name, specified as a string scalarValue
— Value of state parameter, specified as adlarray
object
Layer states contain information calculated during the layer operation to be retained for use in subsequent forward passes of the layer. For example, the cell state and hidden state of LSTM layers, or running statistics in batch normalization layers.
This property is read-only.
Network learnable parameters, specified as a table with three columns.
Layer
— Layer name, specified as a string scalarParameter
— Parameter name, specified as a string scalarValue
— Value of parameter, specified as adlarray
object
The network learnable parameters contain the features that the network learns. For example, the parameters include the weights of convolution and fully connected layers.
Object Functions
predict | Predict unnormalized anomaly scores |
---|---|
classify | Classify image as normal or anomalous |
anomalyMap | Predict per-pixel anomaly score map |
Examples
Create a fastFlowAnomalyDetector
object.
detector = fastFlowAnomalyDetector
detector = fastFlowAnomalyDetector with properties:
Threshold: []
References
[1] Yu, Jiawei, Ye Zheng, Xiang Wang, Wei Li, Yushuang Wu, Rui Zhao, and Liwei Wu. "FastFlow: Unsupervised Anomaly Detection and Localization via 2D Normalizing Flows." arXiv, November 16, 2021. https://doi.org/10.48550/arXiv.2111.07677.
[2] He, Kaiming, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. “Deep Residual Learning for Image Recognition.” In 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 770–78. Las Vegas, NV, USA: IEEE, 2016. https://doi.org/10.1109/CVPR.2016.90.
Extended Capabilities
Version History
Introduced in R2023a
Specify the backbone feature extraction network as a dlnetwork (Deep Learning Toolbox) object by using the Backbone name-value argument.
Specify the number of steps in the flow network by using the NumFlowSteps name-value argument. For example, NumFlowSteps=10
sets the number of steps in the flow network of the FastFlow detector to 10.
Specify the ratio of input channels to hidden channels in the input and output subnet layers of the FastFlow detector by using the FlowModelChannelRatio name-value argument.