Hybrid sheep variety identification method, device, medium and equipment

By constructing the similarity matrix between sheep faces and the hard labels that fuse YOLOv7 model, soft labels of the target breed are generated, which solves the problem of low accuracy in identifying hybrid sheep breeds in the prior art, and achieves higher recognition accuracy.

CN119600646AInactive Publication Date: 2025-03-11INNER MONGOLIA AGRICULTURAL UNIVERSITY
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411618372.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-13
Publication Date
2025-03-11
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The prior art is difficult to effectively identify hybrid sheep breeds, resulting in low recognition accuracy.

Method used

By obtaining sheep images of different breeds, the sheep face data set is constructed, the sheep face features are extracted based on the deep neural network, the similarity matrix between sheep faces is constructed, and it is fused with the breed hard label of the YOLOv7 model to generate the target breed soft label, and the loss function of the YOLOv7 model is optimized.

Benefits of technology

The recognition accuracy of hybrid varieties is improved, and the learning difficulty of the YOLOv7 model for the recognition of different varieties with high similarity is reduced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119600646A_ABST
    Figure CN119600646A_ABST
Patent Text Reader

Abstract

The invention discloses a hybrid sheep variety identification method and device, a medium and equipment, and relates to the field of image processing, and the method comprises the steps: constructing a sheep face data set; based on a deep neural network, sheep face features in the sheep face data set are extracted, sheep face feature vectors are determined, and a sheep face inter-class similarity matrix is obtained through a cosine similarity algorithm; according to the sheep face inter-class similarity matrix, determining a sheep variety inter-class similarity vector, and fusing the sheep variety inter-class similarity vector with a hard tag of a YOLOv7 model to obtain a target variety soft tag; training the YOLOv7 model through the target variety soft label to obtain a sheep variety identification model; and inputting a to-be-identified sheep image into the sheep variety identification model, and determining a sheep variety identification result. According to the method, the sheep face inter-class similarity matrix is constructed, the sheep face inter-class similarity matrix and the target detection algorithm are combined, recognizable features are effectively extracted, and the precision of a hybrid variety recognition model can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image processing, and in particular to a hybrid sheep breed identification method, device, medium and equipment. Background Art

[0002] The productivity and reproductive performance of sheep directly determine the economic benefits of sheep production enterprises. At present, most countries and regions adopt the method of hybridizing local sheep breeds with foreign imported breeds to achieve the purpose of improving the productivity of sheep breeds. Due to the introduction of hybridization technology, the sheep breeds raised in various regions of China include not only local breeds and foreign imported breeds, but also a large number of hybrid breeds, making the demand for accurate and real-time breed identification more urgent.

[0003] However, at the current stage, computer vision technology for variety identification does not take into account the large number of hybrid varieties raised in actual agricultural production. Hybrid varieties have a high degree of similarity in phenotypic traits with their father and mother, making it difficult for existing computer vision-based variety identification models to extract effective features, resulting in low accuracy in hybrid variety identification. Summary of the invention

[0004] The present invention provides a hybrid sheep breed identification method, device, medium and equipment to solve the above-mentioned problem existing in the prior art, that is, how to improve the recognition accuracy of hybrid breeds in the prior art. The present invention provides a hybrid sheep breed identification method, which comprises:

[0005] Obtain images of sheep of different breeds and construct a sheep face dataset;

[0006] Based on deep neural network, the sheep face features in the sheep face dataset are extracted, the sheep face feature vector is determined, and the sheep face inter-class similarity matrix is ​​obtained by using the cosine similarity algorithm.

[0007] According to the sheep face inter-class similarity matrix, determine the sheep breed inter-class similarity vector, fuse the sheep breed inter-class similarity vector with the breed hard label of the YOLOv7 model, and obtain the target breed soft label;

[0008] The YOLOv7 model is trained using the target breed soft label to obtain a sheep breed recognition model for identifying sheep breeds;

[0009] Obtain a sheep image to be identified, input the sheep image into a sheep breed identification model to perform sheep face recognition, and determine the identification result of the sheep breed in the image.

[0010] Also includes:

[0011] After obtaining the soft labels of the target species, the YOLOv7 target detection algorithm is optimized using the progressive learning method.

[0012] Optionally, the step of acquiring images of sheep of different breeds and constructing a sheep face dataset specifically includes:

[0013] Obtain images of sheep of different breeds, remove blurred and ghosted sheep images, and determine the original data set;

[0014] According to the original data set, the rectangular area with sheep faces is marked and intercepted to construct a sheep face data set.

[0015] Optionally, the method of extracting sheep face features from the sheep face data set based on a deep neural network, determining the sheep face feature vector, and obtaining the sheep face inter-class similarity matrix by using a cosine similarity algorithm specifically includes:

