Computer-implemented method for detecting an anomalous image among a first dataset of images using an Adversarial Autoencoder (12, 14, 16) wherein the Adversarial Autoencoder (12, 14, 16) is trained in a first training with a training dataset of images, whereas the Adversarial Autoencoder (12, 14, 16) is optimized such that a distribution of latent representations of images of the training dataset of images approaches a predetermined prior distribution and that a reconstruction error of reconstructed images of the training dataset of images is minimized, after the first training of the Adversarial Autoencoder (12, 14, 16), anomalies are detected in the latent representations and the Adversarial Autoencoder (12, 14, 16) is trained in a second training with the training dataset of images, but taking into account the detected anomalies, wherein anomalies detected in the latent representation are taken into account either by excluding detected anomalies from the training set, or by using a weighted loss function for tuning the Adversarial Autoencoder (12, 14, 16), whereas anomalies detected in the latent representation receive a reduced weight, or by modifying a reconstruction target for each of a set of the anomalies detected in the latent representation to a noise-corrupted version of itself, or by modifying a reconstruction target for each of a set of the anomalies detected in the latent representation to an image close or closest in the latent space that is identified as no anomaly, the anomalous image among the first dataset of images is detected by the trained Adversarial Autoencoder (12, 14, 16) dependent on at least one of the reconstruction error of the image and the probability density under the predetermined prior distribution. first dataset of images using an Adversarial Autoencoder (12, 14, 16) wherein the Adversarial Autoencoder (12, 14, 16) is trained in a first training with a training dataset of images, whereas the Adversarial Autoencoder (12, 14, 16) is optimized such that a distribution of latent representations of images of the training dataset of images approaches a predetermined prior distribution and that a reconstruction error of reconstructed images of the training dataset of images is minimized, after the first training of the Adversarial Autoencoder (12, 14, 16), anomalies are detected in the latent representations and the Adversarial Autoencoder (12, 14, 16) is trained in a second training with the training dataset of images, but taking into account the detected anomalies, wherein anomalies detected in the latent representation are taken into account either by excluding detected anomalies from the training set, or by using a weighted loss function for tuning the Adversarial Autoencoder (12, 14, 16), whereas anomalies detected in the latent representation receive a reduced weight, or by modifying a reconstruction target for each of a set of the anomalies detected in the latent representation to a noise-corrupted version of itself, or by modifying a reconstruction target for each of a set of the anomalies detected in the latent representation to an image close or closest in the latent space that is identified as no anomaly, the anomalous image among the first dataset of images is detected by the trained Adversarial Autoencoder (12, 14, 16) dependent on at least one of the reconstruction error of the image and the probability density under the predetermined prior distribution.