CN-121997163-A - Egg gender detection method and device
Abstract
The disclosure provides a method and a device for detecting sex of hatching eggs, and relates to the technical field of artificial intelligence. The method comprises the steps of respectively obtaining spectral data of light penetrating through an egg to be detected from the egg to be detected through a plurality of sampling points of the egg to be detected, generating spectral features of the spectral data, training a model to be trained by taking the spectral features as training samples to obtain a trained model, predicting the probability of indicating the gender of the egg from the spectral data of each sampling point through the trained model, and determining the gender of the egg to be detected according to each probability. According to the method, the spectrum data are acquired from a plurality of sampling points, training and modeling are carried out, the local spectrum difference is fully reserved, and the information loss caused by averaging is effectively avoided.
Inventors
- YU LIANG
- ZHANG YAO
- XU HAILONG
Assignees
- 北京魔芋科技有限公司
Dates
- Publication Date
- 20260508
- Application Date
- 20251210
Claims (10)
- 1. The method for detecting the sex of the hatching eggs is characterized by comprising the following steps: acquiring spectral data of light penetrating through an egg from the egg to be detected through a plurality of sampling points of the egg to be detected, wherein the sampling points are positioned on eggshells at the upper part of the egg; generating spectral features for the spectral data, taking the spectral features as training samples, and training a model to be trained to obtain a trained model; And predicting the probability of indicating the gender of the egg according to the spectral data of each sampling point through the trained model, and determining the gender of the egg to be detected according to each probability.
- 2. The method of claim 1, wherein the model is a classification model, the number of models to be trained is one or at least two, the training the model to be trained using the spectral features as training samples comprises: If the number of the models to be trained is at least two, training the at least two models to be trained by taking the spectral characteristics of each sampling point as training samples to obtain at least two trained models, wherein the training is the training of the at least two models to be trained for each sampling point or the training is the training of the at least two models to be trained for each sampling point; Selecting an optimal model for predicting each sampling point from the at least two trained models; The predicting, by the trained model, the probability of indicating the gender of the egg for the spectral data of each sampling point includes: And predicting the probability of indicating the gender of the egg according to the spectral characteristics corresponding to the sampling points by utilizing the optimal model.
- 3. The method of claim 2, wherein determining the gender of the egg to be tested based on the respective probabilities comprises: Under the condition that the weights of all the probabilities are the same, carrying out equal weight averaging on all the probabilities, and determining the gender of the egg to be detected according to the gender indicated by the average result; And under the condition that the respective probabilities have respective corresponding weights, carrying out weighted average on the respective probabilities to obtain an average probability, and determining the gender of the egg to be detected according to the gender indicated by the average probability.
- 4. A method according to claim 3, characterized in that the method further comprises: Under the condition that the respective corresponding weights exist in each probability, if a preset weight updating condition is met, updating the weights through the current weights and the performance parameters of the trained model to obtain updated weights; The weight updating condition comprises at least one of a preset time period, a sampling batch update and a sampling equipment batch update, wherein the sampling batch update and the sampling equipment batch update are used for updating the weight corresponding to at least one sampling point.
- 5. The method of claim 1, wherein the probability of indicating the gender of the egg comprises a probability of being male and a probability of being female, the method further comprising: determining the absolute value of the difference value of the male probability and the female probability as the confidence of the egg to be detected; And if the confidence coefficient is smaller than a preset threshold value, returning and executing the steps of respectively acquiring spectrum data for the plurality of sampling points of the egg to be detected.
- 6. The method of claim 5, wherein if the confidence level is less than a preset threshold, the method further comprises: adding a new sampling point; The step of returning and executing the plurality of sampling points of the egg to be detected to acquire spectrum data respectively comprises the following steps: and respectively acquiring spectrum data for the new sampling point and the plurality of sampling points.
- 7. A method according to claim 3, wherein said determining the sex of the egg to be detected based on the respective probabilities further comprises: Processing auxiliary data and one of the average result and the average probability by a meta learner for predicting the gender of the egg to obtain a processing result, wherein the auxiliary data comprises environmental data of the egg to be detected; And processing the auxiliary data and the probabilities by a meta learner for predicting the gender of the egg to obtain updated probabilities.
- 8. The method of claim 7, wherein the method further comprises: If the egg to be detected is a new egg, training a current model through transfer learning or few sample learning based on a prototype network to update the current model, wherein the new egg is a new egg type egg or a few sample egg type egg, and the current model comprises the optimal model and/or the meta learner.
- 9. The method of claim 1, wherein the generating spectral features for the spectral data comprises: Extracting characteristics from the spectrum data of each sampling point, wherein the characteristics comprise at least one of peak value, peak width, integral area, energy ratio, derivative characteristics, frequency domain characteristics, light intensity and transmissivity; And reducing the dimension of the feature to generate a spectrum feature corresponding to the dimension-reduced feature.
- 10. An egg sex detection device, characterized by comprising: The sampling unit is configured to acquire spectral data of light penetrating through an egg to be detected from the egg to be detected through a plurality of sampling points of the egg to be detected, wherein the sampling points are positioned on eggshells at the upper part of the egg; the training unit is configured to generate spectral characteristics for the spectral data, train the model to be trained by taking the spectral characteristics as a training sample, and obtain a trained model; And the determining unit is configured to predict the probability of indicating the gender of the egg for the spectrum data of each sampling point through the trained model, and determine the gender of the egg to be detected according to the respective probabilities.
Description
Egg gender detection method and device Technical Field The disclosure relates to the technical field of artificial intelligence, in particular to a method and a device for detecting sex of hatching eggs. Background The sex of eggs is difficult to detect, invasive methods such as puncture sampling can destroy eggshells, increasing the risk of contamination/infection. The hyperspectral camera can acquire spectral data of an object and is used in the technical fields of agriculture, biological tissue detection and the like. Thus, non-invasive detection can be performed using spectral data obtained with a hyperspectral camera. However, the accuracy of the current non-invasive detection is low, and a detection method is needed to realize accurate detection of the gender of the egg. Disclosure of Invention In view of the above, the disclosure aims to provide a method and a device for detecting sex of hatching eggs, which can solve the existing problems in a targeted manner. Based on the above object, in a first aspect, the disclosure provides a method for detecting sex of eggs, which includes obtaining spectral data of light penetrating through eggs through a plurality of sampling points of eggs to be detected, respectively, for the eggs to be detected, wherein the sampling points are located on eggshells at the upper parts of the eggs, generating spectral features for the spectral data, training a model to be trained by taking the spectral features as training samples to obtain a trained model, predicting probability of indicating the sex of the eggs through the trained model for the spectral data of each sampling point, and determining the sex of the eggs to be detected according to each probability. The device for detecting the sex of the eggs comprises a sampling unit, a training unit and a determining unit, wherein the sampling unit is configured to obtain spectral data of light penetrating through the eggs to be detected through a plurality of sampling points of the eggs to be detected, the sampling points are located on eggshells at the upper parts of the eggs, the training unit is configured to generate spectral features for the spectral data, the spectral features are used as training samples, a model to be trained is trained to obtain a trained model, the determining unit is configured to predict the probability of indicating the sex of the eggs for the spectral data of each sampling point through the trained model, and the sex of the eggs to be detected is determined according to each probability. In a third aspect, there is also provided an electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor running the computer program to implement the method of the first aspect. In a fourth aspect, there is also provided a computer readable storage medium having stored thereon a computer program for execution by a processor to implement the method of any of the first aspects. In a fifth aspect, there is also provided a computer program product comprising a computer program for execution by a processor to implement the method of any one of the first aspects. In general, the method has the advantages that spectrum data are acquired from a plurality of sampling points, training and modeling are carried out, local spectrum differences are fully reserved, and information loss caused by averaging is effectively avoided. Through real-time training, a model aiming at the egg to be detected can be obtained, and the detection accuracy is improved. Drawings In the drawings, the same reference numerals refer to the same or similar parts or elements throughout the several views unless otherwise specified. The figures are not necessarily drawn to scale. It is appreciated that these drawings depict only some embodiments according to the disclosure and are not to be considered limiting of its scope. FIG. 1 illustrates a flow chart of a method of detecting gender of an egg in accordance with an embodiment of the present disclosure; FIG. 2 shows a schematic diagram of an egg gender detection device according to an embodiment of the present disclosure; FIG. 3 is a schematic diagram of an electronic device according to an embodiment of the disclosure; fig. 4 shows a schematic diagram of a storage medium according to an embodiment of the present disclosure. Detailed Description The present disclosure is described in further detail below with reference to the drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be noted that, for convenience of description, only the portions related to the present invention are shown in the drawings. It should be noted that, without conflict, the embodiments of the present disclosure and features of the embodiments may be combined with each other. The present disclosure will be described