Uncontrolled animal face recognition method and device based on generative structure prior guidance
Patent Information
- Application Number
- CN202610794350.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-03
- Publication Date
- 2026-10-23
AI Technical Summary
[0005]本发明的目的在于克服现有技术中所存在的非受控场景下数据量少、姿态不一致导致识别准确率低的问题,提供一种基于生成式结构先验引导的非受控动物脸部识别方法及设备
本发明通过语义分割模型对待识别动物的面部图像进行掩码处理,再输入到双分支混合识别网络中进行特征提取和增强处理,最后将增强后的特征输入到全连接层中进行分类识别,输出待识别动物的动物个体识别结果。本发明创新性地利用生成大模型的潜空间作为结构先验,弥补了小样本数据下判别模型对物体三维结构认知不足的缺陷,显著提升了模型在数据匮乏场景下的泛化能力。通过结构引导的特征交互机制,使判别网络能够抵抗姿态变化带来的形变干扰。同时,通过结构引导通道特征注意力模块和特征级线性调制机制,将生成分支提取的显式结构信息注入判别分支,使特征提取过程能够抵抗姿态变化带来的形变干扰。结合语义分割掩码的注意力机制,有效提升了复杂背景下的识别鲁棒性。同时结合语义分割掩码,在特征层级直接抑制背景噪声的响应,有效解决了野外复杂背景下的误识别问题,多子中心损失函数允许同一动物个体拥有多个特征中心,符合非受控场景下类内差异大的数据分布规律。
Smart Images

