A method, system, device and medium for group closed set small sample precise individual identification in a group pig house

CN122929609APending Publication Date: 2026-10-16CHINA AGRI UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611144247.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-30
Publication Date
2026-10-16

AI Technical Summary

Technical Problem

[0006]针对现有视觉识别方法在群养猪舍场景中未充分利用栏位封闭身份集合、缺少组内一一互斥约束、栏位小样本注册能力不足以及多栏位应用中完整模型权重存储和切换开销较大的问题,本发明的目的是提供一种面向群养猪舍的组内封闭集小样本精准个体识别方法、系统、设备及介质,通过利用目标栏位注册时间窗口内的少量图像完成身份登记和栏位适配,将栏位相关的少量可训练权重和身份原型进行存储,并在在线推理阶段按照栏位标识调用相应权重和身份原型,同时利用组内一一互斥约束得到整组一致的身份识别结果

Benefits of technology

1、通过将群养猪舍猪只个体识别限定于目标栏位内的固定猪只身份集合,使在线识别过程与实际栏位中的候选身份范围相对应;

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122929609A_ABST
    Figure CN122929609A_ABST
Patent Text Reader

Abstract

The present application relates to a kind of group-oriented pig house's in-group closed set small sample precision individual identification method, system, equipment and medium, comprising: the pig video of target column in the preset registration time window and pig identity calibration information are respectively constructed support sample set and registration training sample set, the improved inference model established in advance is trained, and the corresponding column lightweight weight, identity prototype and column identification of each target column after training are written in weight database;Get to be identified image and its corresponding column identification, read identity prototype from weight database according to column identification and replace column lightweight weight, obtain the inference model suitable for to be identified image, and output high-dimensional embedding;The similarity between the high-dimensional embedding of to be identified image and identity prototype is calculated, and the pig identity assignment result meeting one-to-one mutual exclusion constraint is output using hungarian algorithm.The present application can be applied to computer vision and precision livestock breeding identity recognition technical field.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of smart farming and computer vision technology, specifically relating to a method, system, equipment and medium for accurate individual identification of small samples in closed groups of pig houses. It is applicable to individual identification scenarios under closed individual set conditions, combining small sample registration, prototype matching and global one-to-one allocation. Background Technology

[0002] In precision livestock farming, individual pig identification is the foundation for growth monitoring, health early warning, behavior analysis, feeding management, and production traceability. Unlike individual rearing or controlled filming scenarios, multiple pigs in group-housed pigsties spend a lot of time in the same pen, and image acquisition is prone to changes in posture, mutual occlusion, adhesion, partial truncation, and changes in lighting. This results in significant differences in the visual appearance of the same pig at different times, while different pigs may have similar appearances in certain areas.

[0003] Currently, pig individual identification solutions typically include contact-based identification schemes and visual identification schemes. Contact-based identification schemes generally rely on ear tags, RFID tags, or other attached tags. These schemes require additional hardware and are affected by the wearing status, reading and writing distance, and on-site deployment conditions. Visual identification schemes acquire images of pigs through camera equipment and then use image features to complete identification, featuring non-contact data collection.

[0004] Existing visual recognition solutions often model pig identification as a single-image classification task, outputting an independent identity category for each image to be identified. While this approach can reflect the local similarity between a single image and candidate identities, it fails to fully utilize the relatively stable identity set within a group-housed pen. Within a stable pen, the pigs to be identified typically belong to the set of registered identities for that pen, and different images to be identified in the same round of recognition should satisfy a one-to-one mutual exclusion relationship. If an independent classification method is still used, multiple images to be identified may be assigned to the same pig identity, or a registered identity may be missed in the same round of recognition, resulting in inconsistent identification results.

[0005] Furthermore, the practical application of group-housed pigs typically requires the target pen to be registered first, followed by online recognition of images subsequently collected from that pen. Since the set of pig identities, collection time, posture distribution, and local appearance differences within a pen vary from pen to pen, the recognition system needs to be adaptable to different pens. Training and storing complete model weights separately for each pen would increase storage and loading overhead in multi-pen applications; conversely, using identical identity discrimination parameters across all pens would struggle to adapt to fine-grained differences in pig identities between different pens. Summary of the Invention

[0006] To address the shortcomings of existing visual recognition methods in group-house pigsty scenarios, such as underutilization of the closed identity set of each pen, lack of intra-group mutual exclusion constraints, insufficient small-sample registration capability of each pen, and high overhead in storing and switching complete model weights in multi-pen applications, the present invention aims to provide a method, system, device, and medium for accurate individual identification of small samples within a closed set of each pen in group-house pigsties. This method utilizes a small number of images within the target pen's registration time window to complete identity registration and pen adaptation, stores a small number of trainable weights and identity prototypes related to each pen, and retrieves the corresponding weights and identity prototypes according to the pen identifier during the online inference stage. Simultaneously, it leverages intra-group mutual exclusion constraints to obtain consistent identity recognition results for the entire group.

[0007] To achieve the above objectives, the present invention adopts the following technical solution: In a first aspect, the present invention provides a method for accurate individual identification in small samples within closed groups of pigsties, comprising: Using pig videos and pig identification information within a preset registration time window for the target field, a support sample set and a registration training sample set are constructed respectively. The pre-established improved inference model is trained, and the lightweight weights, identity prototypes, and field identifiers of each target field after training are written into the weight database. Obtain the image to be recognized and its corresponding field identifiers. Read the identity prototype from the weight database according to the field identifiers and replace the lightweight weights of the fields to obtain an inference model suitable for the image to be recognized, and output a high-dimensional embedding. The similarity between the high-dimensional embedding of the image to be identified and the identity prototype is calculated, and the Hungarian algorithm is used to output the pig identity assignment results that satisfy the one-to-one mutual exclusion constraint.

