Diffuse reflection occurs when light, further waves, or particles are reflected off a surface in such a way that a ray encountered on the surface is dispersed at several angles instead of one as in specular reflection. With the rapid development of modern industry, irregular diffuse reflection may appear due to the particles on the surface, such as frosted paint surfaces, making the defect information easy to be covered up by scattered light, preventing the defect from being detected, and reducing detection accuracy. Therefore, this paper aims to deeply explore the diffuse reflection surface defect detection approach based on machine learning. The Gray code and four-step phase shift technique are used to resolve the absolute phase of a reflection image while the image defect is determined by converting the absolute phase's gradient. The automatic edge finding algorithm is then used to obtain the image vertex of the sample to be measured, the affine transformation is used for attitude correction, and the module matching approach is used to locate the diffuse reflection surface defect. The gray morphological opening and closing operation is used for the original image to obtain the morphology and position information of the defect. Finally, Adam optimizer is chosen as the gradient descent algorithm's optimizer. Experimental results show that the proposed approach can effectively improve the accuracy of diffuse reflection surface defect detection and reduce the economic cost of defect detection, which has a certain practical value.