Figure CN122967307A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer image recognition technology, and in particular to a method and device for uncontrolled animal face recognition based on generative structure prior guidance. Background Technology
[0002] Animal identification is a key technology in wildlife conservation, ecological research, and livestock management. Traditional animal identification often relies on manual tagging (such as ear tags and collars), which can cause invasive harm to animals and is costly. In recent years, deep learning-based computer vision methods have gradually become mainstream. Current animal identification methods mainly draw on mature frameworks of facial recognition. In terms of feature extraction, they typically use LightCNN, optimized for faces, as the backbone network to extract deep semantic features from images. They also widely use metric learning methods to shorten the distance between similar samples and widen the distance between dissimilar samples. These methods have achieved high recognition accuracy in controlled scenarios (uniform lighting and limited equipment to ensure animal cooperation during filming).
[0003] However, animal face recognition faces significant challenges in uncontrolled outdoor environments: First, the amount of data is typically limited, with sample sizes far smaller than human face datasets, making direct training of deep networks highly susceptible to overfitting. Second, animal postures change drastically, with significant differences between the frontal and side views of the same individual, resulting in extremely high intra-class variance. Existing discriminative models often treat posture changes as "noise" and suppress them, lacking prior knowledge of the animal's three-dimensional head structure, thus failing to extract robust identity features under extreme postures. Third, the background is complex and often occluded. Existing methods struggle to effectively decouple animal features from environmental background features, easily mistaking background textures for identity features, and prone to overfitting to background noise or local textures, leading to a significant drop in recognition rates during posture changes or occlusion. How to introduce external knowledge to compensate for insufficient data and guide the model to understand the animal's inherent structure to resist posture interference is a pressing technical challenge.
[0004] Therefore, there is a need for an uncontrolled animal face recognition method and device that can overcome the current problems of low recognition accuracy caused by insufficient data and inconsistent poses in uncontrolled scenarios. Summary of the Invention
[0005] The purpose of this invention is to overcome the problems of low recognition accuracy caused by insufficient data and inconsistent poses in the existing technology in uncontrolled scenarios, and to provide a method and device for uncontrolled animal face recognition based on generative structure prior guidance.
[0006] To achieve the above-mentioned objectives, the present invention provides the following technical solution: A method for uncontrolled animal face recognition based on generative structural prior guidance includes the following steps: S1: Acquire the facial image of the animal to be identified, generate the corresponding foreground mask, and perform data augmentation processing on the facial image to obtain an enhanced facial image. Input the enhanced facial image and the foreground mask into a pre-constructed dual-branch hybrid recognition network. The dual-branch hybrid recognition network comprises a generative prior branch and a discriminative feature branch; the generative prior branch is a pre-trained generative model; and the discriminative feature branch is a convolutional neural network. S2: In the generative prior branch, latent variable inversion is performed on the enhanced facial image to obtain optimized latent variables containing image distribution information, and structural features of the enhanced facial image are extracted. S3: In the discriminative feature branch, the identity features of the enhanced facial image are extracted by a convolutional neural network; S4: Generate modulation parameters based on the structural features, perform feature-level modulation on the identity features through a pre-trained structure-guided channel feature attention module, and add the foreground mask to suppress background noise, thereby generating enhanced identity features; S5: Input the enhanced identity features into a pre-trained fully connected layer for classification, and output the individual animal identification result of the animal to be identified.
[0007] As a preferred embodiment of the present invention, the latent variable inversion in S2 includes the following steps: Freeze the parameters of the variational autoencoder in the generative model and use the mean of the output of the variational autoencoder as the initial latent variable; Construct an optimization objective function that targets the mean square error between the reconstructed image and the original image; The latent variables are iteratively updated using the optimization objective function until a preset number of iterations or a convergence condition is reached, and the optimized latent variables containing image distribution information are output.
[0008] As a preferred embodiment of the present invention, in step S2, structural features are extracted through a priori-driven structure refinement module; the priori-driven structure refinement module includes an encoding convolutional layer, a multi-head self-attention layer, and a decoding convolutional layer connected in sequence.
[0009] As a preferred embodiment of the present invention, the extraction process of the structural features includes the following steps: The optimization latent variables are mapped to a high-dimensional feature space, and the global structural dependencies in the optimization latent variables are captured by a multi-head self-attention mechanism. Then, the structural features that are robust to pose changes are output through group normalization and decoding convolutional layers.
[0010] As a preferred embodiment of the present invention, the discriminative feature branch further includes a pre-trained domain discriminator; the domain discriminator is pre-trained using a domain adaptation loss, and the pre-training includes the following steps: A domain discriminator is constructed and connected to the end of the discriminative feature branch through a gradient inversion layer; the domain discriminator includes a fully connected layer, a ReLU activation function, a Dropout layer, and a binary classification output layer connected in sequence. The facial image is labeled as the source domain, and the enhanced facial image is labeled as the target domain; By performing adversarial training against the prior-driven structure refinement module, the classification error of the domain discriminator is maximized.
[0011] As a preferred embodiment of the present invention, the structural guidance channel feature attention module in S4 includes a parameter generation unit, a feature linear modulation unit, a window partitioning unit, a hybrid attention unit, and a window inverse transformation unit connected in sequence. The parameter generation unit is used to predict affine transformation parameters as modulation parameters based on the structural features. The feature linear modulation unit is used to scale and translate the feature map output by the convolutional neural network according to the affine transformation parameters, and the output is a modulated feature map. The window partitioning unit is used to divide the modulated feature map and the foreground mask into several non-overlapping local windows; The hybrid attention unit is used to calculate spatial attention and channel attention within each window; and when calculating the attention weights within a window, the foreground mask is used as a weighted suppression. The window inverse transformation unit is used to restore the processed local window to a complete feature map through window inverse transformation.
[0012] As a preferred embodiment of the present invention, the pre-training of the fully connected layer in S5 is optimized using an identity recognition loss; the identity recognition loss employs a multi-subcenter angle marginal loss, and includes the following steps: Calculate the cosine similarity between the enhanced identity features and the K subcenters corresponding to the current category; The value with the highest cosine similarity to the enhanced identity feature among the K sub-centers is selected as the representative value; An angular marginal penalty is added to the representative value, and the cross-entropy loss is calculated.
[0013] As a preferred embodiment of the present invention, the pre-training of the generative model is optimized using latent variable consistency loss, including the following steps: Structural features are extracted from the facial image and the enhanced facial image respectively, and the cosine similarity loss between the two is calculated as a latent variable consistency loss to constrain the consistency of structural features.
[0014] As a preferred embodiment of the present invention, the foreground mask in S1 is generated using a pre-trained segmentation large model; the data augmentation process includes random patch swapping and local occlusion simulation, used to simulate occlusion in uncontrolled outdoor environments.
[0015] An uncontrolled animal face recognition device based on generative structure prior guidance includes at least one processor and a memory communicatively connected to the at least one processor; the memory stores instructions executable by the at least one processor, which, when executed by the at least one processor, enable the at least one processor to perform any of the above-described generative structure prior guidance uncontrolled animal face recognition methods.
[0016] Compared with the prior art, the beneficial effects of the present invention are as follows: This invention employs a semantic segmentation model to mask facial images of the animal to be identified, then inputs these images into a dual-branch hybrid recognition network for feature extraction and enhancement. Finally, the enhanced features are input into a fully connected layer for classification and recognition, outputting the individual animal identification result. This invention innovatively utilizes the latent space of the large generative model as a structural prior, compensating for the deficiency in the discriminative model's understanding of the object's three-dimensional structure under small sample data, significantly improving the model's generalization ability in data-scarce scenarios. Through a structure-guided feature interaction mechanism, the discriminative network can resist deformation interference caused by pose changes. Simultaneously, through a structure-guided channel feature attention module and a feature-level linear modulation mechanism, explicit structural information extracted from the generative branch is injected into the discriminative branch, enabling the feature extraction process to resist deformation interference caused by pose changes. Combined with the attention mechanism of semantic segmentation masking, the robustness of recognition in complex backgrounds is effectively improved. Simultaneously, by combining semantic segmentation masks, the response of background noise is directly suppressed at the feature level, effectively solving the problem of misidentification in complex backgrounds in the wild. The multi-subcenter loss function allows the same animal individual to have multiple feature centers, which conforms to the data distribution pattern of large intra-class differences in uncontrolled scenarios. Attached Figure Description
[0017] Figure 1 This is a flowchart illustrating an uncontrolled animal face recognition method based on generative structure prior guidance, as described in Embodiment 1 of the present invention. Figure 2 This is a flowchart illustrating an uncontrolled animal face recognition method based on generative structure prior guidance, as described in Embodiment 2 of the present invention. Figure 3 This is a flowchart illustrating the generative prior branch in the uncontrolled animal face recognition method based on generative structure prior guidance described in Embodiment 2 of the present invention. Figure 4 This is a schematic diagram of the structure-guided channel feature attention module in the uncontrolled animal face recognition method based on generative structure prior guidance described in Embodiment 2 of the present invention; Figure 5 This is a flowchart illustrating an uncontrolled animal face recognition method based on generative structure prior guidance, as described in Embodiment 2 of the present invention. Figure 6 This is a schematic diagram illustrating the principle of the multi-subcenter angle marginal loss function in an uncontrolled animal face recognition device based on generative structure prior guidance, as described in Embodiment 3 of the present invention. Detailed Implementation
[0018] The present invention will be further described in detail below with reference to experimental examples and specific embodiments. However, this should not be construed as limiting the scope of the above-mentioned subject matter of the present invention to the following embodiments; all technologies implemented based on the content of the present invention fall within the scope of the present invention.
[0019] Example 1 like Figure 1 As shown, a method for uncontrolled animal face recognition based on generative structure prior guidance includes the following steps: S1: Acquire the facial image of the animal to be identified, generate the corresponding foreground mask, and perform data augmentation processing on the facial image to obtain an enhanced facial image. Input the enhanced facial image and the foreground mask into a pre-constructed dual-branch hybrid recognition network. The dual-branch hybrid recognition network comprises a generative prior branch and a discriminative feature branch; the generative prior branch is a pre-trained generative model; and the discriminative feature branch is a convolutional neural network.
[0020] S2: In the generative prior branch, latent variable inversion is performed on the enhanced facial image to obtain optimized latent variables containing image distribution information, and structural features of the enhanced facial image are extracted.
[0021] S3: In the discriminative feature branch, the identity features of the enhanced facial image are extracted by a convolutional neural network.
[0022] S4: Generate modulation parameters based on the structural features, perform feature-level modulation on the identity features through a pre-trained structure-guided channel feature attention module, and add the foreground mask to suppress background noise, thereby generating enhanced identity features.
[0023] S5: Input the enhanced identity features into a pre-trained fully connected layer for classification, and output the individual animal identification result of the animal to be identified.
[0024] Example 2 This embodiment is a specific implementation of the uncontrolled animal face recognition method based on generative structure prior guidance described in Embodiment 1. Figure 2 As shown, it includes the following steps: S1: Obtain the facial image of the animal to be identified, generate the corresponding foreground mask, and perform data augmentation processing on the facial image to obtain an enhanced facial image. Input the enhanced facial image and the foreground mask into the pre-constructed dual-branch hybrid recognition network.
[0025] The input image is first normalized in size. To eliminate interference from complex backgrounds, this embodiment integrates a pre-trained Segment Anything Model (SAM) to automatically generate a binarized foreground mask for each training image. This mask will be used for subsequent attention weighting. Furthermore, to simulate complex occlusion in uncontrolled outdoor environments, this embodiment applies a specially designed strong data augmentation strategy before the input image enters the network. This includes random patch swapping and local occlusion simulation, thereby simulating occlusion in uncontrolled outdoor environments and forcing the model to focus on local texture details rather than relying solely on the overall contour. The processed image and its corresponding foreground mask are then fed into the subsequent dual-branch network.
[0026] The dual-branch hybrid recognition network includes a generative prior branch (Structure Branch) and a discriminative feature branch (Identity Branch).
[0027] Generative Prior Branch: The core purpose of this branch is to utilize the general visual knowledge contained in the generative model pre-trained on a large-scale dataset (this embodiment uses the VAE part of Stable Diffusion V1.5) to extract essential structural features that do not change with lighting and texture.
[0028] Discriminative feature branch: Used to extract identity features for classification. It employs a convolutional neural network; this embodiment uses the lightweight convolutional neural network LightCNN as the backbone to adapt to the relatively small size of the animal dataset.
[0029] S2: In the generative prior branch, latent variable inversion is performed on the enhanced facial image to obtain optimized latent variables containing image distribution information, and structural features of the enhanced facial image are extracted.
[0030] Furthermore, the latent inversion includes the following steps: Freeze the parameters of the variational autoencoder (VAE) in the generative model, and use the mean of the initial latent variable distribution output by the variational autoencoder as the initial latent variable z.
[0031] An optimization objective function is constructed, with the mean squared error between the reconstructed image and the original image as the target. The expression of the optimization objective function is as follows:
[0032] Where I is the input image, D(·) is the decoder of the pre-trained variational autoencoder, z is the current latent variable, and z0 is the optimization latent variable.
[0033] The latent variable z is iteratively updated using the optimization objective function until a preset number of iterations or convergence condition is reached, so that the pixel-level error between the image decoded by VAE and the original image is minimized; the output is an optimized latent variable z0 containing image distribution information (i.e., containing rich texture and structural information).
[0034] Furthermore, this embodiment extracts structural features through a priori driven structure refinement module (PDSLRM). This module comprises a sequentially connected encoding convolutional layer, a multi-head self-attention layer, and a decoding convolutional layer. Its purpose is to remove high-frequency noise from latent variables and extract global structural features that are invariant to pose changes. .
[0035] Furthermore, the extraction process of the structural features includes the following steps: The optimization latent variables are mapped to a high-dimensional feature space, and the global structural dependencies in the optimization latent variables are captured by a multi-head self-attention mechanism. Then, the structural features that are robust to pose changes are output through group normalization and decoding convolutional layers.
[0036] Furthermore, such as Figure 3 As shown, this embodiment also includes a structural feature extractor (a shallow network consisting of convolutional layers and fully connected layers) for mapping feature map information into a one-dimensional structural feature vector, which highly condenses the pose and structural information of the animal's face.
[0037] S3: In the discriminative feature branch, the identity features of the enhanced facial image are extracted by a convolutional neural network.
[0038] S4: Generate modulation parameters based on the structural features, perform feature-level modulation on the identity features through a pre-trained Structure-Guided Channel Feature Attention Module (SGCLFA), and add the foreground mask to suppress background noise, thereby generating enhanced identity features.
[0039] Furthermore, such as Figure 4As shown, the structure-guided channel feature attention module includes a parameter generation unit, a feature linear modulation unit, a window partitioning unit, a hybrid attention unit, and a window inverse transformation unit connected in sequence. The parameter generation unit is used to predict affine transformation parameters as modulation parameters based on the structural features; that is, utilizing the structural features. Feature map of the discriminant branch To perform feature-level linear modulation, the structural features need to be generated through two independent parameter generation subnetworks in the parameter generation unit. Mapped to a scaling factor vector of the channel dimension Translation coefficient vector .
[0040] The Feature-wise Linear Modulation (FiLM) unit is used to scale and translate the feature map output by the convolutional neural network according to the affine transformation parameters, outputting a modulated feature map. That is, it is used to scale and translate each channel of the feature map. Perform an affine transformation to obtain the modulated feature map. For coordinates on the feature map The eigenvalue at point is calculated using the following formula:
[0041] in, and They represent the first The scaling and translation parameters corresponding to each channel allow the model to adaptively enhance or suppress the feature responses of specific channels based on the extracted global structural priors, thereby calibrating the local features extracted by the convolutional neural network and achieving structure guidance.
[0042] The window partitioning unit is used to divide the modulated feature map and the foreground mask into several non-overlapping local windows. In this embodiment, in order to capture local details and suppress the background, a window partitioning mechanism is used to divide the modulated feature map and the foreground mask. Divided into non-overlapping groups Local window.
[0043] The hybrid attention unit is used to calculate spatial attention and channel attention within each window; and when calculating the attention weights within a window, the foreground mask is used as weighted suppression. In this embodiment, when calculating the spatial attention map, the foreground mask is used... This is multiplied by a weighted term and added to the attention weights. This forces the feature weights of the background region to be lowered, causing the network to focus on the animal's facial region.
[0044] The window inverse transformation unit is used to restore the processed local window to a complete feature map through window inverse transformation.
[0045] The restored complete feature map is residually concatenated with the original input, and the output is the enhanced identity feature.
[0046] S5: Input the enhanced identity features into a pre-trained fully connected layer for classification, and output the individual animal identification result of the animal to be identified.
[0047] Furthermore, in order to improve the recognition accuracy of the model, this embodiment adds a multi-task joint loss function during the pre-training process. The multi-task joint loss function includes multi-subcenter angle marginal loss, latent variable consistency loss, and domain adaptation loss.
[0048] ① Marginal loss at multiple subcenters: like Figure 5 As shown, considering the significant differences in frontal and side profile features of the same animal in uncontrolled scenarios, making it difficult to fit with a single feature center, this invention improves the ArcFace loss by employing a sub-center strategy. Specifically, the pre-training of the fully connected layer is optimized using an identity recognition loss; this identity recognition loss employs a sub-center angle marginal loss, comprising the following steps: Calculate the cosine similarity between the enhanced identity feature and the K sub-centers corresponding to the current category; select the value with the largest cosine similarity to the enhanced identity feature among the K sub-centers as the representative value; add an angle marginal penalty to the representative value and calculate the cross-entropy loss.
[0049] By employing multi-subcenter perspective marginal loss, the model can learn multiple modal distributions under the same identity. Specifically, let the training samples... The corresponding feature vector is Its real label is For categories , preset Subcenter vectors First, calculate the eigenvectors. With all of this category The cosine similarity of each subcenter is used, and the maximum value is selected as the representative similarity of the category to which the sample belongs. :
[0050] For non-target categories Similarly, select its In the individual center and The most similar one is used for calculation, resulting in the final loss function. Defined as:
[0051] Where N is the batch size, s is the feature scaling parameter, and m is the angle margin penalty parameter.
[0052] ② Latent variable consistency loss (LSC Loss): The pre-training of the generative model is optimized using latent variable consistency loss, and includes the following steps: The structural features of the facial image and the enhanced facial image are extracted respectively, and the cosine similarity loss between the two is calculated. This forces the structural features of the original image and its enhanced view to remain consistent in the generative branch, thereby further improving robustness. This consistency loss serves as a latent variable to constrain the consistency of structural features.
[0053] ③ Domain adaptation loss: To address the feature distribution shift caused by lighting variations, blurring, and local occlusion in uncontrolled outdoor environments, the discriminative feature branch also includes a pre-trained domain discriminator. The domain discriminator is pre-trained using Domain Adaptation Loss, and the pre-training process includes the following steps: A domain discriminator is constructed and connected to the end of the discriminative feature branch through a gradient reversal layer (GRL). The domain discriminator includes a fully connected layer, a ReLU activation function, a Dropout layer, and a binary classification output layer connected in sequence.
[0054] The facial image is labeled as the source domain, and the enhanced facial image is labeled as the target domain. In the training process of this embodiment, the original clear image (facial image) is labeled as the "source domain" (label 0), and the image after strong data augmentation (enhanced facial image) is labeled as the "target domain" (label 1). The features extracted by the discriminative feature branch are input to the discriminator through the gradient inversion layer.
[0055] By performing adversarial training against the prior-driven structure refinement module, the classification error of the domain discriminator is maximized. Specifically, during forward propagation, the gradient reversal layer acts as an identity transformation; during backward propagation, the gradient reversal layer multiplies the gradient by a negative constant. λ is then passed to the feature extraction network. Through this adversarial training mechanism, the feature extraction network strives to extract features that cannot be distinguished from the source by the domain discriminator, i.e., "domain-invariant features," thereby forcing the model to ignore interference from non-identity factors such as lighting and occlusion, maximizing the classification error of the domain discriminator while minimizing the identity recognition error.
[0056] This invention significantly improves the accuracy and robustness of animal individual identification in uncontrolled scenarios by introducing generative structural priors and finely designed attention mechanisms, without increasing the additional data requirements in the inference stage.
[0057] Example 3 like Figure 6 As shown, a generative structure prior-guided uncontrolled animal face recognition device includes at least one processor, a memory communicatively connected to the at least one processor, and at least one input / output interface communicatively connected to the at least one processor. The memory stores instructions executable by the at least one processor, which, when executed, enables the at least one processor to perform the generative structure prior-guided uncontrolled animal face recognition method described in the foregoing embodiments. The input / output interface may include a display, keyboard, mouse, and USB interface for inputting and outputting data.
[0058] Furthermore, the uncontrolled animal face recognition device based on generative structure prior guidance can be a desktop computer, mobile phone, tablet computer, wearable uncontrolled animal face recognition device based on generative structure prior guidance, etc., capable of performing deep information recognition.
[0059] Furthermore, the processor may include one or more processing cores. The processor connects various parts of the generative structure-based a priori-guided uncontrolled animal face recognition device using various interfaces and lines. It executes various functions and processes data by running or executing instructions, programs, code sets, or instruction sets stored in memory, and by calling data stored in memory. Optionally, the processor may be implemented using at least one hardware form of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). The processor may integrate one or more of a Central Processing Unit (CPU), Graphics Processing Unit (GPU), and modem. The CPU primarily handles the operating system, user interface, and applications; the GPU is responsible for rendering and drawing the displayed content; and the modem handles wireless communication. It is understood that the modem may also be implemented separately as a communication chip, without being integrated into the processor.
[0060] The memory may include random access memory (RAM) or read-only memory (ROM). The memory can be used to store instructions, programs, code, code sets, or instruction sets, such as instructions or code sets used to implement the generative structure prior-guided uncontrolled animal face recognition method provided in this application embodiment. The memory may include a program storage area and a data storage area. The program storage area may store instructions for implementing an operating system, instructions for implementing at least one function, instructions for implementing the various method embodiments described above, etc. The data storage area may also store data created during use by the generative structure prior-guided uncontrolled animal face recognition device (such as a mapping table of modulation sequences and depths, image data, spectrogram data, etc.).
[0061] Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps of the above method embodiments. The aforementioned storage medium includes various media that can store program code, such as mobile storage devices, read-only memory (ROM), magnetic disks, or optical disks.
[0062] When the integrated units of the present invention are implemented as software functional units and sold or used as independent products, they can also be stored in a computer-readable storage medium. The computer-readable storage medium stores program code, which can be called by a processor to execute the methods described in the above method embodiments. Based on this understanding, the technical solution of the embodiments of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes electronic memories such as flash memory, EEPROM (Electrically Erasable Programmable Read-Only Memory), EPROM, hard disk, or ROM. Optionally, the computer-readable storage medium includes a non-transitory computer-readable storage medium. The computer-readable storage medium has storage space for program code that executes any of the method steps described above. This program code can be read from or written to one or more computer program products. The program code can be compressed, for example, in an appropriate form.
[0063] This invention is used in a reasonable manner.
[0064] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A method for uncontrolled animal face recognition based on generative structure prior guidance, characterized in that, Includes the following steps: S1: Acquire the facial image of the animal to be identified, generate the corresponding foreground mask, and perform data augmentation processing on the facial image to obtain an enhanced facial image. Input the enhanced facial image and the foreground mask into a pre-constructed dual-branch hybrid recognition network. The dual-branch hybrid recognition network comprises a generative prior branch and a discriminative feature branch; the generative prior branch is a pre-trained generative model; and the discriminative feature branch is a convolutional neural network. S2: In the generative prior branch, latent variable inversion is performed on the enhanced facial image to obtain optimized latent variables containing image distribution information, and structural features of the enhanced facial image are extracted. S3: In the discriminative feature branch, the identity features of the enhanced facial image are extracted by a convolutional neural network; S4: Generate modulation parameters based on the structural features, perform feature-level modulation on the identity features through a pre-trained structure-guided channel feature attention module, and add the foreground mask to suppress background noise, thereby generating enhanced identity features; S5: Input the enhanced identity features into a pre-trained fully connected layer for classification, and output the individual animal identification result of the animal to be identified.
2. The method for uncontrolled animal face recognition based on generative structure prior guidance according to claim 1, characterized in that, The latent variable inversion in S2 includes the following steps: Freeze the parameters of the variational autoencoder in the generative model and use the mean of the output of the variational autoencoder as the initial latent variable; Construct an optimization objective function that targets the mean square error between the reconstructed image and the original image; The latent variables are iteratively updated using the optimization objective function until a preset number of iterations or a convergence condition is reached, and the optimized latent variables containing image distribution information are output.
3. The method for uncontrolled animal face recognition based on generative structure prior guidance according to claim 1, characterized in that, In S2, structural features are extracted through a priori-driven structure refinement module; the priori-driven structure refinement module includes a coding convolutional layer, a multi-head self-attention layer, and a decoding convolutional layer connected in sequence.
4. The method for uncontrolled animal face recognition based on generative structure prior guidance according to claim 3, characterized in that, The extraction process of the structural features includes the following steps: The optimization latent variables are mapped to a high-dimensional feature space, and the global structural dependencies in the optimization latent variables are captured by a multi-head self-attention mechanism. Then, the structural features that are robust to pose changes are output through group normalization and decoding convolutional layers.
5. The method for uncontrolled animal face recognition based on generative structure prior guidance according to claim 3, characterized in that, The discriminative feature branch further includes a pre-trained domain discriminator; the domain discriminator is pre-trained using a domain adaptation loss, and the pre-training includes the following steps: A domain discriminator is constructed and connected to the end of the discriminative feature branch through a gradient inversion layer; the domain discriminator includes a fully connected layer, a ReLU activation function, a Dropout layer, and a binary classification output layer connected in sequence. The facial image is labeled as the source domain, and the enhanced facial image is labeled as the target domain; By performing adversarial training against the prior-driven structure refinement module, the classification error of the domain discriminator is maximized.
6. The method for uncontrolled animal face recognition based on generative structure prior guidance according to claim 1, characterized in that, The structure-guided channel feature attention module in S4 includes a parameter generation unit, a feature linear modulation unit, a window partitioning unit, a hybrid attention unit, and a window inverse transform unit connected in sequence. The parameter generation unit is used to predict affine transformation parameters as modulation parameters based on the structural features. The feature linear modulation unit is used to scale and translate the feature map output by the convolutional neural network according to the affine transformation parameters, and the output is a modulated feature map. The window partitioning unit is used to divide the modulated feature map and the foreground mask into several non-overlapping local windows; The hybrid attention unit is used to calculate spatial attention and channel attention within each window; and when calculating the attention weights within a window, the foreground mask is used as a weighted suppression. The window inverse transformation unit is used to restore the processed local window to a complete feature map through window inverse transformation.
7. The method for uncontrolled animal face recognition based on generative structure prior guidance according to claim 1, characterized in that, The pre-training of the fully connected layer in S5 is optimized using identity recognition loss; the identity recognition loss uses multi-subcenter angle marginal loss and includes the following steps: Calculate the cosine similarity between the enhanced identity features and the K subcenters corresponding to the current category; The value with the highest cosine similarity to the enhanced identity feature among the K sub-centers is selected as the representative value; An angular marginal penalty is added to the representative value, and the cross-entropy loss is calculated.
8. The method for uncontrolled animal face recognition based on generative structure prior guidance according to claim 1, characterized in that, The pre-training of the generative model is optimized using latent variable consistency loss, and includes the following steps: Structural features are extracted from the facial image and the enhanced facial image respectively, and the cosine similarity loss between the two is calculated as a latent variable consistency loss to constrain the consistency of structural features.
9. The method for uncontrolled animal face recognition based on generative structure prior guidance according to claim 1, characterized in that, The foreground mask in S1 is generated using a pre-trained segmentation model; the data augmentation process includes random patch swapping and local occlusion simulation, used to simulate occlusion in uncontrolled outdoor environments.
10. A generative structure prior-guided uncontrolled animal face recognition device, characterized in that, The method includes at least one processor and a memory communicatively connected to the at least one processor; the memory stores instructions executable by the at least one processor, which, when executed by the at least one processor, enable the at least one processor to perform the uncontrolled animal face recognition method based on generative structure prior guidance according to any one of claims 1 to 9.