Autoencoder reconstructions are widely used for the task of unsupervised\nanomaly localization. Indeed, an autoencoder trained on normal data is expected\nto only be able to reconstruct normal features of the data, allowing the\nsegmentation of anomalous pixels in an image via a simple comparison between\nthe image and its autoencoder reconstruction. In practice however, local\ndefects added to a normal image can deteriorate the whole reconstruction,\nmaking this segmentation challenging. To tackle the issue, we propose in this\npaper a new approach for projecting anomalous data on a autoencoder-learned\nnormal data manifold, by using gradient descent on an energy derived from the\nautoencoder's loss function. This energy can be augmented with regularization\nterms that model priors on what constitutes the user-defined optimal\nprojection. By iteratively updating the input of the autoencoder, we bypass the\nloss of high-frequency information caused by the autoencoder bottleneck. This\nallows to produce images of higher quality than classic reconstructions. Our\nmethod achieves state-of-the-art results on various anomaly localization\ndatasets. It also shows promising results at an inpainting task on the CelebA\ndataset.\n