Computer-implemented method for detecting an anomalous image among a first dataset of images using an Adversarial Autoencoder wherein the Adversarial Autoencoder is trained in a first training with a training dataset of images , whereas the Adversarial Autoencoder 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 , anomalies are detected in the latent representations and the Adversarial Autoencoder 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 , 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 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 wherein the Adversarial Autoencoder is trained in a first training with a training dataset of images , whereas the Adversarial Autoencoder 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 , anomalies are detected in the latent representations and the Adversarial Autoencoder 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 , 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 dependent on at least one of the reconstruction error of the image and the probability density under the predetermined prior distribution . <EOS>