[0008] Furthermore, the step of constructing a support sample set and a registration training sample set using pig videos and pig identification information within a preset registration time window for each target field, training an inference model containing a frozen self-supervised pre-trained visual backbone and a trainable lightweight fine-tuning adapter structure, and writing the corresponding lightweight weights, identity prototypes, and field identifiers for each target field into a weight database after training, includes: Obtain pig videos for the target field within a preset registration time window, and combine them with pig identification information obtained through manual or semi-automatic calibration to construct the target field registration dataset; Construct a support sample set and a registration training sample set based on the target field registration dataset; An improved inference model is established, comprising a frozen self-supervised pre-trained visual backbone, a trainable Bottleneck Adapter structure, and a trainable Embedding Layer. The self-supervised pre-trained visual backbone includes a Patch Embedding layer and a Transformer Encoder structure. The Patch Embedding layer is used to transform the input pig image. The Transformer Encoder structure includes multiple Encoder Blocks for encoding the visual features corresponding to the pig image. The Bottleneck Adapter structure is located within a designated Encoder Block. The Embedding Layer is located at the output of the self-supervised pre-trained visual backbone and is used to map the visual features into high-dimensional discriminative embeddings. Except for the Bottleneck Adapter structure and the Embedding Layer, the parameters of the self-supervised pre-trained visual backbone are frozen during the registration phase. Based on the support sample set, an identity prototype for each pig is generated, and based on the registered training sample set, the improved inference model is trained to align the prototypes to obtain the lightweight weights of the target pen. Write the field identifier, field lightweight weight, and identity prototype into the weight database.

[0009] Furthermore, the step of acquiring pig videos within a preset registration time window for the target field and combining them with pig identity information obtained through manual or semi-automatic calibration to construct a target field registration dataset includes: Based on the on-site deployment structure of the target field, the pig videos in the target field are obtained within the preset registration time window; The obtained pig videos in the target column are segmented into video frames, and the continuous pig videos are converted into a sequence of pig images. The pig image sequence was filtered to remove occluded, blurred, truncated, and extremely lit images; Individual pig locations and center cropping are performed on the selected pig images; By combining the pig identification information obtained through manual or semi-automatic calibration, a correspondence is established between pig images and pen identifiers, collection time, and pig identification. Pig images are labeled with pose and attributes to form a target field registration dataset.

[0010] Furthermore, the step of constructing a support sample set and a registration training sample set based on the target field registration dataset includes: Based on the target field registration dataset, determine the set of registered pig identities within the target field; K pig images are selected from the target field registration dataset for each registered pig identity as support samples, and the support samples of each registered pig identity are combined into a support sample set. The remaining pig images that were not selected as supporting samples but meet the image quality requirements are used as registration training candidate images, and the registration training candidate images are organized according to the registered pig identities to form a registration training sample set.

[0011] Furthermore, the step of generating identity prototypes for each pig based on the supporting sample set, and performing prototype alignment training on the improved recognition model based on the registered training sample set, includes: The support sample set is organized according to the registered pig identities in the target column. The improved inference model is used to obtain the high-dimensional embedding of the support samples corresponding to each registered pig identity. The average value is calculated according to identity and the samples are arranged in order to obtain the identity prototype set. Construct target field registration training batches from the registration training sample set, so that each registration training image corresponds to the identity prototype set, and use the improved inference model to obtain the registration training image features corresponding to each registration training image; Calculate the cosine similarity between the features of the registered training images and the identity prototypes to obtain the similarity matrix; Temperature scaling and normalization are applied to the similarity matrix to obtain the probability similarity matrix; Prototype alignment training is performed by constructing a loss function based on the probability similarity matrix. After training, the lightweight weights of the target field are obtained.

[0012] Further, the process of obtaining the image to be recognized and its corresponding field identifier, reading the identity prototype from the weight database according to the field identifier and replacing the lightweight weights of the field to obtain an inference model suitable for the image to be recognized, and outputting a high-dimensional embedding includes: Obtain the image to be recognized and its corresponding target field identifier; Based on the target field identifier, retrieve the corresponding identity prototype, field lightweight weight, and model version information from the weight database; Load the frozen self-supervised pre-trained visual backbone that matches the model version information; Replace the Bottleneck Adapter structure parameters and Embedding Layer parameters in the improved inference model with the read field lightweight weights; The image to be identified is input into the improved inference model after parameter replacement to obtain the high-dimensional embedding of the image to be identified.

[0013] Furthermore, the calculation of the similarity between the high-dimensional embedding of the image to be identified and the identity prototype, and the output of pig identity assignment results satisfying one-to-one mutual exclusion constraints using the Hungarian algorithm, includes: A similarity matrix is ​​constructed based on the similarity between the high-dimensional embedding of the image to be identified and the identity prototype of the target field within the same identification batch; Convert the similarity matrix into a cost matrix; With the constraints that one image to be identified within the same identification batch is assigned to one registered pig identity and one registered pig identity can receive at most one image to be identified, the Hungarian algorithm is used to solve the global identity allocation result; The global identity assignment result is used as the identity recognition result of the pig to be identified in the target column.

[0014] Secondly, the present invention provides a precise individual identification system for small samples within a closed group of pigsties, comprising: The registration module is configured to use pig videos and pig identification information within a preset registration time window for the target field to construct a support sample set and a registration training sample set respectively, train the pre-established improved inference model, and write the corresponding lightweight weights, identity prototypes and field identifiers of each target field into the weight database after training. The online inference module is configured to obtain the image to be recognized and its corresponding field identifier, read the identity prototype from the weight database according to the field identifier and replace the light weight of the field to obtain an inference model suitable for the image to be recognized, and output a high-dimensional embedding. The global assignment module is configured to calculate the similarity between the high-dimensional embedding of the image to be identified and the identity prototype, and uses the Hungarian algorithm to output the pig identity assignment results that satisfy the one-to-one mutual exclusion constraint.

[0015] Thirdly, the present invention provides a computer-readable storage medium for storing one or more programs, said one or more programs including instructions that, when executed by a computing device, cause the computing device to perform any method.

[0016] Fourthly, the present invention provides a computing device including one or more processors and a memory, wherein the memory stores one or more programs and is configured to be executed by the one or more processors, the one or more programs including instructions for performing any method.

