Egg gender detection method and device

By acquiring spectral data from multiple sampling points on the egg and training the model, the problems of high invasiveness and low accuracy in egg sex detection were solved, achieving high-precision non-invasive detection.

CN121997163APending Publication Date: 2026-05-08BEIJING KONJAC TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
BEIJING KONJAC TECH CO LTD
Filing Date
2025-12-10
Publication Date
2026-05-08

AI Technical Summary

Technical Problem

Existing methods for detecting egg sex have problems such as high risk of invasive testing and low accuracy, especially the accuracy of non-invasive testing.

Method used

By acquiring spectral data from multiple sampling points on the egg, generating spectral features and training a model, the trained model is used to predict the probability of the egg's sex, ultimately determining the sex of the egg.

Benefits of technology

It improves the accuracy of egg sex detection, avoids information loss, and enhances the precision of detection, especially in the case of new egg varieties, it can adapt quickly.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121997163A_ABST
    Figure CN121997163A_ABST
Patent Text Reader

Abstract

The invention provides an egg gender detection method and device, and relates to the technical field of artificial intelligence. The method comprises the steps that spectrum data of light penetrating through an egg to be detected are obtained from the egg to be detected through a plurality of sampling points of the egg to be detected, and the sampling points are located on an eggshell on the upper portion of the egg; generating spectral features for the spectral data, and training a to-be-trained model by taking the spectral features as training samples to obtain a trained model; and through the trained model, predicting the probability of indicating the gender of the egg for the spectral data of each sampling point, and determining the gender of the to-be-detected egg according to each probability. According to the invention, the spectral data are acquired from the plurality of sampling points and are trained and modeled, so that local spectral difference is fully reserved, and information loss caused by averaging processing is effectively avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of artificial intelligence technology, and in particular to a method and apparatus for detecting the sex of an egg. Background Technology

[0002] Determining the sex of an egg is very difficult. Invasive testing methods, such as puncture sampling, can damage the eggshell and increase the risk of contamination / infection.

[0003] Hyperspectral cameras can acquire spectral data of objects and have been used in fields such as agriculture and biological tissue detection. Therefore, spectral data obtained from hyperspectral cameras can be used for non-invasive detection. However, the accuracy of current non-invasive detection methods is low, and there is an urgent need for a detection method to accurately determine the sex of eggs. Summary of the Invention

[0004] In view of this, the purpose of this disclosure is to provide a method and apparatus for detecting the sex of an egg, which can specifically solve existing problems.

[0005] Based on the above objectives, in a first aspect, this disclosure proposes a method for detecting the sex of an egg, comprising: acquiring spectral data of light penetrating the egg through multiple sampling points on the egg to be tested, wherein the sampling points are located on the eggshell at the top of the egg; generating spectral features from the spectral data; using the spectral features as training samples to train a model to be trained, thereby obtaining a trained model; using the trained model to predict the probability of indicating the sex of the egg based on the spectral data of each sampling point; and determining the sex of the egg to be tested based on the probabilities.

[0006] Secondly, an egg sex detection device is also provided, comprising: a sampling unit configured to acquire spectral data of light penetrating the egg through multiple sampling points on the egg to be detected, wherein the sampling points are located on the eggshell at the top of the egg; a training unit configured to generate spectral features from the spectral data, and use the spectral features as training samples to train a model to be trained, thereby obtaining a trained model; and a determination unit configured to predict the probability of indicating the sex of the egg based on the spectral data of each sampling point using the trained model, and determine the sex of the egg to be detected based on the probabilities.

[0007] Thirdly, an electronic device is also provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, the processor running the computer program to implement the method of the first aspect.

[0008] Fourthly, a computer-readable storage medium is also provided, on which a computer program is stored, the computer program being executed by a processor to implement the method described in any one of the first aspects.

[0009] Fifthly, a computer program product is also provided, comprising a computer program that is executed by a processor to implement the method described in any one of the first aspects.

[0010] In summary, this disclosure offers at least the following advantages: acquiring spectral data from multiple sampling points for training and modeling fully preserves local spectral differences and effectively avoids information loss caused by averaging. Real-time training allows for the acquisition of a model specific to the egg to be detected, improving detection accuracy. Attached Figure Description

