Defect detection is an important step in the field of industrial production. Through the study of deep learning and transfer learning, this paper proposes a method of defect detection based on deep learning and transfer learning. Our method firstly establishes Deep Belief Networks and trains it according to the source domain sample feature, in order to obtain the weights of the network according to source domain samples. Then, the structure and parameters of the source domain DBN is transferred to the target domain and target domain samples are used to fine-tune the network parameters to get the mapping relationship between the target domain training sample and defect-free template. Finally, the defects of testing samples will be detected by compared with the reconstruction image. This method not only can make full use of the advantages of DBN, also can solve over-fitting in DBN network training through parameters transfer learning. These experiments show that DBN is a successful approach in the high-dimensional-feature-space information extraction task, which can perfectly establishes the mapping relationship, and can quickly detect defects with a high accuracy.