[0017] The present invention has the following advantages due to the adoption of the above technical solutions: 1. By limiting the identification of individual pigs in group-housed pigsties to a fixed set of pig identities within the target pen, the online identification process corresponds to the range of candidate identities in the actual pen. 2. Construct a registration dataset using pig videos within a preset registration time window, generate identity prototypes, and train lightweight weights for each field, enabling the target field to complete identity registration and model adaptation under small sample conditions; 3. By sharing and freezing the self-supervised pre-trained visual backbone, and storing lightweight weights and identity prototypes for different target columns, the model storage and model switching overhead in multi-column deployment scenarios are reduced. 4. The Hungarian algorithm is used to perform global identity assignment on the images to be identified in the target field, and a one-to-one mutual exclusion constraint is applied to reduce identity conflicts caused by multiple images to be identified being assigned to the same pig identity, thereby improving the consistency of the overall recognition results in the target field. Attached Figure Description

[0018] Various other advantages and benefits will become apparent to those skilled in the art upon reading the following detailed description of preferred embodiments. The accompanying drawings are for illustrative purposes only and are not intended to limit the invention. Throughout the drawings, the same reference numerals denote the same parts. In the drawings: Figure 1 This is a schematic diagram of the on-site deployment and video capture of the target field provided in an embodiment of the present invention; Figure 2 This is a schematic diagram illustrating the construction of field video acquisition and registration data provided in an embodiment of the present invention; Figure 3 This is a schematic diagram illustrating the construction of the registration dataset, support sample set, and registration training sample set provided in an embodiment of the present invention. Figure 4 This is a schematic diagram of the frozen self-supervised pre-trained visual backbone and lightweight fine-tuning adapter structure provided in an embodiment of the present invention; Figure 5 This is a schematic diagram of identity prototype generation and prototype alignment training provided in an embodiment of the present invention; Figure 6 This is a schematic diagram of the processing device and computer-readable storage medium structure provided in the embodiments of the present invention. Detailed Implementation

[0019] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the described embodiments of the present invention are within the scope of protection of the present invention.

[0020] It should be noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the scope of exemplary embodiments according to the invention. As used herein, the singular form is intended to include the plural form as well, unless the context clearly indicates otherwise. Furthermore, it should be understood that when the terms "comprising" and / or "including" are used in this specification, they indicate the presence of features, steps, operations, devices, components, and / or combinations thereof.

[0021] In some embodiments of the present invention, a method for accurate individual identification within a small sample size in a group-housed pigsty is provided. This method includes: pen video acquisition and registration data construction; construction of support sample sets and registration training sample sets; freezing of the self-supervised pre-trained visual backbone and lightweight fine-tuning adapter structure; identity prototype generation and prototype alignment training; writing lightweight pen weights and identity prototypes; lightweight weight replacement during online inference; and one-to-one mutually exclusive allocation within the group based on the Hungarian algorithm. This invention can accurately identify individual pigs within a group-housed pigsty.

[0022] In other embodiments of the present invention, a system, device, and computer-readable storage medium for precise individual identification of small samples within a closed group of pigsties are provided.

[0023] Exemplary embodiments of the invention will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the invention are shown in the drawings, it should be understood that the invention can be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided to enable a more thorough understanding of the invention and to fully convey the scope of the invention to those skilled in the art.

[0024] Example 1 like Figures 1 to 5 As shown, this embodiment provides a method for accurate individual identification in small samples within closed groups in group-housed pigsties, mainly including a registration phase and an online inference phase. Specifically, it includes the following steps: S1, based on the on-site deployment structure of the target column, acquires pig videos within the target column during the preset registration time window.

[0025] like Figure 1 As shown, in this embodiment, the target pen 101 is an enclosed feeding space with pen markings in a group-housed pigsty. The target pen 101 is bounded by a pen fence 104, defining the activity boundary of the pigs. The pigs raised in the target pen 101 constitute a set 105 of registered pig identities. A top image acquisition device 102 is installed above the target pen 101 to form an image acquisition coverage area 103 covering the activity area of ​​the target pen 101, and to acquire video data of the pigs in the target pen 101 within a preset registration time window.

[0026] In practice, the pig video captured by the top image acquisition device 102 is sent to the processing device 106 via the video data transmission device 107.

[0027] S2 performs frame segmentation, image filtering, individual cropping, identity labeling, and posture attribute annotation on pig videos of target fields obtained within the preset registration time window to construct the target field registration dataset.

[0028] In this embodiment, after receiving pig video data sent by the top image acquisition device 102 through the video data transmission device 107, the processing device 106 performs frame segmentation and image filtering on the pig video. It then combines the pen identification information of the target pen 101 with the pig identity information obtained through manual or semi-automatic calibration to establish a correspondence between pen identification, video acquisition time, pig image, and pig identity. This ensures that subsequent registration training and online inference are limited to the set 105 of registered pig identities for the target pen 101. Through this step, the video data and identity boundaries corresponding to the target pen 101 can be obtained, avoiding the introduction of non-target pen identities into the subsequent intra-group closed set recognition process.

[0029] Specifically, such as Figure 2 As shown, it includes the following steps: S21, the obtained pig videos in the target column are segmented into video frames, and the continuous pig videos are converted into a sequence of pig images.

[0030] The processing device 106 segments the pig videos collected in the target field 101 within a preset registration time window into video frames, converting the continuous pig videos into a sequence of pig images. Through this processing, the video data corresponding to the registration time window is converted into image data that can be filtered and processed frame by frame.

[0031] S22, Image filtering is performed on the pig image sequence.

[0032] The image screening process for pig image sequences primarily involves removing images with severe occlusion, motion blur, individual truncation, or extreme lighting conditions, while retaining images that can characterize the physical features of individual pigs. This process reduces the interference of low-quality images on subsequent identity prototype generation and pen weight training.

[0033] S23, perform individual pig localization and center cropping on the selected pig images to obtain an image region with the individual pig as the main body.

[0034] Among them, center cropping is used to reduce the influence of pen floor, fence, feeding equipment and other background areas on the extraction of individual appearance features, so that the pig images input into the improved recognition model are more focused on the individual pig itself.

[0035] S24. Combine the pig identification information obtained by manual or semi-automatic calibration to establish image metadata between pig images and pen identifiers, collection time, and identification calibration results.

