Dried red date defect detection method, device, equipment and medium
By improving the convolutional layers and loss function of the YOLO11 n model, a second defect detection model for dried jujubes was constructed, which solved the problems of detection accuracy and real-time performance, and achieved efficient and accurate defect detection.
Patent Information
- Application Number
- CN202511687418.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-18
- Publication Date
- 2026-02-27
AI Technical Summary
Existing target detection models suffer from domain mismatch, difficulty in detecting subtle defects, poor adaptability to complex scenarios, and difficulty in balancing real-time performance and accuracy in the detection of defects in dried red dates. This results in high false negative and false positive rates, making it difficult to run in real time on resource-constrained embedded devices.
An improved YOLO11 n model is adopted. By updating the convolutional layers to GPR and DSDBM modules, combined with an improved WIoU loss function and multi-round optimization, a second jujube defect detection model is constructed to enhance feature extraction and detection accuracy, adapt to complex scenarios, and reduce computational complexity.
It significantly improves the detection accuracy of minute defects in dried red dates, reduces the false negative rate, and enables real-time detection on embedded devices, adapting to complex processing line scenarios while balancing high efficiency and high precision.
Smart Images

Figure CN121582170A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of agricultural production, and in particular to a method for detecting defects of dried red dates, a corresponding device, an electronic device, and a computer readable storage medium. BACKGROUND
[0002] As an important agricultural product, the quality control of postharvest processing of red dates is directly related to economic benefits and market competitiveness. Dried red dates are prone to defects such as cracks, pulp rot, mold, and dry streaks during processing, storage, and transportation due to environmental factors, mechanical damage, or biological infestation. Currently, the sorting of defective dates in red date processing enterprises still faces great challenges.
[0003] In recent years, deep learning has shown great potential in the field of visual detection of agricultural products, especially convolutional neural networks (CNN) and target detection models based on CNN (such as YOLO, SSD series). There have been a large number of studies applying deep learning to jujube fruit detection. For example, Chen et al. (2025) improved the YOLOv5 model to achieve high-precision detection of fresh dates on trees; Yin et al. (2024) proposed the JujubeSSD method for detecting diseased dates; Xu et al. (2023) developed the YOLO-Jujube model to classify red dates of different maturity.
[0004] The existing target detection models directly applied to the detection of defects of dried red dates in the processing process still face the following unresolved technical defects, which include:
[0005] First, the field does not match. Most existing researches are aimed at fresh dates growing on trees, and there are significant differences in surface features, imaging background, and defect morphology between processed dried red dates. The direct migration application of the model has poor effect.
[0006] Second, it is difficult to detect subtle defects. The defects of dried red dates, such as small mold spots, fine dry streaks, and superficial pulp rot color changes, are very subtle and not obvious. The feature extraction network of the general target detection model cannot effectively capture these key information.
[0007] Third, the adaptability to complex scenes is poor. In actual processing lines, dates often appear in a dense arrangement, mutual overlap, and shielding state, with uneven lighting, projection shadows, and other interference. The existing model has a sharp increase in the miss rate and false detection rate under such complex scenes.
[0008] Fourthly, real-time and accuracy are difficult to balance. In order to realize the line deployment, the model must meet the requirements of lightweight and high speed. However, the existing high-performance model has a huge number of parameters and complex calculation (such as YOLO11 s, the number of parameters is 9.42M), which is difficult to run in real time on the resource-limited embedded device; and the lightweight model (such as YOLO11 n) has some compromises in detection accuracy.
[0009] In summary, the target detection model in the prior art is directly applied to the defect detection of dried jujube in the processing process, which has problems such as mismatch of fields, difficulty in detecting subtle defects, poor adaptability in complex scenes, and difficulty in balancing real-time and accuracy. The present application makes corresponding exploration to solve the problem. SUMMARY
[0010] The present application aims to solve the above problems and provide a dried jujube defect detection method, a corresponding device, an electronic equipment and a computer readable storage medium.
[0011] In order to achieve the various purposes of the present application, the present application adopts the following technical solutions:
[0012] A dried jujube defect detection method is proposed to adapt to one of the purposes of the present application, comprising:
[0013] In response to the dried jujube defect detection instruction, a to-be-detected dried jujube image containing a plurality of defective dried jujubes is obtained;
[0014] In the backbone network of the first jujube defect detection model, all ordinary convolution layers except the first layer of ordinary convolution layers are updated to GPR modules, part of the C3k2 modules are updated to DSDBM modules, and the CIoU loss function is updated to the improved WIoU loss function, to construct a second jujube defect detection model. The GPR module includes a main feature extraction branch, a residual compensation branch and an element-wise addition layer. The DSDBM module includes a detailed feature extraction branch, a semantic feature extraction branch and a feature splicing and compression fusion layer.
[0015] The to-be-detected dried jujube image is input into the second jujube defect detection model trained to a convergent state, to detect each defective dried jujube in the to-be-detected dried jujube image, to complete the defect detection of the dried jujube.
[0016] Optionally, the main feature extraction branch includes a group convolution layer with a convolution kernel size of 1x1, a point-wise convolution layer with a convolution kernel size of 1x1 and a maximum pooling layer with a pooling kernel size of 3x3 connected in sequence; and the residual compensation branch includes a convolution layer with a convolution kernel size of 1x1.
[0017] The detailed feature extraction branch includes a 1×1 convolutional layer and multiple reparameterized convolutional layers connected in sequence; the semantic feature extraction branch includes a 3×3 convolutional layer, a 3×3 dilated convolutional layer, and a channel attention module connected in sequence; the feature concatenation, compression, and fusion layer includes a channel dimension concatenation layer and a 1×1 convolutional layer; wherein each reparameterized convolutional layer includes a 1×1 convolutional layer and a 3×3 convolutional layer connected in sequence;
[0018] The backbone network of the second jujube defect detection model includes a regular convolutional layer, a first GPR module, a first DSDBM module, a second GPR module, a second DSDBM module, a third GPR module, a first C3k2 module, a fourth GPR module, a second C3k2 module, an SPPF module, and a C2PSA module connected in sequence.
[0019] Optionally, the step of inputting the image of the dried red dates to be detected into a second red date defect detection model that has been trained to a convergent state to detect each defective dried red date in the image of the dried red dates to be detected includes:
[0020] In the backbone network of the second jujube defect detection model, the image of the dried jujube to be detected is first input into the ordinary convolutional layer of the backbone network, and the initial dried jujube feature map is obtained through convolution operation;
[0021] The initial dried jujube feature map is input to the first GPR module, and is processed sequentially by a 1×1 grouped convolutional layer, a 1×1 pointwise convolutional layer, and a 3×3 max pooling layer in the main feature extraction branch. At the same time, it is processed by a 3×3 convolutional layer in the residual compensation branch, and then fused by an element-wise addition layer to output the first enhanced feature map.
[0022] The first enhanced feature map is input into the first DSDBM module. Subtle defect features are extracted through a 1×1 convolutional layer and multiple reparameterized convolutional layers in the detail feature extraction branch. Global semantic features are extracted through a 3×3 convolutional layer, a 3×3 dilated convolutional layer, and a channel attention module in the semantic feature extraction branch. The second enhanced feature map is then output through a feature splicing, compression, and fusion layer.
[0023] The second enhanced feature map is processed sequentially through the second GPR module, the second DSDBM module, the third GPR module, the first C3k2 module, the fourth GPR module, and the second C3k2 module to obtain the third enhanced feature map after multiple rounds of optimization.
[0024] The third enhanced feature map is input to the SPPF module for multi-scale feature aggregation, and then input to the C2PSA module to enhance the defect features through the attention mechanism, and outputs the jujube defect discrimination feature map;
[0025] Based on the defect discrimination feature map of the jujube, the detection head network of the second jujube defect detection model detects each defective dried jujube in the image of the dried jujube to be detected, so as to complete the defect detection of the dried jujube.
[0026] Optionally, the step of inputting the image of the dried red dates to be detected into a second red date defect detection model that has been trained to a convergent state to detect each defective dried red date in the image of the dried red dates to be detected includes:
[0027] Obtain the dried jujube feature map corresponding to the image of the dried jujube to be detected;
[0028] In the main feature extraction branch of the first GPR module, the dried red date feature map is grouped by channel and convolutional operation is performed by a grouped convolutional layer with a convolutional kernel size of 1×1 to determine the grouped convolutional result. The grouped convolutional result is then fully fused by a pointwise convolutional layer with a convolutional kernel size of 1×1 and the number of channels is doubled to determine the pointwise convolutional result. The pointwise convolutional result is then downsampled by a max pooling layer with a pooling kernel size of 3×3 to output the first dried red date feature map. The first dried red date feature map represents the key defects and contour features of the dried red date after channel optimization and dimension compression.
[0029] Meanwhile, in the residual compensation branch of the first GPR module, the dried red date feature map is subjected to convolution operation by a convolutional layer with a kernel size of 1×1 to double the number of channels and adjust the spatial size, so as to output a second dried red date feature map. The second dried red date feature map represents the supplementation and repair of the subtle defect features of dried red dates lost during the downsampling process of the main feature extraction branch.
[0030] In the element-wise addition layer of the first GPR module, the first dried jujube feature map and the second dried jujube feature map are added element-wise to determine the first enhanced feature map. The first enhanced feature map is then transmitted to subsequent network layers. The first enhanced feature map represents the enhanced dried jujube defect features that combine high-discrimination defect features and subtle defect features.
[0031] Optionally, the step of inputting the image of the dried red dates to be detected into a second red date defect detection model that has been trained to a convergent state to detect each defective dried red date in the image of the dried red dates to be detected includes:
[0032] Obtain the dried jujube feature map corresponding to the image of the dried jujube to be detected;
[0033] In the detail feature extraction branch of the first DSDBM module, the dried red date feature map is compressed by a convolutional layer with a kernel size of 1×1, and then feature extraction and cross-scale fusion are performed sequentially by multiple reparameterized convolutional layers to output a detail feature map that represents the subtle defects of dried red dates.
[0034] Meanwhile, in the semantic feature extraction branch of the first DSDBM module, local spatial correlation features are extracted by downsampling through a convolutional layer with a kernel size of 3×3, and then the receptive field is expanded through a dilated convolutional layer with a kernel size of 3×3 to capture global contextual semantic features. The channel attention module is used to weight and strengthen the channel features that are strongly related to defects, and outputs a semantic feature map that represents the overall scene of dried red dates and the larger defect area.
[0035] In the channel dimension splicing layer of the feature splicing, compression and fusion layer of the first DSDBM module, the detail feature map and the semantic feature map are spliced in the channel dimension, and then channel compression and feature fusion are performed through a convolutional layer with a kernel size of 1×1 to obtain a second enhanced feature map containing subtle defect details and global semantic information. The second enhanced feature map is then transmitted to subsequent network layers.
[0036] Optionally, the steps for training the second jujube defect detection model include:
[0037] Obtain a sample training set, wherein the sample training set includes multiple training samples and their corresponding sample labels. Each training sample represents an image of dried red dates containing multiple defective dried red dates. The sample label represents the annotation information corresponding to the dried red date target in each training sample. The annotation information includes the true bounding box of the dried red date defect and its corresponding red date defect category.
[0038] The sample training set is input into the constructed second jujube defect detection model. An improved WIoU loss function is used to calculate the loss value between the model's prediction results and the labeled information. The model parameters are updated through backpropagation. The formula for calculating the improved WIoU loss function is as follows:
[0039]
[0040] in, ρ represents the value of the improved WIoU loss function; IoU represents the intersection-union ratio, which is the ratio of the overlap area of the predicted bounding box of the dried red date defect to the union area of the manually labeled true bounding box, and its value ranges from 0 to 1. The larger the IoU, the more accurate the bounding box localization; 2 (b,b gt ) represents the predicted bounding box center b and the actual bounding box center b of defects in dried red dates.gt The squared Euclidean distance is used to quantify the deviation between the center position of the predicted bounding box and the true bounding box for defects in dried red dates; c 2 The square of the diagonal length of the minimum bounding rectangle between the predicted and actual bounding boxes for defects in dried red dates; λ IoU This represents the weighting coefficients associated with IoU; This represents the monotonic focusing coefficient term; the smaller the IoU, the better. The smaller the value, the greater the loss contribution to hard-to-detect defects in dried red dates, allowing the model to prioritize optimizing these samples; α represents the focus loss weight, used to balance the focus loss term L. Focus The proportion of contribution to the total loss; L Focus This represents the dynamic focusing loss term, used to suppress the loss contribution of easy samples and amplify the loss contribution of difficult samples, making the model training more focused on the hard-to-detect defects in dried red dates.
[0041] During training, after each iteration, the model performance is evaluated using a validation set. If the model performance does not improve within a preset number of iterations, an early stopping mechanism is triggered to terminate training. If the early stopping mechanism is not triggered, training continues until the preset maximum number of iterations is reached, resulting in a second jujube defect detection model that has been trained to convergence.
[0042] Optionally, the basic network architecture of the first jujube defect detection model is the original YOLO11 n model, and the basic network architecture of the second jujube defect detection model is the improved YOLO11 n model; the defective dried jujubes include one or more of the following: cracked jujubes, rotten jujubes, dried strips of jujubes, moldy jujubes, and jujubes with rotten pulp.
[0043] A defect detection device for dried red dates, provided for another purpose of this application, includes:
[0044] The jujube image acquisition module is configured to respond to the dried jujube defect detection command and acquire an image of the dried jujube to be detected containing multiple defective dried jujubes.
[0045] The detection model construction module is configured to update all ordinary convolutional layers except the first ordinary convolutional layer to GPR modules, update some C3k2 modules to DSDBM modules, and update the CIoU loss function to an improved WIoU loss function in the backbone network of the first jujube defect detection model to construct the second jujube defect detection model. The GPR module includes a main feature extraction branch, a residual compensation branch, and an element-wise addition layer. The DSDBM module includes a detail feature extraction branch, a semantic feature extraction branch, and a feature concatenation, compression, and fusion layer.
[0046] The jujube defect detection module is configured to input the image of the dried jujube to be detected into a second jujube defect detection model that has been trained to convergence, so as to detect each defective dried jujube in the image of the dried jujube to be detected, thereby completing the defect detection of the dried jujube.
[0047] An electronic device provided for another purpose of this application includes a central processing unit and a memory, the central processing unit being configured to invoke and run a computer program stored in the memory to perform the steps of the dried jujube defect detection method of this application.
[0048] A computer-readable storage medium is provided for another purpose of this application, which stores, in the form of computer-readable instructions, a computer program implemented according to the described method for detecting defects in dried jujubes, which, when invoked by a computer, executes the steps included in the corresponding method.
[0049] Compared to existing technologies, this application addresses the problem that directly applying existing target detection models to the defect detection of dried jujubes during processing suffers from issues such as domain mismatch, difficulty in detecting minute defects, poor adaptability to complex scenarios, and difficulty in balancing real-time performance and accuracy. This application offers the following advantages, including but not limited to:
[0050] Firstly, existing methods for detecting defects in jujubes are prone to false negatives and missed detections in cases of minute defects (such as early mold and small cracks) and dense occlusion. This application, however, amplifies the loss contribution of difficult-to-detect samples through the WIoU v3 loss function (combined with a dynamic focusing mechanism), allowing the model to focus more on optimizing minute and ambiguous defects, significantly improving the detection accuracy of such defects. Simultaneously, the dual-branch design of the DSDBM module preserves details of subtle defects such as mold spots and dry streaks while capturing global scene semantics, effectively solving the recognition challenge in cases of dense jujube occlusion and significantly reducing the false negative rate.
[0051] Secondly, this application uses the grouped convolution and pointwise convolution design of the GPR module, which reduces the number of parameters and computation to only 22.2% of that of ordinary convolution. Combined with the anchorless framework advantage of the YOLO11 model, real-time inference can be achieved on embedded devices, which is fully adapted to the conveyor belt speed of the dried jujube processing line, balancing accuracy and efficiency.
[0052] Thirdly, this application achieves hierarchical improvement of features from initial extraction, detailed semantic fusion, multi-scale optimization, and defect attention enhancement through multiple rounds of GPR module and DSDBM module iteration, SPPF multi-scale aggregation, and C2PSA attention enhancement. This enables the model to accurately identify defects in jujubes of different sizes and shapes (such as rotten jujubes, mold, and cracks), avoiding the problems of poor generalization caused by the single feature level in the existing technology.
[0053] In summary, this application provides a high-precision, high-efficiency, and robust solution for defect detection in dried jujubes, promoting the technological upgrade of intelligent agricultural product processing. Attached Figure Description
[0054] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, wherein:
[0055] Figure 1 This is a flowchart illustrating the defect detection method for dried red dates in this application embodiment;
[0056] Figure 2 This is an exemplary network architecture diagram of the improved YOLO11 n model in the embodiments of this application;
[0057] Figure 3 This is an exemplary network architecture diagram of the GPR module in the embodiments of this application;
[0058] Figure 4 This is an exemplary network architecture diagram of the DSDBM module in the embodiments of this application;
[0059] Figure 5 This is a schematic diagram of the dried jujube defect detection device in the embodiments of this application;
[0060] Figure 6 This is a schematic diagram of the structure of the computer device in the embodiments of this application. Detailed Implementation
[0061] The embodiments of this application are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain this application, and should not be construed as limiting this application.
[0062] Those skilled in the art will understand that, unless specifically stated otherwise, the singular forms “a,” “an,” “the,” and “the” used herein may also include the plural forms. It should be further understood that the term “comprising” as used in this application means the presence of the stated features, integers, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof. It should be understood that when we say an element is “connected” or “coupled” to another element, it can be directly connected or coupled to the other element, or there may be intermediate elements. Furthermore, “connected” or “coupled” as used herein can include wireless connections or wireless coupling. The term “and / or” as used herein includes all or any units and all combinations of one or more associated listed items.
[0063] It will be understood by those skilled in the art that, unless otherwise defined, all terms used herein (including technical and scientific terms) have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains. It should also be understood that terms such as those defined in general dictionaries should be understood to have the same meaning as in the context of the prior art, and should not be interpreted in an idealized or overly formal sense unless specifically defined as herein.
[0064] Those skilled in the art will understand that the terms "client," "terminal," and "terminal device" as used herein include both devices that receive wireless signals, devices that only possess wireless signal receiver capabilities without transmission capabilities, and devices with receiving and transmitting hardware, devices that have receiving and transmitting hardware capable of bidirectional communication over a bidirectional communication link. Such devices may include: cellular or other communication devices such as personal computers or tablets, having single-line displays, multi-line displays, or cellular or other communication devices without multi-line displays; PCS (Personal Communications Service) that can combine voice, data processing, fax, and / or data communication capabilities; PDA (Personal Digital Assistant) that may include a radio frequency receiver, pager, internet / intranet access, web browser, notepad, calendar, and / or GPS (Global Positioning System) receiver; and conventional laptops and / or handheld computers or other devices that have and / or include radio frequency receivers. As used herein, "client," "terminal," and "terminal device" can be portable, transportable, installed in a means of transportation (air, sea, and / or land), or suitable and / or configured to operate locally and / or in a distributed manner, operating in any other location on Earth and / or in space. "Client," "terminal," and "terminal device" as used herein can also be a communication terminal, an internet access terminal, or a music / video playback terminal, such as a PDA, a MID (Mobile Internet Device), and / or a mobile phone with music / video playback capabilities, or a smart TV, set-top box, etc.
[0065] The hardware referred to by the names "server," "client," and "service node" in this application is essentially an electronic device with the equivalent capabilities of a personal computer. It is a hardware device with the necessary components revealed by the von Neumann architecture, such as a central processing unit (including an arithmetic logic unit and a control unit), memory, input devices, and output devices. The computer program is stored in its memory, and the central processing unit loads the program stored in the secondary storage into the main memory to run it, execute the instructions in the program, and interact with the input and output devices to complete specific functions.
[0066] It should be noted that the concept of "server" used in this application can also be extended to the case of server clusters. Based on the network deployment principles understood by those skilled in the art, the servers should be logically divided. Physically, these servers can be independent of each other but accessible through interfaces, or they can be integrated into a single physical computer or a computer cluster. Those skilled in the art should understand this flexibility and should not use it to constrain the implementation of the network deployment method in this application.
[0067] One or more of the technical features of this application, unless explicitly specified herein, can be deployed on a server and accessed by a client remotely calling the online service interface provided by the server, or can be directly deployed and run on a client for access.
[0068] Unless otherwise specified, the neural network models referenced or potentially referenced in this application may be deployed on a remote server and invoked remotely on the client, or deployed on a client with the capability to invoke directly. In some embodiments, when running on the client, the corresponding intelligence may be acquired through transfer learning in order to reduce the requirements on the client's hardware resources and avoid excessive consumption of the client's hardware resources.
[0069] Unless otherwise specified, all data involved in this application may be stored remotely on a server or on a local terminal device, as long as it is suitable for use by the technical solution of this application.
[0070] Those skilled in the art will understand that although the various methods in this application are described based on the same concept and thus present commonality among them, they can be performed independently unless otherwise specified. Similarly, the various embodiments disclosed in this application are all based on the same inventive concept; therefore, concepts expressed in the same way, as well as concepts that are appropriately changed for convenience but are expressed differently, should be understood equivalently.
[0071] Unless otherwise expressly stated, the various embodiments disclosed in this application can be combined in a cross-cutting manner to flexibly construct new embodiments, as long as such combination does not depart from the inventive spirit of this application and can meet the needs of the prior art or solve a certain deficiency in the prior art. Those skilled in the art should be aware of such modifications.
[0072] Please see Figure 1 In one embodiment of the method for detecting defects in dried jujubes according to this application, the method includes:
[0073] Step S10: Respond to the dried red date defect detection command and acquire an image of the dried red dates to be detected containing multiple defective dried red dates;
[0074] The dried jujube defect detection system in the terminal device can respond to the dried jujube defect detection command and acquire an image of dried jujubes to be detected containing multiple defective dried jujubes; wherein, the defective dried jujubes include one or any combination of cracked jujubes, rotten jujubes, dried strips of jujubes, moldy jujubes, and rotten pulp jujubes.
[0075] Specifically, the experimental material consisted of dried jujubes from a certain region. Based on the "Dried Jujube Quality Grading Standard," six categories were selected: cracked jujubes, rotten jujubes, dried jujubes, moldy jujubes, rotten jujubes, and normal jujubes. Normal jujubes were whole fruits that met the jujube standards, with smooth surfaces and no obvious defects in the skin. Decayed jujubes showed signs of partial rot on the surface, appearing as large black patches and some depressions. Dried jujubes indicated a lack of internal moisture, resulting in numerous shriveled lines on the surface. Moldy jujubes showed a single black mold spot on the surface, a precursor to rotten jujubes and a relatively minor defect. Cracked jujubes showed one or two long, deep cracks on the surface.
[0076] Furthermore, an industrial camera was used to acquire images in a simulated processing environment. The conveyor belt speed was set to 0.2 m / s, and the vertical distance between the camera and the conveyor belt was 40 cm. The original images were obtained by extracting video frames.
[0077] Data annotation and preprocessing: The acquired images were meticulously annotated using the X-AnyLabeling tool according to the aforementioned grading standards. The annotation categories included: Normal, Decay, Damaged, Dry, Mold, and Cracked. The original 720×1080 resolution images were uniformly cropped to the standard input size of 640×640 for YOLO series models. Finally, after screening, 769 high-quality images were obtained for constructing the dataset, containing a total of 1987 labeled targets.
[0078] Data Augmentation and Dataset Splitting: To improve the model's generalization ability and alleviate sample imbalance, various offline data augmentation processes were performed on the original images, including horizontal mirroring, vertical mirroring, contrast enhancement, and random brightness adjustment. The number of images in the training and validation sets was expanded to 3690 and 924, respectively. All data were divided into training and test sets in an 8:2 ratio to ensure the fairness of model evaluation.
[0079] Step S20: In the backbone network of the first jujube defect detection model, all ordinary convolutional layers except the first ordinary convolutional layer are updated to GPR modules, some C3k2 modules are updated to DSDBM modules, and the CIoU loss function is updated to the improved WIoU loss function to construct the second jujube defect detection model. The GPR module includes a main feature extraction branch, a residual compensation branch, and an element-wise addition layer. The DSDBM module includes a detail feature extraction branch, a semantic feature extraction branch, and a feature concatenation, compression, and fusion layer.
[0080] Please see Figure 2After acquiring images of dried red dates containing multiple defects, the backbone network of the first red date defect detection model is updated by replacing all ordinary convolutional layers (except the first ordinary convolutional layer) with GPR modules, replacing some C3k2 modules with DSDBM modules, and replacing the CIoU loss function with an improved WIoU loss function to construct the second red date defect detection model. The GPR module includes a main feature extraction branch, a residual compensation branch, and an element-wise addition layer; the DSDBM module includes a detail feature extraction branch, a semantic feature extraction branch, and a feature concatenation, compression, and fusion layer. The basic network architecture of the first red date defect detection model is the original YOLO11 n model, and the basic network architecture of the second red date defect detection model is an improved YOLO11 n model. The model is named YOLO11-GDW. The main feature extraction branch includes a grouped convolutional layer with a 1×1 kernel, a pointwise convolutional layer with a 1×1 kernel, and a max-pooling layer with a 3×3 kernel, all connected in sequence. The residual compensation branch includes a convolutional layer with a 1×1 kernel. The detail feature extraction branch includes a convolutional layer with a 1×1 kernel and multiple reparameterized convolutional layers, all connected in sequence. The semantic feature extraction branch includes a convolutional layer with a 3×3 kernel, a dilated convolutional layer with a 3×3 kernel, and a channel attention layer, all connected in sequence. The force module; the feature splicing compression fusion layer includes a channel dimension splicing layer and a convolutional layer with a kernel size of 1×1; wherein, each reparameterized convolutional layer includes a convolutional layer with a kernel size of 1×1 and a convolutional layer with a kernel size of 3×3 connected in sequence; the backbone network in the second jujube defect detection model includes a normal convolutional layer, a first GPR module, a first DSDBM module, a second GPR module, a second DSDBM module, a third GPR module, a first C3k2 module, a fourth GPR module, a second C3k2 module, an SPPF module, and a C2PSA module connected in sequence.
[0081] Specifically, please refer to Figure 3 In the backbone network of the original YOLO11 n model, all ordinary convolutional layers except the first ordinary convolutional layer are updated to GPR modules (lightweight feature extraction modules based on grouped pointwise convolution and residual connections) to reduce feature coupling and computational burden. The GPR module includes a main feature extraction branch, a residual compensation branch, and an element-wise addition layer. The main feature extraction branch includes a grouped convolutional layer with a kernel size of 1×1, a pointwise convolutional layer with a kernel size of 1×1, and a max pooling layer with a kernel size of 3×3, connected in sequence. The residual compensation branch includes a convolutional layer with a kernel size of 1×1.
[0082] In the main feature extraction branch of the GPR module, firstly, grouped convolution operations are performed on the input channels with grouped convolutional layers with a kernel size of 1×1. This groups the input channels and performs independent convolutions, reducing cross-channel interaction and computational costs. Secondly, pointwise convolution with a kernel size of 1×1 is applied to perform full-channel interaction on the high-dimensional channel features output by the grouped convolutional layers, thereby avoiding the loss of cross-group related features. Simultaneously, increasing the number of groups achieves high-dimensional channel mapping, enabling different types of defect features to be represented independently. Finally, the feature map is downsampled using a max-pooling layer with a stride of 2 and a kernel size of 3×3.
[0083] In the residual compensation branch of the GPR module: the input channels are processed by a convolutional layer with a stride of 2 and a kernel size of 1×1, simultaneously achieving downsampling and channel number adjustment, and then feature fusion with the residual main feature extraction branch is completed.
[0084] In the element-wise addition layer of the GPR module, the outputs of the main feature extraction branch and the residual compensation branch are added element-wise.
[0085] With the above improvements, the number of parameters and the number of floating-point operations (FLOPs) of the GPR module in this application are only 22.2% of those of a regular convolutional layer. The number of parameters and computational complexity of the GPR module can be quantitatively characterized by the following formulas (1) and (2).
[0086] Let the height and width of the input feature map be h and w, respectively. The number of channels in the input feature map is C. in The number of channels in the output feature map is C. out Where k1 represents the kernel size of the grouped convolutional layer in the GPR module, k represents the kernel size of the ordinary convolutional layer, and g represents the number of groups in the grouped convolution; therefore, the formula for calculating the ratio between the number of parameters in the GPR module and the number of parameters in the ordinary convolutional layer is as follows:
[0087]
[0088] Params GPR Indicates the number of parameters in the GPR module; Params Conv C represents the number of parameters in a typical convolutional layer. in Indicates the number of channels in the input feature map; k1 represents the kernel size of the grouped convolutional layers in the GPR module; C out represents the number of channels in the output feature map; g represents the number of groups in the grouped convolution; k represents the kernel size of the ordinary convolutional layer.
[0089] Furthermore, the formula for calculating the ratio of the number of floating-point operations in the GPR module to the number of floating-point operations in a regular convolutional layer is as follows:
[0090]
[0091] Among them, FLOPs GPR Indicates the number of floating-point operations performed by the GPR module; FLOPS Conv The number of floating-point operations in a typical convolutional layer is represented by h; the height of the input feature map is represented by h; the width of the input feature map is represented by w; and C represents the number of floating-point operations in the input feature map. in C represents the number of channels in the input feature map; out The output feature map has the number of channels; k1 represents the kernel size of the grouped convolutional layers in the GPR module; and k represents the kernel size of the ordinary convolutional layers.
[0092] Taking the improved YOLO11 model of this application as an example, where the number of input channels is half the number of output channels in the backbone network, important conclusions can be drawn from formulas (1) and (2): the number of parameters and FLOPs of GPR are only 22.2% of those of ordinary convolutional layers. While greatly reducing the amount of computation, it maintains or even enhances the ability to extract key features such as defect color and shape.
[0093] In some embodiments, please refer to Figure 4 The C3k2 modules in the backbone network of the original YOLO11 n model will be updated to DSDBM modules to achieve collaborative extraction and fusion of local details and global semantic information. The DSDBM module includes a detail feature extraction branch, a semantic feature extraction branch, and a feature concatenation and compression fusion layer. The detail feature extraction branch includes a 1×1 convolutional layer and multiple reparameterized convolutional layers connected in sequence. The semantic feature extraction branch includes a 3×3 convolutional layer, a 3×3 dilated convolutional layer, and a channel attention module connected in sequence. The feature concatenation and compression fusion layer includes a channel dimension concatenation layer and a 1×1 convolutional layer. Each reparameterized convolutional layer includes a 1×1 convolutional layer and a 3×3 convolutional layer connected in sequence.
[0094] In the detail feature extraction branch of the DSDBM module, this branch first performs channel compression on the input feature map using a 1×1 convolutional layer. This reduces the dimensionality and computational cost of subsequent modules, laying the foundation for efficient fine-grained feature extraction. Secondly, it employs stacked reparameterized convolutional (RepConv) layers. Each reparameterized convolutional layer includes a 1×1 kernel layer and a 3×3 kernel layer connected sequentially. Within each reparameterized convolutional layer, the 1×1 kernel layer focuses on key local features of small objects, while the 3×3 kernel layer facilitates cross-scale fusion of high- and low-order features. This detail feature extraction branch focuses on extracting high-resolution spatial detail features such as the edges, fine lines, and tiny mold spots of jujubes.
[0095] In the semantic feature extraction branch of the DSDBM module, this branch first performs downsampling using a convolutional layer with a stride of 2 and a kernel size of 3×3, compressing the spatial dimension while initially extracting local spatial relationships between the jujubes. Secondly, it introduces a dilated convolutional layer with a dilation rate of 2 and a kernel size of 3×3. Essentially, this sets fixed-interval sampling points within the kernel, making the actual receptive field of the 3×3 kernel equivalent to 7×7. Finally, it connects to the Channel Attention module. Through global average pooling and adaptive weight learning of channel features, it assigns higher weights to channels strongly correlated with defects (such as color changes in rotten areas and texture distribution in moldy areas), achieving selective enhancement of key semantic features. This branch focuses on acquiring wide receptive field contextual semantic information of the image to understand the overall scene and larger defect areas.
[0096] In the feature concatenation, compression, and fusion layer of the DSDBM module, the output feature maps of the detail feature extraction branch and the semantic feature extraction branch are concatenated along the channel dimension. Then, a 1x1 convolution is used for channel compression and fusion to form a unified feature representation rich in multi-scale information.
[0097] As can be seen from the above embodiments, in the backbone network of the original YOLO11 n model, some C3k2 modules are updated to DSDBM modules, which effectively alleviates the problem of information loss in the feature extraction process. It is particularly suitable for detecting subtle defects (such as mold and rot) and handling densely occluded scenes.
[0098] In some embodiments, the step of training the second jujube defect detection model includes:
[0099] Step S201: Obtain a sample training set, wherein the sample training set includes multiple training samples and their corresponding sample labels. Each training sample represents an image of dried red dates containing multiple defective dried red dates. The sample label represents the annotation information corresponding to the dried red date target in each training sample. The annotation information includes the true bounding box of the dried red date defect and its corresponding red date defect category.
[0100] Step S202: Input the sample training set into the constructed second jujube defect detection model, use the improved WIoU loss function to calculate the loss value between the model prediction result and the annotation information, and update the model parameters through backpropagation;
[0101] Step S203: During the training process, after each iteration, the model performance is evaluated using a validation set. If the model performance does not improve within a preset number of iterations, an early stopping mechanism is triggered to terminate the training. If the early stopping mechanism is not triggered, training continues until the preset maximum number of iterations is reached, resulting in a second jujube defect detection model that has been trained to a convergent state.
[0102] Specifically, the improved WIoU (Wise-IoU) loss function replaces the CIoU loss function in the original YOLO11 n model, optimizing the regression accuracy of bounding boxes, particularly improving the localization ability for low-quality samples (such as small targets or occluded targets). The improved WIoU loss function in this application not only considers basic factors such as aspect ratio, center distance, and overlap area, but also cleverly introduces a dynamic non-monotonic focusing mechanism. Furthermore, it uses a carefully designed gradient gain allocation strategy to evaluate anchor box quality, dynamically adjusting the level of attention to different targets based on the sample quality.
[0103] Furthermore, the original expression for the WIoU loss function is:
[0104]
[0105] in, ρ represents the value of the original WIoU loss function; IoU represents the intersection-union ratio, which is the ratio of the overlap area of the predicted bounding box of the dried red date defect to the union area of the manually labeled true bounding box, and its value ranges from 0 to 1. The larger the IoU, the more accurate the bounding box localization; 2 (b,b gt ) represents the predicted bounding box center b and the actual bounding box center b of defects in dried red dates. gt The squared Euclidean distance is used to quantify the deviation between the center position of the predicted bounding box and the true bounding box for defects in dried red dates; c 2 The square of the diagonal length of the minimum bounding rectangle between the predicted and actual bounding boxes for defects in dried red dates; λ IoUL represents the weighting coefficient related to IoU; IoU This represents the IoU basic loss term.
[0106] By incorporating the monotonic focusing coefficient into the above formula (3), the improved WIoU (Wise-IoU) loss function of this application is derived, which can effectively reduce the negative impact of direct samples on the loss value. This adaptive adjustment enables the model to prioritize extreme samples, thereby enhancing its classification performance. The formula for calculating the improved WIoU (Wise-IoU) loss function is expressed as follows:
[0107]
[0108] in, ρ represents the value of the improved WIoU (Wise-IoU) loss function; IoU represents the intersection-union ratio, which is the ratio of the overlap area of the predicted bounding box of defects in dried red dates to the union area of the manually labeled true bounding boxes, and its value ranges from 0 to 1. The larger the IoU, the more accurate the bounding box localization; 2 (b,b gt ) represents the predicted bounding box center b and the actual bounding box center b of defects in dried red dates. gt The squared Euclidean distance is used to quantify the deviation between the center position of the predicted bounding box and the true bounding box for defects in dried red dates; c 2 The square of the diagonal length of the minimum bounding rectangle between the predicted and actual bounding boxes for defects in dried red dates; λ IoU This represents the weighting coefficients associated with IoU; This represents the monotonic focusing coefficient term; the smaller the IoU, the better. The smaller the value, the greater the contribution to the loss of hard-to-detect defects in dried jujubes (such as early mold, small cracks, etc.), allowing the model to prioritize optimizing these types of samples. α represents the focus loss weight, used to balance the focus loss term L. Focus The contribution ratio of α to the total loss can be adjusted according to the needs of the dried jujube defect detection scenario. For example, for datasets with a high proportion of minor defects, α can be increased to enhance the focusing effect. Focus This represents the dynamic focusing loss term, used to suppress the loss contribution of easy samples (such as obviously rotten dates) and amplify the loss contribution of difficult samples (such as tiny mold spots), making the model training more focused on the difficult-to-detect defects in dried dates.
[0109] Step S30: Input the image of dried red dates to be detected into the second red date defect detection model that has been trained to convergence state, so as to detect each defective dried red date in the image of dried red dates to be detected, thereby completing the defect detection of dried red dates.
[0110] In the backbone network of the first jujube defect detection model, all ordinary convolutional layers except the first ordinary convolutional layer are updated to GPR modules, some C3k2 modules are updated to DSDBM modules, and the CIoU loss function is updated to the improved WIoU loss function. After constructing the second jujube defect detection model, the dried jujube image to be detected is input into the second jujube defect detection model that has been trained to convergence, so as to detect each defective dried jujube in the image to be detected, thereby completing the defect detection of dried jujube.
[0111] In some embodiments, the step of inputting the image of dried red dates to be detected into a second red date defect detection model that has been trained to a convergent state to detect various defective dried red dates in the image of dried red dates to be detected includes:
[0112] Step S31: In the backbone network of the second jujube defect detection model, the image of the dried jujube to be detected is first input into the ordinary convolutional layer of the backbone network, and the initial dried jujube feature map is obtained through convolution operation.
[0113] Step S32: The initial dried red date feature map is input to the first GPR module, and is processed sequentially by a 1×1 grouped convolutional layer, a 1×1 pointwise convolutional layer, and a 3×3 max pooling layer in the main feature extraction branch. At the same time, it is processed by a 3×3 convolutional layer in the residual compensation branch, and then fused by an element-wise addition layer to output the first enhanced feature map.
[0114] Step S33: Input the first enhanced feature map into the first DSDBM module, extract subtle defect features through a 1×1 convolutional layer and multiple reparameterized convolutional layers in the detail feature extraction branch, extract global semantic features through a 3×3 convolutional layer, a 3×3 dilated convolutional layer and a channel attention module in the semantic feature extraction branch, and then output the second enhanced feature map through a feature splicing, compression and fusion layer.
[0115] Step S34: The second enhanced feature map is processed sequentially through the second GPR module, the second DSDBM module, the third GPR module, the first C3k2 module, the fourth GPR module, and the second C3k2 module to obtain the third enhanced feature map after multiple rounds of optimization;
[0116] Step S35: The third enhanced feature map is input to the SPPF module for multi-scale feature aggregation, and then input to the C2PSA module to enhance the defect features through the attention mechanism, and outputs the jujube defect discrimination feature map;
[0117] Step S36: Based on the defect discrimination feature map of the jujube, the detection head network of the second jujube defect detection model is used to detect each defective dried jujube in the image of the dried jujube to be detected, so as to complete the defect detection of the dried jujube.
[0118] As shown in steps S31 to S36 above, initial features are extracted using ordinary convolutional layers, laying the foundation for subsequent processing. The first GPR module combines main feature extraction and residual compensation to enhance feature representation under lightweight conditions, improving the ability to capture minute defects. The first DSDBM module, through multi-scale feature fusion of detail and semantic branches, accurately extracts minute defects such as mold spots and cracks while grasping global semantics, solving the recognition problem in dense scenes. Through multiple rounds of iterative optimization of the GPR and DSDBM modules, feature representation is continuously strengthened to adapt to defects of different sizes and shapes. The SPPF and C2PSA modules aggregate multi-scale features and strengthen defect attention, highlighting key defect information. The detection head network finally achieves accurate defect localization and classification. The overall process, from feature extraction and enhancement to discrimination, is progressive, effectively reducing the false negative and false positive rates, improving the detection accuracy of minute, occluded, and blurred defects, and meeting the real-time and efficient detection needs of the dried jujube processing line.
[0119] In a further embodiment, the step of inputting the image of the dried red dates to be detected into a second red date defect detection model that has been trained to a convergent state to detect each defective dried red date in the image of the dried red dates to be detected includes:
[0120] Step S301: Obtain the dried jujube feature map corresponding to the image of the dried jujube to be detected;
[0121] Step S302: In the main feature extraction branch of the first GPR module, the dried red date feature map is grouped by channel and convolutional operation is performed by a grouped convolutional layer with a convolutional kernel size of 1×1 to determine the grouped convolutional result. The grouped convolutional result is then fully fused by a pointwise convolutional layer with a convolutional kernel size of 1×1 and the number of channels is doubled to determine the pointwise convolutional result. The pointwise convolutional result is then downsampled by a max pooling layer with a pooling kernel size of 3×3 to output the first dried red date feature map. The first dried red date feature map represents the key defects and contour features of the dried red date after channel optimization and dimension compression.
[0122] Step S303: Simultaneously, in the residual compensation branch of the first GPR module, the dried red date feature map is subjected to convolution operation through a convolutional layer with a kernel size of 1×1 to double the number of channels and adjust the spatial size, so as to output a second dried red date feature map. The second dried red date feature map represents the supplementation and repair of the subtle defect features of dried red dates lost during the downsampling process of the main feature extraction branch.
[0123] Step S304: In the element-wise addition layer of the first GPR module, the first dried jujube feature map and the second dried jujube feature map are added element-wise to determine the first enhanced feature map. The first enhanced feature map is then transmitted to the subsequent network layer. The first enhanced feature map represents the enhanced dried jujube defect features that combine high-discrimination defect features and subtle defect features.
[0124] As shown in steps S301 to S304 above, the main feature extraction branch uses 1×1 grouped convolution, pointwise convolution, and max pooling to achieve channel optimization and dimensionality compression, accurately capturing key defects and contour features of dried jujubes. The residual compensation branch uses 1×1 convolution to supplement and repair the subtle defect features lost in the downsampling of the main branch. In S304, element-wise addition is used to fuse the two types of features, forming a first enhanced feature map that combines high discriminative power with subtle defect information. Subsequently, through multi-scale detail and semantic feature fusion of the DSDBM module, multiple rounds of GPR and C3k2 module iterative optimization, SPPF multi-scale aggregation, and C2PSA attention enhancement, the detection head accurately locates and classifies defects. The overall process, from feature extraction and enhancement to discrimination, is progressive, effectively improving the recognition rate of difficult-to-detect defects such as tiny mold spots and thin cracks, reducing false negatives and missed detections in dense and occluded scenes, and meeting the high-efficiency and accurate detection requirements of dried jujube processing lines.
[0125] In a further embodiment, the step of inputting the image of the dried red dates to be detected into a second red date defect detection model that has been trained to a convergent state to detect each defective dried red date in the image of the dried red dates to be detected includes:
[0126] Step S3001: Obtain the dried jujube feature map corresponding to the image of the dried jujube to be detected;
[0127] Step S3002: In the detail feature extraction branch of the first DSDBM module, the dried red date feature map is compressed by a convolutional layer with a kernel size of 1×1, and then feature extraction and cross-scale fusion are performed sequentially by multiple reparameterized convolutional layers to output a detail feature map that represents the subtle defects of dried red dates.
[0128] Step S3003: Simultaneously, in the semantic feature extraction branch of the first DSDBM module, downsampling and local spatial correlation features are extracted through a convolutional layer with a kernel size of 3×3. Then, the receptive field is expanded through a dilated convolutional layer with a kernel size of 3×3 to capture global contextual semantic features. The channel attention module is used to weight and strengthen the channel features that are strongly related to defects, and outputs a semantic feature map representing the overall scene of dried red dates and the larger defect area.
[0129] Step S3004: In the channel dimension splicing layer of the feature splicing, compression and fusion layer of the first DSDBM module, the detail feature map and the semantic feature map are spliced in the channel dimension, and then channel compression and feature fusion are performed through a convolutional layer with a kernel size of 1×1 to obtain a second enhanced feature map containing subtle defect details and global semantic information. The second enhanced feature map is then transmitted to subsequent network layers.
[0130] As shown in steps S3001 to S3004 above, the dual-branch design of the first DSDBM module achieves a refined and global fusion of defect features in dried jujubes. The detail feature branch uses 1×1 convolutional channel compression and multiple reparameterized convolutions to accurately extract subtle defect features such as mold spots and cracks, preserving defect details. The semantic feature branch uses 3×3 convolutional downsampling and dilated convolutions to expand the receptive field, combined with channel attention to strengthen defect-related channels, capturing semantic information of the global scene and larger defects. Channel concatenation and 1×1 convolution fuse detail and semantic features to generate a second enhanced feature map that combines subtle defect details with global semantics. This process effectively solves the problems of lost defect details and insufficient global semantics in dried jujubes, accurately identifying small and vague defects while grasping the overall scene to avoid missed detections. It provides more comprehensive and discriminative feature support for subsequent detection, improving the accuracy and robustness of defect detection in complex scenarios.
[0131] In some embodiments, taking the deployment of a dried jujube defect detection system in a jujube processing plant as an example, the specific implementation process of this application is illustrated as follows:
[0132] Phase 1: System hardware deployment and environment setup
[0133] Set and stabilize the conveyor belt speed at 0.2 m / s. Install an industrial camera or equivalent image acquisition device with a large aperture and automatic focus tracking 40 cm directly above the conveyor belt on the jujube processing production line. This device will ensure that properly exposed and detailed images are captured under the production line's lighting conditions.
[0134] Deploy the computing unit: Select a server equipped with an NVIDIA Jetson AGX Orin edge computing module (or an NVIDIA RTX 4090 GPU) as the core computing device.
[0135] Software and data preparation:
[0136] Install the Ubuntu 22.04LTS operating system on the compute unit. Install Python 3.8+ and the PyTorch 2.1.2 deep learning framework, and configure the corresponding CUDA 11.8 and cuDNN acceleration libraries to ensure that model training and inference can be accelerated using the GPU.
[0137] Phase Two: Data Preparation and Preprocessing
[0138] Data Acquisition: Start the conveyor belt and image acquisition equipment to continuously record video of dried red dates randomly placed on the conveyor belt, with a total duration of about 40 minutes.
[0139] Video frame extraction and filtering: Using libraries such as OpenCV, one frame is extracted from the recorded video every 2 seconds to avoid high repetition of image information between adjacent frames. The extracted images are manually filtered to remove blurry, incomplete, or poor-quality images, ultimately retaining 769 valid images.
[0140] Data annotation: Using the X-AnyLabeling annotation tool, each jujube in the image was meticulously annotated strictly according to the "Xinjiang Dried Jujube Fruit Quality Grading Standard" (DB65 / T 4296-2020). Six categories were categorized: Normal, Decayed, Damaged, Dried, Moldy, and Cracked. The annotation information was saved as a YOLO format txt file.
[0141] Image preprocessing and enhancement:
[0142] All labeled images were uniformly scaled or center-cropped to 640x640 pixels to meet the model's input requirements. To improve the model's generalization ability and robustness, offline data augmentation was performed on the training set images. Specific augmentation methods included: random horizontal flipping, random vertical flipping, random adjustment of image contrast (scaling factor range 0.8-1.2), and random adjustment of image brightness (scaling factor range 0.8-1.2). Through augmentation, the number of training set images was expanded from 615 to 3690.
[0143] Dataset partitioning: The augmented dataset is randomly divided into a training set (3690 images) and a test set (924 images) in an 8:2 ratio to ensure that the distribution ratio of each category of samples in the two sets is basically the same.
[0144] Phase 3: Model Training and Optimization
[0145] Model Construction: Based on the PyTorch framework, the original YOLO11 n model is loaded as a baseline. As described in this application, three core improvements are made:
[0146] Replace all standard convolutional layers (except the first layer) in the backbone and neck networks with GPR modules.
[0147] Replace the C3k2 module in the backbone network with the DSDBM module.
[0148] Replace CIoU with WIoU v3 in the bounding box regression loss function.
[0149] Training parameter settings:
[0150] Optimizer: Stochastic gradient descent (SGD) is used, and momentum is set to 0.937.
[0151] Learning rate: The initial learning rate (lr0) is set to 0.01 and decays using a cosine annealing scheduling strategy.
[0152] Weight decay: set to 0.005 to prevent overfitting.
[0153] Batch size: Set to 32 based on GPU memory.
[0154] Training rounds: The maximum number of training rounds is set to 300, and the early stopping mechanism is enabled. If the validation set performance does not improve for 50 consecutive rounds, training will be automatically terminated.
[0155] Execute training: Load the prepared training and validation sets into the data loader and start the training process. Monitor the changes in the loss function curve and evaluation metrics (such as mAP@0.5) to ensure that the training process converges normally.
[0156] Phase 4: Model Deployment and System Operation
[0157] Model Export: After training, the optimal YOLO11-GDW model weights are exported in ONNX format to optimize inference efficiency on edge devices.
[0158] Deployment and Integration: Load the optimized model file into the deployed Jetson edge computing device. Develop the host computer software, which needs to implement the following functions:
[0159] The camera driver is invoked to capture the video stream from the conveyor belt in real time.
[0160] Each frame of the image is preprocessed (scaled to 640x640, normalized).
[0161] The preprocessed image is input into the YOLO11-GDW model to perform inference.
[0162] The output of the analytical model yields the bounding box coordinates, class label, and confidence score for each detected target.
[0163] Online inspection and sorting:
[0164] The system runs continuously, monitoring the dates on the conveyor belt in real time.
[0165] When a defective date is detected, the host computer software immediately sends a trigger signal to the connected sorting actuator (such as a solenoid valve-controlled nozzle) via serial port or GPIO.
[0166] Under precise timing control, the sorting mechanism blows defective dates off the production line, thereby achieving automated grading.
[0167] By implementing the above four stages, a complete intelligent detection and sorting system for defects in dried jujubes based on this application can be constructed and operated. This embodiment fully demonstrates that the technical solution of this application is feasible and repeatable, and can effectively solve the various problems raised in the prior art.
[0168] In some embodiments, the improved YOLO11 n model of this application includes the following advantages:
[0169] Firstly, the detection accuracy is significantly improved: On the self-built defect dataset of dried red dates, the YOLO11-GDW model of this invention achieved an mAP of 89.8%@0.5, which is 4.2 percentage points higher than the original YOLO11 n model (85.6%).
[0170] Secondly, the model is lightweight and highly efficient: the final model has only 2.89M parameters, a model size of 5.1MB, and a computational complexity of 8.5 GFLOPs. While maintaining high accuracy, it has the potential to be deployed on edge devices, meeting real-time detection requirements.
[0171] Thirdly, it exhibits strong robustness: ablation experiments and visualization results confirm that, in complex scenarios such as dense jujube fruit and shadow occlusion, the present invention significantly reduces the false negative rate and false positive rate compared to the baseline model, demonstrating stronger environmental adaptability.
[0172] To comprehensively evaluate the detection performance of the YOLO11-GDW model, six representative object detection models were selected for comparative experiments. These models included SSD, DETR, RT-DETR-L, YOLOv8n, YOLO11n, and YOLO11s. All models were trained and tested on the same defective jujube dataset, using the same training parameters and evaluation criteria to ensure fairness in the comparison. The comparison results are shown in Table 1.
[0173] Table 1 Performance Comparison of Different Target Detection Models
[0174]
[0175] In comparison, YOLO11-GDW achieves an optimal balance in terms of precision, recall, mAP, and lightweighting, fully demonstrating the effectiveness of the improved YOLO11 n model in this application.
[0176] The module synergy effect is obvious: the three improvements, GPR, DSDBM and WIoU, work together to optimize the model from the three levels of feature extraction, multi-scale fusion and localization regression, and jointly contribute to the final performance improvement.
[0177] To systematically evaluate the contribution of each improved module to the model performance, this application designed an ablation experiment. Using the original YOLO11 n model as a baseline, the GPR module, DSDBM module, and WIoU loss function were added sequentially to analyze the independent role and synergistic effect of each component.
[0178] Table 2 shows the average accuracy of different model configurations across various defect categories; AP1 to AP6 represent the average accuracy of six categories: pulp rot, rotten dates, dry strips, mold, normal, and cracks, respectively; Table 3 compares the overall performance indicators of different model configurations from a macroscopic perspective.
[0179] Table 2 Comparison of average accuracy for each defect category in ablation experiments.
[0180]
[0181] Table 3 Comparison of comprehensive performance in ablation experiments
[0182]
[0183] As can be seen from the above embodiments, compared with the prior art, the present application directly applies the target detection model in the prior art to the defect detection of dried red dates in the processing process, which has problems such as domain mismatch, difficulty in detecting subtle defects, poor adaptability to complex scenarios, and difficulty in balancing real-time performance and accuracy. The present application has, but is not limited to, the following beneficial effects:
[0184] Firstly, existing methods for detecting defects in jujubes are prone to false negatives and missed detections in cases of minute defects (such as early mold and small cracks) and dense occlusion. This application, however, amplifies the loss contribution of difficult-to-detect samples through the WIoU v3 loss function (combined with a dynamic focusing mechanism), allowing the model to focus more on optimizing minute and ambiguous defects, significantly improving the detection accuracy of such defects. Simultaneously, the dual-branch design of the DSDBM module preserves details of subtle defects such as mold spots and dry streaks while capturing global scene semantics, effectively solving the recognition challenge in cases of dense jujube occlusion and significantly reducing the false negative rate.
[0185] Secondly, this application uses the grouped convolution and pointwise convolution design of the GPR module, which reduces the number of parameters and computation to only 22.2% of that of ordinary convolution. Combined with the anchorless framework advantage of the YOLO11 model, real-time inference can be achieved on embedded devices, which is fully adapted to the conveyor belt speed of the dried jujube processing line, balancing accuracy and efficiency.
[0186] Thirdly, this application achieves hierarchical improvement of features from initial extraction, detailed semantic fusion, multi-scale optimization, and defect attention enhancement through multiple rounds of GPR module and DSDBM module iteration, SPPF multi-scale aggregation, and C2PSA attention enhancement. This enables the model to accurately identify defects in jujubes of different sizes and shapes (such as rotten jujubes, mold, and cracks), avoiding the problems of poor generalization caused by the single feature level in the existing technology.
[0187] In summary, this application provides a high-precision, high-efficiency, and robust solution for defect detection in dried jujubes, promoting the technological upgrade of intelligent agricultural product processing.
[0188] Please see Figure 5 A defect detection device for dried red dates provided for one of the purposes of this application includes a red date image acquisition module 1100, a detection model construction module 1200, and a defect detection module 1300. The red date image acquisition module 1100 is configured to acquire an image of dried red dates containing multiple defective dried red dates in response to a dried red date defect detection command. The detection model construction module 1200 is configured to update all ordinary convolutional layers except the first ordinary convolutional layer to GPR modules, update some C3k2 modules to DSDBM modules, and update the CIoU loss function to an improved WIoU loss function in the backbone network of the first red date defect detection model to construct a second red date defect detection model. The GPR module includes a main feature extraction branch, a residual compensation branch, and an element-wise addition layer. The DSDBM module includes a detail feature extraction branch, a semantic feature extraction branch, and a feature concatenation, compression, and fusion layer. The red date defect detection module 1300 is configured to input the image of dried red dates to be detected into the second red date defect detection model that has been trained to convergence to detect each defective dried red date in the image of dried red dates to be detected, thereby completing the defect detection of dried red dates.
[0189] Based on any embodiment of this application, please refer to Figure 6 Another embodiment of this application also provides an electronic device, which can be implemented by a computer device, such as... Figure 6The diagram shows the internal structure of a computer device. The computer device includes a processor, a computer-readable storage medium, a memory, and a network interface connected via a system bus. The computer-readable storage medium stores an operating system, a database, and computer-readable instructions. The database may store control information sequences. When the computer-readable instructions are executed by the processor, the processor can implement a method for detecting defects in dried red dates. The processor provides computing and control capabilities to support the operation of the entire computer device. The memory stores computer-readable instructions, which, when executed by the processor, can cause the processor to execute the method for detecting defects in dried red dates as described in this application. The network interface of the computer device is used for communication with a terminal. Those skilled in the art will understand that… Figure 6 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0190] In this embodiment, the processor is used to execute... Figure 5 The specific functions of each module are defined within the device, and the memory stores the program code and various data required to execute these modules. A network interface is used for data transmission between the user terminal and the server. In this embodiment, the memory stores the program code and data required to execute all modules in the dried jujube defect detection device of this application, and the server can call the server's program code and data to execute the functions of all modules.
[0191] This application also provides a storage medium storing computer-readable instructions, which, when executed by one or more processors, cause the one or more processors to perform the steps of the dried jujube defect detection method described in any embodiment of this application.
[0192] This application also provides a computer program product, including a computer program / instructions that, when executed by one or more processors, implement the steps of the dried jujube defect detection method described in any embodiment of this application.
[0193] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments of this application can be implemented by a computer program instructing related hardware. This computer program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the methods described above. The aforementioned storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.
[0194] The above description is only a partial embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A method for detecting defects in dried jujubes, characterized in that, include: In response to the dried jujube defect detection command, acquire an image of the dried jujube to be detected containing multiple defective dried jujubes; In the backbone network of the first jujube defect detection model, all ordinary convolutional layers except the first ordinary convolutional layer are updated to GPR modules, some C3k2 modules are updated to DSDBM modules, and the CIoU loss function is updated to the improved WIoU loss function to construct the second jujube defect detection model. The GPR module includes a main feature extraction branch, a residual compensation branch, and an element-wise addition layer. The DSDBM module includes a detail feature extraction branch, a semantic feature extraction branch, and a feature concatenation, compression, and fusion layer. The image of the dried red dates to be detected is input into the second red date defect detection model that has been trained to convergence, so as to detect each defective dried red date in the image of the dried red dates to be detected, thereby completing the defect detection of the dried red dates.
2. The method for detecting defects in dried jujubes according to claim 1, characterized in that, The main feature extraction branch includes a grouped convolutional layer with a kernel size of 1×1, a pointwise convolutional layer with a kernel size of 1×1, and a max pooling layer with a kernel size of 3×3, connected in sequence; the residual compensation branch includes a convolutional layer with a kernel size of 1×1. The detailed feature extraction branch includes a 1×1 convolutional layer and multiple reparameterized convolutional layers connected in sequence; the semantic feature extraction branch includes a 3×3 convolutional layer, a 3×3 dilated convolutional layer, and a channel attention module connected in sequence; the feature concatenation, compression, and fusion layer includes a channel dimension concatenation layer and a 1×1 convolutional layer; wherein each reparameterized convolutional layer includes a 1×1 convolutional layer and a 3×3 convolutional layer connected in sequence; The backbone network of the second jujube defect detection model includes a regular convolutional layer, a first GPR module, a first DSDBM module, a second GPR module, a second DSDBM module, a third GPR module, a first C3k2 module, a fourth GPR module, a second C3k2 module, an SPPF module, and a C2PSA module connected in sequence.
3. The method for detecting defects in dried jujubes according to claim 2, characterized in that, The step of inputting the image of dried red dates to be detected into a second red date defect detection model that has been trained to convergence, in order to detect each defective dried red date in the image of dried red dates to be detected, includes: In the backbone network of the second jujube defect detection model, the image of the dried jujube to be detected is first input into the ordinary convolutional layer of the backbone network, and the initial dried jujube feature map is obtained through convolution operation; The initial dried jujube feature map is input to the first GPR module, and is processed sequentially by a 1×1 grouped convolutional layer, a 1×1 pointwise convolutional layer, and a 3×3 max pooling layer in the main feature extraction branch. At the same time, it is processed by a 3×3 convolutional layer in the residual compensation branch, and then fused by an element-wise addition layer to output the first enhanced feature map. The first enhanced feature map is input into the first DSDBM module. Subtle defect features are extracted through a 1×1 convolutional layer and multiple reparameterized convolutional layers in the detail feature extraction branch. Global semantic features are extracted through a 3×3 convolutional layer, a 3×3 dilated convolutional layer, and a channel attention module in the semantic feature extraction branch. The second enhanced feature map is then output through a feature splicing, compression, and fusion layer. The second enhanced feature map is processed sequentially through the second GPR module, the second DSDBM module, the third GPR module, the first C3k2 module, the fourth GPR module, and the second C3k2 module to obtain the third enhanced feature map after multiple rounds of optimization. The third enhanced feature map is input to the SPPF module for multi-scale feature aggregation, and then input to the C2PSA module to enhance the defect features through the attention mechanism, and outputs the jujube defect discrimination feature map; Based on the defect discrimination feature map of the jujube, the detection head network of the second jujube defect detection model detects each defective dried jujube in the image of the dried jujube to be detected, so as to complete the defect detection of the dried jujube.
4. The method for detecting defects in dried jujubes according to claim 2, characterized in that, The step of inputting the image of dried red dates to be detected into a second red date defect detection model that has been trained to convergence, in order to detect each defective dried red date in the image of dried red dates to be detected, includes: Obtain the dried jujube feature map corresponding to the image of the dried jujube to be detected; In the main feature extraction branch of the first GPR module, the dried red date feature map is grouped by channel and convolutional operation is performed by a grouped convolutional layer with a convolutional kernel size of 1×1 to determine the grouped convolutional result. The grouped convolutional result is then fully fused by a pointwise convolutional layer with a convolutional kernel size of 1×1 and the number of channels is doubled to determine the pointwise convolutional result. The pointwise convolutional result is then downsampled by a max pooling layer with a pooling kernel size of 3×3 to output the first dried red date feature map. The first dried red date feature map represents the key defects and contour features of the dried red date after channel optimization and dimension compression. Meanwhile, in the residual compensation branch of the first GPR module, the dried red date feature map is subjected to convolution operation by a convolutional layer with a kernel size of 1×1 to double the number of channels and adjust the spatial size, so as to output a second dried red date feature map. The second dried red date feature map represents the supplementation and repair of the subtle defect features of dried red dates lost during the downsampling process of the main feature extraction branch. In the element-wise addition layer of the first GPR module, the first dried jujube feature map and the second dried jujube feature map are added element-wise to determine the first enhanced feature map. The first enhanced feature map is then transmitted to subsequent network layers. The first enhanced feature map represents the enhanced dried jujube defect features that combine high-discrimination defect features and subtle defect features.
5. The method for detecting defects in dried jujubes according to claim 2, characterized in that, The step of inputting the image of dried red dates to be detected into a second red date defect detection model that has been trained to convergence, in order to detect each defective dried red date in the image of dried red dates to be detected, includes: Obtain the dried jujube feature map corresponding to the image of the dried jujube to be detected; In the detail feature extraction branch of the first DSDBM module, the dried red date feature map is compressed by a convolutional layer with a kernel size of 1×1, and then feature extraction and cross-scale fusion are performed sequentially by multiple reparameterized convolutional layers to output a detail feature map that represents the subtle defects of dried red dates. Meanwhile, in the semantic feature extraction branch of the first DSDBM module, local spatial correlation features are extracted by downsampling through a convolutional layer with a kernel size of 3×3, and then the receptive field is expanded through a dilated convolutional layer with a kernel size of 3×3 to capture global contextual semantic features. The channel attention module is used to weight and strengthen the channel features that are strongly related to defects, and outputs a semantic feature map that represents the overall scene of dried red dates and the larger defect area. In the channel dimension splicing layer of the feature splicing, compression and fusion layer of the first DSDBM module, the detail feature map and the semantic feature map are spliced in the channel dimension, and then channel compression and feature fusion are performed through a convolutional layer with a kernel size of 1×1 to obtain a second enhanced feature map containing subtle defect details and global semantic information. The second enhanced feature map is then transmitted to subsequent network layers.
6. The method for detecting defects in dried jujubes according to any one of claims 1 to 5, characterized in that, The steps for training the second jujube defect detection model include: Obtain a sample training set, wherein the sample training set includes multiple training samples and their corresponding sample labels. Each training sample represents an image of dried red dates containing multiple defective dried red dates. The sample label represents the annotation information corresponding to the dried red date target in each training sample. The annotation information includes the true bounding box of the dried red date defect and its corresponding red date defect category. The sample training set is input into the constructed second jujube defect detection model. An improved WIoU loss function is used to calculate the loss value between the model's prediction results and the labeled information. The model parameters are updated through backpropagation. The formula for calculating the improved WIoU loss function is as follows: in, ρ represents the value of the improved WIoU loss function; IoU represents the intersection-union ratio, which is the ratio of the overlap area of the predicted bounding box of the dried red date defect to the union area of the manually labeled true bounding box, and its value ranges from 0 to 1. The larger the IoU, the more accurate the bounding box localization; 2 (b,b gt ) represents the predicted bounding box center b and the actual bounding box center b of defects in dried red dates. gt The squared Euclidean distance is used to quantify the deviation between the center position of the predicted bounding box and the true bounding box for defects in dried red dates; c 2 The square of the diagonal length of the minimum bounding rectangle between the predicted and actual bounding boxes for defects in dried red dates; λ IoU This represents the weighting coefficients associated with IoU; This represents the monotonic focusing coefficient term; the smaller the IoU, the better. The smaller the value, the greater the loss contribution to hard-to-detect defects in dried red dates, allowing the model to prioritize optimizing these samples; α represents the focus loss weight, used to balance the focus loss term L. Focus The proportion of contribution to the total loss; L Focus This represents the dynamic focusing loss term, used to suppress the loss contribution of easy samples and amplify the loss contribution of difficult samples, making the model training more focused on the hard-to-detect defects in dried red dates. During training, after each iteration, the model performance is evaluated using a validation set. If the model performance does not improve within a preset number of iterations, an early stopping mechanism is triggered to terminate training. If the early stopping mechanism is not triggered, training continues until the preset maximum number of iterations is reached, resulting in a second jujube defect detection model that has been trained to convergence.
7. The method for detecting defects in dried jujubes according to any one of claims 1 to 5, characterized in that, The basic network architecture of the first jujube defect detection model is the original YOLO11n model, and the basic network architecture of the second jujube defect detection model is the improved YOLO11n model; the defective dried jujubes include one or more of the following: cracked jujubes, rotten jujubes, dried strips of jujubes, moldy jujubes, and jujubes with rotten pulp.
8. A defect detection device for dried red dates, characterized in that, include: The jujube image acquisition module is configured to respond to the dried jujube defect detection command and acquire an image of the dried jujube to be detected containing multiple defective dried jujubes. The detection model construction module is configured to update all ordinary convolutional layers except the first ordinary convolutional layer to GPR modules, update some C3k2 modules to DSDBM modules, and update the CIoU loss function to an improved WIoU loss function in the backbone network of the first jujube defect detection model to construct the second jujube defect detection model. The GPR module includes a main feature extraction branch, a residual compensation branch, and an element-wise addition layer. The DSDBM module includes a detail feature extraction branch, a semantic feature extraction branch, and a feature concatenation, compression, and fusion layer. The jujube defect detection module is configured to input the image of the dried jujube to be detected into a second jujube defect detection model that has been trained to convergence, so as to detect each defective dried jujube in the image of the dried jujube to be detected, thereby completing the defect detection of the dried jujube.
9. An electronic device comprising a central processing unit and a memory, characterized in that, The central processing unit is used to invoke and run a computer program stored in the memory to perform the steps of the method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, It stores, in the form of computer-readable instructions, a computer program implemented according to any one of claims 1 to 7, which, when invoked by a computer, executes the steps included in the corresponding method.