[0011] In the accompanying drawings, unless otherwise specified, the same reference numerals throughout the various drawings denote the same or similar parts or elements. These drawings are not necessarily drawn to scale. It should be understood that these drawings depict only some embodiments disclosed in this disclosure and should not be construed as limiting the scope of this disclosure.

[0012] Figure 1 A flowchart of a method for detecting the sex of an egg according to an embodiment of the present disclosure is shown; Figure 2 A schematic diagram of an egg sex detection device according to an embodiment of the present disclosure is shown; Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure is shown; Figure 4 A schematic diagram of a storage medium provided according to an embodiment of the present disclosure is shown. Detailed Implementation

[0013] The present disclosure will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are for illustrative purposes only and are not intended to limit the invention. Furthermore, it should be noted that, for ease of description, only the parts relevant to the invention are shown in the accompanying drawings.

[0014] It should be noted that, unless otherwise specified, the embodiments and features described in this disclosure can be combined with each other. This disclosure will now be described in detail with reference to the accompanying drawings and embodiments.

[0015] Figure 1 A method for detecting the sex of an egg according to this disclosure is shown. In embodiments of this disclosure, the method includes: Step S101: By using multiple sampling points on the egg to be tested, spectral data of light penetrating the egg are obtained respectively. The sampling points are located on the eggshell at the top of the egg.

[0016] In this embodiment, the entity executing the egg sex detection method can acquire spectral data collected by devices such as a hyperspectral camera. This spectral data can be directly acquired by the device, or it can be information such as a spectral curve obtained after processing the directly acquired information. The sampling point can be preset and is usually located on the outside of the eggshell (relative to the inside). The egg can be any type of egg, such as a chicken egg. The egg to be tested can be placed upright, for example, with the air cell facing upwards, i.e., the larger end of the egg facing upwards.

[0017] Step S102: Generate spectral features from the spectral data, use the spectral features as training samples to train the model to be trained, and obtain the trained model.

[0018] In this embodiment, spectral features can be generated in various ways, such as inputting spectral data into a preset model. This model can be any learning model capable of learning.

[0019] Step S103: Using the trained model, predict the probability of indicating the sex of the egg based on the spectral data of each sampling point, and determine the sex of the egg to be detected based on the probabilities.

[0020] In this embodiment, the predicted probabilities may include the probability that the egg to be tested is male and / or female. Various methods can be used to determine the sex of the egg to be tested based on these probabilities. For example, if the probabilities of being male and female both reach a probability threshold, the egg can be directly determined to be male if the probability is male, and female if the probability is female. If the probabilities are both male and female, the sex corresponding to the higher probability that reaches the aforementioned probability threshold can be taken as the sex of the egg to be tested.

[0021] This disclosure acquires spectral data from multiple sampling points and uses it for training and modeling, fully preserving local spectral differences and effectively avoiding information loss caused by averaging. Through real-time training, a model specific to the egg to be detected can be obtained, improving detection accuracy.

[0022] In some optional implementations of any embodiment of this disclosure, the model is a classification model; the number of models to be trained is one or at least two; the step of using the spectral features as training samples to train the models to be trained includes: if the number of models to be trained is at least two, using the spectral features of each sampling point as training samples to train at least two models to be trained, obtaining at least two trained models, wherein the training is performed separately for each sampling point, or the training is performed for each sampling point; for each sampling point, the optimal model for prediction of the sex of the indicator egg is selected from the at least two trained models; the step of predicting the probability of the sex of the indicator egg based on the spectral data of each sampling point using the trained model includes: using the optimal model to predict the probability of the sex of the indicator egg based on the spectral features corresponding to the sampling point.

[0023] These implementations improve prediction accuracy by training multiple models and selecting the best one. Furthermore, training at least two models for each sampling point enhances the specificity of predictions for different sampling points, leading to even higher accuracy; actual measured precision has improved by 5-12%.

[0024] In some optional implementations of any embodiment of this disclosure, determining the sex of the egg to be tested based on each probability includes: averaging the probabilities with equal weights when each probability has the same weight, and determining the sex of the egg to be tested based on the sex indicated by the average result; or averaging the probabilities with corresponding weights to obtain an averaged probability, and determining the sex of the egg to be tested based on the sex indicated by the averaged probability.