[0036] Among them, image metadata is used to record the target field to which each pig image belongs, the collection time, and the corresponding pig identity, so that pig images can be organized into registration data with identity association.

[0037] S25. Based on image metadata, pig images are labeled with pose and attributes to form a target field registration dataset.

[0038] In this embodiment, the postures involved include standing, lying on one's side, lying prone, and other postures. By recording images of pigs in different postures, the ability of the identity prototype to represent changes in pig postures can be improved when constructing a support sample set later.

[0039] In this embodiment, after video frame segmentation, image filtering, individual pig localization and center cropping, identity labeling and image metadata establishment, and pose and attribute annotation, a target stall registration dataset is formed. This target stall registration dataset is used to subsequently construct the support sample set and the registration training sample set.

[0040] S3, based on the target field registration dataset, construct the support sample set and the registration training sample set.

[0041] Specifically, it includes the following steps: S31, Based on the target field registration dataset, determine the set of registered pig identities.

[0042] like Figure 3 As shown, based on the pig identification results recorded in the target field registration dataset, the set of registered pig identities within target field 101 is determined. It is assumed that the set of registered pig identities includes M pig identities. In this embodiment, the M pig identities are used as the candidate identity range for in-group closed set identification, and only the registered images corresponding to the M pig identities are retained for subsequent support sample set and registration training sample set construction.

[0043] S32, for any registered pig identity in the set of registered pig identities, select K pig images from the target column registration dataset as its supporting samples to form a supporting sample set for generating prototypes of each pig identity.

[0044] For each registered pig identity, this embodiment selects K pig images from the target field registration dataset as supporting samples for that identity, and combines the supporting samples of M pig identities within the target field to form a support sample set. This support sample set is used to generate the corresponding pig identity prototype in subsequent steps. In one specific implementation, the K pig images should cover standing, lying on their side, prone, and other postures, so that the generated identity prototype can represent the appearance characteristics of the same pig in different postures, obtaining a more representative prototype through the largest possible appearance differences.

[0045] S33. Take the pig images that were not selected as supporting samples from each registered pig identity and that meet the image quality requirements as registration training candidate images, and organize the registration training candidate images into a registration training sample set according to the pig identity labeling results.

[0046] The registration training sample set and the support sample set are distinct from each other. The support sample set is used to generate identity prototypes, while the registration training sample set is used to train the lightweight weights of the corresponding fields in the target field.

[0047] In practical implementation, this embodiment constructs registration training batches on a target field basis. Each registration training batch selects pig images from the registration training sample set that correspond to the set of registered pig identities, enabling the pig images in the registration training batch to establish a correspondence with the identity prototype set. Thus, the registration training process is no longer carried out according to the independent classification of individual images, but rather performs prototype alignment training around a fixed identity set within the target field.

[0048] Through the above sample construction method, the target pen registration dataset is organized into two types of data: a support sample set and a registration training sample set. The support sample set provides the prototype representation of the identity of each pig in the target pen, while the registration training sample set provides the training data basis for the pen with lightweight weights. Therefore, this invention can limit individual identification in group-housed pigsties to a fixed set of pig identities within the target pen under the condition of small-sample registration in the target pen, ensuring that subsequent model training and online inference revolve around the registered pig identities within the target pen.

[0049] S4. Establish an improved inference model that includes a frozen self-supervised pre-trained visual backbone, a trainable lightweight fine-tuning adapter structure, and a trainable embedding layer.

[0050] like Figure 4As shown, the improved inference model constructed in this embodiment adopts a structure that includes a frozen self-supervised pre-trained visual backbone and a trainable lightweight fine-tuning adapter. Specifically, the self-supervised pre-trained visual backbone includes a Patch Embedding layer, a Transformer Encoder layer, and an Embedding Layer. The Patch Embedding layer segments the input pig image into multiple fixed-size image patches, unfolds each patch into a one-dimensional feature vector, and then maps it to a preset feature dimension through linear projection, thereby converting the two-dimensional pig image into a one-dimensional sequence composed of embedding vectors for processing by the Transformer Encoder layer. The Transformer Encoder layer includes multiple Encoder Blocks, each of which encodes the visual features corresponding to the pig image. A Bottleneck Adapter structure is inserted inside the specified Encoder Block in the Transformer Encoder layer, and the Bottleneck Adapter structure is set to be trainable. The Embedding Block layer is a trainable linear projection layer used to map the visual features output by the self-supervised pre-trained visual backbone into high-dimensional discriminative embedding features for individual recognition. These high-dimensional discriminative embedding features are used for subsequent identity prototype generation, prototype alignment training, and similarity calculation in the online inference stage.

[0051] When building the improved recognition model, all parameters in the self-supervised pre-trained visual backbone, except for those at specified locations, are frozen. That is, the frozen parameters include the Patch Embedding layer parameters and the Encoder Block parameters that are not specified as trainable locations. By freezing most of the pre-trained parameters of the self-supervised pre-trained visual backbone, different target fields can share the same general visual feature extraction capability.

[0052] In one specific implementation, the Bottleneck Adapter structure is inserted after the Multi-Head Attention within the Encoder Block. This is used to adapt to fine-grained appearance differences between individual pigs in the target pen while maintaining the original pre-trained visual backbone feature representation. In other words, the Encoder Block includes Norm, Multi-Head Attention, Bottleneck Adapter, Norm, and MLP processing paths, and feature transfer is achieved through residual connections. The Bottleneck Adapter structure, as a trainable lightweight structure, is integrated into the Encoder Block processing path, ensuring that only a small number of parameters related to the target pen are updated during the registration and training phase, without updating the main parameters of the self-supervised pre-trained visual backbone.

[0053] During the target field registration training process, the Bottleneck Adapter structural parameters and Embedding Layer parameters constitute the lightweight trainable parameters corresponding to the target field. After registration training is completed, these lightweight trainable parameters form the lightweight weights of the target field and are stored in correspondence with the field identifier and identity prototype.

[0054] In one specific implementation, the self-supervised pre-trained visual backbone is the DINOv3 model.

