This study proposes a workpiece recognition method based on an improved YOLOv7 to address the shortcomings of traditional template matching and simple machine learning algorithms in workpiece recognition.The method primarily focuses on modifying the convolutional layers by replacing the standard convolutional layers of the YOLOv7 deep network with improved ones,aiming to enhance network computation speed and recognition accuracy.Additionally,the dataset parameters are clustered using a modified K-means clustering method to obtain prediction boxes better suited for workpiece recognition.Moreover,an improved spatial pyramid pooling algorithm is introduced to achieve speed improvements while maintaining the receptive field unchanged.Experimental results demonstrate that the proposed method outperforms the traditional YOLOv7 algorithm in workpiece recognition tasks,achieving higher recognition accuracy and faster detection speed.