Goose gender identification method and system based on active learning and ResViT

By using active learning and ResViT to identify goose sex, a training dataset was constructed and a goose sex identification model was trained. This solved the problems of low accuracy and invasiveness in traditional goose sex identification, and achieved high accuracy and non-invasive goose sex identification.

CN120853221APending Publication Date: 2025-10-28SHANDONG TIANGE AGRI & ANIMAL HUSBANDRY DEV CO LTD +2
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510986514.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-17
Publication Date
2025-10-28

AI Technical Summary

Technical Problem

Existing technologies are insufficient for accurately and non-invasively identifying the sex of geese. Traditional methods are highly subjective and have limited accuracy, while invasive methods can negatively impact the health of the geese.

Method used

A goose sex identification method based on active learning and ResViT is adopted. By constructing an initial training dataset, an initial goose sex identification model is trained using an active learning framework and a hybrid sampling strategy, combined with sample uncertainty measurement and feature space diversity measurement. The model includes feature embedding, feature extraction, fusion and normalization, and classification decision modules.

Benefits of technology

It improves the accuracy and generalization ability of goose sex identification, reduces the dependence on a large amount of labeled data, adapts to the sex characteristics of different breeds of geese, and maintains high recognition performance when facing new environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120853221A_ABST
    Figure CN120853221A_ABST
Patent Text Reader

Abstract

The invention discloses a goose gender identification method and system based on active learning and ResViT, and relates to the technical field of artificial intelligence, and the method specifically comprises the steps: collecting a goose image, and constructing an initial training data set; constructing a goose sex initial identification model; an active learning framework is adopted to initialize parameters of a goose sex initial recognition model, pre-training weights are preloaded, a hybrid sampling strategy is implemented through a dynamic data loader, a training data set is constructed based on an initial training data set in combination with sample uncertainty measurement and feature space diversity measurement, and a goose sex initial recognition model is obtained. Training the goose gender initial identification model by using the training data set to obtain a final goose gender identification model; obtaining a to-be-recognized goose image, inputting the to-be-recognized goose image into the goose gender recognition model, and outputting the goose gender; according to the method, the uncertainty and diversity of the samples are considered at the same time, the expression of the model on the aspect of unseen data can be enhanced, and the generalization ability of the model can be effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of artificial intelligence technology, and more specifically to a method and system for sex identification of geese based on active learning and ResViT. Background Technology

[0002] In modern animal husbandry, sex determination is a crucial step in improving production efficiency, optimizing resource utilization, and enhancing animal welfare. This is especially true for goose farming, where accurate sex identification has become paramount due to diversified market demands and technological advancements. Once geese reach a certain stage of development, various sex-based management measures, such as breeding pairing and slaughter plans, rely on reliable sex information. However, traditional methods for goose sex determination have several limitations.

[0003] Traditionally, farmers have relied on experience and intuition to determine the sex of geese. This method is not only highly subjective but also has limited accuracy. Especially as geese grow, their sex characteristics can become more difficult to distinguish, further increasing the difficulty of identification. For example, adult geese show little difference in appearance and feather color, making it impossible to directly distinguish their sex by observing specific features (such as comb size or feather color) like chickens or ducks. Furthermore, some more precise but invasive methods, such as vent examination, while providing some accuracy, require specialized skills and can cause stress to the geese, thus affecting their health and economic benefits.

[0004] Therefore, developing an automated, non-invasive goose sex identification system using artificial intelligence technology is particularly urgent. In recent years, significant progress has been made in poultry sex identification, especially in chickens and ducks. For example, sex has been determined by analyzing the Mel frequency cepstral coefficients in chick calls; the Squeeze-and-Excitation (SE) attention mechanism has been used to improve the ResNet model to increase the accuracy of adult chicken sex classification; and object detection and classification networks have been used to classify Muscovy ducks by sex. However, research on goose sex identification remains limited, mainly because the sex characteristics of geese are not readily apparent, making existing technologies difficult to apply directly. Therefore, developing a non-invasive and accurate goose sex identification system and method is a problem that urgently needs to be solved by those skilled in the art. Summary of the Invention

[0005] In view of this, the present invention provides a method and system for identifying the sex of geese based on active learning and ResViT, which overcomes the above-mentioned defects.

[0006] To achieve the above objectives, the present invention adopts the following technical solution:

