I would like to detect defects/anomalies in images. Due to the lack of images with anomalies, I try to solve the problem in an unsupervised manner. Until now, I trained a variational autoencoder together with an generative adversarial network with “good” images. Now, I have an encoder/decoder network which is able to produce images without anomalies. Here are two examples:
original image | cropped image & input of the encoder | output of the decoder
In those images, if the object is rotated (not vertical), then it is an anomaly (like the second image). To measure the difference between the input/output of the encoder/decoder network, I tried the structural similarity metric SSIM. However, the result is not satisfying enough as many images without an anomaly also have a low similarity value. Also the pixel-wise MAE or MSE metrics are not good as they do not look specifically on the structure and are very sensitive to the brightness. Here is the result with the SSIM metric (green are the good examples, red are the anomalies):
What I want to avoid is to add specific rules for the detection, in this example to detect vertical lines because there are many other objects with different anomalies which I would like to detect.
Do you have a suggestion for another image similarity metric? Am I on the right path or are there other/better methods to do unsupervised anomaly detection?
PS: There are only a few images with anomalies (<10 images), but many without an anomaly..