A posture-guided animal image synthesis and recognition integrated method
By constructing a feature adaptation module and a semi-supervised triplet loss function, the problem of uncontrollable pose in animal image generation models is solved, achieving efficient individual animal recognition and improving recognition accuracy and generalization ability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- 陶涛
- Filing Date
- 2026-04-21
- Publication Date
- 2026-07-14
AI Technical Summary
Existing animal image generation models lack explicit physical constraints on the geometric topology of animal limbs, resulting in highly random and uncontrollable spatial poses in the generated animal images. Furthermore, the synthesized images cannot be effectively incorporated into the metric space of real individual recognition models, leading to a decrease in recognition accuracy.
A diffusion model with a feature adaptation module is constructed. By converting animal pose features into Gaussian heatmaps and injecting them into a denoising U-Net network, a synthetic image under pose control is generated. The feature extraction network is optimized using a semi-supervised triplet loss function, and the synthetic image is introduced to enhance the generalization ability of the recognition model.
It achieves precise control over the anatomical posture of synthetic animal images, improves the generalization recognition ability and retrieval accuracy of individual wildlife identification models, and overcomes the computational obstacle of synthetic data lacking real identity labels.
Smart Images

Figure CN122391407A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer vision technology, and more specifically to a posture-guided integrated method for animal image synthesis and recognition. Background Technology
[0002] In natural ecological protection and refined management of animal husbandry, computer vision-based animal identification technology is a key means to achieve non-contact monitoring. Current animal identification typically relies on deep metric learning to extract the animal's phenotypic features. However, in real-world or complex natural scenarios, the generalization ability of deep learning models is severely limited by the size of the training samples and the diversity of data distribution.
[0003] Due to the elusive activity patterns of wild animals and the uncontrolled shooting environment, obtaining high-quality images of the same animal from multiple perspectives, poses, and lighting conditions is extremely difficult. This results in a prevalent long-tail effect and missing pose features in real animal image datasets. To address this data scarcity, existing traditional image augmentation techniques (such as 2D rotation, cropping, or color dithering) can only perform linear transformations on the 2D pixel plane of the image, failing to generate effective samples with novel skeletal poses in the 3D anatomical semantics. In recent years, although text-based generative diffusion models (such as StableDiffusion) have emerged to synthesize supplementary data, existing generative domain techniques suffer from two core defects that directly hinder their application to individual identification:
[0004] First, existing text-driven diffusion models lack explicit physical constraints on the geometric topology of animal limbs when generating animal images, resulting in highly random and uncontrollable spatial poses in the generated animal images. This misaligned pose distribution not only fails to effectively fill the feature gaps of the target individual in a specific motion state, but also easily introduces noisy data with anatomical abnormalities.
[0005] Second, when training a recognition model using synthetic images, the traditional triplet loss function must rely on deterministic real-world labels to construct positive and negative sample pairs. Since synthetic images do not correspond to any real animal individuals in the objective physical world (i.e., lacking real hard labels), traditional feature measurement networks cannot effectively incorporate them into distance calculations within the measurement space. This results in the high-dimensional feature space still only being able to overfit between a limited number of real samples during optimization, failing to effectively utilize synthetic data to increase inter-class distances and reduce intra-class variance. Ultimately, this leads to a significant decrease in recognition accuracy when the model faces real, unknown individuals with significant pose changes. Summary of the Invention
[0006] To achieve the above objectives, the present invention provides the following technical solution:
[0007] This invention provides a posture-guided integrated method for animal image synthesis and recognition, comprising the following steps: S100: acquiring raw image data of real animals and extracting animal posture features to construct a training set for the generative model;
[0008] S200: Construct a diffusion model with a feature adaptation module, and train the diffusion model using the generative model training set to obtain a pose-guided animal image synthesis model.
[0009] S300: Input the posture control conditions into the animal image synthesis model to generate a synthetic animal image with different identity features, and combine the synthetic animal image with the original image data to obtain an augmented dataset;
[0010] S400: Construct a feature extraction network, input the augmented dataset into the feature extraction network for feature mapping, and obtain high-dimensional image features;
[0011] S500: Construct a semi-supervised triplet loss function based on the high-dimensional image features, and optimize and train the feature extraction network under the constraints of the loss function to obtain an animal individual recognition model for target individual recognition.
[0012] Further, the processing of the original image data in step S100 includes:
[0013] The acquired raw image is normalized to linearly map the image pixel values to a preset range. The calculation formula for the normalization process is as follows:
[0014]
[0015] in, These are the original image pixel values. These are the normalized pixel values. The preset pixel average value, The standard deviation is the preset value.
[0016] The specific steps for extracting animal posture features include:
[0017] A pre-trained pose estimation model is used to detect animal keypoints in the original image, obtaining the keypoint coordinate set of each individual animal. :
[0018]
[0019] in, Indicates the first The horizontal and vertical coordinates of the key points in the image coordinate system This indicates the visibility confidence level of the key point. The total number of key points for the defined animal.
[0020] Furthermore, step S100, which involves constructing the training set for the generative model, also includes:
[0021] Based on the key point coordinate set A pose heatmap with the same dimensions as the original image is generated using a Gaussian kernel function, serving as a representation image of the animal's pose features; the pixels in the pose heatmap... response value The calculation formula is as follows:
[0022]
[0023] in, The set of coordinates of the key points The Middle The coordinates of the key points This is the preset Gaussian standard deviation used to control the diffusion range of thermal points. This represents the total number of key points in the animal.
[0024] The posture heatmap, the corresponding original image, and the text prompts describing the animal category are combined into triplet data pairs to construct the training set for the generative model.
[0025] Further, step S200 involves constructing a diffusion model with a feature adaptation module, including:
[0026] The diffusion model adopts a denoising U-Net network structure that includes an encoder, an intermediate layer, and a decoder;
[0027] A feature adaptation module is constructed in parallel with the denoising U-Net network encoder. This feature adaptation module contains convolutional layers of multiple scales, used to downsample the pose heatmap and extract multi-scale features, obtaining a multi-scale pose feature set with the same spatial resolution as the corresponding layer in the denoising U-Net network encoder. ,in The total number of feature levels;
[0028] The feature adaptation module injects pose guidance information into the diffusion model, specifically including:
[0029] The multiple scale pose feature sets pose features at various scales After being processed by zero-initialized convolutional layers, residual connections are added element-wise according to resolution level and injected into the encoder feature maps of each level of the denoising U-Net network to achieve deep fusion of pose guidance information and image space generation features.
[0030] Further, in step S200, the diffusion model is trained using the generative model training set, specifically as follows:
[0031] During training, the original pre-trained parameters of the denoised U-Net network are kept frozen, and only the network parameters of the feature adaptation module are updated with gradients.
[0032] The model is optimized using a denoising diffusion objective function, the calculation formula of which is as follows:
[0033]
[0034] in, This represents the latent feature representation of the original image after compression by a variational autoencoder. For the time step of the diffusion model, For the first Latent feature representation after adding noise. The sampled real Gaussian noise, This is the noise prediction network of the denoising U-Net network. This is an embedded representation of text prompt words. The attitude heatmap, This indicates the pose features extracted and injected through the feature adaptation module.
[0035] Furthermore, in step S300, the posture control conditions are input into the animal image synthesis model, and the specific process of generating the synthesized animal image includes:
[0036] Acquire target-driven images or manually set skeletal key points to generate corresponding target pose heatmaps. As a condition for attitude control;
[0037] Initialize a random Gaussian noise tensor that follows a standard normal distribution. , as the initial latent features of the diffusion model;
[0038] At the set reasoning time step Inside, the random Gaussian noise tensor Text cue words describing the target animal are embedded. and the target attitude heatmap The image is input into the trained animal image synthesis model, where pose features are injected through the feature adaptation module, and the denoising U-Net network is used for progressive reverse denoising sampling.
[0039] The final latent features obtained by reverse denoising sampling The image is reconstructed by inputting it into the decoder of the variational autoencoder to obtain the output synthetic animal image. ;
[0040] Generate synthetic animal images with distinct identity features, and combine the synthetic animal images with the original image data to obtain an augmented dataset, specifically including:
[0041] While maintaining the target attitude heatmap and text prompt word embedding Under the condition that remains unchanged, the initialized random Gaussian noise tensor is changed multiple times. The random seed, or the dynamic addition of environmental and appearance modifiers to the text prompts, can generate multiple synthetic animal images with different fur colors, textures or background environments under the same posture;
[0042] Each generated synthetic animal image is assigned a corresponding pseudo-label, which is then mixed with the original image data containing real labels and formatted to construct an augmented dataset for subsequent training of the recognition network.
[0043] Furthermore, the feature extraction network described in step S400 includes a cascaded backbone network and a feature head module;
[0044] The backbone network is a convolutional neural network containing residual structures or a Transformer architecture network based on a self-attention mechanism;
[0045] The feature head module includes a linear fully connected layer and a batch normalization layer connected thereto, which is used to map the feature vectors output by the backbone network to a unified high-dimensional metric space.
[0046] The augmented dataset is input into the feature extraction network for feature mapping to obtain high-dimensional image features. The specific process includes:
[0047] After the images in the amplified dataset are processed to be of uniform size, they are input into the backbone network for local receptive field feature extraction or global sequence feature extraction.
[0048] If the backbone network is a convolutional neural network, then the spatial features at the end of the network are extracted and aggregated into a one-dimensional feature vector through a global average pooling layer; if the backbone network is a Transformer architecture network, then its class label is extracted as a global one-dimensional feature vector.
[0049] The one-dimensional feature vector is input into the feature head module, where it is scaled in dimension by the linear fully connected layer and normalized in distribution by the batch normalization layer, outputting high-dimensional image features with a dimension between 256 and 1024. , which serves as the final vector representing the animal's identity attributes.
[0050] Furthermore, in step S500, a semi-supervised triplet loss function is constructed, which includes anchor points, positive samples, and negative samples. The specific sample combination and construction strategy includes:
[0051] In a single training iteration, an image is selected from the augmented dataset as the anchor image;
[0052] Select another image with the same real identity label or the same pseudo label as the anchor point image as the positive sample image;
[0053] Images with different real identity labels and different pseudo labels from the anchor point image are selected as negative sample images;
[0054] In order to achieve semi-supervised feature space optimization, the triplet consisting of the anchor image, positive sample image and negative sample image is required to include at least one synthetic animal image generated by step S300, so as to introduce the diversity constraints of pose and appearance features in the metric space.
[0055] Furthermore, the feature extraction network is optimized and trained under the constraints of the semi-supervised triplet loss function. The calculation formula is as follows:
[0056]
[0057] in, For the size of the training batch, The first The anchor point image, positive sample image, and negative sample image in each triplet are processed by the feature extraction network to output high-dimensional image features; This is a preset edge threshold used to control the boundary between positive and negative samples; This is a feature metric function used to calculate the distance between two high-dimensional image features. The calculation formula is Euclidean distance:
[0058]
[0059] in, The dimension of the high-dimensional image feature is denoted as .
[0060] Further, in step S500, the animal individual recognition model is used to identify the target individual in the animal image to be identified. The specific steps are as follows:
[0061] Construct a registered image database of known animal individuals, and use a trained animal individual recognition model to extract the registration high-dimensional features of each image in the database;
[0062] The animal image to be identified is input into the trained animal individual recognition model to extract the query high-dimensional features of the image to be identified;
[0063] Calculate the feature distance between the query high-dimensional feature and each of the registered high-dimensional features respectively;
[0064] The features are sorted from smallest to largest based on their distances. The individual corresponding to the registered high-dimensional feature with the smallest distance that is less than the preset matching threshold is output as the final recognition result of the animal image to be identified. If all distances are greater than the preset matching threshold, the individual is determined to be an unknown individual.
[0065] Beneficial effects
[0066] This invention constructs a parallel feature adaptation module outside the denoising network of the diffusion model, maps discrete skeletal key points into Gaussian heatmaps and injects them into the network in a residual manner, thereby achieving precise control of the anatomical pose of synthetic animal images without destroying the pre-training distribution. This effectively solves the physical limitations of single individual pose and scarce samples in real datasets.
[0067] This invention innovatively constructs a semi-supervised triplet loss function, which successfully overcomes the computational obstacle of synthetic data lacking real identity labels by forcibly introducing diverse synthetic images with pseudo-labels into isomorphic metric space sampling. This guides the feature extraction network to perform more discriminative feature mapping in a high-dimensional space that takes into account both pose diversity and appearance differences, thereby significantly improving the model's generalization recognition ability and retrieval accuracy for individual wild animals in practical application scenarios. Attached Figure Description
[0068] Figure 1 This is a flowchart illustrating the overall method of the present invention;
[0069] Figure 2 This is a schematic diagram of the diffusion model structure of the feature adaptation module of the present invention.
[0070] Figure 3 This is a schematic diagram of the construction process of the augmented dataset of the present invention. Figure 1 ;
[0071] Figure 4 This is a schematic diagram of the construction process of the augmented dataset of the present invention. Figure 2 . Detailed Implementation
[0072] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0073] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but includes other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0074] The present invention will now be described in further detail with reference to the accompanying drawings:
[0075] Example:
[0076] like Figure 1-4 As shown, a posture-guided method for integrated animal image synthesis and recognition includes the following steps:
[0077] S100: Obtain raw image data of real animals and extract animal posture features to construct a training set for the generative model;
[0078] S200: Construct a diffusion model with a feature adaptation module, and train the diffusion model using the generative model training set to obtain a pose-guided animal image synthesis model.
[0079] S300: Input the posture control conditions into the animal image synthesis model to generate a synthetic animal image with different identity features, and combine the synthetic animal image with the original image data to obtain an augmented dataset;
[0080] S400: Construct a feature extraction network, input the augmented dataset into the feature extraction network for feature mapping, and obtain high-dimensional image features;
[0081] S500: Construct a semi-supervised triplet loss function based on the high-dimensional image features, and optimize and train the feature extraction network under the constraints of the loss function to obtain an animal individual recognition model for target individual recognition.
[0082] Furthermore, the specific implementation process of step S100 is as follows:
[0083] In this embodiment, a posture-guided integrated method for animal image synthesis and recognition first performs step S100: acquiring raw image data of real animals and extracting animal posture features to construct a training set for the generative model. This step aims to transform unstructured image data into multimodal tensor features for subsequent diffusion models to read.
[0084] After acquiring the original images of the real animals to be processed, pixel-level normalization is performed on the original images to eliminate differences in pixel value distribution caused by different acquisition devices or lighting environments. The specific operation logic is as follows: for the RGB color space of the image, the original pixel values in each channel are linearly mapped to a preset numerical range. This pixel mapping process is achieved through a calculation formula. Execute point by point, among which This represents the pixel scalar value of the original image in the current coordinate channel. These are the normalized pixel values output after mapping. The global pixel mean is obtained in advance based on statistics from the entire wildlife image dataset. This corresponds to the global standard deviation obtained from the statistics. Through this mathematical transformation, the originally unevenly distributed image pixel matrix is transformed into a standard distribution tensor with a mean close to 0 and a variance close to 1, thereby ensuring the scale consistency of the input data in the feature space.
[0085] After pixel space normalization, the system proceeds to the coordinate domain extraction stage for animal pose features. The system calls a pre-trained 2D pose estimation model to perform forward propagation calculations on the processed image input, directly outputting the anatomical skeletal keypoint location information of the individual animal, thereby obtaining the keypoint coordinate set of the individual animal. This coordinate set is defined as a multidimensional set in the algorithm logic. In this data structure, Representing the The absolute horizontal and vertical coordinates of each key point in the pixel coordinate system of a two-dimensional image; The total number of key points in the animal is pre-defined, usually based on the number of physiological joints in the target animal. (The set contains...) This is a visibility confidence scalar output from the end of the model network. Its value is constrained to the interval [0,1] by the Sigmoid function, and it is used to characterize the probability that the corresponding keypoint is not occluded by the environment and truly exists in the current image field of view. This confidence parameter provides a numerical basis for filtering low-quality coordinate points in the subsequent feature processing stage.
[0086] Considering that the subsequent denoising U-Net diffusion network, due to the inherent characteristics of its convolutional structure, cannot directly receive and parse the aforementioned discrete set of coordinate vectors, this method employs a two-dimensional Gaussian kernel function in the feature domain to process the discrete keypoint coordinate set. The image is converted into a pose heatmap with the exact same spatial topology as the original image at the same resolution, which serves as a dense representation matrix of the animal's pose features. For this pose heatmap... Figure 2 Any pixel coordinate point in the 3D matrix Its characteristic response value According to the calculation formula Perform calculations and assign values.
[0087] In this core conversion formula, This is an exponential function with the natural constant as its base. (The part above the semicolon is...) The items constitute the currently traversed pixels. With the Key Targets The square of the Euclidean distance between them. (In the denominator) The predefined Gaussian standard deviation parameter acts as a control variable during feature mapping, determining the gradient range and decay rate of the Gaussian distribution centered on the keypoints diverging towards the outer pixels. The algorithm iterates through all... For each key point, the Gaussian response distribution generated by that point on the entire feature map is calculated, and then accumulated at the pixel level. Multi-peak stacking is performed. The final output attitude heatmap is a single-channel two-dimensional floating-point tensor, where the closer the value is to 1, the higher the probability of the presence of animal limb joints.
[0088] After completing the aforementioned feature transformations, the system proceeds to the data alignment and packaging stage. The system extracts natural language text describing the animal classification labels in the current original image and processes it into text prompts. Subsequently, along the data channel dimension, the system binds the generated single-channel pose heatmap tensor, the corresponding three-channel normalized original image matrix, and the descriptive text prompts, combining them into strongly aligned triplet data pairs. By traversing all original images of the target animal and executing the above standardization process, the system ultimately constructs a large-scale generative model training set, which is stored in the computing device's storage unit as the data base for subsequent joint training of the feature adaptation module and the diffusion model.
[0089] Furthermore, the specific implementation process of step S200 is as follows:
[0090] First, a denoising diffusion network architecture based on latent space is constructed. The system introduces a pre-trained variational autoencoder (VAE) to spatially compress the input high-resolution RGB raw image matrix during the training phase, mapping it to a low-dimensional latent feature tensor. The diffusion model primarily employs a denoising U-Net network structure. Topologically, this U-Net network sequentially comprises an encoder for feature downsampling, an intermediate layer for deep feature extraction, and a decoder for feature upsampling. The encoder consists of cascaded downsampling convolutional modules and self-attention modules at various spatial resolutions.
[0091] To achieve explicit guidance of image generation based on animal pose information, a feature adaptation module with a completely parallel structure to the encoder portion of the denoising U-Net network is constructed around its physical structure. This feature adaptation module independently receives the single-channel pose heatmap tensor output from step S100. Internally, it consists of a series of cascaded convolutional layers, activation layers, and pooling layers, used to progressively downsample and extract multi-scale features from the input pose heatmap. By setting the stride and padding parameters of each convolutional layer within this module, it outputs a series of multi-scale pose feature sets that are strictly aligned with the feature maps of each encoder level of the denoising U-Net network in terms of spatial resolution and channel dimension. .in, This represents the layer depth of the U-Net network encoder used for denoising. Representing the Animation feature tensor at various scales.
[0092] At the feature mapping and network connection level, this method injects the pose guidance information extracted by the feature adaptation module into the main stream of the diffusion model through a specific residual bypass. Specifically, for multi-scale pose feature sets... Each scale feature in Before its output is fed into the corresponding layer of the denoising U-Net network, a zero-initialized convolutional layer is forcibly connected. The weight matrix and bias vector of this zero-initialized convolutional layer are strictly assigned zero scalar values during network initialization. Subsequently, the pose feature tensor output from this zero-initialized convolutional layer is superimposed onto the spatially generated feature map of the corresponding layer of the denoising U-Net network using a residual connection with element-wise addition. This tensor-level bypass injection mechanism ensures that the feature adaptation module contributes strictly zero to the feature output of the backbone network during the initial iteration cycle of network training, thereby physically preventing untrained random pose features from disrupting the original pre-training data distribution of the denoising U-Net network.
[0093] After completing the physical topology construction of the model, the network parameter optimization calculation is initiated by generating the model training set. In the backpropagation gradient calculation settings, a parameter freezing strategy is executed: all layer parameters of the denoising U-Net network and the parameter state of the variational autoencoder are set to untrainable, and only the parameter nodes of the feature adaptation module and the zero-initialized convolutional layer are allowed to participate in gradient updates.
[0094] In the forward propagation of data during a single training iteration, the system randomly samples a time step from a standard normal distribution. and the corresponding Gaussian noise tensor Using a Markov forward process, the Gaussian noise tensor is transformed... According to time step The corresponding preset noise scheduling table is attenuated and superimposed onto the latent feature tensor. Above, obtain the latent feature representation after adding noise. Simultaneously, the text prompts in the current data pair are mapped into text embedding representations using the CLIP text encoder. And the attitude heatmap The input is fed into the feature adaptation module. The denoising U-Net network is based on the input... and pose features injected through the adapter module The predicted noise distribution at the current time step is output through forward computation. .
[0095] The joint optimization of the model is achieved by calculating the denoising diffusion objective function. This is achieved by computing the real Gaussian noise tensor. With network prediction noise tensor Perform pixel-by-pixel mean square error (MSE) calculation, the mathematical expectation expression of which is:
[0096]
[0097] Based on the calculated loss scalar The system invokes the adaptive moment estimation optimizer, which calculates the gradients of only the relevant nodes in the feature adaptation module using the backpropagation algorithm, and performs iterative updates to the network weight matrix parameters. After multiple epochs of batch training, training terminates when the loss function converges to a preset threshold range. The system then solidifies the parameters and outputs the trained pose-guided animal image synthesis model.
[0098] Furthermore, the specific implementation process of step S300 is as follows:
[0099] Preset posture control conditions and text prompts are input into the trained posture-guided animal image synthesis model. Forward inference is performed to generate synthetic animal images with differentiated identity features, and an augmented animal dataset is constructed. This step aims to leverage the model's generative capabilities in the latent space to overcome the objective limitations of the number of wild animal samples and their appearance diversity in the real physical world.
[0100] First, the system enters the forward inference preparation stage for image generation. The system receives a target-driven image from user input or an external database, or receives manually configured 2D skeletal keypoint coordinates, and generates a single-channel target pose heatmap tensor using the same 2D Gaussian kernel function mapping logic as in step S100. This is used as the absolute attitude control condition during the model inference stage. Simultaneously, in the graphics memory of the computing device, the system initializes a random Gaussian noise tensor with a specific dimension. The noise tensor is strictly constrained to follow a standard normal distribution. , as the initial latent feature state in the reverse denoising process of the diffusion model, where This represents the preset maximum inference time step.
[0101] During the reverse denoising sampling phase, the system executes from time step... The calculation is iterated in a loop, decreasing to time step 0. At each time step... The system will then convert the latent feature tensor of the current state. Text cue word embedding vectors describing the target animal species and fixed target attitude heatmap The data is synchronously input into the synthetic model. This includes the target attitude heatmap. Multi-scale feature extraction is performed by the trained and converged feature adaptation module, and the extracted features are injected into the corresponding encoder layer of the denoising U-Net network via residual bypass in the form of feature superposition. The denoising U-Net network integrates the aforementioned spatial pose conditions and semantic text conditions to calculate and output the distribution of predicted noise contained in the latent feature tensor at the current time step. Subsequently, the system uses a discretized denoising scheduling algorithm (such as DDIM or DDPM sampling algorithm) to extract the predicted noise from the current latent feature tensor. By subtracting the predicted noise component, the latent feature tensor for the next time step can be derived and calculated. .go through After several iterations of denoising stripping calculations, the system finally obtains a fully denoised, clear latent feature tensor. .
[0102] To map the latent features back to a human-visually readable pixel space, the system outputs the latent feature tensor. The input is fed into the decoder network of a variational autoencoder (VAE). The decoder performs spatial resolution augmentation and channel decoding of the low-dimensional latent features through a series of upsampling and transposed convolution operations, ultimately reconstructing a high-resolution synthetic animal image with the same output size as the original training image. Due to the persistent spatial constraints of the feature adaptation module in each step of denoising, the synthesized image... It was rigorously replicated at the physical geometry level. The animal's limb posture is defined.
[0103] Based on the successful validation of a single synthesis, the system further initiated a batch diversity amplification process. To introduce extremely high-dimensional individual phenotypic differences while maintaining the target animal's posture, the system preserved the target posture heatmap. Under the boundary condition that the basic species text prompts remain unchanged, a two-dimensional perturbation strategy is implemented: First, the random Gaussian noise tensor generated is dynamically modified at the system's underlying level. The pseudo-random number seed ensures that the initial Gaussian distribution starting point for each inference is shifted by Euclidean distance in the latent space; secondly, it embeds the basic text cue words. Based on this, the natural language processing module randomly concatenates appearance modifiers covering animal fur color (such as "spots" and "solid color"), fur texture, lighting conditions, and background environment (such as "snow" and "rainforest"). Through the injection of these micro-perturbations, the synthetic model can render and generate hundreds or thousands of synthetic animal images with different identity features (fur texture, ambient lighting, and individual markings) under the strong constraints of the same skeleton pose.
[0104] Finally, the system enters the augmented dataset construction and formatting stage. Since the generated synthetic images do not correspond to any real wild animal individuals in the physical world, the system assigns a unique pseudo-label to each synthetic animal image in the label dimension to absolutely isolate it from real individuals in the category space. The system extracts the tensors of all synthetic images with pseudo-labels in this batch and performs data structure-level mixing and alignment with the original images with real identity labels in the original dataset. After uniformly cropping the images and reshaping the tensor dimensions, the system finally encapsulates it into a standardized augmented animal dataset and writes it to persistent storage media.
[0105] Furthermore, the specific implementation process of step S400 is as follows:
[0106] A feature extraction network for individual animal identification is constructed, and the augmented animal dataset is input into this network for forward feature mapping to obtain high-dimensional image features representing individual identity attributes. This step aims to nonlinearly map high-resolution pixel-level visual spatial data into a compact and highly discriminative continuous mathematical metric space.
[0107] In constructing the network physical topology, the feature extraction network is designed as a cascaded deep learning computation graph containing a backbone network structure and feature head modules. To adapt to different computing resource conditions and feature extraction preferences, the backbone network structure in this embodiment is configured with two switchable deep learning architectures:
[0108] The first approach uses a convolutional neural network with residual structures as its backbone (e.g., the ResNet series architecture). In this architecture, the network consists of multiple cascaded residual blocks, each containing multiple cascaded 2D convolutional layers and cross-layer shortcut connections. The input image undergoes layer-by-layer spatial resolution downsampling and channel dimension augmentation. Through sliding computation of the convolutional kernels across the image plane, the network progressively extracts local receptive field features from shallow edge textures to deep abstract semantics. After forward computation of all residual blocks, the network outputs a multi-channel 3D spatial feature map tensor. Subsequently, a global average pooling layer is invoked to calculate the pixel mean on each spatial channel surface of the 3D spatial feature map, thereby completely compressing the spatial dimension and aggregating to output a global 1D feature vector.
[0109] The second approach employs a Transformer architecture (e.g., the ViT architecture) with a backbone network based on a self-attention mechanism. When using this architecture, the system first segments the input image spatially into multiple non-overlapping, fixed-size image patches using a patch mapping module. Each patch is then flattened and transformed into a one-dimensional image patch sequence vector through a linear projection layer. Simultaneously, a learnable class label vector is forcibly appended to the beginning of the sequence, and a one-dimensional positional encoding is superimposed on all sequence elements to preserve spatial priors. This mixed sequence is then fed into multiple cascaded Transformer encoder layers, where a multi-head self-attention mechanism is used to calculate the global association weight matrix between image patches, achieving global feature interaction across spatial distances. After computation by all encoder layers, the system extracts the feature state corresponding to the class label vector from the network output sequence through a slicing operation, using it as a one-dimensional feature vector representing the global semantic information of the entire image.
[0110] After obtaining the global one-dimensional feature vector output by the backbone network, in order to further eliminate the dimensional differences of the underlying network architecture and optimize the distribution of the feature in the metric space to adapt to the subsequent distance metric task, the system inputs the one-dimensional feature vector into the feature head module for high-dimensional mapping processing.
[0111] The feature head module, in its network topology, sequentially comprises a linear fully connected layer and a batch normalization layer. First, the one-dimensional feature vector passes through the linear fully connected layer, where it undergoes scaling and reshaping of its feature dimension through pre-defined weight matrix multiplication and bias vector addition operations, mapping it to a pre-defined target feature dimension space. Subsequently, this feature vector flows into the batch normalization layer. Based on the statistical parameters of all feature vectors within the current training batch, the system calculates the batch mean and batch variance, and uses these statistical parameters to perform distribution normalization on the feature vectors. This normalization operation not only forcibly corrects the internal covariance shift of the features, ensuring that the output features strictly conform to a standard distribution with a mean of 0 and a variance of 1, but also further smooths the optimized terrain of the feature space, preventing individual extreme feature values from dominating the weights of subsequent distance metric calculations.
[0112] After cascaded processing by the feature head module, the system finally outputs high-dimensional image feature representations with dimensions precisely controlled between 256 and 1024. (The specific dimensional value is instantiated and defined in the weight matrix of the feature head module according to the actual accuracy requirements.) This high-dimensional image feature representation As a dense floating-point tensor, it completely strips away the redundant background noise and pose geometry information of the original image, becoming an essential mathematical representation that only represents the unique identity attribute of an individual animal, and is temporarily stored in the tensor cache queue of the computing device.
[0113] Furthermore, the specific implementation process of step S500 is as follows:
[0114] Based on the high-dimensional image feature representation, a semi-supervised triplet loss function is constructed. Under the numerical constraints of this loss function, the system jointly optimizes and trains the weight parameters of the feature extraction network, and finally deploys the trained model to perform target individual recognition. This step aims to reshape the feature distribution in the metric space by introducing synthetic pseudo-label data, thereby increasing the inter-class distance and reducing the intra-class variance.
[0115] First, in a single backpropagation training iteration, the system adjusts the batch size according to the set parameters. The system extracts the corresponding high-dimensional image features from the tensor cache queue. To construct the computational basis of the loss function, the system executes a rigorous triplet sampling strategy. In the feature space, the system randomly anchors a high-dimensional image feature as the anchor feature (denoted as ). Subsequently, based on the label attributes in the dataset, the system retrieves and extracts a high-dimensional image feature that has the same real identity label or the same pseudo label as the anchor feature as a positive sample feature (denoted as Positive). Simultaneously, a high-dimensional feature with different real identity labels and different pseudo labels from the anchor feature is retrieved and extracted as a negative sample feature (denoted as ). )
[0116] Within the semi-supervised learning framework of this invention, in order to forcibly inject the pose and appearance diversity generated in step S300 into the metric space, the system embeds a mandatory constraint rule in the sampling logic of the above triples: for each constituent... Triples are required to contain at least one data node generated from a synthetic animal image in their corresponding original image tensor.
[0117] After completing the triplet feature sampling, the system calls the feature metric function to calculate the relative distance in the high-dimensional space. This embodiment uses Euclidean distance as the metric. For any two dimensions of size... High-dimensional image features and The system calculates the absolute distance scalar between the two entities in the feature metric space by performing dimension-wise difference calculations, squaring operations, and global summation and square root operations. The specific calculation formula is as follows:
[0118]
[0119] in, This represents the channel index of the feature vector in the current metric space. and These represent the floating-point response values of the two feature vectors in that dimension channel, respectively.
[0120] Based on the distance metric formula mentioned above, the system calculates the distance between the anchor feature and the positive sample feature respectively. And the distance between anchor features and negative sample features. Subsequently, the system constructs a semi-supervised triplet loss function based on this relative distance difference. The overall mathematical expectation expression for the objective loss function is as follows:
[0121]
[0122] in, This refers to the index number of the triplet within the current training batch. The system's preset margin threshold hyperparameter is a constant scalar greater than zero. This margin threshold geometrically defines the minimum absolute width of the inter-class separation band. The system subtracts the negative sample distance from the positive sample distance and then adds this margin threshold. Then, the non-linear activation function is called. The system performs a truncation operation: when the calculated result is less than zero, it indicates that negative sample features have been pushed outside the safe boundary, and the system truncates the gradient of the current triplet to zero, preventing further invalid parameter updates. Conversely, when the calculated result is greater than zero, the system accumulates the results and calculates the batch mean, outputting the final scalar loss value. Based on this loss value, the system executes the backpropagation algorithm to calculate the gradient of the network parameters, continuously driving the backbone network and feature head module to bring similar identity features closer together and push away dissimilar identity features.
[0123] After the loss function converges and the model training is complete, the system enters the target individual identification and deployment phase in the actual physical environment. First, the system extracts multiple prior visual images of known animal individuals as registration base maps. Through a pre-defined feature extraction network, it performs forward inference to acquire and store the registration high-dimensional features of these base maps, constructing an offline feature database. When an image of an animal to be identified is received from the field acquisition device, the system maps its input network to a query high-dimensional feature. The system calculates the Euclidean distance between this query high-dimensional feature and all registered high-dimensional features in the feature database, and performs bubble sort or quick sorting based on the distance scalar from largest to smallest. The system extracts the registered high-dimensional feature with the smallest distance and logically compares its value with a preset matching threshold. If the smallest distance is less than the matching threshold, the system outputs the individual identity associated with this feature as the final identification result for the image to be identified. If all distance scalars after sorting exceed the matching threshold, the system triggers a new individual alarm, determining that the animal in the current field of view is an unregistered unknown individual, thus achieving highly robust identification and abnormal individual detection in an open environment.
[0124] The above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions will not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A posture-guided integrated method for animal image synthesis and recognition, characterized in that, Includes the following steps: S100: Obtain raw image data of real animals and extract animal posture features to construct a training set for the generative model; S200: Construct a diffusion model with a feature adaptation module, and train the diffusion model using the generative model training set to obtain a pose-guided animal image synthesis model. S300: Input the posture control conditions into the animal image synthesis model to generate a synthetic animal image with different identity features, and combine the synthetic animal image with the original image data to obtain an augmented dataset; S400: Construct a feature extraction network, input the augmented dataset into the feature extraction network for feature mapping, and obtain high-dimensional image features; S5 00: Construct a semi-supervised triplet loss function based on the high-dimensional image features, and optimize and train the feature extraction network under the constraints of the loss function to obtain an animal individual recognition model for target individual recognition.
2. The posture-guided integrated method for animal image synthesis and recognition according to claim 1, characterized in that, Step S100, processing the original image data, includes: The acquired raw image is normalized to linearly map the image pixel values to a preset range. The calculation formula for the normalization process is as follows: in, These are the original image pixel values. These are the normalized pixel values. The preset pixel average value, The standard deviation is the preset value. The specific steps for extracting animal posture features include: A pre-trained pose estimation model is used to detect animal keypoints in the original image, obtaining the keypoint coordinate set of each individual animal. : in, Indicates the first The horizontal and vertical coordinates of the key points in the image coordinate system This indicates the visibility confidence level of the key point. The total number of key points for the defined animal.
3. The posture-guided integrated method for animal image synthesis and recognition according to claim 2, characterized in that, Step S100, which involves constructing the training set for the generative model, also includes: Based on the key point coordinate set A pose heatmap with the same dimensions as the original image is generated using a Gaussian kernel function, serving as a representation image of the animal's pose features; the pixels in the pose heatmap... response value The calculation formula is as follows: in, The set of coordinates of the key points The Middle The coordinates of the key points This is the preset Gaussian standard deviation used to control the diffusion range of thermal points. This represents the total number of key points in the animal. The posture heatmap, the corresponding original image, and the text prompts describing the animal category are combined into triplet data pairs to construct the training set for the generative model.
4. The posture-guided integrated method for animal image synthesis and recognition according to claim 3, characterized in that, Step S200 involves constructing a diffusion model with a feature adaptation module, including: The diffusion model adopts a denoising U-Net network structure that includes an encoder, an intermediate layer, and a decoder; A feature adaptation module is constructed in parallel with the denoising U-Net network encoder. This feature adaptation module contains convolutional layers of multiple scales, used to downsample the pose heatmap and extract multi-scale features, obtaining a multi-scale pose feature set with the same spatial resolution as the corresponding layer in the denoising U-Net network encoder. ,in The total number of feature levels; The feature adaptation module injects pose guidance information into the diffusion model, specifically including: The multiple scale pose feature sets pose features at various scales After being processed by zero-initialized convolutional layers, residual connections are added element-wise according to resolution level and injected into the encoder feature maps of each level of the denoising U-Net network to achieve deep fusion of pose guidance information and image space generation features.
5. The posture-guided integrated method for animal image synthesis and recognition according to claim 4, characterized in that, In step S200, the diffusion model is trained using the generative model training set. The specific process is as follows: During training, the original pre-trained parameters of the denoised U-Net network are kept frozen, and only the network parameters of the feature adaptation module are updated with gradients. The model is optimized using a denoising diffusion objective function, the calculation formula of which is as follows: in, This represents the latent feature representation of the original image after compression by a variational autoencoder. For the time step of the diffusion model, For the first Latent feature representation after adding noise. The sampled real Gaussian noise, This is the noise prediction network of the denoising U-Net network. This is an embedded representation of text prompt words. The attitude heatmap, This indicates the pose features extracted and injected through the feature adaptation module.
6. The posture-guided integrated method for animal image synthesis and recognition according to claim 5, characterized in that, In step S300, the posture control conditions are input into the animal image synthesis model to generate the synthetic animal image. The specific process includes: Acquire target-driven images or manually set skeletal key points to generate corresponding target pose heatmaps. As a condition for attitude control; Initialize a random Gaussian noise tensor that follows a standard normal distribution. , as the initial potential features of the diffusion model; At the set reasoning time step Inside, the random Gaussian noise tensor Text cue words describing the target animal are embedded. and the target attitude heatmap The image is input into the trained animal image synthesis model, where pose features are injected through the feature adaptation module, and the denoising U-Net network is used for progressive reverse denoising sampling. The final latent features obtained by reverse denoising sampling The image is reconstructed by inputting it into the decoder of the variational autoencoder to obtain the output synthetic animal image. ; Generate synthetic animal images with distinct identity features, and combine the synthetic animal images with the original image data to obtain an augmented dataset, specifically including: While maintaining the target posture heatmap and text prompt word embedding Under the condition that remains unchanged, the initialized random Gaussian noise tensor is changed multiple times. The random seed, or the dynamic addition of environmental and appearance modifiers to the text prompts, can generate multiple synthetic animal images with different fur colors, textures or background environments under the same posture; Each generated synthetic animal image is assigned a corresponding pseudo-label, which is then mixed with the original image data containing real labels and formatted to construct an augmented dataset for subsequent training of the recognition network.
7. The posture-guided integrated method for animal image synthesis and recognition according to claim 6, characterized in that, The feature extraction network described in step S400 includes a cascaded backbone network and a feature head module; The backbone network is a convolutional neural network containing residual structures or a Transformer architecture network based on a self-attention mechanism; The feature head module includes a linear fully connected layer and a batch normalization layer connected thereto, which is used to map the feature vectors output by the backbone network to a unified high-dimensional metric space. The augmented dataset is input into the feature extraction network for feature mapping to obtain high-dimensional image features. The specific process includes: After the images in the amplified dataset are processed to be of uniform size, they are input into the backbone network for local receptive field feature extraction or global sequence feature extraction. If the backbone network is a convolutional neural network, then the spatial features at the end of the network are extracted and aggregated into a one-dimensional feature vector through a global average pooling layer; if the backbone network is a Transformer architecture network, then its class label is extracted as a global one-dimensional feature vector. The one-dimensional feature vector is input into the feature head module, where it is scaled in dimension by the linear fully connected layer and normalized in distribution by the batch normalization layer, outputting high-dimensional image features with a dimension between 256 and 1024. , which serves as the final vector representing the animal's identity attributes.
8. The posture-guided integrated method for animal image synthesis and recognition according to claim 7, characterized in that, Step S500 constructs a semi-supervised triplet loss function containing anchor points, positive samples, and negative samples. The specific sample combination and construction strategy includes: In a single training iteration, an image is selected from the augmented dataset as the anchor image; Select another image with the same real identity label or the same pseudo label as the anchor point image as the positive sample image; Images with different real identity labels and different pseudo labels from the anchor point image are selected as negative sample images; In order to achieve semi-supervised feature space optimization, the triplet consisting of the anchor image, positive sample image and negative sample image is required to include at least one synthetic animal image generated by step S300, so as to introduce the diversity constraints of pose and appearance features in the metric space.
9. The posture-guided integrated method for animal image synthesis and recognition according to claim 8, characterized in that, The feature extraction network is optimized and trained under the constraints of the semi-supervised triplet loss function. The calculation formula is as follows: in, For the size of the training batch, The first The anchor point image, positive sample image, and negative sample image in each triplet are processed by the feature extraction network to output high-dimensional image features; This is a preset edge threshold used to control the boundary between positive and negative samples; This is a feature metric function used to calculate the distance between two high-dimensional image features. The calculation formula is Euclidean distance: in, The dimension of the high-dimensional image feature is denoted as .
10. The posture-guided integrated method for animal image synthesis and recognition according to claim 9, characterized in that, In step S500, the animal individual recognition model is used to identify the target individual in the animal image to be identified. The specific steps are as follows: Construct a registered image database of known animal individuals, and use a trained animal individual recognition model to extract the registration high-dimensional features of each image in the database; The animal image to be identified is input into the trained animal individual recognition model to extract the query high-dimensional features of the image to be identified; Calculate the feature distance between the query high-dimensional feature and each of the registered high-dimensional features respectively; The features are sorted from smallest to largest based on their distances. The individual corresponding to the registered high-dimensional feature with the smallest distance that is less than the preset matching threshold is output as the final recognition result of the animal image to be identified. If all distances are greater than the preset matching threshold, the individual is determined to be an unknown individual.