[0007] A method for sex identification of geese based on active learning and ResViT, the specific steps of which are as follows:

[0008] Collect images of geese and construct an initial training dataset based on these images;

[0009] Construct an initial model for sex identification of geese;

[0010] The parameters of the initial goose sex identification model are initialized using an active learning framework, preloaded with pre-trained weights, and a hybrid sampling strategy is implemented through a dynamic data loader. A training dataset is constructed based on the initial training dataset, combining sample uncertainty measurement and feature space diversity measurement. The initial goose sex identification model is trained using the training dataset to obtain the final goose sex identification model.

[0011] Acquire an image of the goose to be identified, input the image into the goose gender recognition model, and output the goose's gender.

[0012] Optionally, the initial sex identification model for geese includes a feature embedding module, a feature extraction module, a feature fusion and normalization module, and a classification decision module;

[0013] The feature embedding module is used to divide the input image into multiple patch blocks, map the multiple patch blocks into multiple embedding vectors, and stack the multiple embedding vectors into an image feature matrix;

[0014] The feature extraction module consists of a serial inverted residual module and a multi-scale Transformer module. It extracts local and global features from the image feature matrix. The inverted residual module uses depthwise separable convolution to extract local features, while the multi-scale Transformer module introduces a residual attention mechanism to extract global features and generate an attention matrix.

[0015] The feature fusion and normalization module is used to perform cross-layer feature fusion on the attention matrix;

[0016] The classification decision module is used to output classification results based on the fused features.

[0017] Optionally, each embedding vector is subjected to a sine / cosine positional encoding, the expression of which is:

[0018] ;

[0019] ;

[0020] In the formula, The position encoding vector of the first Values ​​for each dimension; For the location index of the patch block; The dimension of the embedded vector; For dimension indexing; The position encoding vector of the first The values ​​of each dimension.

[0021] Optionally, the steps for extracting local features are as follows:

[0022] After the image feature matrix undergoes dimensionality transformation through a fully connected layer, it is input into a depthwise separable convolutional layer for convolution operation to obtain a local feature sequence.

[0023] Construct a local feature matrix based on local feature sequences.

[0024] Alternatively, the expression for the residual attention mechanism is:

[0025] ;

[0026] In the formula, This is the query vector for the first level; The key vector of the first layer; This is a transpose operation; Key vector The dimension; For gating variables; For the first The query vector of the layer; For the first Layer key vector; Key vector The dimension; For the first Attention output of the layer.

[0027] Optionally, the feature fusion and normalization module includes layer normalization and residual connections to perform cross-layer fusion of the attention matrix and generate fused features.

[0028] Optionally, the expression for the classification decision module is:

[0029] ;

[0030] In the formula, Features of fusion; Indicates the activation function; and All are weight matrices for linear layers.

[0031] Optionally, the sample uncertainty measure includes an uncertainty measure of the predicted probability based on the initial sex identification model for geese and an uncertainty measure of the predicted confidence based on the initial sex identification model for geese.

[0032] Optionally, feature space diversity measures include cosine similarity and dissimilarity measures.

[0033] A goose sex recognition system based on active learning and ResViT, comprising:

[0034] The training dataset building module is used to collect images of geese and build an initial training dataset based on these images.

[0035] The model building module is used to build an initial sex identification model for geese.

[0036] The model training module is used to initialize the parameters of the initial goose sex identification model using an active learning framework, preload the pre-trained weights, implement a hybrid sampling strategy through a dynamic data loader, and construct a training dataset based on the initial training dataset by combining sample uncertainty measurement and feature space diversity measurement. The initial goose sex identification model is then trained using the training dataset to obtain the final goose sex identification model.

[0037] The goose gender recognition module is used to acquire images of geese to be recognized, input the images into the goose gender recognition model, and output the gender of the goose.

[0038] As can be seen from the above technical solution, the present invention provides a method and system for goose sex identification based on active learning and ResViT, which has the following advantages compared with the prior art:

[0039] 1. The application of active learning strategies enables the system to prioritize the most informative samples for training during the training process, thereby effectively improving the model's learning efficiency and generalization ability, while reducing the dependence on a large amount of labeled data; this not only helps to quickly adapt to the sex characteristics of different breeds of geese, but also maintains high recognition performance when facing new environments or new data.

[0040] 2. The use of an initial sex identification model for geese can more accurately capture subtle sex differences in images, significantly improving the accuracy of sex identification. Attached Figure Description