[0025] By averaging the results of each sampling point, the results from multiple sampling points can be fused, thus improving the accuracy of the detection.

[0026] Optionally, the method further includes: if each probability has its own corresponding weight, and if a preset weight update condition is met, then the weight is updated using the current weight and the performance parameters of the trained model to obtain the updated weight; the weight update condition includes at least one of the following: reaching a preset time period, batch update of sampling, and batch update of sampling devices.

[0027] When various data collection conditions change, the accuracy of weighted calculations can be improved by updating the weights.

[0028] Optionally, determining the sex of the egg to be tested based on the probabilities further includes: processing auxiliary data and one of the average result and the averaged probability using a meta-learner for predicting egg sex to obtain a processing result; using the sex indicated by the processing result as the sex of the egg to be tested, wherein the auxiliary data includes environmental data of the egg to be tested; and processing the auxiliary data and the probabilities using a meta-learner for predicting egg sex to obtain updated probabilities.

[0029] These implementations can further optimize the probabilities before or after averaging through meta-learners, which helps to improve recognition accuracy.

[0030] In some application scenarios of this optional implementation, the method further includes: if the egg to be detected is a new breed egg, then the current model is trained by transfer learning or few-shot learning based on the prototype network to update the current model, wherein the new breed egg is a new egg type egg or a few-shot breed egg, and the current model includes the optimal model and / or the meta-learner.

[0031] When the egg to be tested is a new breed of egg, the meta-learner can be quickly trained through transfer learning or a few-shot learning strategy based on prototype networks.

[0032] In some optional implementations of any embodiment of this disclosure, the probability of indicating the sex of the egg includes the probability of being male and the probability of being female; the method further includes: determining the absolute value of the difference between the probability of being male and the probability of being female as the confidence level of the egg to be tested; if the confidence level is less than a preset threshold, returning and executing the step of obtaining spectral data from multiple sampling points of the egg to be tested respectively.

[0033] These implementations can determine the reliability of the predicted sex by using the difference between the probability of the egg being male and the probability of it being female, thus improving the accuracy of the predicted value.

[0034] Optionally, if the confidence level is less than a preset threshold, the method further includes: adding new sampling points; the step of returning and executing the multiple sampling points of the egg to be tested to obtain spectral data respectively includes: obtaining spectral data for the new sampling points and the multiple sampling points respectively.

[0035] These alternative implementations can increase the sample data by adding new sampling points when the confidence level is low or the data is unreliable, thereby helping to improve the accuracy of gender identification results.

[0036] In some optional implementations of any embodiment of this disclosure, generating spectral features from the spectral data includes: extracting features from the spectral data of each sampling point, wherein the features include at least one of the following: peak value, peak width, integral area, energy ratio, derivative features, frequency domain features, light intensity, and transmittance. The features are then dimensionality-reduced to generate spectral features corresponding to the dimensionality-reduced features.

[0037] After obtaining the dimensionality-reduced features, redundancy can be removed from these features. For example, redundancy removal can be done by retaining features whose cumulative variance contribution is greater than a preset high proportion threshold, such as retaining principal component features with a cumulative variance contribution ≥ 95%.

[0038] These implementations can accurately extract features for identifying egg sex, and through operations such as dimensionality reduction, facilitate subsequent feature processing.

[0039] This disclosure also provides a method for detecting the sex of an egg according to an embodiment of this disclosure. The method for detecting the sex of an egg includes: 1. Multi-point spectral data acquisition With the support of a hyperspectral camera or spectral acquisition device, n spectral data points are collected for each egg at predetermined locations. The spectral data corresponding to each spectral data point is spectral curve data. The spectral information of each spectrum is an m-dimensional vector (m is the number of wavelength channels, for example, several channels in the range of 400–1000 nm).

[0040] Record the spatial coordinates and acquisition conditions (exposure, light source power, acquisition time, device ID, batch number, etc.) of each point i for post-processing and traceability of each point.

