Deep learning-based co-rearing young silkworm sleep rate detection method and system
Through the deep learning-based object detection model and multi-objective tracking method, real-time and accurate detection of the sleep acupoint rate of small silkworms is achieved, and the problems of low credibility and poor timeliness observation in the existing technology are solved, and the quality of co-cultivation of small silkworms is improved.
Patent Information
- Application Number
- CN202510193715.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-21
- Publication Date
- 2025-06-20
AI Technical Summary
The observation of sleeping behavior during co-cultivation of small silkworms in the prior art depends on artificial experience, resulting in low observation credibility and poor timeliness, making it difficult to obtain the real-time sleeping rate of small silkworms in a timely and accurate manner.
Using a deep learning-based object detection model, by acquiring and preprocessing the images of small silkworms during sleep, labeling and training, using ByteTrack multi-objective tracking method and improved YOLOX-S detection method, accurate identification and tracking of small silkworms and silkworms, and calculating their sleeping rate.
Real-time and accurate detection of the sleeping rate of small silkworms is achieved, the timeliness and credibility of sleeping treatment is improved, the dependence on artificial observations is reduced, and the quality of co-cultivation of small silkworms is improved.
Smart Images

Figure CN120183035A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of silkworm breeding, and particularly to a detection method and system for the molting rate of co-reared young silkworms based on deep learning. Background Art
[0002] The sericulture industry is a labor-intensive industry and occupies an important position in agricultural production. The high-quality development of the sericulture industry is of great significance for realizing rural revitalization.
[0003] At present, sericulture production still mainly adopts the traditional rural household decentralized breeding mode. The feeding of silkworms is mainly carried out in stages, that is, the newly hatched silkworm larvae are reared to the third or fourth instar after molting through co-rearing of young silkworms, and then the large silkworms are distributed to sericulturists for subsequent feeding. During the co-rearing process of young silkworms, the occurrence of molting behavior means that the young silkworms are about to enter the next instar. Since young silkworms consume a large amount of nutrients for self-tissue renewal during molting and have weak resistance to the external environment, molting treatment is a crucial link in improving the quality of co-rearing of young silkworms.
[0004] However, at present, the co-rearing of young silkworms is mainly manual, with low levels of intelligence and specialization. The observation of the molting rate of young silkworms mostly relies on visual inspection by experience, with low credibility and poor timeliness. Therefore, how to obtain the real-time molting rate of young silkworms in a timely and accurate manner and adjust the details of molting treatment according to the molting rate in a timely manner is a technical problem that urgently needs to be solved in this field. Summary of the Invention
[0005] In order to solve the above technical problems, the present application proposes the following technical solutions:
[0006] In a first aspect, an embodiment of the present application provides a detection method for the molting rate of co-reared young silkworms based on deep learning, including:
[0007] After obtaining the images of young silkworms in the molting period, preprocess the images of young silkworms in the molting period;
[0008] Label the preprocessed images of young silkworms in the molting period and divide them into a training set, a test set, and a validation set;
[0009] Input the training set into a deep learning object detection model for training, and use the validation set and the test set to verify and test the object detection model to obtain the target recognition result;
[0010] Track all young silkworm bodies and molting silkworms in the target recognition result through the ByteTrack multi-object tracking method;
[0011] Count all the young silkworm bodies and molting silkworms tracked according to the detection line method, and calculate the molting rate of young silkworms according to the counting result.
[0012] In a possible implementation, after obtaining the images of young silkworms in the molting stage, preprocessing the images of young silkworms in the molting stage includes:
[0013] Collecting the images of young silkworms in the molting stage through an image acquisition module;
[0014] Resizing the collected images of young silkworms in the molting stage and converting them into grayscale images;
[0015] After performing contrast enhancement and blurring denoising processing on the grayscale images, identifying and highlighting the edge information in the images.
[0016] In a possible implementation, annotating the preprocessed images of young silkworms in the molting stage and dividing them into a training set, a test set, and a validation set includes:
[0017] Annotating the silkworm bodies and the molting triangles of the heads of young silkworms in the preprocessed images of young silkworms in the molting stage respectively to form a silkworm body dataset and a molting silkworm head dataset;
[0018] Dividing the silkworm body dataset and the molting silkworm head dataset into a training set, a test set, and a validation set according to a preset ratio.
[0019] In a possible implementation, inputting the training set into a deep learning object detection model for training includes:
[0020] Inputting the training set into the backbone network of YOLOX for training, and the backbone network selects YOLOX-S and the Efficient Multi-Scale Attention mechanism;
[0021] Extracting the description information of the attention weights of the grouped feature maps through two parallel 1×1 branches and one 3×3 branch parallel paths;
[0022] Using two non-linear Sigmoid functions to fit the two-dimensional binomial distribution after linear convolution to achieve channel interaction;
[0023] Encoding the global information through 2D global average pooling, and at the same time using a multi-scale feature fusion module to replace the original PAFPN structure.
[0024] In a possible implementation, tracking all silkworm bodies and molting silkworms in the target recognition results through the ByteTrack multi-object tracking method includes:
[0025] Dividing the results detected by the target detection model into high-score detection boxes and low-score detection boxes;
[0026] Matching the high-score detection boxes with the tracking trajectories, and screening the low-score detection boxes using a better low-score box screening algorithm;
[0027] The filtered low-score detection boxes are matched again with the tracking trajectories that were not successfully matched initially;
[0028] For the high-score detection boxes that are not successfully matched, new tracking trajectories are created to achieve the tracking of all small silkworm bodies and molting silkworms in the target recognition results.
[0029] In a possible implementation, the calculation formula for the low-score box screening threshold is:
[0030]
[0031] where IoU is Intersection / Union; α is the influence hyperparameter of the center point distance, β is the influence hyperparameter of the width-height difference, c l is the center point of the low-score detection box, c h is the center point of the high-score detection box, ρ(c l , c h ) is the Euclidean distance between the center points of the low-score detection box and the high-score detection box, a t is the width of the minimum bounding rectangle of the high-score detection box and the low-score detection box, b t is the height of the minimum bounding rectangle of the high-score detection box and the low-score detection box, a h and a l are the widths of the high-score detection box and the low-score detection box respectively, b h and b l are the heights of the high-score detection box and the low-score detection box respectively.
[0032] In a possible implementation, the counting of all the tracked small silkworm bodies and molting silkworms according to the detection line method includes:
[0033] Define the input image frame, and the input image frame includes a detection line, a counting area, and a preparation area;
[0034] Judge the position where the detection box crosses the detection line;
[0035] If the detection box crosses the detection line from the left side, it does not participate in the counting;
[0036] Or,
[0037] If the detection box crosses the detection line from the right side, the left line of the detection box touches the detection line, and the target ID is verified;
[0038] If the target ID is not recorded, the count is incremented by one, otherwise it does not participate in the counting.
[0039] In a possible implementation, the calculation formula for the molting rate is:
[0040]
[0041] Among them, uniformity counting is the sleep-wake rate, Num counting Num is the number of small silkworm sleeping triangles identified. total is the total number of identified silkworm bodies.
[0042] In a second aspect, the embodiment of the present application provides a system for detecting the sleep and wake-up rate of co-reared silkworms based on deep learning, comprising:
[0043] An image collection and processing module, used for acquiring images of young silkworms in the dormant stage and preprocessing the images of young silkworms in the dormant stage;
[0044] The labeling module is used to label the pre-processed images of dormant silkworms and divide them into training set, test set and validation set;
[0045] A model training module is used to input the training set into the deep learning target detection model for training, and obtain the target recognition result using the validation set and the test set;
[0046] The target tracking module is used to track all the young silkworms and sleeping silkworms in the target recognition results through the ByteTrack multi-target tracking method;
[0047] The sleep-wake rate calculation module is used to count all the tracked silkworm bodies and sleeping silkworms according to the detection line method, and calculate the sleep-wake rate of the silkworms according to the counting results.
[0048] Compared with the prior art, the beneficial effects of this application are:
[0049] This application uses a deep learning target detection model to dynamically detect the sleeping triangles of all sleeping silkworms and the silkworm bodies in the silkworm plaque, so as to achieve accurate identification of sleeping silkworms and silkworm bodies. The rate of sleeping silkworms is calculated based on the identification results, so that silkworm farmers do not need to be on duty to check the rate of sleeping silkworms. At the same time, silkworm farmers can check the status of sleeping silkworms in time through their mobile phones, so as to make preparations for sleeping silkworms in advance and prevent delays.
[0050] This application adopts the improved YOLOX-S detection method and ByteTrack tracking method, which has the advantages of high detection and tracking accuracy and fast reaction rate, and can realize real-time detection and counting. The method of using detection lines to count the bodies of young silkworms and the sleeping triangles on their heads reduces the probability of repeated counting, making the counting more accurate. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] Figure 1 A schematic flow chart of a method for detecting the sleep and wake-up rate of co-reared silkworms based on deep learning provided in an embodiment of the present application;
[0052] Figure 2 Schematic diagram of the detection line provided by the embodiment of the present application;
[0053] Figure 3 Schematic diagram of the counting process provided by the embodiment of the present application;
[0054] Figure 4 Schematic diagram of a co-rearing small silkworm molting rate detection system based on deep learning provided by the embodiment of the present application. Specific implementation manners
[0055] The following elaborates on this solution in combination with the accompanying drawings and specific implementation manners.
[0056] Figure 1 Schematic diagram of the process of a co-rearing small silkworm molting rate detection method based on deep learning provided by the embodiment of the present application. Refer to Figure 1 In this embodiment, a co-rearing small silkworm molting rate detection method based on deep learning includes:
[0057] S101, After obtaining the images of small silkworms in the molting stage, preprocess the images of small silkworms in the molting stage.
[0058] In this embodiment, the images of small silkworms in the molting stage are collected through an image acquisition module, and both une molted silkworms and molted silkworms coexist in the images of small silkworms in the molting stage. After the collected images of small silkworms in the molting stage are scaled, they are converted into grayscale images. After the grayscale images are subjected to contrast enhancement and blurring denoising processing, the edge information in the images is recognized and highlighted.
[0059] S102, Label the preprocessed images of small silkworms in the molting stage, and divide them into a training set, a test set, and a validation set.
[0060] In this embodiment, the DarkLabel software is used to label the silkworm bodies and the molting triangles of the heads of small silkworms in the preprocessed images of small silkworms in the molting stage respectively, forming a silkworm body data set and a molted silkworm head data set. The ratio of the silkworm body data set to the molted silkworm head data set is 2:1. The silkworm body data set and the molted silkworm head data set are divided into a training set, a test set, and a validation set according to the ratio of 6:2:2.
[0061] S103, Input the training set into the deep learning object detection model for training, use the validation set and the test set to verify and test the object detection model, and obtain the object recognition result.
[0062] In this embodiment, the training set is input into the backbone network of YOLOX for pre-training. The pre-trained weight model is used as the initial network weight for the recognition of small silkworm bodies and sleeping silkworms. Hyperparameters are set, and the training environment is deployed for training. The trained recognition and detection model for small silkworm bodies and sleeping silkworms is tested to obtain the recognition results of small silkworm bodies and sleeping silkworms. Among them, in this embodiment, the backbone network selects YOLOX-S. On this basis, the Efficient Multi-Scale Attention mechanism is added. The description information of the attention weights of the grouped feature maps is extracted through two parallel 1×1 branches and one 3×3 branch parallel path. Two non-linear Sigmoid functions are used to fit the two-dimensional binomial distribution after linear convolution to achieve channel interaction. Then, 2D global average pooling is used to encode the global information to achieve cross-space learning. At the same time, the original PAFPN structure is replaced with a multi-scale feature fusion module, which realizes the complementarity of fine-grained features and semantic features by fusing the features of the low layer, middle layer, and high layer, and enhances the inter-layer interaction of features to enhance the expression ability of the feature map. In this embodiment, during the training of the network model, the hyperparameters are set as follows: Batch size is 4, the initial lr is 0.001, the number of training epochs is 300, and the weight decay rate is 0.0005.
[0063] S104, track all small silkworm bodies and sleeping silkworms in the target recognition results through the ByteTrack multi-object tracking method.
[0064] In this embodiment, on the basis of ByteTrack, the detection box matching mechanism is optimized. The strategy of matching all low-score bounding boxes in the current frame with the track is changed to only process the low-score bounding boxes within the minimum bounding rectangle of the overlapping high-score bounding boxes. At the same time, a better low-score box screening algorithm is added. Among them, the better low-score box screening algorithm first screens out the better low-score boxes before track matching, and then matches them with the track prediction boxes, effectively reducing the number of mis-matches.
[0065] In this embodiment, first, the results detected by the target detection model are divided into high-score detection boxes and low-score detection boxes. The high-score detection boxes are matched with the tracking trajectories. The better low-score box screening algorithm is used to screen the low-score detection boxes. The screened low-score detection boxes are matched with the tracking trajectories that were not successfully matched initially again. The trajectories that were not successfully matched will be retained for 60 frames, and the high-score detection boxes that were not successfully matched will create new tracking trajectories to achieve the tracking of all small silkworm bodies and sleeping silkworms in the target recognition results.
[0066] The calculation formula for the low-score box screening threshold is as follows. If the low-score box screening threshold (T 0.5 ) is greater than 0.5, it is a better low-score box:
[0067]
[0068] Among them, IoU is Intersection / Union; α is the influence hyperparameter of the center point distance, β is the influence hyperparameter of the width-height difference, c l is the center point of the low-score detection box, c h is the center point of the high-score detection box, ρ(c l , c h ) is the Euclidean distance between the center points of the low-score detection box and the high-score detection box, a t is the width of the minimum circumscribed rectangle of the high-score detection box and the low-score detection box, b t is the height of the minimum circumscribed rectangle of the high-score detection box and the low-score detection box, a h and a l are the widths of the high-score detection box and the low-score detection box respectively, b h and b l are the heights of the high-score detection box and the low-score detection box respectively.
[0069] S105. Count all the tracked small silkworm bodies and molting silkworms respectively according to the detection line method, and calculate the molting rate of small silkworms according to the counting results.
[0070] In this embodiment, the input image screen is defined. Among them, the input image screen includes a detection line, a counting area, and a preparation area. See Figure 2 . In this embodiment, in the improved ByteTrack algorithm, the counting area on the left side of the input video screen, the preparation area on the right side, and the detection line located on the left side of the counting area are defined. The target detection boxes in the preparation area are not processed. The detection line is used for counting molting silkworms. On this basis, the specific counting rule is: See Figure 3 . Judge the position where the detection box crosses the detection line. When the left side line of the detection box on the right side of the detection line touches the detection line, verify its ID. If the ID has not been recorded, record the ID and increment the count by 1. All other events do not change the count.
[0071] The calculation formula for the molting rate is:
[0072]
[0073] Among them, uniformity counting is the molting rate, Num counting is the number of small silkworm molting triangles identified, Num total is the total number of small silkworm bodies identified.
[0074] Finally, upload the calculated molting rate data of small silkworms to the server, and send the real-time molting rate data to the mobile phones of sericulturists to facilitate sericulturists to perform small silkworm molting treatment in a timely manner.
[0075] Corresponding to the method for detecting the molting rate of jointly reared young silkworms based on deep learning provided in the above embodiment, the present application also provides an embodiment of a system for detecting the molting rate of jointly reared young silkworms based on deep learning.
[0076] Referring to Figure 4 , a system 20 for detecting the molting rate of jointly reared young silkworms based on deep learning provided in an embodiment of the present application includes: an image collection and processing module 201, configured to acquire images of young silkworms in the molting stage and preprocess the images of young silkworms in the molting stage.
[0077] A labeling module 202, configured to label the preprocessed images of young silkworms in the molting stage and divide them into a training set, a test set, and a validation set.
[0078] A model training module 203, configured to input the training set into a deep learning object detection model for training, and use the validation set and the test set to obtain the recognition results of the object.
[0079] A target tracking module 204, configured to track all young silkworm bodies and molting silkworms in the object recognition results by the ByteTrack multi-object tracking method.
[0080] A molting rate calculation module 205, configured to count all young silkworm bodies and molting silkworms tracked according to the detection line method, and calculate the molting rate of the young silkworms according to the counting results.
[0081] In the embodiment of the present application, "a plurality of" means two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B may represent the situation where A exists alone, A and B exist simultaneously, or B exists alone. Where A and B may be singular or plural. The character " / " generally represents an "or" relationship between the front and back associated objects.
[0082] It should be noted that in this article, the terms "include", "comprise" or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not expressly listed, or further includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "including a..." does not exclude the existence of additional identical elements in the process, method, article or device including the said element.
[0083] The above is only the specific implementation manner of the present application. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed in the present application, and all should be covered by the protection scope of the present application. The protection scope of the present application shall be subject to the protection scope of the said claims.
Claims
1. A method for detecting the sleep and wake rate of co-reared silkworms based on deep learning, characterized in that: include: After acquiring the image of the young silkworm in the dormant stage, preprocessing the image of the young silkworm in the dormant stage; The pre-processed dormant silkworm images are labeled and divided into training set, test set and validation set; The training set is input into a deep learning target detection model for training, and the target detection model is verified and tested using a validation set and a test set to obtain a target recognition result; All the young silkworms and sleeping silkworms in the target recognition results are tracked using the ByteTrack multi-target tracking method; According to the detection line method, all the tracked silkworm bodies and dormant silkworms are counted respectively, and the dormant silkworm waking rate is calculated based on the counting results.
2. The method for detecting the sleep and wake-up rate of co-reared silkworms based on deep learning according to claim 1, characterized in that: After acquiring the image of the young silkworm in the dormant stage, preprocessing the image of the young silkworm in the dormant stage comprises: The images of dormant silkworms are collected through an image collection module; The collected images of the sleeping silkworms are scaled and converted into grayscale images; After contrast enhancement and fuzzy denoising processing are performed on the grayscale image, edge information in the image is identified and highlighted.
3. The method for detecting the sleep and wake-up rate of co-reared silkworms based on deep learning according to claim 1, characterized in that: The pre-processed dormant silkworm images are labeled and divided into a training set, a test set and a validation set, including: The silkworm bodies and the sleeping triangles of the silkworm heads in the preprocessed images of the sleeping silkworms are respectively labeled to form a silkworm body dataset and a sleeping silkworm head dataset. The silkworm body data set and the sleeping silkworm head data set are divided into a training set, a test set and a verification set according to a preset ratio.
4. The method for detecting the sleep and wake-up rate of co-reared silkworms based on deep learning according to claim 1, characterized in that: The training set is input into the deep learning target detection model for training, including: The training set is input into the backbone network of YOLOX for training, wherein the backbone network uses YOLOX-S and the Efficient Multi-Scale Attention mechanism; Extract the description information of the attention weight of the grouped feature map through two parallel 1×1 branches and one 3×3 branch parallel pathway; Two nonlinear Sigmoid functions are used to fit the two-dimensional binomial distribution after linear convolution to achieve channel interaction; The global information is encoded through 2D global average pooling, and the multi-scale feature fusion module is used to replace the original PAFPN structure.
5. The method for detecting the sleep and wake-up rate of co-reared silkworms based on deep learning according to claim 1, characterized in that: The ByteTrack multi-target tracking method is used to track all young silkworms and sleeping silkworms in the target recognition results, including: Dividing the results detected by the target detection model into high-score detection frames and low-score detection frames; Matching the high-score detection frame with the tracking trajectory, and using a better low-score frame screening algorithm to screen the low-score detection frame; The low-score detection frames after screening are matched again with the tracking tracks that were not successfully matched the first time; For the high-score detection frames that are not successfully matched, new tracking tracks are created to track all the small silkworm bodies and sleeping silkworms in the target recognition results.
6. The method for detecting the sleep and wake-up rate of co-reared silkworms based on deep learning according to claim 5, characterized in that: The calculation formula for the low frame screening threshold is: Among them, IoU is Intersection / Union; α is the hyperparameter affecting the center point distance, β is the hyperparameter affecting the width and height difference, and c l is the center point of the low-score detection box, c h is the center point of the high-resolution detection box, ρ(c l ,c h ) is the Euclidean distance between the center points of the low-score detection box and the high-score detection box, a t is the minimum bounding rectangle width of the high-score detection frame and the low-score detection frame, b t is the minimum circumscribed rectangle height of the high-score detection frame and the low-score detection frame, a h and a l are the widths of the high-score detection frame and the low-score detection frame, respectively, and b h and b l are the heights of the high-score detection frame and the low-score detection frame, respectively.
7. The method for detecting the sleep and wake-up rate of co-reared silkworms based on deep learning according to claim 1, characterized in that: The method of counting all the tracked young silkworm bodies and sleeping silkworms according to the detection line method includes: An input image screen is defined, wherein the input image screen includes a detection line, a counting area, and a preparation area; Determine the position where the detection frame crosses the detection line; If the detection box passes through the left side of the detection line, it will not be counted; or, If the detection frame passes through the right side of the detection line, the left line of the detection frame touches the detection line, and the target ID is verified; If the target ID is not recorded, the count is increased by one, otherwise it does not participate in the counting.
8. The method for detecting the sleep and wake-up rate of co-reared silkworms based on deep learning according to claim 1, characterized in that: The calculation formula of the sleep-to-wake rate is: Among them, uniformity counting is the sleep-wake rate, Num counting Num is the number of small silkworm sleeping triangles identified. total is the total number of identified silkworm bodies.
9. A system for detecting the sleep and wake rate of co-reared silkworms based on deep learning, characterized in that: include: An image collection and processing module, used for acquiring images of young silkworms in the dormant stage and preprocessing the images of young silkworms in the dormant stage; The labeling module is used to label the pre-processed images of dormant silkworms and divide them into training set, test set and validation set; A model training module is used to input the training set into the deep learning target detection model for training, and obtain the target recognition result using the validation set and the test set; The target tracking module is used to track all the young silkworms and sleeping silkworms in the target recognition results through the ByteTrack multi-target tracking method; The sleep-wake rate calculation module is used to count all the tracked silkworm bodies and sleeping silkworms according to the detection line method, and calculate the sleep-wake rate of the silkworms according to the counting results.