[0041] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0042] Figure 1 This is a schematic diagram of the method flow provided by the present invention;

[0043] Figure 2 This is a schematic diagram of the active learning method provided by the present invention;

[0044] Figure 3 This is a schematic diagram of the system flow provided by the present invention; Detailed Implementation

[0045] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.

[0046] One embodiment of the present invention discloses a method for sex identification of geese based on active learning and ResViT, such as... Figure 1 As shown, the specific steps are as follows:

[0047] Step 1: Collect images of geese and build an initial training dataset based on the images of geese;

[0048] Step 2: Construct an initial sex identification model for geese;

[0049] Step 3: Initialize the parameters of the initial goose sex identification model using an active learning framework, preload the pre-trained weights, implement a hybrid sampling strategy through a dynamic data loader, and construct a training dataset based on the initial training dataset by combining sample uncertainty measurement and feature space diversity measurement. Use the training dataset to train the initial goose sex identification model to obtain the final goose sex identification model.

[0050] Step 4: Obtain the image of the goose to be identified, input the image of the goose to be identified into the goose gender recognition model, and output the gender of the goose.

[0051] In one embodiment, the initial sex identification model for geese includes a feature embedding module, a feature extraction module, a feature fusion and normalization module, and a classification decision module;

[0052] The feature embedding module is used to divide the input image into multiple patch blocks, map the multiple patch blocks into multiple embedding vectors, and stack the multiple embedding vectors into an image feature matrix;

[0053] The feature extraction module consists of a serial inverted residual module and a multi-scale Transformer module. It extracts local and global features from the image feature matrix. The inverted residual module uses depthwise separable convolution to extract local features, while the multi-scale Transformer module introduces a residual attention mechanism to extract global features and generate an attention matrix.

[0054] The feature fusion and normalization module is used to perform cross-layer feature fusion on the attention matrix;

[0055] The classification decision module is used to output classification results based on the fused features.

[0056] Furthermore, the initial training dataset consists of images captured from surveillance videos of various goose breeds, including the Wulong Goose, at different growth and development stages. First, the images are processed by a feature embedding module, mapping them from the original RGB three-channel space to a higher-dimensional feature space. Then, the image feature sequence after feature embedding is fed into the main body of the goose sex initial identification model to extract local and global features. These features are then fed into a feature fusion and normalization module for normalization. After a linear mapping and a softmax activation function, the normalized sequence outputs a probability value for each category, representing the model's confidence in that category. For goose sex classification, the model outputs two probability values: one for "male" and the other for "female." Finally, the model selects the category with the highest probability value as the prediction result; this probability value represents the model's confidence in this prediction.

[0057] Furthermore, in this embodiment, images were extracted from monitoring videos of different goose sheds in the goose farm. The geese in the sheds had already undergone sex identification when they were young, ensuring that each image was accompanied by accurate sex identification information. These images covered geese from 60 to 150 days old, and data was collected every week to ensure that subtle changes in the growth cycle of the geese could be captured. A total of 2,657 images were collected as the initial training dataset.

[0058] The training images in the initial training dataset are standardized to 224×224 pixels. At the same time, techniques such as horizontal flipping, scaling, and cropping are used to increase the diversity of the initial training dataset. This is intended to improve the generalization ability and robustness of the goose sex recognition model, reduce overfitting, and thus improve the prediction accuracy and stability of the goose sex recognition model in practical applications.

[0059] In one embodiment, sine / cosine position coding is applied to each embedding vector.

[0060] Furthermore, the feature embedding module is configured as a two-dimensional convolutional module, responsible for converting the input image into an embedded representation of a series of patches, preparing for subsequent feature extraction and classification tasks; the specific steps are as follows:

[0061] First, the input image is divided into patches of the same size. Then, each patch is subjected to a two-dimensional convolution. After convolution, each patch is then subjected to a linear mapping to obtain a flattened feature vector. Sine and cosine encoding is performed on each patch to obtain spatial location information.

[0062] Furthermore, the feature embedding module performs feature embedding and encoding on the image data during data processing. The specific steps are as follows:

[0063] First, the 224×224×3 image is divided into 196 fixed-size image blocks (i.e., patch blocks) of 16×16×3 pixels each. The patches do not overlap. Each image patch is converted into an embedding vector through a two-dimensional convolutional layer, which transforms the two-dimensional spatial features of the image into a series of one-dimensional sequences. The embedding vector of each patch block... The dimension is 1×768 pixels. To preserve spatial information, the embedding vector of each patch block is encoded with positional codes. The expression for the positional codes is:

