As a biometric recognition technology, face recognition has the characteristics of universality, high reliability and strong individual differences, and has broad application prospects in the field of smart security. According to the needs of the access control and attendance system in the construction of the school's smart campus, this paper applies the face recognition algorithm based on deep learning to the face recognition access control and attendance system, and makes lightweight improvements to the algorithm to address the common problem of large amounts of calculation. This paper uses the improved RetainNet face detection model to design and implement an automatic attendance system based on face recognition for the classroom scene. Based on the classroom surveillance video stream, face detection is first performed, and the face filtering method is used after obtaining the face image set. Eliminate face images with low face quality and successfully recognized positions, then perform face super-resolution and face alignment, and finally send them to the face recognition model for face comparison to complete attendance. Experiments show that the improvements proposed in this article effectively improve the accuracy of classroom face detection.