X-ray-based traditional Chinese medicine decoction piece sorting method and system

Through dual-view X-ray imaging and deep learning technology, combined with deformable convolution and 3D convolution attention module, the problem of insufficient recognition accuracy in the stacking of Chinese herbal medicines is solved, and high-precision decoction sorting and air blowing control are achieved.

CN120094869AActive Publication Date: 2025-06-06四川省中药饮片有限责任公司

Patent Information

Application Number
CN202510578450.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-07
Publication Date
2025-06-06
Estimated Expiration
2045-05-07

AI Technical Summary

Technical Problem

In the prior art, when Chinese herbal medicines are partially or completely stacked, the recognition accuracy is insufficient and it is difficult to effectively sort.

Method used

Two-view X-ray imaging is used to obtain orthogonal projected images of the decoction to be sorted, combined with a deformable convolutional network and a 3D convolutional attention module, to enhance image feature extraction capabilities, and to improve model generalization capabilities through the generation of adversarial networks and Mixup strategies, and finally to combine kinematic models and array nozzle control to achieve sorting.

Benefits of technology

The overlapping target recognition rate and foreign object recognition signal-to-noise ratio are improved, the extraction accuracy of the characteristics of different forms of decoctions is enhanced, the air blowing hit rate and energy utilization rate are improved, and the error blowing rate and leakage detection rate are reduced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120094869A_ABST
    Figure CN120094869A_ABST
Patent Text Reader

Abstract

The invention provides a traditional Chinese medicine decoction piece sorting method and system based on X-rays, and relates to the technical field of decoction piece sorting. The traditional Chinese medicine decoction piece sorting method based on the X-rays specifically comprises the steps that orthogonal projection images of decoction pieces to be sorted are obtained through double-view-angle X-ray imaging, overlapping interference is compensated through a digital model, and the orthogonal projection images of the decoction pieces to be sorted are obtained; a deformable convolutional network is embedded to optimize image feature extraction; based on a Neck structure of YOLOv5, a 3D convolution attention module and a depth supervision mechanism are introduced to enhance the feature extraction capability of overlapped targets; utilizing a generative adversarial network to dynamically generate a shielding sample, and combining with a Mixup strategy to improve the generalization ability of the model; and sorting of the to-be-sorted decoction pieces is realized by combining a kinematic model and array type air tap control. According to the method, closed-loop control is formed through multi-dimensional perception of the imaging end, self-adaptive learning of the algorithm end and precise control of the execution end, and it can be effectively guaranteed that high sorting accuracy is still achieved under the application scene that the stacking rate of the decoction pieces is high.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of decoction piece sorting, and in particular to a method and system for sorting Chinese herbal medicine decoction pieces based on X-rays. Background Art

[0002] At present, in the process of automated sorting of Chinese herbal medicines, the sorting process is generally as follows: a conveyor belt is used to transport the pieces to be processed, and impurities and / or unqualified products in the pieces to be processed are first identified by X-rays at the conveyor belt. Then, an array of air blowpipes is set at the end of the conveyor belt to blow the identified impurities and unqualified products out of the flow trajectory of the pieces to be sorted.

[0003] However, there may be a certain degree of stacking of the Chinese herbal medicines to be sorted on the conveyor belt (for example, two Chinese herbal medicines overlap completely or partially). At this time, the Chinese herbal medicines that are stacked to a certain extent will form overlapping projections in the X-ray image (for example, the edge texture of the bottom layer of herbal medicines may be blocked by the upper objects). The current algorithm cannot accurately segment a single target and can easily misjudge this overlapping projection as impurities.

[0004] That is to say, the existing related technologies do not have sufficient recognition accuracy to meet the needs when the medicinal pieces to be sorted are partially or completely stacked. Summary of the invention

[0005] In order to solve the technical problems in the related art, the present invention provides a method and system for sorting Chinese herbal medicine slices based on X-ray.

[0006] In order to achieve the above object, the technical solution adopted by the present invention includes: According to a first aspect of the present invention, there is provided a method for sorting Chinese herbal medicine pieces based on X-rays, comprising: Step S1: Obtain orthogonal projection images of the medicinal pieces to be sorted through dual-view X-ray imaging, use a digital model to compensate for overlapping interference, and embed a deformable convolutional network to optimize image feature extraction; Step S2: Based on the Neck structure of YOLOv5, a 3D convolutional attention module and a deep supervision mechanism are introduced to enhance the feature extraction capability of overlapping targets; Step S3: Generate occlusion samples dynamically using the generative adversarial network and combine it with the Mixup strategy to improve the generalization ability of the model; Step S4: combining the kinematic model and array-type air nozzle control to achieve the sorting of the medicinal pieces to be sorted.

[0007] Optionally, the step S1 specifically includes: Step S1-1: Arrange two X-ray sources at an angle of 45° above the conveyor belt to obtain orthogonal projection images of the slices to be sorted; Step S1-2: Establish the dynamic compensation formula of the attenuation coefficient: In the formula, is the X-ray projection intensity after compensation, , and is the position parameter in the three-dimensional coordinate system, and is a dynamic compensation factor, which is updated in real time through Kalman filtering to adapt to the attenuation differences of different materials. is the linear attenuation coefficient of the upper particles, is the linear attenuation coefficient of the lower layer particles; Step S1-3: Embed the deformable convolutional network DCNv2 in the image preprocessing layer and dynamically adjust the convolution kernel sampling position of DCNv2 to adapt to the attenuation characteristics of different materials.