[0064] (1);

[0065] (2);

[0066] In the formula, The position encoding vector of the first Values ​​for each dimension; For the location index of the patch block; This represents the dimension of the hidden layer of the model, i.e., the dimension of the embedding vectors; For dimension indexing; The position encoding vector of the first The values ​​of each dimension.

[0067] Then, the feature vectors of all image patches are stacked together to form a B×N×C image feature matrix. Where B is the batch size of the input image, N=196 is the number of blocks in an image, and C=768 is the embedding vector dimension of the image.

[0068] In one embodiment, the local feature extraction step is as follows:

[0069] After the image feature matrix undergoes dimensionality transformation through a fully connected layer, it is input into a depthwise separable convolutional layer for convolution operation to obtain a local feature sequence.

[0070] Construct a local feature matrix based on local feature sequences.

[0071] Furthermore, the feature extraction module, configured with a serially inverted residual module and an improved attention mechanism multi-scale Transformer module, is responsible for extracting features from the image feature matrix. It employs depthwise separable convolution and residual attention mechanisms. Depthwise separable convolution is used to extract local features; this convolution operation is computationally efficient and reduces model parameters. Through the residual attention mechanism, the goose sex initial recognition model can not only capture image features at different scales, but also, compared to traditional attention mechanisms, effectively mitigates the disappearance of low-level features extracted from shallow layers in subsequent layers by establishing direct connections between consecutive attention layers, thus enhancing feature diversity and model robustness. This mechanism allows the goose sex initial recognition model to better preserve local features from shallow layers while utilizing deep global context information, thereby achieving higher accuracy and generalization ability in visual recognition tasks. Local feature extraction is achieved through fully connected layers, depthwise separable convolution, and compression operations. Global feature extraction is achieved through learnable matrix mapping, calculating spatial attention scores, scaling dot products, introducing gated variables in cross-layer attention connections, and softmax function mapping.

[0072] Furthermore, the data processing steps in the feature extraction module are as follows:

[0073] The specific steps for local feature extraction are as follows:

