Most factories use automatic dispensing machines for workpiece sealing, and the processing efficiency is very high. The traditional manual detection is inefficient and costly. Besides, the rate of false detection and missed detection of defect products remains high. In view of this problem, this paper proposes a glue line defect detection model based on Yolov5 and the self-built workpiece defect data set is used for the research. Firstly, some conventional convolution modules in Backbone network are replaced with the corresponding deformable convolution modules to improve the generalization ability of the model. Then in order to improve the feature extraction ability of the model, the coordinate attention module is embedded in the Backbone network. The results show that the mean average precision of the proposed algorithm can reach 95.62%, which is greatly higher than initial Yolov5 algorithm. And the detection rate reaches 28.67 FPS, which can meet the real time detection.