[0008] Optionally, the step S2 specifically includes: Step S2-1: Improve the Neck structure of YOLOv5 and construct a dual-path feature pyramid. Among them, the main path uses C3 module to extract global features; The auxiliary path is embedded in the 3D convolutional attention module, and its processing formula is: In the formula, is the activation function, is the first learnable weight matrix, is the average pooling operation, is the maximum pooling operation, is the input feature map, is the second learnable weight matrix, is element-wise multiplication, is the three-dimensional convolution kernel, is tensor multiplication; Step S2-2: Introduce a deep supervision mechanism, set auxiliary detection heads at the P3-P5 feature layers respectively, and perform weighted fusion of the loss functions of each feature layer: In the formula, is the total loss function, is the learnable dynamic weight corresponding to the P3 feature layer, is the Complete IoU loss applied to the P3 feature layer, is the learnable dynamic weight corresponding to the P4 feature layer, is the Distribution Focal Loss applied to the P4 feature layer, is the learnable dynamic weight corresponding to the P5 feature layer, is the target existence loss applied to the P5 feature layer.

[0009] Optionally, the step S3 specifically includes: Step S3-1: Construct a generative adversarial network enhancement system, where the generator G is used to create particle overlapping interference samples: In the formula, is a random noise vector, is the hyperbolic tangent activation function, is the weight matrix of the fully connected layer of the generator, is the feature vector of the real herbal medicine sample, Represents feature concatenation operation; Step S3-2: Improve the Mixup strategy to dynamic adversarial mixing: In the formula, For dynamically generated mixed samples, is the dynamic mixing scale factor, and ; Step S3-3: The discriminator D and the detector are optimized alternately, and the loss function is: In the formula, is an adversarial loss function used to jointly optimize the game process of the generator G and the discriminator D. Represents the discriminant output of the discriminator for the real medicinal material samples, Represents the discriminant output of the discriminator for the generated interference samples.

[0010] Optionally, the step S4 specifically includes: Step S4-1: Establish a kinematic model and dynamically adjust the air blowing delay time according to the conveyor belt speed: In the formula, is the delay time of air blowing, is the horizontal distance between the impurity position and the gas nozzle, is the real-time speed of the conveyor belt, is the speed fluctuation compensation coefficient and , is the air blowing response time; Step S4-2: construct an array air nozzle control system, and the pressure equation corresponding to each air nozzle is: In the formula, For the The output air pressure of each nozzle, is the base pressure coefficient, The target impurity and The vertical distance between the gas nozzles, is the pressure diffusion coefficient, is the confidence gain factor, To test confidence; Step S4-3: deploy a multi-target tracking algorithm to establish motion trajectory associations for suspected overlapping targets to reduce continuous false blows.

[0011] Optionally, the X-ray-based Chinese herbal medicine slice sorting method further comprises: Step S5: realizing impurity removal optimization through secondary detection and dynamic threshold adjustment.

[0012] Optionally, the step S5 specifically includes: Step S5-1: setting up secondary testing in the air blowing blanking area and collecting rejected samples for result verification; Step S5-2: Establish an online learning mechanism, and error samples automatically trigger model fine-tuning: In the formula, is the model parameter update amount, is the learning rate, is the gradient operation function, is the air blowing error sample data set, is the validation set loss function, is the regularization coefficient, are the current model parameters, are the initial model parameters; Step S5-2: Correct the detection sensitivity according to the environmental parameters: In the formula, is the adjusted detection sensitivity threshold, is the basic threshold, is the humidity change, is the temperature change.

[0013] According to the second aspect of the present invention, there is also provided a Chinese herbal medicine slice sorting system based on X-rays, which is applied to the Chinese herbal medicine slice sorting method based on X-rays described in any one of the technical solutions in the first aspect of the present invention, and the Chinese herbal medicine slice sorting system based on X-rays comprises: A dual-viewing angle X-ray imaging unit, comprising a linear array detector and two X-ray sources arranged at a 45° angle above the conveyor belt, for collecting orthogonal projection images of the slices to be sorted; A YOLOv5 model unit, wherein a 3D convolutional attention module and a deep supervision mechanism are introduced into the Neck structure of the YOLOv5 model; Generative adversarial network unit, used to generate occluded samples; The air blowing execution unit includes an array air nozzle group, a kinematic controller and a pressure regulator. The array air nozzle group includes a plurality of air nozzles arranged at equal intervals at the end of a conveyor belt; the kinematic controller is used to calculate the air blowing delay time according to the real-time speed of the conveyor belt, and the pressure regulator is used to adjust the air blowing pressure of the air nozzle.

[0014] According to the third aspect of the present application, a computer device is also provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the steps of the X-ray-based method for sorting Chinese herbal medicines described in any one of the technical solutions in the first aspect of the present application can be implemented.

[0015] According to the fourth aspect of the present application, a computer-readable storage medium is also provided, on which a computer program is stored. When the computer program is executed by a processor, it can implement the steps of the X-ray-based Chinese herbal medicine sorting method described in any technical solution in the first aspect of the present application.

[0016] Beneficial effects: 1. Through the above technical scheme, first, in step S1 of the present invention, the dual-view X-ray imaging and dynamic compensation mechanism can not only break through the geometric limitations of single-view projection and improve the recognition rate of overlapping targets, but also improve the signal-to-noise ratio of foreign body recognition through dynamic attenuation compensation. In addition, the extraction accuracy of features of medicinal materials of different forms can be improved through deformable convolution.

[0017] Second, in step S2 of the present invention, by introducing a 3D convolutional attention module and a deep supervision mechanism into the Neck structure of YOLOv5, not only can the mAP of overlapping target detection be improved through the 3D convolutional attention module, but also the small target missed detection rate can be reduced through the deep supervision mechanism.

