Visual surface anomaly detection focuses on the classification (CLS) and location (LOC) of regions that deviate from the normal appearance, and generally, only normal samples are provided for training. The reconstruction-based method is widely used, which locates the anomalies by analyzing the reconstruction error. However, there are two problems unsettled in the reconstruction-based method. First, the reconstruction error in the normal regions is sometimes large. This might mislead the model to take the normal regions as anomalies, which is named an overkill problem. Second, it has been observed that the anomalous regions sometimes cannot be repaired to normal, which results in a small reconstruction error in the anomalous regions. This misleads the model to take the anomalies as normal, which is called an anomaly escape problem. Aiming at the above two problems, we propose a model named dual branch autoencoder with prior information (DBPI) which is mainly composed of a dual-branch AE structure and a GA unit. To alleviate the overkill problem, a natural idea is to reduce the reconstruction error in the normal regions, and therefore a dual branch AE is proposed. The dual-branch AE reconstructs two images with consistent normal regions and different anomalous regions. By analyzing the reconstruction error between the above two reconstructed images, the anomalies can be detected without causing overkill. For the anomaly escape problem, an effective solution is to add prior information of normal appearance to the reconstructive network, which assists in repairing the anomalous regions and increasing the reconstruction error in the anomalous regions. Since the mathematical expectation map of the training data contains crucial features of the normal appearance, we utilize it as the prior information of the normal appearance. And the prior information is selectively introduced by the proposed gated attention (GA) unit, which effectively assists in reconstructing a normal image and further mitigates the anomaly escape problem. On the average precision (AP) metric for the anomaly detection benchmark dataset MVTec, the proposed unsupervised method outperforms the current stateof-the-art reconstruction-based method self-supervised predictive convolutional attentive block (SSPCAB) by 7.4%. Meanwhile, our unsupervised method also exhibits comparable performance to the best supervised methods on the surface defect detection DAGM dataset.