Abstract:To solve the problem that the closed-set pig face recognition model cannot recognize pig individuals that have not appeared in the training set, an open-set pig face recognition method that integrated attention mechanism was proposed, which can realize open-set pig face image recognition and recognize pig individuals that the model had never seen. Firstly, a lightweight feature extraction module (GCDSC) was constructed based on a global attention mechanism, inverted residual structure, and depth separable convolution. Secondly, C3ECAGhost module was designed based on efficient attention mechanism, Ghost convolution, and residual network to extract high-level semantic features of pig face images. Finally, based on the MobileFaceNet network, incorporating GCDSC module, C3ECAGhost module, SphereFace loss function, and Euclidean distance measurement method, the model PigFaceNet was constructed to realize open-set pig face recognition. The experimental results showed that the GCDSC module can improve the accuracy of pig face recognition by 1.05 percentage points, and the C3ECAGhost module can further improve the accuracy of the model by 0.56 percentage points. The accuracy of the PigFaceNet model in open-set pig face recognition verification can reach 94.28%, which was 1.61 percentage points higher than that before modification. The model proposed was a lightweight model with 5.44MB parameters, which can improve the accuracy and provide a reference for intelligent breeding of pig farms.