[0018] Third, in step S3 of the present invention, through adversarial generation and dynamic Mixup strategies, it can be achieved that: the occluded samples generated by GAN can improve the F1-score of the model in overlapping scenes, and the dynamic mixing strategy can reduce the risk of overfitting and reduce the loss of the verification set.

[0019] Fourth, the coordinated control of the kinematic model and the array air nozzle can not only effectively improve the air blowing hit rate, but also effectively improve the air blowing energy utilization rate. In addition, it can also effectively reduce the misblowing rate.

[0020] In general, the method of the present invention forms a closed-loop control through multi-dimensional perception at the imaging end, adaptive learning at the algorithm end, and precise control at the execution end, which can effectively ensure a high sorting accuracy in application scenarios with a high stacking rate of medicinal pieces.

[0021] 2. Other beneficial effects or advantages of the present invention will be described in detail in the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without paying any creative labor.

[0023] in: Figure 1 It is a schematic flow chart of the steps of a method for sorting Chinese herbal medicine pieces based on X-rays provided by an exemplary embodiment of the present invention; Figure 2 It is a schematic diagram of the layout of an X-ray-based Chinese herbal medicine slice sorting system provided by an exemplary embodiment of the present invention.

[0024] Description of the reference numerals in the accompanying drawings: 100-X-ray based Chinese herbal medicine sorting system; 200-conveyor belt; 300-herbal medicine; 1-dual-view X-ray imaging unit; 2-YOLOv5 model unit; 3-generative adversarial network unit; 4-air blowing execution unit. DETAILED DESCRIPTION

[0025] The technical solution of the present invention is described in detail below with reference to the accompanying drawings.

[0026] According to a first aspect of the present invention, Figure 1 As shown, the present invention provides a method for sorting Chinese herbal medicine pieces based on X-ray, comprising: Step S1: obtaining 300 orthogonal projection images of the slices to be sorted by dual-view X-ray imaging, compensating for overlapping interference using a digital model, and embedding a deformable convolutional network to optimize image feature extraction; Step S2: Based on the Neck structure of YOLOv5, a 3D convolutional attention module and a deep supervision mechanism are introduced to enhance the feature extraction capability of overlapping targets; Step S3: Generate occlusion samples dynamically using the generative adversarial network and combine it with the Mixup strategy to improve the generalization ability of the model; Step S4: combining the kinematic model and array-type air nozzle control to achieve the sorting of the medicinal pieces 300 to be sorted.

[0027] Through the above technical scheme, first, in step S1 of the present invention, the dual-view X-ray imaging and dynamic compensation mechanism can not only break through the geometric limitations of single-view projection and improve the recognition rate of overlapping targets, but also improve the signal-to-noise ratio of foreign body recognition through dynamic attenuation compensation. In addition, the extraction accuracy of 300 features of medicinal pieces with different forms can be improved through deformable convolution.

[0028] Among them, for dual-view X-ray imaging, dual-view orthogonal projection can form the basis for three-dimensional information reconstruction. When the slices 300 are stacked on the plane of the conveyor belt 200 (XY axis), two X-ray sources at a 45° angle are projected along the XZ and YZ planes respectively, and the overlapping structure in the Z axis direction can be analyzed. For example, the upper layer of slices 300 is displayed as horizontal expansion in the XZ projection, and longitudinal compression in the YZ projection, and the stacking level is solved by the projection difference.

[0029] In addition, for deformable convolutional networks, DCNv2 uses deformable convolution kernel sampling position offset Adaptive adjustment: In the formula, is the offset prediction quantity, is the input feature map.

[0030] In this way, the convolution kernel can dynamically fit the edge of the medicinal material 300, and is particularly suitable for the irregular hole characteristics of insect-eaten medicinal materials.

[0031] Second, in step S2 of the present invention, by introducing a 3D convolutional attention module and a deep supervision mechanism into the Neck structure of YOLOv5, not only can the mAP (mean Average Precision) of overlapping target detection be improved through the 3D convolutional attention module, but also the small target missed detection rate can be reduced through the deep supervision mechanism.

[0032] Among them, for the 3D convolutional attention module, it can calculate the attention weight in the three-dimensional domain of channel-space-depth. , and its operation process is: In the formula, , and are the attention weight matrices of channel, space, and depth dimensions respectively. In this way, this structure can accurately capture the texture of the bottom layer of medicinal pieces that is blocked by the upper layer.

[0033] Third, in step S3 of the present invention, through adversarial generation and dynamic Mixup strategies, it can be achieved that: the occluded samples generated by GAN can improve the F1-score of the model in overlapping scenes, and the dynamic mixing strategy can reduce the risk of overfitting and reduce the loss of the verification set.

[0034] Among them, the generative adversarial network can learn the physical stacking rules of real medicinal materials through adversarial training. Its latent space encoding can include parameters such as position offset, transparency, texture variation, etc., and can generate occluded samples that conform to the actual sorting situation.

[0035] Fourth, the coordinated control of the kinematic model and the array air nozzle can not only effectively improve the air blowing hit rate, but also effectively improve the air blowing energy utilization rate. In addition, it can also effectively reduce the misblowing rate.

[0036] In general, the method of the present invention forms a closed-loop control through multi-dimensional perception at the imaging end, adaptive learning at the algorithm end, and precise control at the execution end, which can effectively ensure a high sorting accuracy in application scenarios with a high stacking rate of medicinal pieces 300.