[0016] ResNet50 is used as the basic network, and the sheep face feature extraction network is obtained by training ResNet50;

[0017] The multi-dimensional feature vector corresponding to each sheep is obtained according to the sheep face breed feature extraction network. The face feature vectors of sheep of the same breed are averaged, and the average facial features of each breed of sheep are obtained using the following formula:

[0018]

[0019] Among them, L ik is the 2048-dimensional feature vector obtained after each sheep face picture passes through the sheep facial feature extraction network, and n is the number of pictures corresponding to each sheep breed in the training set;

[0020] According to the average facial features of each breed of sheep, the cosine similarity algorithm is used to obtain the sheep face similarity matrix. The specific calculation formula is as follows:

[0021]

[0022] Among them, S (i,j) represents the similarity between the facial features of the i-th and j-th sheep, L i ,L j Represents the facial feature vectors of different breeds of sheep, A k , B k Represents L i and L j The kth element in the feature vector.

[0023] Optionally, data augmentation is performed on the sheep face dataset by superimposing noise, random rotation, mirror flipping, or brightness change.

[0024] The present invention provides a hybrid sheep breed identification device, comprising:

[0025] The acquisition module is used to obtain images of sheep of different breeds and construct a sheep face dataset;

[0026] An extraction module is used to extract sheep face features from the sheep face dataset based on a deep neural network, determine the sheep face feature vector, and obtain the sheep face inter-class similarity matrix by using a cosine similarity algorithm;

[0027] A fusion module is used to determine the inter-class similarity vector of sheep breeds based on the inter-class similarity matrix of sheep faces, fuse the inter-class similarity vector of sheep breeds with the breed hard label of the YOLOv7 model, and obtain the target breed soft label;

[0028] A training module, used to train the YOLOv7 model using a target breed soft label to obtain a sheep breed recognition model for identifying sheep breeds;

[0029] The recognition module is used to obtain the sheep image to be identified, input the sheep image into the sheep breed recognition model to perform sheep face recognition, and determine the recognition result of the sheep breed in the image.

[0030] The present invention provides a computer-readable storage medium, wherein the storage medium stores a computer program, and when the computer program is executed by a processor, the hybrid sheep breed identification method is implemented.

[0031] The present invention provides a computer device, comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned hybrid sheep breed identification method when executing the program.

[0032] Compared with the prior art, the beneficial effects of the present invention are as follows: the present invention provides a hybrid sheep breed identification method, which constructs a similarity matrix between sheep face classes to represent the similarity of facial features between hybrid breeds, so that effective features can be extracted in the subsequent sheep breed identification model, thereby improving the model's recognition accuracy for hybrid breeds; by weighted averaging the similarity matrix between sheep face classes and the YOLOv7 breed hard label to generate a target breed soft label, the loss function of the YOLOv7 network model is optimized, thereby reducing the learning difficulty of the original YOLOv7 network model for identifying different breeds with higher similarity, and further effectively improving the recognition accuracy of the entire sheep breed identification model. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0034] Figure 1 A flow chart of a hybrid sheep breed identification method provided by an embodiment of the present invention;

[0035] Figure 2 A flowchart of constructing a sheep face inter-class similarity matrix provided in an embodiment of the present invention;

[0036] Figure 3 A structural diagram of a sheep breed identification model provided by an embodiment of the present invention;

[0037] Figure 4 A schematic diagram of a computer device for a hybrid sheep breed identification method provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0038] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0039] The technical solution of the present invention and how the technical solution of the present invention solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present invention will be described below in conjunction with the accompanying drawings.

[0040] Figure 1 : is a flow chart of a hybrid sheep breed identification method provided by an embodiment of the present invention, such as Figure 1 As shown, a hybrid sheep breed identification method shown in this embodiment includes:

[0041] S1: Obtain images of sheep of different breeds and build a sheep face dataset.

[0042] For example, the sheep face dataset may be labeled, and the labeled dataset may be divided into a training set, a validation set, and a test set in a ratio of 7:2:1.

[0043] Among them, the data in the training set and validation set can be enhanced by using superimposed noise, rotation, mirroring, brightness enhancement and dimming methods.

[0044] S2: Based on the deep neural network, the sheep face features in the sheep face dataset are extracted, the sheep face feature vector is determined, and the sheep face inter-class similarity matrix is ​​obtained by using the cosine similarity algorithm.

[0045] like Figure 2As shown in the figure, ResNet50 is selected as the basic network for sheep face image recognition. The sheep face feature vector is obtained, and then the feature vectors of sheep faces of the same breed are averaged, and the sheep face inter-class similarity matrix is ​​obtained through the cosine similarity algorithm.

[0046] The average facial feature vector of each breed of sheep is obtained using the following formula:

[0047]