[0041] 2. Spectral preprocessing Spectral information for each sampling point Perform the following preprocessing pipeline (modularly replaceable, the pipeline ultimately includes at least one preprocessing step, each step is optional): Dark field and whiteboard calibration (radiometric calibration); Denoising: Savitzky–Golay smoothing filter (window and order configurable) or wavelet denoising; Scattering correction: Standard Normal Transform (SNV) or Multivariate Scattering Correction (MSC); Band selection or cropping (excluding noisy bands, such as regions with strong water absorption); Optional first- or second-order derivative transformations can be used to enhance the current processing results of the pipeline. The processed result is a standardized eigenvector. .

[0042] 3. Feature engineering and dimensionality reduction (independent for each point) The collected spectral data are used as a training set, and feature extraction is performed on the peak value, peak width, integral area, energy ratio, derivative features, and frequency domain features. In addition, other spectral data besides these multiple spectral data can be used as a validation set, i.e., a test set, and feature extraction is also performed on the validation data in the validation set.

[0043] PCA, LDA, or an autoencoder are used to reduce the dimensionality and remove redundancy of the features, retaining principal components with a cumulative variance contribution ≥95%. The final low-dimensional feature representation for each point is as follows: ∈Rk.

[0044] 4. Multi-point independent modeling (point modeling) Using the low-dimensional features of the training set, for each point Train one or more candidate classification models individually. These include Support Vector Machine (SVM), Random Forest (RF), Gradient Boosting Tree (GBDT / XGBoost / LightGBM), Multilayer Perceptron (MLP), 1D-CNN, or Lightweight Transformer.

[0045] Cross-validation (K-fold) and grid / Bayesian optimization are used to select the optimal model Mi for each point.

[0046] The output of the trained model (i.e., the point model) is a binary classification probability:

[0047]

[0048] 5. Soft voting fusion decision-making (fusion strategy) Basic soft voting (equal weight): averaging the probabilities of n points.

[0049] Weighted soft voting (each site has an adaptive weight): Considering site reliability and model performance, a weighted average is calculated using weights Wi.

[0050] The weights Wi can be initialized based on the AUC / F1 / accuracy of the points on the validation set or based on the signal-to-noise ratio (SNR), and can be dynamically updated using a self-learning strategy (see step 7).

[0051] The final determination of gender is based on probability.

[0052] 6. Confidence assessment and re-examination strategy Calculate the confidence level of the decision:

[0053] Set a threshold τ, for example, 0.15–0.25. When Confidence < τ, it is marked as a "low confidence sample". A re-inspection or manual review process is adopted, or the system is triggered to collect the egg multiple times (increasing the number of sampling points or repeating the collection to improve reliability).

[0054] 7. Weight Adaptation and Model Self-Learning Mechanism To improve long-term stability and adapt to differences in batches / equipment / products, dynamic weight updates are introduced: Weights are updated according to the following rules at each preset time period (i.e., training / validation period or time window t):

[0055] in The F1 or AUC of the point model on the latest validation data, where α is the smoothing coefficient (e.g., 0.8), can also be weighted separately by acquisition device / batch if necessary.

[0056] The point model supports semi-supervised / incremental learning: low-confidence samples or newly labeled samples enter the buffer, and the point model is adjusted with small batches, such as fine-tuning, or updated with transfer learning strategies to cope with batch drift.

[0057] 8. Multimodal and Meta-learning Extensions If available auxiliary data (temperature, humidity, incubation days, egg weight and / or eggshell color, etc.) is available, a meta-learner (Stacking), also known as a secondary learner, can be introduced during the fusion stage: the point model probability, environmental features, etc. are input into the secondary learner (such as lightweight GBDT or MLP) for final judgment, so as to further improve performance.

[0058] For new egg types or varieties with few samples, transfer learning or few-sample learning strategies based on prototype networks can be used for rapid adaptation.

[0059] 9. Deployment and Engineering Implementation Details Training environment: GPU servers (such as NVIDIA A100 / RTX series) are used for training models (the various models in this application), and CPU / GPU hybrids are used for online prediction.

[0060] Prediction latency: Multi-point parallel sampling of a single egg - model inference time controlled within 0.2–1s (depending on model complexity and parallelism).