[0037] In one embodiment of the present invention, step S1 of the present invention may specifically include: Step S1-1: Arrange two X-ray sources at an angle of 45° above the conveyor belt 200 to obtain orthogonal projection images of the slices to be sorted 300; Step S1-2: Establish the dynamic compensation formula of the attenuation coefficient: In the formula, is the X-ray projection intensity after compensation, , and is the position parameter in the three-dimensional coordinate system, and is a dynamic compensation factor, which is updated in real time through Kalman filtering to adapt to the attenuation differences of different materials. is the linear attenuation coefficient of the upper particles, is the linear attenuation coefficient of the lower layer particles; Step S1-3: Embed the deformable convolutional network DCNv2 in the image preprocessing layer and dynamically adjust the convolution kernel sampling position of DCNv2 to adapt to the attenuation characteristics of different materials.

[0038] Thus, in this embodiment, first, for step S1-1, by arranging the two X-ray sources at an angle of 45°, the spatial resolution can be effectively improved (for example, for thin slices of medicinal materials with a thickness of ≤3 mm, such as white peony slices, dual-view projection can resolve position differences of 0.2 mm in the Z-axis direction). At the same time, it can also effectively improve the overlap discrimination rate and provide more accurate spatial coordinate input for subsequent kinematic models.

[0039] It should be noted that for projection geometry modeling, the plane of the conveyor belt 200 can be set as the XY axis, the X-ray source A can be projected at 45° along the XZ plane, and the X-ray source B can be projected at 45° along the YZ plane. When the slice P1 is stacked on top of the slice P2: In the view of the X-ray source A, the projection of the slice P1 extends along the X axis. , is the stack height. In the view of X-ray source B, the projection of slice P1 extends along the Y axis. , calculate the stack height by the difference of two-view projection .

[0040] For example, in an application scenario, for example, angelica slices (impurities) are located above tuckahoe slices. In the existing related technology, angelica slices (with finer textures) and tuckahoe slices are both considered as impurities. In the dual-view projection of the present invention, in the view of X-ray source A, the angelica slices are extended by 3.2 mm along the X-axis, and in the view of X-ray source B, the angelica slices are extended by 3.2 mm along the Y-axis, so the stacking height can be determined. There is an independent object at 3.2mm. Combined with the difference in attenuation coefficients of Angelica and Poria in the material library, the two can be accurately distinguished.

[0041] Second, for step S2-1, the dynamic compensation factor is and It can be adapted to different types of medicinal pieces 300 (for example, mineral medicinal pieces or plant medicinal pieces) respectively to meet the needs of sorting medicinal pieces 300 of different materials. In this way, when a high linear attenuation coefficient area is detected, the weight of the corresponding layer can be automatically increased to reduce the influence of another layer of interference on the detection result. For example, in an exemplary embodiment, when mud blocks are mixed in the licorice slices and are transported on the conveyor belt 200, the mud blocks are located above or below the licorice slices. At this time, in the existing related technology, the attenuation difference between the licorice slices and the mud blocks will cause the X-ray image to be saturated, but it is impossible to accurately distinguish between the licorice slices and the mud blocks. In the method of the present invention, when the Kalman filter recognizes that the local linear attenuation coefficient is large, it will automatically adjust the weight of the corresponding layer. For example, when the mud block is above the licorice slice, at this time, the linear attenuation coefficient of the upper layer (that is, the mud block) is large, and the weight of the upper layer will be automatically adjusted (that is, Corresponding dynamic compensation factor ) increases, the weight of the lower layer (i.e., Corresponding dynamic compensation factor ) is reduced, so that the edge sharpness of the mud block will be improved in the compensated image, so as to accurately distinguish the licorice slices and mud blocks and accurately mark the position of the mud blocks.

[0042] Third, in step S1-3 of the present invention, by embedding the deformable convolutional network DCNv2 in the image preprocessing layer and dynamically adjusting the convolution kernel sampling position of DCNv2, the feature extraction accuracy of the irregular edges of worm-eaten medicinal pieces (for example, wormholes in white pieces) can be improved.

[0043] For example, in an exemplary embodiment, when it is necessary to remove the moth-eaten part of the Baibu slices and sort out the complete, non-moth-eaten Baibu slices, the standard 3×3 convolution kernel in the existing algorithm cannot fit the edge of the moth hole, resulting in blurring of the moth hole area in the feature map, and it is impossible to accurately distinguish between the moth-eaten Baibu slices and the non-moth-eaten Baibu slices. In the method of the present invention, the offset is the maximum offset generated by the moth-eaten edge, and the corrected sampling points will closely surround the moth hole edge, thereby making the recognition accuracy of the moth hole area better, and being able to accurately identify defective products with a moth hole area of ​​​​> 5%.

[0044] Take an implementation method of mixed sorting of mineral and plant medicinal pieces as an example.

[0045] The sorting process is to sort the medicinal material flow mixed with gypsum blocks (sorting target) and Poria peel (sorting impurities), with a stacking rate of 30%.

[0046] 1) Dual-view imaging.

[0047] X-ray source A detected abnormal expansion in the X-axis direction. ; X-ray source B detected abnormal expansion in the Y-axis direction. ; Calculated stack height It is 4.1mm.

[0048] 2) Identify the upper layer as having a low linear attenuation coefficient (Poria cocos peel, ), automatically adjust and , to strengthen the lower layer (gypsum blocks, ) of the projection contrast.

[0049] 3) The convolution kernel is generated at the edge of the gypsum block The pixel offset allows precise identification of the edge position of the plaster block.

[0050] In this way, the gypsum blocks and Poria cocos peels can be accurately distinguished, thereby ensuring the accuracy of sorting.

[0051] In this embodiment, it should be noted that First, in the dynamic compensation formula, the Kalman filter is updated in real time and , essentially building a state-space model: In the formula for The dynamic compensation factor at the moment, for The dynamic compensation factor at the moment, is the observation matrix, is the Kalman gain, is the actual measured linear attenuation coefficient, for The dynamic compensation factor at the moment, for The dynamic compensation factor at the moment.