[0055] In this embodiment, by freezing all parameters in the self-supervised pre-trained visual backbone except for those at specified locations, and training only the Bottleneck Adapter structure and the Embedding Layer, the model can perform lightweight adaptation for a fixed set of pig identities within the target pen while maintaining its general visual feature extraction capabilities. Thus, different target pens can share the same self-supervised pre-trained visual backbone, and each pen can store its corresponding lightweight weights.

[0056] S5 generates identity prototypes based on the support sample set and performs prototype alignment training based on the registered training sample set to obtain the lightweight weights of the target field.

[0057] like Figure 5 As shown, it includes the following steps: S51, organize the support sample set according to the registered pig identities in the target column, use the improved inference model to obtain the high-dimensional embedding of the support samples corresponding to each registered pig identity, calculate the mean by identity and arrange them in order to obtain the identity prototype set.

[0058] Specifically, it includes the following steps: First, the supporting sample set will be organized according to the identities of the pigs already registered in the target pen. For the first pig in the target pen... The identity of each registered pig is denoted as the supporting sample set. ,in This represents the number of supporting samples corresponding to the pig's identity. The supporting sample set is then input into the improved inference model to obtain... Each support sample has a high-dimensional embedding.

[0059] Secondly, for the first [item] in the target field Each registered pig's identity, corresponding to that pig's identity The mean of the high-dimensional embeddings of the supporting samples is calculated to generate the first... The prototype of the pig's identity , is represented as: (1) In the formula, This represents the feature extraction and mapping function for improving the recognition model.

[0060] Finally, the identity prototypes of each registered pig in the target field are arranged in identity order to form an identity prototype set. The identity prototype set is used to represent the feature centers of the fixed identity set in the target field and serves as the identity reference in subsequent registration training and online inference.

[0061] S52, construct target field registration training batches from the registration training sample set, so that each registration training image corresponds to the identity prototype set, and use the improved inference model to obtain the registration training image features corresponding to each registration training image.

[0062] Specifically, target pen registration training batches are constructed from the registered training sample set. These batches are organized according to the registered pig identity set within the target pen, ensuring a correspondence between the registered training images and the identity prototype set. The pig images from these target pen registration training batches are then input into the improved recognition model to obtain the registration training image features. For the ... Each registered training image has the following feature representation: .

[0063] S53, calculate the cosine similarity between the registered training image features and the identity prototype to obtain the similarity matrix. .

[0064] Among them, the similarity matrix Matrix elements Calculate according to formula (2): (2) S54, regarding the similarity matrix Temperature scaling and normalization are performed to obtain the probability similarity matrix. .

[0065] Among them, the probability similarity matrix Matrix elements Calculate according to formula (3): (3) In the formula, This is the temperature coefficient, with a value of 0.1.

[0066] S55, based on probability similarity matrix A loss function is constructed for prototype alignment training, and the lightweight weights of the target field are obtained after training.

[0067] This invention uses a probability similarity matrix for prototype alignment training, causing the features of registered training images of the same pig identity to align closer to their corresponding identity prototypes, and distinguishing the features of registered training images of different pig identities from non-corresponding identity prototypes. When the registered training samples are arranged in identity order, the prototype alignment training objective includes increasing the value of the corresponding identity position in the probability similarity matrix, and its loss function... Calculate according to formula (4): (4) In the formula, This means that when i=j, the diagonal elements of the similarity matrix are calculated.

[0068] During prototype alignment training, parameters in the self-supervised pre-trained visual backbone, except for those at specified positions, remain frozen, while the Bottleneck Adapter structural parameters and Embedding Layer parameters are updated. After training, the Bottleneck Adapter structural parameters and Embedding Layer parameters form the lightweight weights corresponding to the target fields.

[0069] Through this step, the present invention generates identity prototypes for each pig in the target pen based on the supporting sample set during the registration phase, and trains lightweight trainable parameters corresponding to the target pen based on the registration training sample set, so that the improved recognition model can be adapted to a fixed set of pig identities in the target pen.

[0070] S6, write the corresponding lightweight weight, identity prototype and field identifier of the target field into the weight database.

[0071] After completing the target pen registration training, the information corresponding to the target pen is written into the weight database. The weight database is indexed by the pen identifier and stores the following information: pen identifier, list of registered pig identities, identity prototype, pen lightweight weight, registration time window information, and model version information.

[0072] Among them, the identity prototype is the high-dimensional embedding representation of the identity of each registered pig in the target pen, the pen lightweight weights include the Bootleneck Adapter structural parameters and Embedding Layer parameters after registration and training, and the model version information is used to determine the frozen self-supervised pre-trained visual backbone version that matches the pen lightweight weights.

[0073] In this embodiment, different target fields share the same frozen self-supervised pre-trained visual backbone, and the weight database stores the corresponding lightweight weights and identity prototypes for each target field. Since the lightweight weights of the fields only correspond to the Bottleneck Adapter structural parameters and the Embedding Layer parameters, the storage overhead in multi-field deployment scenarios can be reduced compared to storing the complete model weights for each target field.

[0074] S7, Online Inference Stage: Obtain the image to be recognized and its corresponding target field identifier, read the identity prototype according to the target field identifier and replace the field lightweight weights to obtain the high-dimensional embedding corresponding to the image to be recognized.

[0075] Specifically, it includes the following steps: S71, Obtain the image to be recognized and its corresponding target field identifier.

[0076] S72, based on the target field identifier, reads the field lightweight weights and identity prototypes corresponding to the target field identifier from the weight database, and loads the matching frozen self-supervised pre-trained visual backbone according to the model version information.

[0077] S73, after loading the frozen self-supervised pre-trained visual backbone, replaces the Bottleneck Adapter structural parameters and Embedding Layer parameters in the backbone with the read column lightweight weights. Through this replacement operation, the inference model is configured as a column-level recognition model corresponding to the target column.

[0078] S74. After completing the lightweight weight replacement of the column, the image to be identified is input into the inference model. After freezing the self-supervised pre-trained visual backbone, the Bottleneck Adapter structure and the Embedding Layer mapping, a high-dimensional embedding of the image to be identified is obtained, which is used to calculate the similarity with the identity prototype read from the weight database.