[0074] After the image undergoes feature embedding, the original two-dimensional spatial features are transformed into a one-dimensional sequence of feature matrices. Then, inverted residual blocks are used to adapt to this one-dimensional sequential data. Given the input feature matrix... First, the feature matrix. It will pass through a fully connected layer similar to a convolution operation, transforming its dimensions from [B,N,C] to [B,N,C'], where, It is a new dimension after the fully connected layer. This transformation not only retains the core idea of ​​traditional convolution operation, but also optimizes it specifically for one-dimensional sequence data, avoiding the problem of information sparsity caused by simple feature matrix fusion, so as to better capture local features in the sequence.

[0075] Will Transform into The specific formula is as follows:

[0076] (3);

[0077] In the formula, For input features Perform channel conversion operation.

[0078] For the transformed sequence Applying depthwise separable convolution, this operation can be decomposed into depthwise convolution and pointwise convolution; depthwise convolution performs convolution operations independently on each input channel, while pointwise convolution uses a 1x1 convolution kernel to merge the results. This operation can be represented as:

[0079] (4);

[0080] In the formula, Output the result of depthwise convolution; For depthwise separable convolution; The output is a pointwise convolution; For pointwise convolution; It is the set of real numbers; This is the new dimension after pointwise convolution.

[0081] Finally, the sequence w after depthwise separable convolution is compressed, reducing the dimension from... Convert back to C. This operation can be represented as:

[0082] (5);

[0083] The dimensionality of the feature matrix remains unchanged after each local feature extraction through the inverted residual block. A total of six local feature extractions are performed to obtain a feature matrix rich in local information. Subsequently Perform global feature extraction.

[0084] The specific steps for global feature extraction are as follows:

[0085] The feature matrix is ​​paired with three learnable matrices WV, WQ, and WK. The attention value matrix is ​​obtained by mapping. Shared query matrix Shared key matrix ;

[0086] Will After transpose and Multiplication yields the spatial attention score. Then on The attention matrix is ​​obtained by scaling the dot product. The purpose of this step is to stabilize the gradient and prevent the attention score from being too high, which would cause the output of the softmax function to be close to 0 or 1 and affect the model performance.

[0087] In this embodiment, a novel method for calculating the attention matrix is ​​proposed by introducing a gating variable. Thus, the first Attention matrix of layer It considers not only the query and key of the current layer, but also the attention score of the previous layer. For the first The formula for defining the layer attention matrix is ​​as follows:

[0088] (6);

[0089] In the formula, Key vector Dimensions.

[0090] The final attention matrix is ​​represented by the following formula:

[0091] (7);

[0092] In the formula, This is the query vector for the first level; The key vector of the first layer; This is a transpose operation; Key vector The dimension; For gating variables; For the first The query vector of the layer; For the first Layer key vector; Key vector The dimension; For the first Attention output of the layer.

[0093] This cross-layer attention connection method, similar to residual connections in ResNet, effectively mitigates the tendency of the attention mechanism to over-focus on global information when propagating between layers, thereby suppressing the global expansion of attention and the accompanying phenomenon of the gradual disappearance of low-level features.

[0094] Use the softmax function to optimize the attention matrix. Mapped to attention weight matrix :

[0095] (8);

[0096] attention weight matrix With matrix Pointwise multiplication is performed to obtain the final attention score for one attention head. Then, the attention scores of all attention heads are concatenated to form the next attention score. Feature matrix of layer Its formula is:

[0097] (9);

[0098] In the formula, For connection operation; The number of heads in a multi-head attention mechanism; For the first The head is the first Attention score calculated by layer; for The value vector.

[0099] This step is repeated 6 times to obtain the final attention matrix. .

[0100] In one embodiment, the feature fusion and normalization module includes layer normalization and residual connections, which perform cross-layer fusion on the attention matrix to generate fused features.

[0101] Furthermore, the feature fusion and normalization module is configured with modules including layer normalization and residual connections. These modules are responsible for fusing features from different layers and maintaining feature stability to improve the training efficiency and generalization ability of the initial goose sex identification model. First, it normalizes the output features from the previous module to reduce internal covariate bias; that is, it normalizes the features of each sample individually. This helps accelerate the training process and improve the generalization ability of the initial goose sex identification model. Then, the normalized features are added to the output of the previous module to achieve feature fusion. This residual connection facilitates the flow of information in the network, reduces the gradient vanishing problem, and enhances the learning ability of the initial goose sex identification model.

[0102] In one embodiment, the classification decision module is configured with a module including a linear layer, a dropout layer and an activation function, which is responsible for mapping the fused features to the final classification result and completing the classification task of the initial sex identification model for geese.

[0103] Furthermore, the features, after feature fusion and normalization, are fed into the classification decision module, which maps them to the dimensions required for the classification task. Classification is then achieved through multiple fully connected layers. This module, containing linear layers, dropout layers, and activation functions, is responsible for mapping the fused features to the final classification result, completing the initial sex identification model for geese. The specific formula is as follows:

[0104] (10);

[0105] in, This represents the activation function. and All represent the weight matrix of the linear layer. The Multilayer Perceptron (MLP) has two layers. The output of the first layer passes through an activation function, and then passes through a linear transformation of the second layer to obtain the final classification result.

[0106] Furthermore, the fused features are passed through fully connected layers, and Dropout is applied to all layers except the last one to reduce overfitting and improve the generalization ability of the initial goose sex identification model.

[0107] The ReLU activation function is applied to introduce non-linearity, enabling the initial goose sex identification model to learn more complex feature representations. The final fully connected layer maps the features to the final binary classification result. Here, the Sigmoid activation function is used, which compresses the output to between 0 and 1, representing the probability that a sample belongs to a certain class.

[0108] In one embodiment, the sample uncertainty measure includes an uncertainty measure of the predicted probability based on the initial sex identification model of geese and an uncertainty measure of the predicted confidence based on the initial sex identification model of geese.

[0109] In one embodiment, the feature space diversity measure includes cosine similarity and dissimilarity measures.

[0110] Furthermore, this embodiment relates to an active learning framework, such as... Figure 2 As shown, this framework aims to improve the performance of a goose sex identification model on a specific task by intelligently selecting and utilizing pre-trained model parameters. The framework employs an active learning strategy, loading the pre-trained parameters of the native ViT model on the ImageNet dataset into this embodiment. This embodiment optimizes the attention mechanism and feature extraction method while maintaining the overall architecture, thus allowing for weight transfer. By introducing an uncertainty query sampling mechanism, the framework can identify the most informative and challenging images, which are then used to train the goose sex identification model. Simultaneously, the framework incorporates a diversity-enhanced sampling strategy to ensure that the goose sex identification model does not overly rely on certain specific samples during training, thereby avoiding overfitting. During training, the framework utilizes an uncertainty- and diversity-guided active learning strategy to achieve self-calibration of the goose sex identification model's weights. This strategy helps the goose sex identification model more accurately adjust its parameters when faced with new and unseen data to adapt to the needs of new tasks.

[0111] In one embodiment, the specific steps of uncertain query sampling are as follows:

[0112] Uncertainty Assessment: During the training of the initial sex identification model for geese, the uncertainty of the prediction results of the initial sex identification model is assessed. The mean squared error of the predicted probability distribution is calculated using an uncertainty metric function to identify the most uncertain or difficult-to-identify samples in the initial sex identification model for geese.

[0113] Selection of high-information samples: Based on the uncertainty assessment results, samples with the highest uncertainty are selected. These samples typically contain rich information and provide the greatest learning value for the initial sex identification model of geese.

[0114] Furthermore, in the data processing and loading stage, this embodiment uses an active learning strategy to initialize the initial goose sex identification model. The architecture of the initial goose sex identification model is similar to the original ViT in the last six layers of feature embedding and feature extraction, as well as the final linear classification layer, allowing for model transfer. The initial goose sex identification model is preloaded with ViT-B / 16 pre-trained weights on ImageNet. ImageNet contains more than 14 million images with rich feature representations. The general features in these images can accelerate the convergence of the initial goose sex identification model and reduce the model's dependence on a large dataset.

[0115] During the training phase, this embodiment defines a custom data loader. This data loader, through pre-set weights and hyperparameters, can select appropriate samples to load data according to the active learning strategy. During training, uncertainty sampling is performed based on an uncertainty metric function, and diversity sampling is performed based on a diversity metric function. This embodiment employs two methods to measure uncertainty. First, samples whose predicted probabilities are closest to the decision boundary of the initial goose sex identification model are selected and re-added to the training set for training. The formula for this uncertainty metric is:

[0116] (11);

[0117] In the formula, For the model to the first Predicted probability of class , These are the true labels of the samples.

[0118] Secondly, uncertainty is measured based on the confidence level predicted by the initial sex identification model for geese. The formula is as follows:

[0119] (12).

[0120] In one embodiment, the specific steps of the diversity-enhancing sampling strategy are as follows:

[0121] Diversity assessment: During the training of the initial sex identification model for geese, the prediction results of the initial sex identification model for geese are assessed for diversity. The diversity-enhancing sampling strategy selects those samples that are more dispersed in the feature space.

[0122] Selection of highly diverse samples: Based on the results of diversity measures, select the samples that are most dissimilar in the feature space. These samples can increase the diversity of the training dataset and help improve the adaptability of the initial goose sex identification model to different data distributions.

[0123] Furthermore, this embodiment also employs two diversity measurement methods, including cosine similarity and dissimilarity measurement. In their natural state, geese exhibit various postures such as crouching, drinking, running, and spreading their wings. The feature vectors obtained after feature embedding of the images show different dissimilarity, which also affects the model recognition effect.

[0124] Cosine similarity is determined by measuring the cosine of the angle between two vectors. In feature space, the closer the feature vectors of two samples are, the higher their cosine similarity. The formula for calculating cosine similarity is:

[0125] (13);

[0126] Where A and B are the feature vectors of the two samples; and Both are the lengths of the vectors. The cosine similarity value ranges from -1 to 1, where 1 indicates that the vectors are exactly the same, 0 indicates that they are orthogonal (i.e., unrelated), and -1 indicates that they are completely opposite.

[0127] Dissimilarity measures are typically used to measure the degree of difference between two samples. In active learning, it is desirable to select samples with high dissimilarity to increase the diversity of the training set. In this embodiment, the Euclidean distance between two samples is used to measure dissimilarity, and the specific formula is as follows:

[0128] (14);

[0129] In the formula, A and B represent the feature vectors of two samples in the feature space; the j-th element of vectors A and B is denoted as Aj. j and B j J is the dimension of the feature vector, that is, the number of elements in the vector.

[0130] Euclidean distance measures the linear distance between two vectors in the feature space. Specifically, the smaller the Euclidean distance, the closer the two samples are in the feature space, and therefore the more similar they are; conversely, the larger the Euclidean distance, the greater the difference in the positions of the two samples in the feature space, and therefore the greater their dissimilarity. This metric helps to select highly dissimilar samples in active learning, thereby enhancing the diversity of the training set and improving the generalization ability of the initial goose sex identification model.

[0131] In one embodiment, the specific steps for applying the active learning strategy that combines two sampling methods are as follows:

[0132] By employing an active learning strategy guided by uncertainty and diversity, the union of selected high-information and high-diversity samples is used for further training of the initial goose sex identification model. This strategy allows the initial goose sex identification model to adjust its parameters more accurately when faced with new and unseen data.

[0133] By combining uncertainty sampling and diversity sampling in this active learning framework, this embodiment can improve the generalization ability of the goose sex identification model on new tasks, while reducing the dependence on a large amount of labeled data. This is of great significance for practical application scenarios that need to process a large amount of unlabeled data.

[0134] Furthermore, for each sample, its marginal uncertainty score and confidence score are calculated, and samples with high marginal uncertainty and low confidence are stored in a set. middle.

[0135] For each sample, calculate its cosine similarity with all samples in the initial training dataset, and then take the maximum value as the diversity score. Similarly, calculate the Euclidean distance between the sample and all samples in the initial training dataset, and take the minimum value. Combine these two scores to obtain the total diversity score, and store the samples with high diversity scores into a set. middle.

[0136] The active learning process involves multiple iterative cycles. In each cycle, the initial goose sex identification model first selects samples with high uncertainty based on the aforementioned uncertainty measurement method. Simultaneously, it uses a diversity measurement method to select representative and diverse samples. Finally, the union of these uncertain and diverse samples forms a new training set, i.e., the training dataset. The formula for selecting the sampling samples is:

[0137] (15);

[0138] In the formula, For a sample set with uncertainty, A diverse set of samples; The final selected samples.

[0139] This training dataset was used to further train the initial sex identification model for geese, with the aim of enabling the model to learn richer and more discriminative features, thereby improving its classification performance. The active learning strategy helps the initial sex identification model improve its performance more effectively with limited labeled data.

[0140] The hyperparameter settings in this embodiment are as follows: Epoch is set to 50, the initial learning rate is 0.001, the gating variable α for the residual attention mechanism is set to 0.5, and the Adam optimizer and cosine annealing algorithm are used for adaptive adjustment of the learning rate. The β of the Adam optimizer is set to 0.9, ε is set to e-8, Weight Decay is set to 0.001, and the iteration period T_max of the cosine annealing algorithm is set to 2500. To measure the difference between the diagnostic result and the true label, a classification loss (usually cross-entropy loss) is used to optimize the classification ability of the initial goose sex identification model. This loss can be expressed as:

[0141] (16);

[0142] In the formula, The number of samples; It is a sample The true label; It is the output diagnostic probability distribution.

[0143] The results of the five-fold cross-validation of the goose sex identification model are shown in Table 1.

[0144] Table 1

[0145]

[0146] In further testing, to verify the generalization ability of the goose sex recognition model of this invention, 200 images of other goose breeds (including Sanhua goose, Hubei white goose, and Anhui white goose) were collected from the internet for testing. These images were not labeled or trained, but were directly used to evaluate the generalization performance of the goose sex recognition model. The test results show that the goose sex recognition model of this embodiment achieved a recognition accuracy of 84% on these different goose breeds. This result is significantly attributed to the active learning strategy adopted in this embodiment.

[0147] This embodiment also discloses a goose sex recognition system based on active learning and ResViT, such as... Figure 3 As shown, it includes:

[0148] The training dataset building module is used to collect images of geese and build an initial training dataset based on these images.

[0149] The model building module is used to build an initial sex identification model for geese.

[0150] The model training module is used to initialize the parameters of the initial goose sex identification model using an active learning framework, preload the pre-trained weights, implement a hybrid sampling strategy through a dynamic data loader, and construct a training dataset based on the initial training dataset by combining sample uncertainty measurement and feature space diversity measurement. The initial goose sex identification model is then trained using the training dataset to obtain the final goose sex identification model.

[0151] The goose gender recognition module is used to acquire images of geese to be recognized, input the images into the goose gender recognition model, and output the gender of the goose.

[0152] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to the method section.

[0153] The above description of the disclosed embodiments is intended to enable one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be readily apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention is not limited to the embodiments shown herein but is intended to conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for sex identification of geese based on active learning and ResViT, characterized in that, The specific steps are as follows: Collect images of geese and construct an initial training dataset based on these images; Construct an initial model for sex identification of geese; The parameters of the initial goose sex identification model are initialized using an active learning framework, preloaded with pre-trained weights, and a hybrid sampling strategy is implemented through a dynamic data loader. A training dataset is constructed based on the initial training dataset, combining sample uncertainty measurement and feature space diversity measurement. The initial goose sex identification model is trained using the training dataset to obtain the final goose sex identification model. Acquire an image of the goose to be identified, input the image into the goose gender recognition model, and output the goose's gender.

2. The method for goose sex identification based on active learning and ResViT according to claim 1, characterized in that, The initial sex identification model for geese includes a feature embedding module, a feature extraction module, a feature fusion and normalization module, and a classification decision module; The feature embedding module is used to divide the input image into multiple patch blocks, map the multiple patch blocks into multiple embedding vectors, and stack the multiple embedding vectors into an image feature matrix; The feature extraction module consists of a serial inverted residual module and a multi-scale Transformer module. It extracts local and global features from the image feature matrix. The inverted residual module uses depthwise separable convolution to extract local features, while the multi-scale Transformer module introduces a residual attention mechanism to extract global features and generate an attention matrix. The feature fusion and normalization module is used to perform cross-layer feature fusion on the attention matrix; The classification decision module is used to output classification results based on the fused features.

3. The method for goose sex identification based on active learning and ResViT according to claim 2, characterized in that, Each embedding vector is assigned a sine / cosine position code, the expression of which is: ; ; In the formula, The position encoding vector of the first Values ​​in each dimension; For the location index of the patch block; The dimension of the embedded vector; For dimension indexing; The position encoding vector of the first The values ​​of each dimension.

4. The method for goose sex identification based on active learning and ResViT according to claim 2, characterized in that, The steps for extracting local features are as follows: After the image feature matrix undergoes dimensionality transformation through a fully connected layer, it is input into a depthwise separable convolutional layer for convolution operation to obtain a local feature sequence. Construct a local feature matrix based on local feature sequences.

5. The method for goose sex identification based on active learning and ResViT according to claim 2, characterized in that, The expression for the residual attention mechanism is: ; In the formula, This is the query vector for the first level; The key vector of the first layer; This is a transpose operation; Key vector The dimension; For gating variables; For the first The query vector of the layer; For the first Layer key vector; Key vector The dimension; For the first Attention output of the layer.

6. The method for goose sex identification based on active learning and ResViT according to claim 2, characterized in that, The feature fusion and normalization module includes layer normalization and residual connections, which perform cross-layer fusion of the attention matrix to generate fused features.

7. The method for goose sex identification based on active learning and ResViT according to claim 2, characterized in that, The expression for the classification decision module is: ; In the formula, Features of fusion; Indicates the activation function; and All are weight matrices for linear layers.

8. The method for goose sex identification based on active learning and ResViT according to claim 1, characterized in that, The sample uncertainty measures include the uncertainty measures of the predicted probability based on the initial sex identification model of geese and the uncertainty measures of the predicted confidence based on the initial sex identification model of geese.

9. The method for goose sex identification based on active learning and ResViT according to claim 1, characterized in that, Features space diversity measures include cosine similarity and dissimilarity measures.

10. A goose sex recognition system based on active learning and ResViT, characterized in that, include: The training dataset building module is used to collect images of geese and build an initial training dataset based on these images. The model building module is used to build an initial sex identification model for geese. The model training module is used to initialize the parameters of the initial goose sex identification model using an active learning framework, preload the pre-trained weights, implement a hybrid sampling strategy through a dynamic data loader, and construct a training dataset based on the initial training dataset by combining sample uncertainty measurement and feature space diversity measurement. The initial goose sex identification model is then trained using the training dataset to obtain the final goose sex identification model. The goose gender recognition module is used to acquire images of geese to be recognized, input the images into the goose gender recognition model, and output the gender of the goose.

Citation Information

Cited By

  • Motor nonlinear parameter modeling method based on hybrid active learning sampling strategy

    CN122452380A