[0052] In this way, the model can adjust the attenuation compensation coefficients of different materials (for example, mineral and plant pieces) online.

[0053] Second, the offset prediction network output is: Deformable convolution kernel at position The sampling point at is corrected to: In the formula, is the original position, is the learned offset.

[0054] In one embodiment of the present invention, step S2 of the present invention may specifically include: Step S2-1: Improve the Neck structure of YOLOv5 and construct a dual-path feature pyramid. The main path uses the C3 module to extract global features; the auxiliary path embeds the 3D convolution attention module, and its processing formula is: ; In the formula, is the activation function, is the first learnable weight matrix, is the average pooling operation, is the maximum pooling operation, is the input feature map, is the second learnable weight matrix, is element-wise multiplication, is the three-dimensional convolution kernel, is tensor multiplication; Step S2-2: Introduce a deep supervision mechanism, set auxiliary detection heads at the P3-P5 feature layers respectively, and perform weighted fusion of the loss functions of each feature layer: ; In the formula, is the total loss function, is the learnable dynamic weight corresponding to the P3 feature layer, is the Complete IoU loss applied to the P3 feature layer, is the learnable dynamic weight corresponding to the P4 feature layer, is the Distribution Focal Loss applied to the P4 feature layer, is the learnable dynamic weight corresponding to the P5 feature layer, is the target existence loss applied to the P5 feature layer.

[0055] In this implementation, we focus on improving the Neck structure of YOLOv5, and significantly improve the feature extraction capability in the overlapping scene of 300 Chinese herbal medicine pieces through the three-dimensional attention mechanism and deep supervision mechanism. Specifically, first, through the dual-path feature pyramid and 3D convolution attention module, not only can the overlapping target recognition be effectively enhanced, but also the fusion accuracy of the P3-P5 feature layer can be effectively improved. In addition, the computational efficiency can also be effectively improved (the dual-path design can increase the model parameters less on the basis of maintaining a certain FPS real-time performance).

[0056] Second, through the deep supervision mechanism and dynamic weighted loss, it can not only effectively achieve the recognition accuracy of small targets (for example, impurities ≤ 5mm), but also effectively strengthen the gradient propagation (through multi-level supervision, improve the efficiency of back propagation and accelerate the training convergence speed). In addition, through the learnable weights , and The model can be automatically adapted to different detection tasks (for example, the sorting of mineral and plant decoction pieces).

[0057] In this embodiment, it should be noted that, first, for the auxiliary path embedding 3D convolution attention module, it can accurately locate the edge texture of the blocked medicinal material 300 (for example, the wrinkled structure of Poria cocos). Second, for the weighted fusion formula of the loss function of each feature layer ( ), Optimize positioning accuracy, Enhance classification confidence, Reduce background misjudgment. For each learnable dynamic weight, the weight can be automatically adjusted according to the gradient contribution of each layer, that is, ,in, is 3 or 4 or 5, is the learning rate. For example, when processing high-density medicinal materials (e.g., calcined oysters), the learnable dynamic weights of the P5 layer Automatically enlarge to enhance deep semantic features.

[0058] In general, this implementation method constructs a deep learning architecture that adapts to the complex stacking scenario of 300 Chinese herbal medicine pieces through multi-dimensional feature fusion and dynamic supervision mechanism, providing core technical support for high-precision sorting.

[0059] In one embodiment of the present invention, step S3 of the present invention may specifically include: Step S3-1: Construct a generative adversarial network enhancement system, where the generator G is used to create particle overlapping interference samples: ; In the formula, is a random noise vector, is the hyperbolic tangent activation function, is the weight matrix of the fully connected layer of the generator, is the feature vector of the real herbal medicine sample, Represents feature concatenation operation; Step S3-2: Improve the Mixup strategy to dynamic adversarial mixing: ; In the formula, For dynamically generated mixed samples, is the dynamic mixing scale factor, and ; Step S3-3: The discriminator D and the detector are optimized alternately, and the loss function is: In the formula, is an adversarial loss function used to jointly optimize the game process of the generator G and the discriminator D. Represents the discriminant output of the discriminator for the real medicinal material samples, Represents the discriminant output of the discriminator for the generated interference samples.

[0060] In this embodiment, by generating highly realistic overlapping samples and optimizing model adversarial training, the generalization ability and robustness of the model in the scenario of stacking 300 Chinese herbal medicine pieces are significantly improved. Specifically, first, for step S3-1, the constructed generative adversarial network enhancement system can realize overlapping sample generation (generator G can synthesize overlapping samples of herbal medicine pieces consistent with the real scene, for example, the projection of angelica slices covering licorice slices, thereby increasing the proportion of overlapping samples in the training data).

[0061] For example, when generating a projection of a gypsum block (high attenuation coefficient) covering a mulberry leaf (low attenuation coefficient), the generator adjusts Weights to enhance the sharp edges of the plaster and the difference in the transmitted texture of the mulberry leaf in the stitching features.

[0062] Second, the dynamic mixing ratio factor of the dynamic adversarial mixing of the present invention , can dynamically control the weights of real samples and production samples, through random The value can simulate different degrees of occlusion (for example, complete occlusion and partial occlusion). Compared with the fixed-ratio mixing method of traditional Mixup, the dynamic mixing ratio factor of the present invention can make the model more adaptable to the random stacking scene in the real production line.

[0063] Third, in step S3-3 of the present invention, by alternately optimizing the discriminator and the detector, it is possible to achieve adversarial attack defense (the detection accuracy can be improved for adversarial samples with perturbations in projection intensity). Specifically, the discriminator D and the generator G compete by minimizing the adversarial loss, the detector and the discriminator are trained alternately, the detector learns anti-interference features by generating samples, and the discriminator drives the generator to approach the real data distribution, thereby improving the detection accuracy.

