Detecting anomalies in an image
To detect anomalies in an image with a trained Amazon Lookout for Vision model, you
call the DetectAnomalies operation. The result
from DetectAnomalies
includes a boolean prediction that the image contains one or more anomalies and a
confidence
value for the prediction.
Images analyzed with DetectAnomalies
must have the same dimensions as the images used to train the model.
Before calling DetectAnomalies
, you must first start your model with the StartModel
operation.
For more information, see Starting your Amazon Lookout for Vision model.
You are charged for the amount of time, in minutes, that a model runs and for the
number of anomaly detection units that your
model uses. If you are not using a model, use the StopModel
operation to stop your model. For more information,
see Stopping your Amazon Lookout for Vision model.
To call DetectAnomalies
, specify the following:
-
Project – The name of the project that contains the model that you want to use.
-
ModelVersion – The version of the model that you want to use.
-
ContentType – The type of image that you want analyze. Valid values are
image/png
(PNG format images) andimage/jpeg
(JPG format images). -
Body – The unencoded binary bytes that represent the image.
The response from DetectAnomalies
contains the following:
-
IsAnomalous– A boolean indicator that the image contains one or more anomalies.
-
Confidence– The confidence that Amazon Lookout for Vision has in the accuracy of the anomaly prediction (
IsAnomalous
).Confidence
is a floating point value between 0 and 1. A higher value indicates a higher confidence. -
Source – Information about the image passed to
DetectAnomalies
.
{ "DetectAnomalyResult": { "Source": { "Type": "direct" }, "IsAnomalous": true, "Confidence": 0.9996867775917053 } }
If you're finding the confidence values returned by DetectAnomalies
are too low,
consider retraining the model.
To detect anomalies in an image (API)
-
If you haven't already done so, do the following:
-
Create or update an IAM user. For more information, see Step 2: Create an IAM administrator user and group.
-
Install and configure the AWS CLI and the AWS SDKs. For more information, see Step 5: Set up the AWS CLI and AWS SDKs.
-
-
Ensure the IAM user calling
DetectAnomalies
has access to the model version that you want to use. -
Use the following examples to call the
DetectAnomalies
operation.Tip If you're using the Getting Started images, use an image from the
extra_images
folder. -
If you aren't planning to continue using your model, stop your model.