[0048] Among them, L ik represents the 2048-dimensional feature vector obtained after each sheep face picture passes through the sheep facial feature extraction network, and n represents the number of pictures corresponding to each sheep breed in the training set.

[0049] Then, based on the average facial features of each breed of sheep, the cosine similarity algorithm is used to obtain the sheep face similarity matrix. The specific calculation formula is as follows:

[0050]

[0051] Among them, S (i,j) represents the similarity between the facial features of the i-th and j-th sheep, L i ,L j Represents the facial feature vectors of different breeds of sheep, A k , B k Represents L i and L j The kth element in the feature vector.

[0052] Among them, the main diagonal of the similarity matrix is ​​all 1, which means that the similarity between the same varieties is exactly the same. Except for the main diagonal, other values ​​in the matrix represent the similarity between different varieties.

[0053] Optionally, the 1×12 similarity vector corresponding to each breed in the similarity matrix is ​​normalized to soften the hard label of the sheep breed identification basic model YOLOv7. The specific calculation formula is as follows:

[0054]

[0055] Among them, N represents the normalized similarity matrix between categories.

[0056] In this step, a sheep face similarity matrix is ​​constructed to represent the similarity of facial features between different breeds, especially hybrid breeds, so that effective features can be extracted in the subsequent sheep breed recognition model, thereby improving the model's recognition accuracy for hybrid breeds.

[0057] S3: According to the sheep face inter-class similarity matrix, determine the sheep breed inter-class similarity vector, fuse the sheep breed inter-class similarity vector with the breed hard label of the YOLOv7 model, and obtain the target breed soft label.

[0058] Based on the original YOLOv7 network model, the sheep face similarity matrix is ​​introduced to obtain the sheep breed recognition model. The structure of the sheep breed recognition model is as follows: Figure 3 shown.

[0059] For example, a sheep image x of a certain size i Input into the YOLOv7 backbone feature extraction network to obtain three sheep face feature vectors of different sizes. The enhanced feature extraction network performs feature fusion of different dimensions. The fused feature vectors are processed by a series of convolution operations to obtain m 1*(12+5) dimensional prediction vectors. The specific calculation formula is as follows:

[0060]

[0061] in, A vector representing 1*12 dimensions is used to predict varieties; The vector representing 1*4 dimensions is used to predict the position and offset of the center point of the sheep face; The 1*1 vector is used to predict the confidence of the object containing the sheep face.

[0062] The similarity vector Ni between sheep breeds and the breed label In the process of softening the label, the variable μ is introduced to control the degree of label softening, so as to obtain the new label Yi. The specific calculation formula is as follows:

[0063]

[0064] The value of μ changes with the number of iterations of the network model during training, and its value range is 0.5-1.

[0065] Finally, the softened species labels are concatenated with the candidate box labels and confidence labels for subsequent supervised training of the YOLOv7 network model.

[0066] In this step, the target breed soft label is generated by weighted averaging the similarity matrix between sheep face classes and the YOLOv7 breed hard label, which optimizes the loss function of the YOLOv7 network model, thereby reducing the learning difficulty of the YOLOv7 network model for identifying different breeds with high similarity, and further effectively improving the accuracy of the entire breed model.

[0067] S4: Train the YOLOv7 model using the target breed soft label to obtain a sheep breed recognition model for identifying sheep breeds.

[0068] S5: Obtain a sheep image to be identified, input the sheep image into a sheep breed identification model to perform sheep face recognition, and determine the identification result of the sheep breed in the image.

[0069] The above is a hybrid sheep breed identification method provided by one or more embodiments of this specification. Based on the same idea, this specification also provides a corresponding hybrid sheep breed identification device including:

[0070] The acquisition module is used to obtain images of sheep of different breeds and construct a sheep face dataset;

[0071] An extraction module is used to extract sheep face features from the sheep face dataset based on a deep neural network, determine the sheep face feature vector, and obtain the sheep face inter-class similarity matrix by using a cosine similarity algorithm;

[0072] A fusion module is used to determine the inter-class similarity vector of sheep breeds based on the inter-class similarity matrix of sheep faces, fuse the inter-class similarity vector of sheep breeds with the breed hard label of the YOLOv7 model, and obtain the target breed soft label;

[0073] A training module, used to train the YOLOv7 model using a target breed soft label to obtain a sheep breed recognition model for identifying sheep breeds;

[0074] The recognition module is used to obtain the sheep image to be identified, input the sheep image into the sheep breed recognition model to perform sheep face recognition, and determine the recognition result of the sheep breed in the image.

[0075] The specific definition of the hybrid sheep breed identification device can be found in the definition of the hybrid sheep breed identification method above, which will not be repeated here. Each module in the above hybrid sheep breed identification device can be implemented in whole or in part by software, hardware and a combination thereof. The above modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0076] The present invention also provides a computer-readable storage medium, which stores a computer program. The computer program can be used to execute the hybrid sheep breed identification method provided above.