[0064] In one embodiment of the present invention, step S4 of the present invention may specifically include: Step S4-1: Establish a kinematic model and dynamically adjust the air blowing delay time according to the speed of the conveyor belt 200: ; In the formula, is the delay time of air blowing, is the horizontal distance between the impurity position and the gas nozzle, is the real-time speed of the conveyor belt 200, is the speed fluctuation compensation coefficient and , is the air blowing response time; Step S4-2: construct an array air nozzle control system, and the pressure equation corresponding to each air nozzle is: ; In the formula, For the The output air pressure of each nozzle, is the base pressure coefficient, The target impurity and The vertical distance between the gas nozzles, is the pressure diffusion coefficient, is the confidence gain factor, To test confidence; Step S4-3: deploy a multi-target tracking algorithm to establish motion trajectory associations for suspected overlapping targets to reduce continuous false blows.

[0065] In this embodiment, the focus is on dynamic kinematics prediction and adaptive air blowing control, and the problem of delayed sorting and high misblowing rate in stacking scenarios is solved by accurately modeling the motion trajectory of the slices 300 and the dynamic matching of the air blowing execution parameters. Specifically, first, for step S4-1, the kinematic model and delay compensation can improve the sorting timing accuracy (when there is a certain fluctuation in the speed of the conveyor belt 200, the speed fluctuation compensation coefficient can be used to compensate for the delay in the sorting sequence). , it can still effectively ensure that the air blowing touch time error is within a smaller range).

[0066] Second, for step S4-2, the dynamic regulation of the array-type air nozzle control can effectively improve the air pressure adaptability (that is, different air blowing pressures can be set according to different impurities to ensure the success rate of blowing away).

[0067] Third, in step S4-3 of the present invention, by establishing a motion trajectory association for the suspected overlapping targets, it is possible to avoid the array-type air nozzle from continuously blowing away two or more overlapping pieces of medicine 300, thereby reducing continuous misblowing.

[0068] In general, the present invention can effectively solve the problem of precise control of the sorting actuator in the stacking scenario through kinematic-air blowing closed-loop optimization, and provides core technical support for high-speed and high-density 300 sorting of Chinese herbal medicine slices.

[0069] In this embodiment, it should be noted that, first, for the air blowing delay time formula, is the speed fluctuation compensation coefficient, which can be dynamically adjusted according to the historical speed variance. For example, when the speed of the conveyor belt 200 drops suddenly from 0.8m / s to 0.7m / s, it can be adjusted by increasing , so that the air blowing delay time is increased, thereby ensuring the accurate timing of air blowing.

[0070] Second, for the air nozzle pressure equation, its physical meaning is: the closer the air nozzle is to the target, the higher the output air pressure, and the higher the detection confidence, the more overpressure injection is triggered.

[0071] In one embodiment of the present invention, the X-ray-based Chinese herbal medicine slice sorting method of the present invention may further include step S5: achieving impurity removal optimization through secondary detection and dynamic threshold adjustment.

[0072] Step S5 of the present invention may specifically include: Step S5-1: setting up secondary testing in the air blowing blanking area and collecting rejected samples for result verification; Step S5-2: Establish an online learning mechanism, and error samples automatically trigger model fine-tuning: In the formula, is the model parameter update amount, is the learning rate, is the gradient operation function, is the air blowing error sample data set, is the validation set loss function, is the regularization coefficient, are the current model parameters, are the initial model parameters; Step S5-2: Correct the detection sensitivity according to the environmental parameters: In the formula, is the adjusted detection sensitivity threshold, is the basic threshold, is the humidity change, is the temperature change.

[0073] In this implementation, a closed-loop process of "initial inspection-execution-re-inspection" is formed through secondary inspection of the air-blowing blanking area, thereby effectively reducing the false blow rate and missed detection rate. At the same time, the detection sensitivity is corrected by environmental parameters ( ), which can be applied to a variety of working conditions (for example, the texture conditions of different medicinal materials under different humidity and temperature conditions), and maintain a relatively stable detection sensitivity to reduce the misjudgment rate. In addition, the online learning mechanism automatically triggers the model fine-tuning formula through error samples ( ) to achieve parameter fine-tuning to ensure that the average accuracy meets actual needs.

[0074] It should be noted that, first, for the error sample to automatically trigger the model fine-tuning formula, the regularization term ( ) uses the Elastic Weight Consolidation strategy, which allows the model to learn new features (such as new impurities) while avoiding catastrophic forgetting. Weight update direction Guided by KL divergence loss, it ensures compatibility between new and old knowledge.

[0075] Second, for the detection sensitivity correction formula, Compensate for the density change caused by the hygroscopic expansion of medicinal materials. The term corresponds to the temperature drift of the detector (for example, the photoelectric conversion efficiency decreases by about 4.8% for every 10°C increase in temperature, and signal stability is maintained through exponential compensation).

[0076] In general, this implementation constructs an intelligent sorting system with self-diagnosis, self-learning and self-adaptation capabilities. Through the deep coupling of the physical detection layer and the digital twin layer, the open-loop process of the traditional sorting system is upgraded to a dynamic closed-loop system with continuous evolution capabilities.