[0061] Interfaces and Pipelines: Modular API supporting batch processing and real-time stream processing. Output includes egg sex determination results, confidence levels, and collected data, written to the database, and reports can be exported. Interfaces include: Acquisition Interface → Preprocessing Interface → Point Model Generation Interface → Fusion Interface → Result Writing Interface.

[0062] This disclosure provides an egg sex detection device, which is used to perform the egg sex detection method described in the above embodiments, such as... Figure 2 As shown, the device includes: a sampling unit 201, configured to acquire spectral data of light penetrating the egg through multiple sampling points on the egg to be tested, wherein the sampling points are located on the eggshell at the top of the egg; a training unit 202, configured to generate spectral features from the spectral data, and use the spectral features as training samples to train a model to be trained, thereby obtaining a trained model; and a determination unit 203, configured to predict the probability of indicating the sex of the egg based on the spectral data of each sampling point using the trained model, and determine the sex of the egg to be tested based on the probabilities.

[0063] The egg sex detection device and egg sex detection method provided in the above embodiments of this disclosure are based on the same inventive concept and have the same beneficial effects as the methods adopted, run or implemented by the applications stored therein.

[0064] This disclosure also provides an electronic device corresponding to the egg sex detection method provided in the foregoing embodiments, for executing the egg sex detection method described above. This disclosure is not limiting.

[0065] Please refer to Figure 3 This illustrates a schematic diagram of an electronic device provided by some embodiments of the present disclosure. For example... Figure 3 As shown, the electronic device 30 includes: a processor 300, a memory 301, a bus 302, and a communication interface 303. The processor 300, the communication interface 303, and the memory 301 are connected via the bus 302. The memory 301 stores a computer program that can run on the processor 300. When the processor 300 runs the computer program, it executes the method provided in any of the foregoing embodiments of this disclosure.

[0066] The memory 301 may include high-speed random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Communication between this system network element and at least one other network element is achieved through at least one communication interface 303 (which can be wired or wireless), such as the Internet, wide area network, local area network, or metropolitan area network.

[0067] Bus 302 can be an ISA bus, PCI bus, or EISA bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. The memory 301 is used to store programs. After receiving an execution instruction, the processor 300 executes the program. The egg sex detection method disclosed in any of the foregoing embodiments of this disclosure can be applied to the processor 300, or implemented by the processor 300.

[0068] The processor 300 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of the processor 300 or by instructions in software form. The processor 300 may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), an off-the-shelf programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this disclosure. The general-purpose processor may be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this disclosure can be directly embodied in the execution of a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software modules may reside in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. The storage medium is located in memory 301. The processor 300 reads the information in memory 301 and, in conjunction with its hardware, completes the steps of the above method.

[0069] The electronic device provided in this disclosure and the egg sex detection method provided in this disclosure are based on the same inventive concept and have the same beneficial effects as the methods they employ, operate, or implement.

[0070] This disclosure also provides a computer-readable storage medium corresponding to the egg sex detection method provided in the foregoing embodiments. Please refer to... Figure 4 The computer-readable storage medium shown is an optical disc 40, on which a computer program (i.e., a program product) is stored. When the computer program is run by a processor, it executes the egg sex detection method provided in any of the foregoing embodiments.

[0071] It should be noted that examples of the computer-readable storage medium may also include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other optical and magnetic storage media, which will not be elaborated here.

[0072] The computer-readable storage medium provided in the above embodiments of this disclosure and the egg sex detection method provided in the embodiments of this disclosure are based on the same inventive concept and have the same beneficial effects as the methods adopted, run or implemented by the applications stored therein.

[0073] It should be noted that: In the foregoing text, the terms "comprising," "including," or any other variations thereof are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, it should be noted that the scope of the methods and apparatuses in this disclosure is not limited to performing functions in the order shown or discussed, but may also include performing functions substantially simultaneously or in the reverse order, depending on the functions involved. For example, the described methods may be performed in a different order than described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.

[0074] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this disclosure, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of this disclosure.

[0075] The embodiments of this disclosure have been described above with reference to the accompanying drawings. These are merely specific implementations of this disclosure, but this disclosure is not limited to the specific implementations described above. The specific implementations described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this disclosure without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this disclosure.

Claims

