A method and system for identifying primates based on metric learning, and a medium
By using the SE-ResNet model based on metric learning, combined with data augmentation and multiple loss functions, the problem of weak inter-class differences and huge intra-class differences in ape identification was solved, achieving efficient individual and population identification and improving identification efficiency and accuracy.
Patent Information
- Application Number
- CN202411777093.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-05
- Publication Date
- 2025-10-21
- Estimated Expiration
- 2044-12-05
AI Technical Summary
The complex habitats of apes, unpredictable individual behavior, and insufficient light make it difficult for traditional methods to efficiently identify individual and population categories. The differences between species are slight, while the differences within species are huge, resulting in low identification efficiency of existing technologies.
We employ the SE-ResNet model based on metric learning, combined with data augmentation, transfer learning, attention mechanisms, and multiple loss functions. We train an ape recognition model using the SE-ResNet model, adaptively adjust feature channel weights using the SE module, and introduce triplet loss and cross-entropy loss to capture inter-class coupling features and mitigate the impact of intra- and intra-class differences.
It improves the efficiency of identifying individual apes and population categories, enhances adaptability to complex environments and identification accuracy, and reduces labor costs.
Smart Images

Figure CN119785378B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a method, system and medium for ape identification based on metric learning. Background Art
[0002] The habitats of apes are generally densely vegetationed, individual behavior is unpredictable, there is insufficient light, and the environment is humid, all of which seriously limit manual individual identification.
[0003] Considering that apes are social animals with distinct home ranges, there is a certain degree of coupling between individuals and populations, resulting in similar characteristics across populations. Furthermore, the fixed habitats of ape groups result in similar background data, leading to slight inter-class differences. Furthermore, different perspectives, movement postures, and lighting conditions produce distinct appearances, resulting in significant intra-class differences. However, the connections between individual apes create deep shared characteristics within populations, leading to a need for improved efficiency in identifying individual and population apes. Summary of the Invention
[0004] The present invention aims to provide a method, system and medium for ape identification based on metric learning to improve the efficiency of identifying individual and population categories of apes.
[0005] In order to achieve the above object, the present invention provides the following technical solutions:
[0006] In a first aspect, an embodiment of the present invention provides a method for ape identification based on metric learning, the method comprising the following steps:
[0007] Obtaining original images of apes, and performing data augmentation on the original images to obtain training samples;
[0008] Constructing an SE-ResNet model, inputting the training samples into the SE-ResNet model for training to obtain an ape recognition model; wherein the SE-ResNet model includes a plurality of residual modules, each of which includes a plurality of residual blocks embedded with SE modules, and the SE modules are used to adaptively adjust the weights of each feature channel;
[0009] The ape recognition model is used to extract features and classify ape images, and simultaneously identify individual and population categories of apes.
[0010] Preferably, the constructing of the SE-ResNet model, inputting the training samples into the SE-ResNet model for training, and obtaining the ape recognition model comprises:
[0011] Using the CNN model parameters pre-trained on the ImageNet database as the hyperparameters of the ape recognition model;
[0012] During the iterative training of the SE-ResNet model, the Adam optimization algorithm is used to train the SE-ResNet model. During the training process, the learning rate scheduling strategy and label smoothing are used to perform joint optimization for a set number of epoch iterations to complete one iterative training of the SE-ResNet model.
[0013] Determine the total loss function of the SE-ResNet model, and determine the loss value of the SE-ResNet model after completing the current iterative training based on the total loss function. When the loss value is lower than a set loss threshold, the training of the SE-ResNet model is completed to obtain a trained ape recognition model.
[0014] Preferably, the method further comprises:
[0015] During iterative training of the SE-ResNet model, an attention mechanism module is added after the plurality of residual modules in the SE-ResNet model, and the plurality of residual modules are retrained; wherein the attention mechanism module comprises two convolutional layers and a Sigmoid activation function, the attention mechanism module is used to generate an attention map and adjust an input feature map, and then use an adaptive average pooling layer to convert the feature map into a global feature vector;
[0016] The global features are normalized through the batch normalization layer, and the individual category prediction scores and scores of different categories are output separately through the classification head.
[0017] Preferably, the expression for processing the feature image by the residual module is:
[0018] ;
[0019] Where x represents the input image, Represents the features output by the input image x after passing through the residual module, and StemBlock represents the primary features converted from the input image x. represents the higher-level features extracted from the input image x after passing through the t-th residual block in the residual module;
[0020] The expression for processing the feature image by the residual block is:
[0021] ;
[0022] Wherein, x is the input image, i.e., the feature image of the input residual block, t is the index of the residual block, is the feature image generated by the tth residual block, 、 、 are the weights of the convolution kernel, and σ is the ReLU activation function.
[0023] Preferably, the processing process of the SE module includes a compression stage and an excitation stage. The processing formula of the compression stage is:
[0024] ;
[0025] in, Represents the numerical distribution of C feature maps, that is, global information, H and W are the height and width of the feature map respectively, x represents the input image, is the eigenvalue of row i, column j, and channel c in the feature image after the residual block, where i and j are the height index and width index of the feature map, respectively, and c is the channel index;
[0026] The processing formula of the excitation stage is:
[0027] ;
[0028] in, and is the weight of the fully connected layer, σ1 and σ2 are the ReLU activation function and Sigmoid activation function layers respectively, s is the output feature after excitation, and z is the input feature after compression.
[0029] Preferably, the expression of the total loss function is:
[0030] ;
[0031] in, is the total loss function of the SE-ResNet model, is the cross entropy loss function, is the triplet loss function, A vector representing individual characteristics, A vector representing population characteristics, λ1 and λ2 are weighted coefficients of the loss function, which are used to control the weights of different losses in the total loss;
[0032] The expression of the cross entropy loss function is:
[0033] ;
[0034] in, represents the weight of the linear function, is the embedding vector of image x of category i;
[0035] The expression of the triple loss function is:
[0036] ;
[0037] Among them, fa is the feature vector of the anchor sample, fp is the feature vector of the positive sample, which belongs to the same category as the anchor sample, and fn is the feature vector of the negative sample, which does not belong to the same category as the anchor sample.
[0038] Preferably, the method further comprises:
[0039] During training the SE-ResNet model, the number of iterations for training the SE-ResNet model is determined, and the weight of the cross entropy loss and the weight of the triplet loss are determined based on the number of iterations, the sum of the weight of the cross entropy loss and the weight of the triplet loss is 1, the weight of the cross entropy loss decreases as the number of iterations increases, and the weight of the triplet loss increases as the number of iterations increases.
[0040] In a second aspect, an embodiment of the present invention provides a system for identifying apes based on metric learning, the system comprising:
[0041] at least one processor;
[0042] at least one memory for storing at least one program;
[0043] When the at least one program is executed by the at least one processor, the at least one processor implements any one of the methods described above.
[0044] In a third aspect, an embodiment of the present invention provides a computer-readable storage medium storing a program executable by a processor, wherein the program executable by the processor is used to execute any one of the methods described above when executed by the processor.
[0045] The beneficial effects of the present invention are as follows: the present invention provides a method, system, and medium for ape identification based on metric learning, which obtains original images of apes and performs data enhancement on the original images to obtain training samples; constructs an SE-ResNet model, inputs the training samples into the SE-ResNet model for training, and obtains an ape identification model; wherein the SE-ResNet model includes multiple residual modules, each of which includes multiple residual blocks embedded with SE modules, and the SE modules are used to adaptively adjust the weights of each feature channel; the SE-ResNet model is a deep neural network model based on metric learning, which can not only be used for individual ape identification, but also can learn the coupling relationship between populations and individuals, thereby improving the performance of resisting the negative effects of inter-class and intra-class differences; finally, the ape identification model is used to extract features and classify ape images, and simultaneously identify individual and population categories of apes. The embodiments provided by the present invention can efficiently identify individual apes and populations. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0047] Figure 1 1 is a flow chart of a method for ape identification based on metric learning in an embodiment of the present invention;
[0048] Figure 2 is a structural diagram of the ape identification model according to an embodiment of the present invention;
[0049] Figure 3 yes Figure 2 A diagram of the spatial attention structure of the ape recognition model;
[0050] Figure 4 yes Figure 2 Schematic diagram of the triplet loss of the ape recognition model;
[0051] Figure 5 It is a schematic diagram of the individual confusion matrix of the CNN model;
[0052] Figure 6 It is a schematic diagram of the population confusion matrix of the CNN model;
[0053] Figure 7 Schematic diagram of the structure of the ape identification system based on metric learning in an embodiment of the present invention. DETAILED DESCRIPTION
[0054] The following will be combined with the embodiments and drawings to clearly and completely describe the concept, specific structure and technical effects of the present invention so as to fully understand the purpose, scheme and effect of the present invention. It should be noted that the embodiments and features in the embodiments of the present invention can be combined with each other unless there is any conflict.
[0055] In recent years, camera trap surveys have become widely used for non-invasive sampling of terrestrial wildlife, including apes. However, traditional infrared cameras are susceptible to environmental interference, leading to false triggering and the capture of numerous useless images. Unmanned aerial vehicles (UAVs) are used to capture thermal infrared images to detect apes, but a single infrared image cannot simultaneously capture the entire rainforest. Fusion of infrared and visible light images can achieve good performance. However, in large areas of tropical rainforest, finding apes inhabiting the high-altitude treetops under foggy conditions is extremely difficult, let alone capturing high-quality images.
[0056] Deep learning has made significant progress in solving problems that have eluded the artificial intelligence community for years. Its approach involves learning representations at multiple levels, achieved by combining simple but nonlinear modules. Each module transforms one level of representation (starting from the raw input) into a higher, slightly more abstract level. Deep learning significantly reduces human effort by automatically identifying and detecting species in images and provides methods for analyzing complex, interactive, and nonlinear data.
[0057] Mainstream species identification methods primarily focus on the independent identification of single individuals, downplaying common characteristics at the population level. This focus on local structure between similar samples within a population can inadvertently destroy the ability to mitigate intra-species differences. Due to biological heredity, facial and behavioral traits are transmitted to a certain extent between parents and offspring.
[0058] In order to address the major challenge of large intra-class differences and weak inter-class differences, the present invention proposes a new deep metric learning method that considers both inter-class and intra-class losses. The intra-class triplet loss makes the samples of the same individual very close, while the samples of different individuals are further apart. The inter-class loss learns the coupling characteristics within the population and forms intra-class clusters, which can significantly reduce the negative impact of inter-class and intra-class differences on ape recognition and improve recognition accuracy. By capturing inter-class differences and intra-class invariance, the inter-class similarity distance is maximized while the intra-class similarity distance is minimized. In addition, the present invention combines the triplet loss with the cross-entropy loss to jointly learn the facial information of apes, and introduces an attention mechanism to enable the model to selectively focus on important features of apes. Through this method, it is possible to reduce labor costs, resist the negative impact of inter-class and intra-class differences, and improve the recognition ability of apes.
[0059] See Figure 1The present invention provides a method for ape identification based on metric learning, the method comprising the following steps:
[0060] S100, obtaining an original image of apes, performing data enhancement on the original image, and obtaining a training sample;
[0061] It should be noted that directly inputting the original image into the model may lead to overfitting. In order to avoid this situation, the present invention uses a series of data enhancement methods. It can change the original data to simulate different lighting conditions, shooting angles and occlusion conditions. Such random changes in training samples can reduce dependence on certain specific attributes, learn more features, and thus obtain better performance. In this embodiment, the present invention uses a composite data enhancement method, which includes horizontal flipping, random rotation, random erasing, and color jittering. Before training the SE-ResNet model, the present invention processes the data set, takes into account the average dimension of the image, and adjusts all images to a uniform resolution of 256*256.
[0062] During the original image acquisition process, the present invention not only focuses on the image quality of individuals, but also analyzes the coupling relationship of populations. Since apes are highly social and gregarious animals, each individual belongs to its fixed population family and has a fixed range of activities. Therefore, this analysis can help the present invention understand the potential related appearance characteristics between individuals in the population and the specific analysis of the environment. The present invention uses the T-SNE algorithm to reduce the dimension of the population characteristics in order to visualize the relationship between different individuals and populations. The results show that although some individuals are far apart, there is generally a relatively obvious clustering phenomenon between different populations, indicating that there is a certain correlation between individuals in terms of appearance characteristics.
[0063] S200, constructing an SE-ResNet model, inputting the training sample into the SE-ResNet model for training, and obtaining an ape recognition model; wherein the SE-ResNet model includes a plurality of residual modules, each of which includes a plurality of residual blocks embedded with SE modules, and the SE modules are used to adaptively adjust the weights of each feature channel;
[0064] S300 uses an ape recognition model to extract features and classify ape images, and simultaneously identifies individual and population categories of apes.
[0065] refer to Figure 2 、 Figure 3 and Figure 4In this paper, a metric learning-based model for simultaneous identification of individual and population apes is proposed to distinguish between individuals and the groups they belong to. To capture subtle differences between individuals and explore commonalities between groups, the present invention uses the SE-ResNet model (Squeeze-and-Excitation Residual Network) as the backbone network for individual ape identification and population classification. The SE module (Squeeze-and-Excitation) in the SE-ResNet model enhances the network's feature recalibration capability, enabling adaptive adjustment of the importance of feature channels. Specifically, the SE-ResNet model comprises multiple residual modules, each of which contains multiple residual blocks and SE modules. The SE modules are embedded in the residual blocks. Each SE module uses 1×1, 3×3, and 1×1 convolution kernel configurations to capture different feature patterns. The SE module embedded in each residual block calculates the weights of feature channels through global average pooling and fully connected layers, thereby improving the representation of important features and suppressing irrelevant information.
[0066] The present invention uses the SE-ResNet model to train an ape recognition model, and uses the ape recognition model to extract features and classify ape images. The SE-ResNet model proposed in the present invention is a deep neural network model based on metric learning, which utilizes individual and population clustering loss functions and a permutation attention module. The deep metric learning method can not only be used for individual ape recognition, but also learn the coupling relationship between populations and individuals, thereby improving the performance of resisting the negative effects of inter-class differences and intra-class differences. The embodiments provided by the present invention can efficiently identify individuals and populations of apes.
[0067] As an improvement to the above embodiment, in S200, constructing the SE-ResNet model and inputting the training samples into the SE-ResNet model for training to obtain the ape recognition model includes:
[0068] S210, using CNN model parameters pre-trained using the ImageNet database as hyperparameters of the ape recognition model;
[0069] To improve the performance of the SE-ResNet model, the present invention employs a transfer learning strategy. Each network layer is initialized using the weights of a CNN pre-trained on the ImageNet database (http: / / www.image-net.org / ), which has similar characteristics to the dataset presented in this paper. Specifically, applying the parameters of the CNN model pre-trained on the ImageNet database to the SE-ResNet model improves the initial performance of the SE-ResNet model and enhances the generalization ability of the ape recognition model.
[0070] S220, during iterative training of the SE-ResNet model, using the Adam optimization algorithm to train the SE-ResNet model. During the training process, a learning rate scheduling strategy and label smoothing are used to perform joint optimization for a set number of epochs, thereby completing one iterative training of the SE-ResNet model.
[0071] To accelerate the convergence of the SE-ResNet model and address the gradient instability issue in deep SE-ResNet models, this paper employs the Adam optimization algorithm. Furthermore, during training, the WarmupMultiStepLR learning rate scheduling strategy is used. The initial learning rate is set to 0.001, and a learning rate warmup is performed at the beginning of training. The warmup factor is 0.01 for the first 10 iterations. Subsequently, at designated epochs (the 60th and 150th), the learning rate is reduced to 0.6 times its original value. To further enhance model stability, this paper also introduces label smoothing for joint optimization. Training is terminated after 200 epochs.
[0072] S230, determining the total loss function of the SE-ResNet model, and determining the loss value of the SE-ResNet model after completing the current iterative training based on the total loss function. When the loss value is lower than the set loss threshold, the training of the SE-ResNet model is completed to obtain a trained ape recognition model.
[0073] As an improvement to the above embodiment, in S220, the method further includes:
[0074] S221, during iterative training of the SE-ResNet model, adding an attention mechanism module after the multiple residual modules in the SE-ResNet model, and retraining the multiple residual modules; wherein the attention mechanism module includes two convolutional layers and a Sigmoid activation function, and the attention mechanism module is used to generate an attention map and adjust the input feature map, and then use an adaptive average pooling layer to convert the feature map into a global feature vector;
[0075] S222, normalizes the global features through the batch normalization layer, and outputs the individual category prediction scores and scores of different categories through the classification head.
[0076] To achieve a balance between generalization and specificity in the task of identifying ape images, the early layers of the pre-trained model are frozen during the transfer learning training process, and only the later layers are fine-tuned. Specifically, to improve the interpretability and recognition performance of the SE-ResNet model and to further identify the specific areas of focus of the SE-ResNet model in population classification problems, the present invention adds a customized attention mechanism module to the SE-ResNet model. The attention mechanism module comprises two convolutional layers and a sigmoid activation function, which are used to generate an attention map and adjust the input features. This allows the SE-ResNet model's attention to be more focused on local feature areas in the image that are critical for classification and recognition, thereby more effectively identifying the facial features and limb details of apes, further improving the recognition accuracy of individuals and populations. An adaptive average pooling layer is then used to convert the feature map into a global feature vector. The global features are then normalized using a batch normalization layer. In addition, the final classification head of the SE-ResNet model includes two fully connected layers: one for generating individual category prediction scores and the other for species prediction, outputting scores for different species.
[0077] As an improvement to the above embodiment, the expression for processing the feature image by the residual module is:
[0078] ;
[0079] Where x represents the input image, Represents the features output by the input image x after passing through the residual module, and StemBlock represents the primary features converted from the input image x. represents the higher-level features extracted from the input image x after passing through the t-th residual block in the residual module;
[0080] The expression for processing the feature image by the residual block is:
[0081] ;
[0082] Wherein, x is the input image, i.e., the feature image of the input residual block, t is the index of the residual block, is the feature image generated by the tth residual block, 、 、 are the weights of the convolution kernel, and σ is the ReLU activation function.
[0083] In this embodiment, the image is first processed preliminarily by the convolution layer and the pooling layer, and then enters the residual module for deep feature extraction. Multi-scale feature fusion is then performed, and the feature maps from different residual modules are adjusted to the same scale and superimposed to capture richer contextual information. Specifically, StemBlock is used to convert the input image x into primary features, and Stage is used to continuously extract higher-level features. This multi-scale processing improves the ability to understand image details and global structures. Finally, the feature map is converted into a vector representation through global average pooling, and the features are further aggregated through the fully connected layer, and finally classified through the Softmax layer. In this way, SE-ResNet can effectively capture the subtle differences between individual apes and achieve high-precision individual recognition and population classification.
[0084] As an improvement to the above embodiment, the processing process of the SE module includes a compression phase and an excitation phase. The processing formula of the compression phase is:
[0085] ;
[0086] in, Represents the numerical distribution of C feature maps, that is, global information, H and W are the height and width of the feature map respectively, x represents the input image, is the eigenvalue of row i, column j, and channel c in the feature image after the residual block, where i and j are the height index and width index of the feature map, respectively, and c is the channel index;
[0087] The processing formula of the excitation stage is:
[0088] ;
[0089] in, and is the weight of the fully connected layer, σ1 and σ2 are the ReLU activation function and Sigmoid activation function layers respectively, s is the output feature after excitation, and z is the input feature after compression.
[0090] As an improvement to the above embodiment, the expression of the total loss function is:
[0091] ;
[0092] in, is the total loss function of the SE-ResNet model, A vector representing individual characteristics, A vector representing population characteristics, λ1 and λ2 are weighted coefficients of the loss function, which are used to control the weights of different losses in the total loss;
[0093] The expression of the cross entropy loss function is:
[0094] ;
[0095] in, represents the weight of the linear function, is the embedding vector of image x of category i;
[0096] The expression of the triple loss function is:
[0097] L triplet =max(0,||fa-fp|| 2 -||fa-fn|| 2 +margin);
[0098] Among them, L triplet represents the triplet loss, fa is the feature vector of the anchor sample, fp is the feature vector of the positive sample, which belongs to the same category as the anchor sample, and fn is the feature vector of the negative sample, which does not belong to the same category as the anchor sample.
[0099] Specifically, after completing one iterative training of the SE-ResNet model, the cross entropy loss function and the triplet loss function of the SE-ResNet model are calculated respectively, and the total loss function of the SE-ResNet model is determined based on the cross entropy loss and the triplet loss; when constructing the loss function module, the present invention first uses the cross entropy loss, and there is an implicit relationship between the learning embeddings established by the cross entropy loss.
[0100] Cross-entropy loss effectively optimizes classification performance during learning. However, to further explore subtle differences between ape populations and the coupling of individual characteristics within populations, this paper introduces a triplet loss mechanism. This approach not only establishes a clearer distinction between class differences but also captures fine-grained similarities within population embeddings, thereby improving the ability to recognize complex individual characteristics.
[0101] In the triplet loss function, the square of the Euclidean distance between the anchor sample and the positive sample is ||fa-fp|| 2, and the square of the Euclidean distance between the anchor sample and the negative sample is ||fa-fn|| 2 In addition, margin is a preset boundary value used to control the distance between positive and negative sample pairs, so that the model can better distinguish samples of different categories.
[0102] During the model training process, the present invention introduces triplet loss to encourage the model to minimize the distance between the anchor sample and the positive sample, and maximize the distance between the anchor sample and the negative sample. This mechanism performs very well in the task of extracting individual and population characteristics, and helps to achieve more accurate individual feature identification and differentiated discrimination between populations. At the same time, during the training process, the present invention adopts a gradual adjustment strategy to balance the weights of cross-entropy loss and triplet loss to ensure that the model can achieve optimal performance in both individual and population identification tasks. In the initial training stage, the present invention increases the weight of cross-entropy loss to quickly optimize classification performance; in the later training stage, the present invention gradually increases the weight of triplet loss to enhance the model's ability to handle inter-class differences and intra-class consistency.
[0103] As an improvement to the above embodiment, the method further includes:
[0104] During training the SE-ResNet model, the number of iterations for training the SE-ResNet model is determined, and the weight of the cross entropy loss and the weight of the triplet loss are determined based on the number of iterations, the sum of the weight of the cross entropy loss and the weight of the triplet loss is 1, the weight of the cross entropy loss decreases as the number of iterations increases, and the weight of the triplet loss increases as the number of iterations increases.
[0105] In the early stage of training the SE-ResNet model, the weight of the cross entropy loss is increased; in the later stage of training the SE-ResNet model, the weight of the triplet loss is gradually increased.
[0106] When building a model or using an existing one, the performance of the model is often evaluated by calculating the accuracy rate. However, relying solely on accuracy to judge the quality of a model is incomplete. The confusion matrix provides a more comprehensive way to interpret the model's predictions. It is a technique used to evaluate various performance characteristics of a model that can be calculated from the model. The confusion matrix converts the probabilities generated by the model and expresses them as a combination of predicted and actual values, presented in a square table format. Figure 5 and Figure 6 The confusion matrix of the CNN model proposed in this invention is shown, which includes the results of individual and population classification.
[0107] and Figure 1 Corresponding to the method, refer to Figure 7 , an embodiment of the present invention provides a system for identifying apes based on metric learning, comprising:
[0108] at least one processor;
[0109] at least one memory for storing at least one program;
[0110] When the at least one program is executed by the at least one processor, the at least one processor implements the above method.
[0111] It can be seen that the contents of the above method embodiments are all applicable to the present system embodiments. The functions specifically implemented by the present system embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0112] In addition, an embodiment of the present invention further discloses a computer program product or computer program, which is stored in a computer-readable storage medium. A processor of a computer device can read the computer program from the computer-readable storage medium, and the processor executes the computer program, causing the computer device to perform the above-mentioned method. Similarly, the contents of the above-mentioned method embodiment are applicable to the present storage medium embodiment. The functions specifically implemented by the present storage medium embodiment are the same as those of the above-mentioned method embodiment, and the beneficial effects achieved are also the same as those achieved by the above-mentioned method embodiment.
[0113] Those skilled in the art will appreciate that all or some of the methods and systems disclosed above can be implemented as software, firmware, hardware, or any suitable combination thereof. Some or all of the physical components may be implemented as software executed by a processor, such as a central processing unit, digital signal processor, or microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on computer-readable media, which may include computer storage media (or non-transitory media) and communication media (or transitory media). As is well known to those skilled in the art, the term computer storage media includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information, such as computer-readable instructions, data structures, program modules, or other data. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVDs) or other optical disk storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer. Furthermore, as is well known to those skilled in the art, communication media typically embodies computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.
[0114] The above is a specific description of the preferred implementation of the present disclosure, but the present disclosure is not limited to the above-mentioned implementation mode. Technical personnel familiar with the art can also make various equivalent modifications or substitutions without violating the spirit of the present disclosure. These equivalent modifications or substitutions are all included in the scope defined by the claims of the present disclosure.
Claims
1. A method for ape identification based on metric learning, characterized in that: The method comprises the following steps: Obtaining original images of apes, and performing data augmentation on the original images to obtain training samples; Constructing an SE-ResNet model, inputting the training samples into the SE-ResNet model for training, determining a total loss function of the SE-ResNet model, and determining a loss value of the SE-ResNet model after completing a current iterative training based on the total loss function. When the loss value is lower than a set loss threshold, completing the training of the SE-ResNet model to obtain an ape recognition model; wherein the SE-ResNet model includes a plurality of residual modules, each of which includes a plurality of residual blocks embedded with SE modules, and the SE modules are used to adaptively adjust the weights of each feature channel; A monkey recognition model is used to extract features and classify monkey images, and to identify individual monkeys and their populations. The expression of the total loss function is: ; in, is the total loss function of the SE-ResNet model, is the cross entropy loss function, is the triplet loss function, A vector representing individual characteristics, A vector representing population characteristics, λ1 and λ2 are weighted coefficients of the loss function, which are used to control the weights of different losses in the total loss; The method further comprises: During iterative training of the SE-ResNet model, an attention mechanism module is added after the plurality of residual modules in the SE-ResNet model, and the plurality of residual modules are retrained; wherein the attention mechanism module comprises two convolutional layers and a Sigmoid activation function, the attention mechanism module is used to generate an attention map and adjust an input feature map, and then use an adaptive average pooling layer to convert the feature map into a global feature vector; The global features are normalized through the batch normalization layer, and the individual category prediction scores and scores of different categories are output separately through the classification head.
2. The method according to claim 1, characterized in that The step of constructing the SE-ResNet model and inputting the training samples into the SE-ResNet model for training to obtain an ape recognition model includes: Using the CNN model parameters pre-trained on the ImageNet database as the hyperparameters of the ape recognition model; During the iterative training of the SE-ResNet model, the Adam optimization algorithm is used to train the SE-ResNet model. During the training process, the learning rate scheduling strategy and label smoothing are used to perform joint optimization for a set number of epoch iterations to complete one iterative training of the SE-ResNet model. Determine the total loss function of the SE-ResNet model, and determine the loss value of the SE-ResNet model after completing the current iterative training based on the total loss function. When the loss value is lower than a set loss threshold, the training of the SE-ResNet model is completed to obtain a trained ape recognition model.
3. The method according to claim 1, characterized in that The expression for processing the feature image by the residual module is: ; Where X represents the input image, Represents the features output by the input image X after passing through the residual module, and StemBlock represents the primary features converted from the input image X. represents the higher-level features extracted from the input image X after passing through the t-th residual block in the residual module; The expression for processing the feature image by the residual block is: ; Where x is the feature image of the input residual block, t is the index of the residual block, is the feature image generated by the tth residual block, 、 、 are the weights of the convolution kernel, and σ is the ReLU activation function.
4. The method according to claim 3, characterized in that The processing process of the SE module includes a compression phase and an excitation phase. The processing formula of the compression phase is: ; in, Represents the numerical distribution of C feature maps, that is, global information, H and W are the height and width of the feature map, i and j are the height index and width index of the feature map, and c is the channel index; The processing formula of the excitation stage is: ; in, and is the weight of the fully connected layer, σ1 and σ2 are the ReLU activation function and Sigmoid activation function layers respectively, s is the output feature after excitation, and z is the input feature after compression.
5. The method according to claim 1, wherein The method further comprises: During training the SE-ResNet model, the number of iterations for training the SE-ResNet model is determined, and the weight of the cross entropy loss and the weight of the triplet loss are determined based on the number of iterations, the sum of the weight of the cross entropy loss and the weight of the triplet loss is 1, the weight of the cross entropy loss decreases as the number of iterations increases, and the weight of the triplet loss increases as the number of iterations increases.
6. A metric learning-based ape identification system, characterized in that: The system comprises: at least one processor; at least one memory for storing at least one program; When the at least one program is executed by the at least one processor, the at least one processor implements the ape identification method based on metric learning as described in any one of claims 1 to 5.
7. A computer-readable storage medium storing a program executable by a processor, characterized in that: The processor-executable program is configured to perform the method according to any one of claims 1 to 5 when executed by the processor.
Citation Information
Patent Citations
Small-strand pedestrian re-identification method based on uncertainty second-order self-attention structure model
CN115761795A
Hainan hylobatidaes individual identification method based on multi-view feature fusion
CN118053178A