[0077] According to a second aspect of the present invention, Figure 2 As shown, there is also provided an X-ray-based Chinese medicine decoction piece sorting system 100, which is applied to the X-ray-based Chinese medicine decoction piece sorting method of any technical solution in the first aspect of the present invention. The X-ray-based Chinese medicine decoction piece sorting system 100 comprises: A dual-viewing angle X-ray imaging unit 1, comprising a linear array detector and two X-ray sources arranged at an angle of 45° above the conveyor belt 200, for collecting orthogonal projection images of the slices to be sorted 300; YOLOv5 model unit 2, the 3D convolutional attention module and deep supervision mechanism are introduced into the Neck structure of the YOLOv5 model; Generate adversarial network unit 3, used to generate occlusion samples; The air blowing execution unit 4 includes an array air nozzle group, a kinematic controller and a pressure regulator. The array air nozzle group includes a plurality of air nozzles arranged at equal intervals at the end of the conveyor belt 200; the kinematic controller is used to calculate the air blowing delay time according to the real-time speed of the conveyor belt 200, and the pressure regulator is used to adjust the air blowing pressure of the air nozzle.

[0078] In this way, through the X-ray based Chinese herbal medicine sorting system 100 of the present invention, firstly, through the dual-view X-ray imaging and dynamic compensation mechanism, it is not only possible to break through the geometric limitations of single-view projection and improve the recognition rate of overlapping targets, but also to improve the signal-to-noise ratio of foreign body recognition through dynamic attenuation compensation. In addition, it is also possible to improve the extraction accuracy of features of herbal medicines of different morphologies through deformable convolution.

[0079] Second, by introducing the 3D convolutional attention module and deep supervision mechanism into the Neck structure of YOLOv5, not only can the mAP of overlapping target detection be improved through the 3D convolutional attention module, but also the missed detection rate of small targets can be reduced through the deep supervision mechanism.

[0080] Third, through adversarial generation and dynamic Mixup strategies, it can be achieved that: the occluded samples generated by GAN can improve the F1-score of the model in overlapping scenes, and the dynamic mixing strategy can reduce the risk of overfitting and reduce the loss of the validation set.

[0081] Fourth, the coordinated control of the kinematic model and the array air nozzle can not only effectively improve the air blowing hit rate, but also effectively improve the air blowing energy utilization rate. In addition, it can also effectively reduce the misblowing rate.

[0082] In general, the X-ray-based Chinese herbal medicine slice sorting system of the present invention forms a closed-loop control through multi-dimensional perception at the imaging end, adaptive learning at the algorithm end, and precise control at the execution end, which can effectively ensure a high sorting accuracy in application scenarios with a high stacking rate of herbal medicine slices.

[0083] According to the third aspect of the present application, a computer device is also provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the X-ray-based Chinese herbal medicine sorting method in any one of the technical solutions in the first aspect of the present application can be implemented.

[0084] It is understood that in this embodiment, the memory may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a read-only memory, a flash memory, a hard disk or a solid state drive; in addition, the memory may also include a combination of the above-mentioned types of memory. This application does not specifically limit this.

[0085] Similarly, the processor may be a processor that implements or executes various exemplary logic steps described in conjunction with the disclosure of the present application. The processor may be a central processing unit, a general-purpose processor, a digital signal processor, an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a transistor logic device, a hardware component, or any combination thereof. It may implement or execute various exemplary logic steps described in conjunction with the disclosure of the present application. The processor may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, and the like.

[0086] According to the fourth aspect of the present application, a computer-readable storage medium is also provided, on which a computer program is stored, characterized in that when the computer program is executed by a processor, it can implement the steps of the X-ray-based Chinese herbal medicine sorting method in any technical solution in the first aspect of the present application.

[0087] In this embodiment, the computer readable storage medium, for example, can be but not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or devices, or any combination of the above. More specific examples (non-exhaustive list) of computer readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (Random Access Memory, RAM), a read-only memory (Read-Only Memory, ROM), an erasable programmable read-only memory (Erasable Programmable Read Only Memory, EPROM), a register, a hard disk, an optical fiber, a portable compact disk read-only memory (Compact Disc Read-Only Memory, CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above, or any other form of computer readable storage medium known in the art. An exemplary storage medium is coupled to a processor so that the processor can read information from the storage medium and can write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC). In the embodiments of the present application, a computer-readable storage medium may be any tangible medium that contains or stores a program, which may be used by or in conjunction with an instruction execution system, apparatus, or device.

[0088] The above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

Claims

1. A method for sorting Chinese herbal medicine pieces based on X-ray, characterized in that: include: Step S1: Obtain orthogonal projection images of the medicinal pieces to be sorted through dual-view X-ray imaging, use a digital model to compensate for overlapping interference, and embed a deformable convolutional network to optimize image feature extraction; Step S2: Based on the Neck structure of YOLOv5, a 3D convolutional attention module and a deep supervision mechanism are introduced to enhance the feature extraction capability of overlapping targets; Step S3: Generate occlusion samples dynamically using the generative adversarial network and combine it with the Mixup strategy to improve the generalization ability of the model; Step S4: combining the kinematic model and array-type air nozzle control to achieve the sorting of the medicinal pieces to be sorted.

2. The method for sorting Chinese herbal medicine pieces based on X-ray according to claim 1, characterized in that: The step S1 specifically includes: Step S1-1: Arrange two X-ray sources at an angle of 45° above the conveyor belt to obtain orthogonal projection images of the slices to be sorted; Step S1-2: Establish the dynamic compensation formula of the attenuation coefficient: In the formula, is the X-ray projection intensity after compensation, , and is the position parameter in the three-dimensional coordinate system, and is a dynamic compensation factor, which is updated in real time through Kalman filtering to adapt to the attenuation differences of different materials. is the linear attenuation coefficient of the upper particles, is the linear attenuation coefficient of the lower layer particles; Step S1-3: Embed the deformable convolutional network DCNv2 in the image preprocessing layer and dynamically adjust the convolution kernel sampling position of DCNv2 to adapt to the attenuation characteristics of different materials.