[0079] Through this step, the present invention does not require replacing the complete self-supervised pre-trained visual backbone when switching between different target fields. It only needs to read and replace the corresponding target field's lightweight weights and identity prototypes according to the target field identifier, thereby achieving fast model switching and low storage overhead recognition in multi-field deployment scenarios.

[0080] S8, based on the high-dimensional embedding of the image to be identified, uses the Hungarian algorithm to output the one-to-one mutually exclusive identity assignment results within the target field group.

[0081] In this embodiment, a similarity matrix is ​​constructed by calculating the similarity between the high-dimensional embedded features of the image to be identified and the identity prototype features within the same target field. The cost matrix is ​​obtained by transforming the similarity matrix. The cost matrix elements The system uses the Hungarian algorithm to solve for the global identity allocation result, with the constraint that one image to be identified within the same identification batch is assigned to one registered identity and one registered identity can receive at most one image to be identified.

[0082] In one specific implementation, let the number of images to be identified within the same identification batch be... The number of registered identities in the target field is , Indicates the first Is the image to be identified assigned to the first... If there are 1 registered pig identities, then the global identity allocation objective is solved according to equation (5) and satisfies the constraints shown in equation (6): (5) (6) The global identity assignment result is the identification result of the pig to be identified within the target field. Compared with the method of selecting the maximum similarity for each image independently, this step utilizes the one-to-one mutual exclusion relationship between the images to be identified within the same target field to reduce identity conflicts when multiple images to be identified are assigned to the same pig identity, thereby improving the consistency of the overall identification results within the target field.

[0083] In this embodiment, the recognition effect is measured using the original maximum similarity accuracy (Acc). raw Hungarian match accuracy (Acc) H The exact match rate (GWEM) and conflict rate (CR) within each group were validated. raw Used to reflect the local prediction capability when no one-to-one mutual exclusion constraint is applied; Acc H It is used to reflect the overall recognition accuracy under one-to-one mutual exclusion constraints; GWEM is used to reflect whether all images to be recognized in the same recognition batch are correctly recognized; CR is used to reflect the situation where multiple images to be recognized are assigned to the same identity.

[0084] In one implementation for performance verification, a dataset containing 172 pigs collected continuously for 58 days was used to validate the method of this embodiment. Under random partitioning conditions, when the number of candidate identities M in the target stall is 12, the method of this embodiment, using a trainable, lightweight, fine-tunable adapter structure, achieved an average Acc in 100 tests with 100 target stall configurations. H 0.992, Acc raw The recognition results are 0.948, GWEM is 0.952, and CR is 0.049. Compared with the independent classification baseline method, which has a GWEM of 0.402 at the same M value, the GWEM of the method in this embodiment is improved by 0.550.

[0085] In another implementation for performance verification, under difficult partitioning conditions, when the number of candidate identities M in the target field is 12, the method of this embodiment using a trainable, lightweight, fine-tunable adapter structure achieves Acc in 100 tests with 100 target field configurations. H 0.982, Acc raw The recognition results were 0.920, GWEM 0.906, and CR 0.073. Compared to the independent classification baseline method with a GWEM of 0.320 at the same M value, the GWEM of the method in this embodiment is improved by 0.586. These results indicate that even when the appearance similarity of individual pigs is high, the intra-group closed set small sample matching method can still maintain the reliability of whole-group recognition within the target pen.

[0086] In the lightweight fine-tuning of the Adapter structure verification, when the number of candidate identities M is 8, the model without an Adapter structure achieves Acc. H 0.957, Acc raw The accuracy is 0.870, GWEM is 0.849, and CR is 0.114; after setting the Adapter structure in the four Transformer blocks after the visual backbone, the model obtains Acc. H 0.992, Acc raw The values ​​were 0.950, GWEM was 0.970, and CR was 0.047. These results indicate that, under the condition of freezing the self-supervised pre-trained visual backbone, training and lightly fine-tuning the Adapter parameters can improve the accuracy of individual pig identification within the target pen and reduce the identity conflict rate.

[0087] Example 2 The above-described embodiment 1 provides a method for accurate individual identification of small samples within closed groups in group-housed pigsties. Correspondingly, this embodiment provides a system for accurate individual identification of small samples within closed groups in group-housed pigsties. The system provided in this embodiment can implement the method for accurate individual identification of small samples within closed groups in group-housed pigsties described in embodiment 1. This system can be implemented through software, hardware, or a combination of both. For example, the system may include integrated or separate functional modules or units to execute the corresponding steps in the methods of embodiment 1. Since the system in this embodiment is basically similar to the method embodiment, the description process in this embodiment is relatively simple. Relevant details can be found in the description of embodiment 1. The system embodiment provided in this embodiment is merely illustrative.

[0088] This embodiment provides a small-sample, precise individual identification system for group-housed pigsties, including: The registration module is configured to use pig videos and pig identification information within a preset registration time window for the target field to construct a support sample set and a registration training sample set respectively, train the pre-established improved inference model, and write the corresponding lightweight weights, identity prototypes and field identifiers of each target field into the weight database after training. The online inference module is configured to obtain the image to be recognized and its corresponding field identifier, read the identity prototype from the weight database according to the field identifier and replace the light weight of the field to obtain an inference model suitable for the image to be recognized, and output a high-dimensional embedding. The global assignment module is configured to calculate the similarity between the high-dimensional embedding of the image to be identified and the identity prototype, and uses the Hungarian algorithm to output the pig identity assignment results that satisfy the one-to-one mutual exclusion constraint.

[0089] Furthermore, the registration module includes a data construction module, a registration training module, and a weight management module. The output of the data construction module is connected to the input of the registration training module, the output of the registration training module is connected to the input of the weight management module, and the weight management module is connected to the online inference module.

[0090] The data construction module is used to acquire pig videos of the target field within a preset registration time window, and combine them with the pig identity information obtained by manual or semi-automatic calibration to perform frame segmentation, image filtering, individual pig localization and center cropping, identity calibration and image metadata establishment, and posture and attribute annotation on the pig videos, so as to construct the target field registration dataset, support sample set and registration training sample set.