1. A method for detecting the sex of an egg, characterized in that, include: By sampling multiple points on the egg to be tested, spectral data of light penetrating the egg are obtained. The sampling points are located on the upper part of the eggshell. Spectral features are generated from the spectral data, and the spectral features are used as training samples to train the model to be trained, thereby obtaining the trained model. The trained model predicts the probability of indicating the sex of the egg based on the spectral data of each sampling point, and determines the sex of the egg to be detected based on the probabilities.

2. The method according to claim 1, characterized in that, The model is a classification model; the number of models to be trained is one or at least two; the step of using the spectral features as training samples to train the model to be trained includes: If the number of models to be trained is at least two, the spectral features of each sampling point are used as training samples to train at least two models to be trained, thereby obtaining at least two trained models. The training is either training the at least two models to be trained separately for each sampling point, or training the at least two models to be trained for each sampling point. For each sampling point, select the optimal model from the at least two trained models for predicting that sampling point; The step of predicting the probability of an egg's sex based on the spectral data of each sampling point using the trained model includes: Using the optimal model, the probability of the sex of the egg is predicted based on the spectral features corresponding to the sampling point.

3. The method according to claim 2, characterized in that, The process of determining the sex of the egg to be tested based on various probabilities includes: With each probability having the same weight, the probabilities are averaged with equal weights, and the sex of the egg to be tested is determined based on the sex indicated by the average result. Given that each probability has its own corresponding weight, the probabilities are weighted and averaged to obtain the averaged probability. The sex of the egg to be tested is determined based on the sex indicated by the averaged probability.

4. The method according to claim 3, characterized in that, The method further includes: Given that each probability has its own corresponding weight, if the preset weight update condition is met, the weights are updated using the current weights and the performance parameters of the trained model to obtain the updated weights. The weight update conditions include at least one of the following: reaching a preset time period, sampling batch update, and sampling device batch update, wherein the sampling batch update and the sampling device batch update are used to update the weights corresponding to at least one sampling point.

5. The method according to claim 1, characterized in that, The probability of indicating the sex of an egg includes the probability of it being male and the probability of it being female; the method further includes: The absolute value of the difference between the probability of being male and the probability of being female is determined as the confidence level of the egg to be tested; If the confidence level is less than a preset threshold, return and execute the step of obtaining spectral data from multiple sampling points of the egg to be tested.

6. The method according to claim 5, characterized in that, If the confidence level is less than a preset threshold, the method further includes: Add new sampling points; The step of returning to and executing the multiple sampling points of the egg to be tested to obtain spectral data respectively includes: Spectral data are acquired for the new sampling point and the multiple sampling points respectively.

7. The method according to claim 3, characterized in that, The step of determining the sex of the egg to be tested based on various probabilities also includes: A meta-learner for predicting egg sex processes auxiliary data, along with one of the average result and the averaged probability, to obtain a processing result; the sex indicated by this processing result is taken as the sex of the egg to be tested, and the auxiliary data includes environmental data of the egg to be tested; The auxiliary data and the various probabilities are processed by a meta-learner used to predict the sex of the egg to obtain updated probabilities.

8. The method according to claim 7, characterized in that, The method further includes: If the egg to be detected is a new breed egg, the current model is trained through transfer learning or few-shot learning based on a prototype network to update the current model. The new breed egg is a new egg type egg or a few-shot breed egg. The current model includes the optimal model and / or the meta-learner.

9. The method according to claim 1, characterized in that, The generation of spectral features from the spectral data includes: Features are extracted from the spectral data of each sampling point, and the features include at least one of the following: peak value, peak width, integral area, energy ratio, derivative features, frequency domain features, light intensity, and transmittance; The features are reduced in dimensionality to generate the corresponding spectral features.

10. A device for detecting the sex of an egg, characterized in that, include: The sampling unit is configured to acquire spectral data of light penetrating the egg through multiple sampling points on the egg to be tested, with the sampling points located on the eggshell at the top of the egg. The training unit is configured to generate spectral features from the spectral data, use the spectral features as training samples to train the model to be trained, and obtain the trained model. The determining unit is configured to predict the probability of indicating the sex of an egg based on the spectral data of each sampling point using the trained model, and determine the sex of the egg to be detected based on the probabilities.