[0077] The present invention also provides Figure 4 The structural diagram of the computer device shown in FIG. Figure 4As shown, at the hardware level, the computer device includes a processor, an internal bus, a network interface, a memory, and a non-volatile memory, and may also include hardware required for other services. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to implement the hybrid sheep breed identification method provided in the above embodiment.

[0078] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided by the present invention can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).

[0079] The technical features of the above embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of the present invention.

Claims

1. A method for identifying hybrid sheep breeds, characterized in that: include: Obtain images of sheep of different breeds and construct a sheep face dataset; Based on deep neural network, the sheep face features in the sheep face dataset are extracted, the sheep face feature vector is determined, and the sheep face inter-class similarity matrix is ​​obtained by using the cosine similarity algorithm. According to the sheep face inter-class similarity matrix, determine the sheep breed inter-class similarity vector, fuse the sheep breed inter-class similarity vector with the breed hard label of the YOLOv7 model, and obtain the target breed soft label; The YOLOv7 model is trained using the target breed soft label to obtain a sheep breed recognition model for identifying sheep breeds; Obtain a sheep image to be identified, input the sheep image into a sheep breed identification model to perform sheep face recognition, and determine the identification result of the sheep breed in the image.

2. The hybrid sheep breed identification method according to claim 1, characterized in that: Also includes: After obtaining the soft labels of the target species, the YOLOv7 target detection algorithm is optimized using the progressive learning method.

3. The hybrid sheep breed identification method according to claim 1, characterized in that: The step of obtaining images of sheep of different breeds and constructing a sheep face dataset specifically includes: Obtain images of sheep of different breeds, remove blurred and ghosted sheep images, and determine the original data set; According to the original data set, the rectangular area with sheep faces is marked and intercepted to construct a sheep face data set.

4. The hybrid sheep breed identification method according to claim 1, characterized in that: The method extracts sheep face features from the sheep face data set based on a deep neural network, determines the sheep face feature vector, and obtains the sheep face inter-class similarity matrix by using a cosine similarity algorithm, specifically including: ResNet50 is used as the basic network, and the sheep face feature extraction network is obtained by training ResNet50; The multi-dimensional feature vector corresponding to each sheep is obtained according to the sheep face breed feature extraction network. The face feature vectors of sheep of the same breed are averaged, and the average facial features of each breed of sheep are obtained using the following formula: Among them, L ik is the 2048-dimensional feature vector obtained after each sheep face picture passes through the sheep facial feature extraction network, and n is the number of pictures corresponding to each sheep breed in the training set; According to the average facial features of each breed of sheep, the cosine similarity algorithm is used to obtain the sheep face similarity matrix. The specific calculation formula is as follows: Among them, S (i,j) represents the similarity between the facial features of the i-th and j-th sheep, L i ,L j Represents the facial feature vectors of different breeds of sheep, A k , B k Represents L i and L j The kth element in the feature vector.

5. The hybrid sheep breed identification method according to claim 1, characterized in that: The sheep face dataset is enhanced by superimposing noise, random rotation, mirror flipping or brightness change.

6. A hybrid sheep breed identification device, characterized in that: include: The acquisition module is used to obtain images of sheep of different breeds and construct a sheep face dataset; An extraction module is used to extract sheep face features from the sheep face dataset based on a deep neural network, determine the sheep face feature vector, and obtain the sheep face inter-class similarity matrix by using a cosine similarity algorithm; A fusion module is used to determine the inter-class similarity vector of sheep breeds based on the inter-class similarity matrix of sheep faces, fuse the inter-class similarity vector of sheep breeds with the breed hard label of the YOLOv7 model, and obtain the target breed soft label; A training module, used to train the YOLOv7 model using a target breed soft label to obtain a sheep breed recognition model for identifying sheep breeds; The recognition module is used to obtain the sheep image to be identified, input the sheep image into the sheep breed recognition model to perform sheep face recognition, and determine the recognition result of the sheep breed in the image.

7. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the hybrid sheep breed identification method according to any one of claims 1 to 5 is implemented.

8. A computer device, characterized in that: The invention comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the hybrid sheep breed identification method according to any one of claims 1 to 5 is implemented.

Citation Information

Patent Citations

  • Intelligent training method and device fusing semantics and image features, equipment and medium

    CN113449821A

  • Knowledge distillation-based YOLOv5s lightweight sheep variety identification method and system

    CN116052211A

  • Fine-grained image classification model training method based on category-level soft target supervision

    CN116563602A

  • Blade fine granularity identification method and system for realizing label enhancement based on prototype learning

    CN117036829A

  • Semantic embedding-based scene identification method and system for inter-class similarity prototype

    CN118506244A