Vaccine quality detection method
Through automated vaccine quality detection methods, the improved ResNet and YOLOv5 networks, combined with MS-Block module and Faiss vector search technology, the existing vaccine detection methods are solved by slow speed and relying on manual operations, and automatic detection with high accuracy and robustness is achieved.
Patent Information
- Application Number
- CN202311607226.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-28
- Publication Date
- 2025-06-06
AI Technical Summary
The existing vaccine testing methods are slow, rely on manual operations, and have high requirements for the proficiency and responsibility of the testers, making it difficult to achieve fast and reliable vaccine quality testing.
An automated vaccine quality detection method is adopted to establish a vaccine quality vector library, obtain the images of the vaccine to be quarantined for feature extraction and vector search, and match the closest sample vector to determine the vaccine quality. This method uses the improved ResNet network and YOLOv5 network, combined with the MS-Block module and Faiss vector search technology to achieve automated detection.
It has realized the automation of vaccine quality testing, improved the accuracy and robustness of testing, reduced manual intervention, and improved the detection speed and reliability.
Smart Images

Figure CN120107140A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical fields of vaccine detection and data processing, and relates to a vaccine quality detection method. Background Art
[0002] At present, during the process from production to use, vaccines may be mixed with impurities, seal failure, and liquid vaccines may deteriorate, change color, agglomerate, precipitate, become turbid, stratify, and other phenomena that may cause liquid vaccines to become ineffective. The use of ineffective vaccines may cause unpredictable harm.
[0003] At present, the widely used manual inspection method is slow on the one hand, and on the other hand, it has high requirements on the professional proficiency and sense of responsibility of the inspectors.
[0004] Therefore, a convenient, fast and highly reliable vaccine testing method has become an industry need. Summary of the invention
[0005] In view of the above analysis, the present invention aims to disclose a vaccine quality detection method to realize the automation of vaccine quality detection and improve the accuracy and robustness of detection.
[0006] The present invention discloses a vaccine quality detection method, comprising:
[0007] Step S1, establishing a vaccine quality vector library; the vaccine quality vector library contains sample vectors of vaccines of different qualities;
[0008] Step S2, obtaining an image of the vaccine to be tested, and performing vaccine main body detection to obtain a main body image of the vaccine to be tested;
[0009] Step S3, extracting features from the main image of the vaccine to be tested to obtain a feature vector of the vaccine to be tested;
[0010] Step S4: perform vector retrieval on the feature vector of the vaccine to be tested, and match the closest sample vector from the vaccine quality vector library; the vaccine quality corresponding to the sample vector is used as the quality of the vaccine to be tested.
[0011] Furthermore, in the construction of the vaccine quality vector library in step S1, historical vaccine images including a variety of determined quality conditions are used, and feature vectors are extracted through a feature extraction model constructed based on the ResNet network. Each vaccine quality condition corresponds to a sample vector; each sample vector corresponds to a vaccine quality label.
[0012] Furthermore, the feature extraction model uses an MS-Block module to replace the standard residual module in the ResNet model; and is used to extract features of vaccine images.
[0013] Furthermore, the MS-Block module adopts a hierarchical structure to form a multi-level feature extraction pyramid, performs multi-scale convolution on the input features, arranges the multi-scale convolution results in order of scale, and then performs feature fusion and output; when fusing features, an attention mechanism is used to extract the unique features of the vaccine image.
[0014] Furthermore, the MS-Block module includes N convolution modules of the same scale, a feature stacking module, a 1×1 convolution module, an SE module and a residual connection module connected in series;
[0015] Among the N convolution modules of the same scale connected in series, the input end of the first convolution module is used as the input end of the MS-Block module to access the original input features, and the output end of each convolution module is respectively connected to the feature stacking module;
[0016] The feature stacking module stacks the features output by each convolution module in descending order of scale to form a pyramid-shaped multi-layer feature set;
[0017] The 1×1 convolution module is connected to the feature stacking module, and a 1×1 convolution kernel is used to perform feature fusion on the multi-layer feature set output by the feature stacking module;
[0018] The SE module is connected to the 1×1 convolution module; it is used to adjust the fused features and sort the importance of feature channels by the learned weights;
[0019] The residual connection module is connected to the input end and the output end of the SE module respectively, and the original input features are merged with the multi-processed features output by the SE module, and output as the output features of the MS-Block module.
[0020] Furthermore, each of the N convolution modules of the same scale uses a 3×3 convolution kernel.
[0021] Furthermore, in step S2, the vaccine body detection is performed on the image of the vaccine to be inspected using the YOLOv5 network.
[0022] Furthermore, the C3RS module is used to replace the C3 module in the YOLOv5 network;
[0023] The C3RS module includes a first CBL layer, a second CBL layer, a RepResBlock layer, a concat layer, a SE layer and a third CBL layer; wherein the first CBL layer is the input layer of the C3RS module, and after the first CBL layer and the RepResBlock layer are connected in series, they are connected to the input end of the concat layer together with the second CBL layer, and the output end of the concat layer is sequentially connected to the SE layer and the third CBL layer; the third CBL layer serves as the output layer of the C3RS module.
[0024] Furthermore, in step S4, a vector search is performed on the feature vector of the vaccine to be tested, using the Faiss vector search method; after the vector search, a similarity score list with each sample vector in the vaccine quality vector library is obtained; in the similarity score list, the vaccine quality in the vaccine quality label corresponding to the sample vector with the highest score is output as the quality test result of the vaccine to be tested.
[0025] Furthermore, when performing vector retrieval, the Euclidean distance between the feature vector of the vaccine to be tested and each sample vector is calculated, and the similarity score is calculated according to the size of the Euclidean distance. The smaller the Euclidean distance, the higher the score.
[0026] The present invention can achieve one of the following beneficial effects:
[0027] The vaccine quality detection method of the present invention realizes the automation of vaccine quality detection and improves the accuracy and robustness of detection.
[0028] When detecting the vaccine body, the detection network is designed taking into account the morphological characteristics of the vaccine in the image. While maintaining the reasoning speed of the original detection network structure, the cropped vaccine area is ensured to be more accurate and avoid false detections.
[0029] When extracting vaccine image features, the improvement of the ResNet network not only inherits the advantages of ResNet in dealing with gradient problems in deep networks, but also achieves a qualitative leap in the multi-scale expression of features and information integration, and achieves more accurate extraction of the unique characteristics of vaccines and enhances the generalization ability of the model, achieving better performance than the traditional ResNet model. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] The accompanying drawings are only used for the purpose of illustrating specific embodiments and are not to be considered as limiting the present invention. In the entire drawings, the same reference symbols represent the same components;
[0031] Figure 1 is a flow chart of a vaccine quality detection method in an embodiment of the present invention;
[0032] Figure 2 It is a conventional ResNet structure diagram in an embodiment of the present invention;
[0033] Figure 3 : is a diagram of the improved ResNet structure in an embodiment of the present invention;
[0034] Figure 4 This is a schematic diagram of the connection of MS-Block modules with N=5 in an embodiment of the present invention;
[0035] Figure 5 It is a conventional YOLOv5 network structure diagram in an embodiment of the present invention;
[0036] Figure 6 It is a diagram of the optimized YOLOv5 network structure in an embodiment of the present invention;
[0037] Figure 7 This is a schematic diagram of the connection of the C3RS module in an embodiment of the present invention;
[0038] Figure 8 Schematic diagram of the structure of RepResBlock during training in an embodiment of the present invention;
[0039] Fig. 9 Schematic diagram of the structure of RepResBlock during reasoning in an embodiment of the present invention. DETAILED DESCRIPTION
[0040] The preferred embodiments of the present invention will be described in detail below in conjunction with the accompanying drawings, wherein the accompanying drawings constitute a part of this application and are used to illustrate the principles of the present invention together with the embodiments of the present invention.
[0041] One embodiment of the present invention discloses a method for detecting vaccine quality. Figure 1 As shown, including:
[0042] Step S1, establishing a vaccine quality vector library; the vaccine quality vector library contains sample vectors of vaccines of different qualities;
[0043] Step S2, obtaining an image of the vaccine to be tested, and performing vaccine main body detection to obtain a main body image of the vaccine to be tested;
[0044] Step S3, extracting features from the main image of the vaccine to be tested to obtain a feature vector of the vaccine to be tested;
[0045] Step S4: perform vector retrieval on the feature vector of the vaccine to be tested, and match the closest sample vector from the vaccine quality vector library; the vaccine quality corresponding to the sample vector is used as the quality of the vaccine to be tested.
[0046] Specifically, in step S1, in the construction of the vaccine quality vector library, historical vaccine images including a variety of determined quality conditions are used, and feature vectors are extracted through a feature extraction model constructed based on the ResNet network. Each vaccine quality condition corresponds to a sample vector; each sample vector corresponds to a vaccine quality label.
[0047] ResNet (Residual Network) is a deep convolutional neural network (CNN) architecture and an existing commonly used feature extraction network. ResNet solves the gradient vanishing and degradation problems in deep neural networks by introducing residual modules. These residual modules can be stacked according to task requirements to form ResNet models of various depths, such as ResNet-34, ResNet-50, etc. ResNet has achieved significant performance improvements in multiple computer vision tasks. Due to its excellent performance and easy-to-expand design, ResNet has become an important benchmark in the field of deep learning and is widely used in various computer vision tasks and other fields.
[0048] Furthermore, in order to improve the feature extraction capability of the ResNet model, the solution of this embodiment improves the ResNet model; that is, the feature extraction model in this embodiment uses the MS-Block module to replace the standard residual module in the ResNet model; and is used to extract features of vaccine images.
[0049] The MS-Block module adopts a hierarchical structure to form a multi-level feature extraction pyramid, performs multi-scale convolution on the input features, arranges the multi-scale convolution results in order of scale, and then performs feature fusion and output; when fusing features, an attention mechanism is used to extract the unique features of the vaccine image.
[0050] like Figure 2 The conventional ResNet structure diagram is given; Figure 3 The improved ResNet structure diagram of this embodiment is given; in the improved ResNe network in this embodiment, the MS-Block module is used to replace the ID Block module in each stage after the first stage stage0 in the ResNet network.
[0051] The improved ResNe network not only inherits the advantages of conventional ResNet in dealing with gradient problems in deep networks, but also achieves a qualitative leap in multi-scale expression of features and information integration through MS-Block. This innovative architecture can more accurately extract the unique features of vaccines and enhance the generalization ability of the model, achieving better performance than the traditional ResNet model.
[0052] More specifically, the MS-Block module includes N convolutional modules of the same scale, a feature stacking module, a 1×1 convolutional module, an SE module, and a residual connection module connected in series;
[0053] Among the N convolution modules of the same scale connected in series, the input end of the first convolution module is used as the input end of the MS-Block module to access the original input features, and the output end of each convolution module is respectively connected to the feature stacking module;
[0054] The feature stacking module stacks the features output by each convolution module in descending order of scale to form a pyramid-shaped multi-layer feature set;
[0055] The 1×1 convolution module is connected to the feature stacking module, and a 1×1 convolution kernel is used to perform feature fusion on the multi-layer feature set output by the feature stacking module;
[0056] The SE module is connected to the 1×1 convolution module to further adjust the fused features, sort the importance of feature channels through the learned weights, strengthen or suppress features with different effects, and enhance the network's ability to respond to key information;
[0057] The residual connection module is connected to the input end and the output end of the SE module respectively, and the original input features are merged with the multi-processed features output by the SE module, and output as the output features of the MS-Block module.
[0058] The residual connection module bypasses a series of complex processing steps and directly merges the original input features with the module output; such residual connections not only facilitate the rapid flow of information and alleviate the gradient vanishing problem in deep network training, but also provide a shortcut that enables the network to adapt to the learning of complex functions more quickly during deep learning.
[0059] In a more preferred solution, each of the N convolution modules of the same scale uses a 3×3 convolution kernel;
[0060] The number of convolution modules is determined according to the specific computing resources.
[0061] like Figure 4 A schematic diagram of the connection of the MS-Block module with N=5 is given.
[0062] By connecting five 3×3 convolution kernels in series, multi-scale features such as 3×3, 5×5, 7×7, 9×9, and 11×11 are formed. In the feature stacking module, they are stacked from large to small scales to form a pyramid-shaped multi-layer feature set.
[0063] The feature extraction experiment on the vaccine image proved that the MS-Block module of this embodiment achieved a balance between reasoning speed and accuracy. This balance is achieved by carefully designing the number of convolutional layers, the size of the convolution kernel, and the comprehensive configuration of the attention mechanism. Nevertheless, the design of the MS-Block module has a certain flexibility, allowing the number and type of convolutional layers to be adjusted according to specific application scenarios, as well as the replacement of SE modules to adapt to different requirements for performance and accuracy. The versatility and configurability of this design make MS-Block not only limited to vaccine feature extraction scenarios, but also widely applicable to other image recognition tasks, demonstrating its wide application potential.
[0064] Specifically, in step S2, the YOLOv5 network is used to detect the vaccine body of the image of the vaccine to be inspected.
[0065] YOLOv5 is a target detection network, such as Figure 5 As shown, it includes 4 parts: 1. Input: Perform adaptive scaling, color adjustment and Mosaic data enhancement to enhance the diversity of data set samples. At the same time, an adaptive anchor frame is used to dynamically calculate the optimal value. 2. Backbone network: mainly CSPDarknet53, including Focus module (to ensure that feature information is not lost during downsampling), SPPF module (to extract features of different spatial sizes) and C3 module (to combine deep and shallow features to enhance geometric and semantic information). 3. Neck network: Combine FPN and PANet to ensure that the features transmitted from top to bottom and bottom to top can be effectively fused. 4. Head network: Perform location and classification of feature maps, and use NMS algorithm to optimize the prediction results.
[0066] Specifically, in this embodiment, when detecting the vaccine body, the YOLOv5 network is improved by replacing the C3 module with the C3RS module; the optimized YOLOv5 network is as follows Figure 6 As shown; Figure 6 All C3 modules in the YOLOv5 network are replaced by C3RS modules.
[0067] The C3RS module, such as Figure 7 As shown, it includes a first CBL layer, a second CBL layer, a RepResBlock layer, a concat layer, a SE layer and a third CBL layer;
[0068] Among them, after the first CBL layer and the RepResBlock layer are connected in series, they are connected to the input end of the concat layer together with the second CBL layer, and the output end of the concat layer is sequentially connected to the SE layer and the third CBL layer;
[0069] Among them, during the training and reasoning process of the model, the structure of RepResBlock is respectively Figure 8and Fig. 9 Given in.
[0070] like Figure 8 As shown in the figure, during the training phase, RepResBlock is based on two connected (3×3) convolutional layers CBL of Res-Unit; a standard convolutional branch (1×1) convolutional layer CBL is added in parallel with the latter (3×3) convolutional layer CBL, which expands the receptive field of the model and merges the two branches after calculation to achieve multi-scale fusion of features. This optimization enables the model to capture richer feature information.
[0071] However, the new branch will increase parameters, which may increase the amount of computation and slow down the inference speed. To solve this problem,
[0072] like Fig. 9 As shown in Figure 1, during the inference phase, the RepResBlock module undergoes structural reparameterization by padding the standard convolution branch with a convolution and fusing it with the convolution weights of another branch.
[0073] In this way, the model improves its representation capabilities during the training phase without adding additional computational burden during deployment.
[0074] In the solution of this embodiment, the C3RS module, which is a combination of C3, RepResBlock and SE, is used to replace the C3 module in the original YOLOv5; the C3RS module enhances the feature extraction capability of the network by performing multi-scale feature fusion while maintaining the reasoning speed of the original network structure. These modifications enhance its application performance in the vaccine quality detection scenario and provide optimization for the recognition process.
[0075] Specifically, when extracting features from the main image of the vaccine to be tested in step S3, the same feature extraction model as that used to establish the vaccine quality vector library in step S1 is used to obtain a feature vector of the vaccine to be tested.
[0076] Specifically, in step S4, a vector search is performed on the feature vector of the vaccine to be tested, and the closest sample vector is matched from the vaccine quality vector library; the Faiss (fast approximate nearest neighbor search library) vector search method is adopted; after the vector search, a similarity score list with each sample vector in the vaccine quality vector library is obtained; in the similarity column score list, the vaccine quality in the vaccine quality label corresponding to the sample vector with the highest score is output as the quality test result of the vaccine to be tested.
[0077] More specifically, when performing vector retrieval, the Euclidean distance between the feature vector of the vaccine to be tested and each sample vector is calculated, and the similarity score is calculated according to the size of the Euclidean distance. The smaller the Euclidean distance, the higher the score.
[0078] In summary, the vaccine quality detection method of the present invention in the embodiment of the present invention realizes the automation of vaccine quality detection and improves the accuracy and robustness of detection. When the vaccine body is detected, the detection network is designed taking into account the morphological characteristics of the vaccine in the image, while maintaining the reasoning speed of the original detection network structure, ensuring that the cropped vaccine area is more accurate to avoid false detection; when extracting vaccine image features, through the improvement of the ResNet network, it not only inherits the advantages of ResNet in dealing with gradient problems in deep networks, but also achieves a qualitative leap in the multi-scale expression of features and information integration, and achieves more accurate extraction of the unique characteristics of the vaccine and enhances the generalization ability of the model, and achieves better performance than the traditional ResNet model.
[0079] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by any technician familiar with the technical field within the technical scope disclosed by the present invention should be covered within the protection scope of the present invention.
Claims
1. A vaccine quality detection method, It is characterized in that include: Step S1, establishing a vaccine quality vector library; the vaccine quality vector library contains sample vectors of vaccines of different qualities; Step S2, obtaining an image of the vaccine to be tested, and performing vaccine main body detection to obtain a main body image of the vaccine to be tested; Step S3, extracting features from the main image of the vaccine to be tested to obtain a feature vector of the vaccine to be tested; Step S4: perform vector retrieval on the feature vector of the vaccine to be tested, and match the closest sample vector from the vaccine quality vector library; the vaccine quality corresponding to the sample vector is used as the quality of the vaccine to be tested.
2. The vaccine quality detection method according to claim 1, It is characterized in that In the construction of the vaccine quality vector library in step S1, historical vaccine images including a variety of determined quality conditions are used, and feature vectors are extracted through a feature extraction model constructed based on the ResNet network. Each vaccine quality condition corresponds to a sample vector; each sample vector corresponds to a vaccine quality label.
3. The vaccine quality detection method according to claim 2, It is characterized in that The feature extraction model uses the MS-Block module to replace the standard residual module in the ResNet model; and is used to extract features of vaccine images.
4. The vaccine quality detection method according to claim 3, It is characterized in that The MS-Block module adopts a hierarchical structure to form a multi-level feature extraction pyramid, performs multi-scale convolution on the input features, arranges the multi-scale convolution results in order of scale, and then performs feature fusion and output; when fusing features, an attention mechanism is used to extract the unique features of the vaccine image.
5. The vaccine quality detection method according to claim 4, It is characterized in that The MS-Block module includes N convolution modules of the same scale, a feature stacking module, a 1×1 convolution module, an SE module and a residual connection module connected in series; Among the N convolution modules of the same scale connected in series, the input end of the first convolution module is used as the input end of the MS-Block module to access the original input features, and the output end of each convolution module is respectively connected to the feature stacking module; The feature stacking module stacks the features output by each convolution module in descending order of scale to form a pyramid-shaped multi-layer feature set; The 1×1 convolution module is connected to the feature stacking module, and a 1×1 convolution kernel is used to perform feature fusion on the multi-layer feature set output by the feature stacking module; The SE module is connected to the 1×1 convolution module; it is used to adjust the fused features and sort the importance of feature channels by the learned weights; The residual connection module is connected to the input end and the output end of the SE module respectively, and the original input features are merged with the multi-processed features output by the SE module, and output as the output features of the MS-Block module.
6. The vaccine quality detection method according to claim 5, It is characterized in that Each of the N convolution modules of the same scale uses a 3×3 convolution kernel.
7. The vaccine quality detection method according to any one of claims 1 to 6, It is characterized in that In step S2, the YOLOv5 network is used to detect the vaccine body of the image of the vaccine to be inspected.
8. The vaccine quality detection method according to claim 7, It is characterized in that In the YOLOv5 network, the C3RS module is used to replace the C3 module; The C3RS module includes a first CBL layer, a second CBL layer, a RepResBlock layer, a concat layer, a SE layer and a third CBL layer; wherein the first CBL layer is the input layer of the C3RS module, and after the first CBL layer and the RepResBlock layer are connected in series, they are connected to the input end of the concat layer together with the second CBL layer, and the output end of the concat layer is sequentially connected to the SE layer and the third CBL layer; the third CBL layer serves as the output layer of the C3RS module.
9. The vaccine quality detection method according to claim 7, It is characterized in that In step S4, a vector search is performed on the feature vector of the vaccine to be tested, using the Faiss vector search method; after the vector search, a similarity score list with each sample vector in the vaccine quality vector library is obtained; in the similarity score list, the vaccine quality in the vaccine quality label corresponding to the sample vector with the highest score is output as the quality test result of the vaccine to be tested.
10. The vaccine quality detection method according to claim 9, It is characterized in that When performing vector retrieval, the Euclidean distance between the feature vector of the vaccine to be tested and each sample vector is calculated, and the similarity score is calculated according to the size of the Euclidean distance. The smaller the Euclidean distance, the higher the score.