[0091] The registration training module is used to load an improved recognition model that includes a frozen self-supervised pre-trained visual backbone, a trainable BottleneckAdapter structure, and a trainable Embedding Layer. It generates identity prototypes for each pig based on the support sample set and performs prototype alignment training based on the registered training sample set to obtain the lightweight weights of the target pen.

[0092] The weight management module is used to write the pen identifier, the list of registered pig identities, the pen lightweight weight, the identity prototype, the registration time window information, and the model version information into the weight database, and read the corresponding pen lightweight weight and identity prototype according to the target pen identifier during the online inference stage.

[0093] Example 3 This embodiment provides a processing device corresponding to the method for accurate individual identification of small samples within a closed group in group-raised pig houses provided in Embodiment 1. The processing device can be a processing device for a client, such as a mobile phone, laptop, tablet computer, desktop computer, etc., to execute the method of Embodiment 1.

[0094] like Figure 6 As shown, the processing device in this embodiment includes a processor 201, a communication interface 202, a memory 203, and a communication bus 204. The processor 201, communication interface 202, and memory 203 communicate with each other via the communication bus 204. The communication interface 202 receives pig videos, pen identifiers, and registered identity information for the target pen within a preset registration time window, and interacts with the weight database. The memory 203 stores computer program 2032 in a preset operating system 2031, and stores registration data, pen weights, identity prototypes, and data index information corresponding to the pen identifier for the target pen in the weight database 2033. The processor 201 calls logical instructions in the memory 203 to execute a method for precise individual identification of small samples within a closed set in group-housed pigsties.

[0095] Specifically, when the processor 201 calls the logic instructions, it can perform frame segmentation, image filtering, and data preprocessing on the pig videos of the target pen to construct the registration dataset of the target pen; construct a support sample set and a registration training sample set based on the registration dataset; load an improved recognition model containing a frozen self-supervised pre-trained visual backbone and a trainable lightweight fine-tuning adapter structure; generate identity prototypes for each pig based on the support sample set, and perform prototype alignment training based on the registration training sample set to obtain the lightweight weights of the pen corresponding to the target pen.

[0096] Furthermore, the processor 201 can also write the trained pen lightweight weights, identity prototypes, and pen identifiers into the weight database 2033; during the online inference stage, it reads the corresponding pen lightweight weights and identity prototypes from the weight database 2033 according to the target pen identifier, and replaces the lightweight trainable parameters in the inference model with the pen lightweight weights; it calculates the similarity between the image features to be identified and the identity prototypes, and outputs the pig identity assignment results that satisfy the one-to-one mutual exclusion constraint through the Hungarian algorithm.

[0097] Furthermore, the logical instructions in the aforementioned memory can be implemented as software functional units and stored in a computer-readable storage medium when sold or used as an independent product. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a computer software product. This computer software product is stored in a storage medium and includes instructions for causing a computer device to execute all or part of the steps of the methods of the various embodiments of the present invention.

[0098] The aforementioned computer equipment may be a personal computer, server, edge computing device, network device, or embedded processing device. The aforementioned storage media include USB flash drives, portable hard drives, read-only memory, random access memory, magnetic disks, or optical disks.

[0099] Example 4 This embodiment provides a computer program product, which includes a computer-readable storage medium on which computer-readable program instructions are loaded for executing the method for accurate individual identification of small samples within a closed group for group-raised pig houses as described in Embodiment 1.

[0100] When the computer-readable program instructions are executed by the processor, the processor is able to perform the following operations: acquire pig videos of the target stall within a preset registration time window; perform frame segmentation, image filtering, and data preprocessing on the pig videos to construct a registration dataset; construct a support sample set and a registration training sample set based on the registration dataset; load an improved recognition model containing a frozen self-supervised pre-trained visual backbone and a trainable lightweight fine-tuning adapter structure; generate identity prototypes and train stall lightweight weights; write the stall lightweight weights, identity prototypes, and stall identifiers into a weight database; and during the online inference stage, read the stall lightweight weights and identity prototypes based on the target stall identifier, replace the lightweight trainable parameters in the inference model, and output the pig identity assignment results that satisfy the one-to-one mutual exclusion constraint.

[0101] A computer-readable storage medium can be a tangible device that holds and stores instructions for use by an instruction execution device. A computer-readable storage medium can be, for example, but not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any combination thereof.

[0102] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0103] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0104] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0105] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0106] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit it. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that modifications or equivalent substitutions can still be made to the specific implementation of the present invention. Any modifications or equivalent substitutions that do not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.

Claims

1. A method for accurate individual identification in small samples within closed groups in group-raised pig houses, characterized in that, include: Using pig videos and pig identification information within a preset registration time window for the target field, a support sample set and a registration training sample set are constructed respectively. The pre-established improved inference model is trained, and the lightweight weights, identity prototypes, and field identifiers of each target field after training are written into the weight database. Obtain the image to be recognized and its corresponding field identifiers. Read the identity prototype from the weight database according to the field identifiers and replace the lightweight weights of the fields to obtain an inference model suitable for the image to be recognized, and output a high-dimensional embedding. The similarity between the high-dimensional embedding of the image to be identified and the identity prototype is calculated, and the Hungarian algorithm is used to output the pig identity assignment results that satisfy the one-to-one mutual exclusion constraint.

