In the current complex assembly scenarios,various workpieces are stacked together,which brings challenges to the accurate recognition of assembly robots.To solve the problem,this paper proposes an im-proved YOLOv5 model for the detection and recognition of stacked workpieces.The EIFM edge informa-tion fusion module is used to enhance the contour information of the target samples;the MAM multi-scale attention module is added at the end of the feature extraction network to enhance the detection of complex scenes and smaller targets;the PANet path aggregation network in the original YOLOv5's Neck network is replaced with the BiFPN bi-directional feature pyramid fusion structure,which performs weighted feature fusion on high and low feature information;finally,the traditional non-great feature fusion network is re-placed with a BiFPN bi-directional feature pyramid fusion structure.fusion;finally,the traditional non-great suppression algorithm is changed to DIOU_NMS to reduce the leakage of detection due to mutual occlusion of artifacts.The algorithm comparison experiments and stacking degree comparison experiments show that:the mAP of the improved YOLOv5 algorithm reaches 97.8%,which is 7.25%higher than the pre-im-provement;the mAP of the target detection in the low,medium and high stacked workpiece datasets reaches 98.76%,97.93%and 94.96%,which is 0.67%,1.56%,4.41%higher than the pre-improvement YOLOv5 algorithm,respectively.Compared with the original YOLOv5 algorithm,the improved algorithm model achieves more accurate identification and localization of workpieces with high stacking degree.