3. The method for sorting Chinese herbal medicine slices based on X-ray according to claim 1, characterized in that: The step S2 specifically includes: Step S2-1: Improve the Neck structure of YOLOv5 and construct a dual-path feature pyramid. The main path uses the C3 module to extract global features; the auxiliary path embeds the 3D convolution attention module, and its processing formula is: In the formula, is the activation function, is the first learnable weight matrix, is the average pooling operation, is the maximum pooling operation, is the input feature map, is the second learnable weight matrix, is element-wise multiplication, is the three-dimensional convolution kernel, is tensor multiplication; Step S2-2: Introduce a deep supervision mechanism, set auxiliary detection heads at the P3-P5 feature layers respectively, and perform weighted fusion of the loss functions of each feature layer: In the formula, is the total loss function, is the learnable dynamic weight corresponding to the P3 feature layer, is the Complete IoU loss applied to the P3 feature layer, is the learnable dynamic weight corresponding to the P4 feature layer, is the Distribution Focal Loss applied to the P4 feature layer, is the learnable dynamic weight corresponding to the P5 feature layer, is the target existence loss applied to the P5 feature layer.

4. The method for sorting Chinese herbal medicine slices based on X-ray according to claim 1, characterized in that: The step S3 specifically includes: Step S3-1: Construct a generative adversarial network enhancement system, where the generator G is used to create particle overlapping interference samples: In the formula, is a random noise vector, is the hyperbolic tangent activation function, is the fully connected layer weight matrix of the generator, is the feature vector of the real herbal medicine sample, Represents feature concatenation operation; Step S3-2: Improve the Mixup strategy to dynamic adversarial mixing: In the formula, For dynamically generated mixed samples, is the dynamic mixing scale factor, and ; Step S3-3: The discriminator D and the detector are optimized alternately, and the loss function is: In the formula, is an adversarial loss function used to jointly optimize the game process of the generator G and the discriminator D. It represents the discriminant output of the discriminator for the real medicinal material samples. Represents the discriminant output of the discriminator for the generated interference samples.

5. The method for sorting Chinese herbal medicine pieces based on X-ray according to claim 1, characterized in that: The step S4 specifically includes: Step S4-1: Establish a kinematic model and dynamically adjust the air blowing delay time according to the conveyor belt speed: In the formula, is the delay time of air blowing, is the horizontal distance between the impurity position and the gas nozzle, is the real-time speed of the conveyor belt, is the speed fluctuation compensation coefficient and , is the air blowing response time; Step S4-2: construct an array air nozzle control system, and the pressure equation corresponding to each air nozzle is: In the formula, For the The output air pressure of each nozzle, is the base pressure coefficient, The target impurity and The vertical distance between the gas nozzles, is the pressure diffusion coefficient, is the confidence gain factor, To test confidence; Step S4-3: deploy a multi-target tracking algorithm to establish motion trajectory associations for suspected overlapping targets to reduce continuous false blows.

6. The method for sorting Chinese herbal medicine slices based on X-ray according to claim 1, characterized in that: The X-ray-based Chinese medicine slice sorting method also includes: Step S5: realizing impurity removal optimization through secondary detection and dynamic threshold adjustment.

7. The method for sorting Chinese herbal medicine slices based on X-ray according to claim 6, characterized in that: The step S5 specifically includes: Step S5-1: setting up secondary testing in the air blowing blanking area and collecting rejected samples for result verification; Step S5-2: Establish an online learning mechanism, and error samples automatically trigger model fine-tuning: In the formula, is the model parameter update amount, is the learning rate, is the gradient operation function, is the air blowing error sample data set, is the validation set loss function, is the regularization coefficient, are the current model parameters, are the initial model parameters; Step S5-2: Correct the detection sensitivity according to the environmental parameters: In the formula, is the adjusted detection sensitivity threshold, is the basic threshold, is the humidity change, is the temperature change.

8. A Chinese herbal medicine slice sorting system based on X-ray, characterized in that: The X-ray-based Chinese herbal medicine slice sorting method applied to any one of claims 1 to 7, wherein the X-ray-based Chinese herbal medicine slice sorting system comprises: A dual-viewing angle X-ray imaging unit, comprising a linear array detector and two X-ray sources arranged at a 45° angle above the conveyor belt, for collecting orthogonal projection images of the slices to be sorted; A YOLOv5 model unit, wherein a 3D convolutional attention module and a deep supervision mechanism are introduced into the Neck structure of the YOLOv5 model; Generative adversarial network unit, used to generate occluded samples; The air blowing execution unit includes an array air nozzle group, a kinematic controller and a pressure regulator. The array air nozzle group includes a plurality of air nozzles arranged at equal intervals at the end of a conveyor belt; the kinematic controller is used to calculate the air blowing delay time according to the real-time speed of the conveyor belt, and the pressure regulator is used to adjust the air blowing pressure of the air nozzle.

9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the X-ray-based Chinese herbal medicine slice sorting method described in any one of claims 1 to 7 can be implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the X-ray-based Chinese herbal medicine slice sorting method described in any one of claims 1 to 7 can be implemented.

Citation Information

Patent Citations

  • Automatic traditional Chinese medicine screening device based on machine vision

    CN109499919A

  • High speed, small footprint x-ray tomography inspection systems, devices, and methods

    CN110632673A

  • Separation and extraction method of X-ray overlapping object

    CN116310306A

  • Security check contraband detection method based on multi-scale attention and data enhancement

    CN116883933A

  • X-ray security check image dangerous goods detection algorithm based on YOLOv7

    CN117274774A

Cited By

  • Intelligent identifying and sorting method and system for traditional Chinese medicinal materials

    CN120599426A