As a classical research direction in the field of computer vision, anomaly detection has a very wide range of application prospects. Surface defect detection is an extremely important part of the industrial production process. Most of the traditional defect detection solutions are based on machine vision or supervised learning paradigms. These methods require the use of a large number of supervised defect samples, but it is difficult to obtain sufficient defect data in the production process. Due to various random factors, it is not easy to identify all types of defects during the inspection phase. With the development of deep unsupervised learning in recent years, autoencoder or generative adversarial networks are widely used in surface defect detection problem, which rely solely on the modeling of good data to discriminate abnormal defects. Therefore, in this paper, we propose a neural architecture search-based defect detection method. We combine neural architecture search and generative adversarial learning to automate the search of encoder-decoder structures with a gradient optimization-based search method. The method learns a pair of an anomalous image and its anomaly-free reconstruction, while simultaneously learning a decision boundary between normal and anomalous examples. Neural architecture search helps to search for a task-appropriate network architecture with better performance. Finally, the proposed method is evaluated on the industrial inspection dataset MVTec AD, and the effectiveness of the model detection is measured by AUROC metrics, demonstrating the validity of the methods is demonstrated by both quantitative and qualitative analysis.