2. The method for accurate individual identification in small samples within closed groups in group-raised pig houses as described in claim 1, characterized in that, The process involves constructing a support sample set and a registration training sample set using pig videos and pig identification information within a preset registration time window for each target field. This is used to train an inference model containing a frozen self-supervised pre-trained visual backbone and a trainable lightweight fine-tuning adapter structure. The trained lightweight weights, identity prototypes, and field identifiers corresponding to each target field are then written into a weight database, including: Obtain pig videos for the target field within a preset registration time window, and combine them with pig identification information obtained through manual or semi-automatic calibration to construct the target field registration dataset; Construct a support sample set and a registration training sample set based on the target field registration dataset; An improved inference model is established, comprising a frozen self-supervised pre-trained visual backbone, a trainable Bottleneck Adapter structure, and a trainable Embedding Layer. The self-supervised pre-trained visual backbone includes a Patch Embedding layer and a Transformer Encoder structure. The Patch Embedding layer is used to transform the input pig image. The Transformer Encoder structure includes multiple Encoder Blocks for encoding the visual features corresponding to the pig image. The Bottleneck Adapter structure is located within a designated Encoder Block. The Embedding Layer is located at the output of the self-supervised pre-trained visual backbone and is used to map the visual features into high-dimensional discriminative embeddings. Except for the Bottleneck Adapter structure and the Embedding Layer, the parameters of the self-supervised pre-trained visual backbone are frozen during the registration phase. Based on the support sample set, an identity prototype for each pig is generated, and based on the registered training sample set, the improved inference model is trained to align the prototypes to obtain the lightweight weights of the target pen. Write the field identifier, field lightweight weight, and identity prototype into the weight database.

3. The method for accurate individual identification in small samples within closed groups of pigsties as described in claim 2, characterized in that, The process of acquiring pig videos within a preset registration time window for the target field and combining them with pig identification information obtained through manual or semi-automatic calibration to construct a target field registration dataset includes: Based on the on-site deployment structure of the target field, the pig videos in the target field are obtained within the preset registration time window; The obtained pig videos in the target column are segmented into video frames, and the continuous pig videos are converted into a sequence of pig images. The pig image sequence was filtered to remove occluded, blurred, truncated, and extremely lit images; Individual pig locations and center cropping are performed on the selected pig images; By combining the pig identification information obtained through manual or semi-automatic calibration, a correspondence is established between pig images and pen identifiers, collection time, and pig identification. Pig images are labeled with pose and attributes to form a target field registration dataset.

4. The method for accurate individual identification in small samples within closed groups in group-raised pig houses as described in claim 2, characterized in that, The step of constructing a support sample set and a registration training sample set based on the target field registration dataset includes: Based on the target field registration dataset, determine the set of registered pig identities within the target field; K pig images are selected from the target field registration dataset for each registered pig identity as support samples, and the support samples of each registered pig identity are combined into a support sample set. The remaining pig images that were not selected as supporting samples but meet the image quality requirements are used as registration training candidate images, and the registration training candidate images are organized according to the registered pig identities to form a registration training sample set.

5. The method for accurate individual identification in small samples within closed groups of pigsties as described in claim 2, characterized in that, The step of generating identity prototypes for each pig based on the supporting sample set, and training the improved recognition model for prototype alignment based on the registered training sample set, includes: The support sample set is organized according to the registered pig identities in the target column. The improved inference model is used to obtain the high-dimensional embedding of the support samples corresponding to each registered pig identity. The average value is calculated according to identity and the samples are arranged in order to obtain the identity prototype set. Construct target field registration training batches from the registration training sample set, so that each registration training image corresponds to the identity prototype set, and use the improved inference model to obtain the registration training image features corresponding to each registration training image; Calculate the cosine similarity between the features of the registered training images and the identity prototypes to obtain the similarity matrix; Temperature scaling and normalization are applied to the similarity matrix to obtain the probability similarity matrix; Prototype alignment training is performed by constructing a loss function based on the probability similarity matrix. After training, the lightweight weights of the target field are obtained.

6. The method for accurate individual identification in small samples within closed groups in group-raised pig houses as described in claim 2, characterized in that, The process of obtaining the image to be recognized and its corresponding field identifiers, reading identity prototypes from the weight database according to the field identifiers and replacing the lightweight weights of the fields, to obtain an inference model suitable for the image to be recognized, and outputting a high-dimensional embedding, includes: Obtain the image to be recognized and its corresponding target field identifier; Based on the target field identifier, retrieve the corresponding identity prototype, field lightweight weight, and model version information from the weight database; Load the frozen self-supervised pre-trained visual backbone that matches the model version information; Replace the Bottleneck Adapter structure parameters and Embedding Layer parameters in the improved inference model with the read field lightweight weights; The image to be identified is input into the improved inference model after parameter replacement to obtain the high-dimensional embedding of the image to be identified.

7. The method for accurate individual identification in small samples within closed groups in group-raised pig houses as described in claim 6, characterized in that, The calculation of the similarity between the high-dimensional embedding of the image to be identified and the identity prototype, and the output of pig identity assignment results satisfying one-to-one mutual exclusion constraints using the Hungarian algorithm, includes: A similarity matrix is ​​constructed based on the similarity between the high-dimensional embedding of the image to be identified and the identity prototype of the target field within the same identification batch; Convert the similarity matrix into a cost matrix; With the constraints that one image to be identified within the same identification batch is assigned to one registered pig identity and one registered pig identity can receive at most one image to be identified, the Hungarian algorithm is used to solve the global identity allocation result; The global identity assignment result is used as the identity recognition result of the pig to be identified in the target column.

8. A precise individual identification system for small-sample, closed-group pig farms, characterized in that, include: The registration module is configured to use pig videos and pig identification information within a preset registration time window for the target field to construct a support sample set and a registration training sample set respectively, train the pre-established improved inference model, and write the corresponding lightweight weights, identity prototypes and field identifiers of each target field into the weight database after training. The online inference module is configured to obtain the image to be recognized and its corresponding field identifier, read the identity prototype from the weight database according to the field identifier and replace the light weight of the field to obtain an inference model suitable for the image to be recognized, and output a high-dimensional embedding. The global assignment module is configured to calculate the similarity between the high-dimensional embedding of the image to be identified and the identity prototype, and uses the Hungarian algorithm to output the pig identity assignment results that satisfy the one-to-one mutual exclusion constraint.

9. A computer-readable storage medium for storing one or more programs, characterized in that, The one or more programs include instructions that, when executed by a computing device, cause the computing device to perform any of the methods described in claims 1 to 7.

10. A computing device, characterized in that, It includes one or more processors and a memory, the memory storing one or more programs and configured to be executed by the one or more processors, the one or more programs including instructions for performing any of the methods described in claims 1 to 7.