Medicine bottle defect detection method and system based on machine vision and deep learning
Through the bottle defect detection method based on machine vision and deep learning, combined with the YOLOV5 model and bottle simulation model, image preprocessing and feature extraction are used to use the mean filter and channel self-association feature pyramid network to perform image preprocessing and feature extraction, the problem of misjudgment of reflective areas in the existing technology is solved, and efficient and accurate bottle defect detection is achieved.
Patent Information
- Application Number
- CN202411765322.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-04
- Publication Date
- 2025-05-23
- Estimated Expiration
- 2044-12-04
AI Technical Summary
The twin defect classification network of existing bottle defect detection methods is more sensitive to the highlight areas caused by reflection in appearance image information, resulting in misjudgment as defects, interfering with the accuracy of defect detection.
Using a bottle defect detection method based on machine vision and deep learning, a bottle simulation model is constructed by obtaining standard bottle parameters, a defect detection model is constructed in combination with the YOLOV5 model, and the bottle images are collected in real time for defect detection, and image preprocessing and feature extraction are used for channel self-association feature pyramid network to improve detection accuracy.
It effectively overcomes the sensitivity of the twin defect classification network to reflective areas, improves the accuracy and efficiency of bottle defect detection, and is suitable for the rapid detection of bottle defects.
Smart Images

Figure CN119580005B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of defect detection, and specifically relates to a medicine bottle defect detection method and system based on machine vision and deep learning. Background Art
[0002] With the development of science and technology and the continuous improvement of people's living standards, medical health and food safety issues have attracted more and more attention. As the main storage equipment for medicines, the quality of medicine bottles is related to the storage, sales, transportation, and use of medicines, and directly affects the effectiveness and safety of medicines. The medicine bottles need to be inspected for surface defects before they are shipped out of the factory. Surface defect inspection mainly detects defects such as air lines, cracks, and spots on the surface of the medicine bottles. The traditional surface defect detection method is manual inspection, that is, the quality inspectors visually inspect whether the medicine bottles have defects. Manual inspection has the disadvantages of slow inspection speed, cumbersome operation, poor reliability, and high missed detection rate.
[0003] Chinese patent CN113324993B discloses a comprehensive method for detecting appearance defects of medicine bottles, including obtaining appearance image information of medicine bottles; using semantic-pixel fusion detection to judge the acquired image information for small appearance defects with blurred boundaries; at the same time, using a twin defect classification network to identify larger appearance defects with obvious feature differences and scarce samples, as well as unknown defects caused by changes in production processes or external environments; however, the twin defect classification network of the existing detection method is more sensitive to the highlight area caused by reflection in the appearance image information, and the highlight area is easy to form a strong contrast change in the image, which causes the twin defect classification network to misjudge it as a defect, interfering with the accuracy of defect detection of the twin defect classification network. To address the above problems, we propose a method and system for detecting defects in medicine bottles based on machine vision and deep learning. Summary of the invention
[0004] The purpose of the present invention is to address the shortcomings of the prior art and provide a medicine bottle defect detection method and system based on machine vision and deep learning, thereby solving the problem that the twin defect classification network of the prior method is more sensitive to the highlight area caused by reflection in the appearance image information, and the highlight area easily forms a strong contrast change in the image, which causes the twin defect classification network to misjudge it as a defect, thereby interfering with the twin defect classification network's defect detection accuracy.
[0005] The present invention is implemented by a method for detecting defects in medicine bottles based on machine vision and deep learning, and the method for detecting defects in medicine bottles based on machine vision and deep learning comprises:
[0006] Obtain standard medicine bottle parameters, build a medicine bottle simulation model based on the standard medicine bottle parameters, and upload the medicine bottle simulation model and standard medicine bottle parameters to a standard database;
[0007] A defect detection model is built based on deep learning combined with the YOLOV5 model. A defect data set is obtained, and the defect data set is divided into a training set and a test set. The defect detection model is iteratively trained through the training set and the test set, and a converged defect detection model is output;
[0008] At least one set of machine vision-based medicine bottle images is collected in real time to obtain a time-series image set, and the defect detection model is executed with the time-series image set as input. The defect detection model performs joint analysis and detection on the time-series image set in combination with the medicine bottle simulation model to determine whether the medicine bottle associated with the time-series image set has defects;
[0009] If there are defects in the medicine bottles associated with the time series image set, the defect detection model will identify the defects in the time series image set, locate the defective area of the medicine bottle, and complete the defect type classification and labeling of the defective area of the medicine bottle by short-circuiting combined with a random vector machine.
[0010] Load the defect type classification and labeling results of the defect area of the medicine bottle, evaluate the defect degree of the defect area of the medicine bottle based on the hierarchical analysis algorithm, and output the defect degree evaluation results.
[0011] Preferably, the method for building a defect detection model based on deep learning combined with the YOLOV5 model specifically includes:
[0012] The YOLOV5 model is used as the initial model of the defect detection model. The YOLOV5 model consists of an input layer, a Backbone block, a Neck block, and an output layer. The input layer is connected to the Backbone block, and the Backbone block is connected to the Neck block. The Backbone block includes three groups of convolutional layers, pooling layers, and activation functions. The Neck block consists of two convolutional layers and an upsampling layer.
[0013] A mean filter and an encoder are introduced into the input layer of the initial model. The mean filter is connected to the encoder. The mean filter filters the temporal image set and performs background noise reduction. The encoder re-encodes the temporal image set after filtering and background noise reduction. A lightweight detection structure SPPCSPC module is introduced into the encoder.
[0014] The Backbone block of the initial model is improved by introducing a channel self-correlation feature pyramid network after the pooling layer of the Backbone block. The channel self-correlation feature pyramid network is used to extract lightweight features from temporal image sets.
[0015] The upsampling layer of the Neck block is frozen and replaced by a weighted bidirectional feature pyramid network to obtain an improved Neck block. The weighted bidirectional feature pyramid network is used to perform feature fusion on the lightweight feature extraction results. The weighted bidirectional feature pyramid network has 5 input nodes, 3 groups of intermediate nodes, and 5 output nodes. The connection modes of the output nodes, intermediate nodes, and output nodes are top-down and bottom-up.
[0016] The BiFormer attention mechanism is integrated into the output layer, and the dynamic K value K-Means++ detection head is used to annotate the defect type of the defect area in the medicine bottle to complete the construction of the initial model of the defect detection model.
[0017] Preferably, the method for iteratively training the defect detection model using a training set and a test set specifically includes:
[0018] Obtain defect data sets and enhance the defect data sets, where the defect data sets include scratches, bulges, dents, cracked bottoms, bubbles, impurities, wrinkles, oil stains, black spots, size defects, and bottle mouth defects of medicine bottles. The defect data sets are enhanced by adding Gaussian noise, random flipping, Mosaic processing, random scaling, and random cropping.
[0019] The defect data set is divided into a training set and a test set in a ratio of 3:1. The defects in the training set and the test set are annotated using Labelimg software.
[0020] Load the initial model of the defect detection model, and initialize the learning rate, hyperparameters, loss function, activation function, image batch size, and iteration rounds of the initial model;
[0021] Obtain a training set, use the training set to iteratively train the initial model, calculate the loss function of the initial model in each round of iterative training, and use Bayesian optimization to update and optimize the hyperparameters of the initial model;
[0022] Iterate the training based on the preset iteration rounds until the termination convergence, and save the best model obtained during the training process as the initial model;
[0023] Obtain a test set, input the test set into the trained initial model, generate defect test results of the initial model based on multiple perspectives, output defect detection results, and determine whether the defect detection results meet the preset test accuracy;
[0024] If the preset test accuracy is met, a converged defect detection model is output;
[0025] If the preset test accuracy is not met, the hyperparameters of the initial model are updated and optimized based on the Adam optimizer.
[0026] Preferably, the method for optimizing the hyperparameter update of the initial model based on the Adam optimizer specifically includes:
[0027] Identify the hyperparameters of the Backbone block and the Neck block in the initial model, and calculate the optimal position of the individual whale and the global optimal position by combining the whale algorithm and the fitness function. The fitness function is expressed as:
[0028] (1)
[0029] in, represents the number of dimensions of the whale population, represents the dimension of the whale individual in the global search space, Respectively Wei, The position of individual whales in the global search space, is the position vector of the individual whale during global search, is the individual update convergence vector, Control parameters for the spiral shape of the whale algorithm;
[0030] The optimal hyperparameters of Backbone block and Neck block are iteratively searched based on the particle swarm optimization algorithm. When the particle swarm optimization algorithm iteratively searches, the iterative calculation formula is expressed as:
[0031] (2)
[0032] (3)
[0033] in, Indicates Particles in The hyperparameters for the iterations, is the inertia weight coefficient of the hyperparameter, are the individual optimal position and the global optimal position respectively, is a uniform random number, is the number of iterative searches, Represents the total number of iterative searches, represents the search acceleration factor, represents the initial search coefficient, For the The current position of each particle;
[0034] Load the optimal hyperparameters of the Backbone block and the Neck block. The Adam optimizer uses the stochastic gradient descent function with momentum update parameters to iteratively update the hyperparameters of the Backbone block and the Neck block.
[0035] The hyperparameter update expression is:
[0036] (4)
[0037] in, Respectively sequence The momentum of the iteration update, denote the learning rate hyperparameter and momentum update parameter respectively, is the gradient of the stochastic gradient descent function.
[0038] Preferably, the defect detection model is combined with the medicine bottle simulation model to perform a joint analysis and detection method on the time series image set, specifically comprising:
[0039] Loading a time series image set, inputting the time series image set into a mean filter, filtering the time series image set with the mean filter and performing background noise reduction processing to obtain a background noise reduction set;
[0040] Load the background noise reduction set, use the mean filter to Poissonize the background noise reduction set, analyze the ambient light noise value of the background noise reduction set based on machine vision, and output the enhanced processing set;
[0041] The encoder re-encodes the light intensity processing set, and the lightweight detection structure SPPCSPC module combines with the medicine bottle simulation model to determine whether the medicine bottle associated with the time series image set has defects.
[0042] The ambient light noise value is calculated by the following formula:
[0043] (5)
[0044] (6)
[0045] in, Represents the ambient light noise value, is the gray value of the background noise reduction set, They are respectively the background noise reduction set , No. The ambient light probability value of a group of temporal images, Represents the optical quantum efficiency of the sequential image acquisition device, are the background light intensity value and the mean light intensity, Indicates the light intensity value of natural light.
[0046] Preferably, the method for the defect detection model to perform defect recognition on a time-series image set specifically includes:
[0047] Obtain the enhanced processing set, the Backbone block performs convolution fusion processing on the enhanced processing set, and transmits the result of the convolution fusion processing to the pooling layer, and the pooling layer performs pooling processing on the result of the convolution fusion processing;
[0048] The channel self-correlation feature pyramid network performs sub-pixel edge extraction on the defective area of the medicine bottle in the enhanced processing set, roughly defines the defective area of the medicine bottle using the minimum circumscribed rectangle, extracts features of the defective area of the medicine bottle, and outputs a defect feature map;
[0049] The dynamic K-value K-Means++ detection head completes the defect type classification and labeling of the defective area of the medicine bottle by short-circuiting combined with a random vector machine.
[0050] On the other hand, the present invention also provides a medicine bottle defect detection system based on machine vision and deep learning, the medicine bottle defect detection system based on machine vision and deep learning comprises:
[0051] A standard model building module is used to obtain standard medicine bottle parameters, build a medicine bottle simulation model based on the standard medicine bottle parameters, and upload the medicine bottle simulation model and standard medicine bottle parameters to a standard database;
[0052] The detection model construction module builds a defect detection model based on deep learning combined with the YOLOV5 model, obtains a defect data set, divides the defect data set into a training set and a test set, iteratively trains the defect detection model through the training set and the test set, and outputs a converged defect detection model;
[0053] A defect judgment module is used to collect at least one set of machine vision-based medicine bottle images in real time to obtain a time-series image set, and to execute the defect detection model with the time-series image set as input. The defect detection model combines the medicine bottle simulation model to perform joint analysis and detection on the time-series image set to determine whether the medicine bottle associated with the time-series image set has defects;
[0054] The defect recognition module identifies defects in a time-series image set based on a defect detection model, locates the defective area of the medicine bottle, completes the defect type classification and labeling of the defective area of the medicine bottle by short-circuiting and combining it with a random vector machine, loads the defect type classification and labeling results of the defective area of the medicine bottle, evaluates the defect degree of the defective area of the medicine bottle based on a hierarchical analysis algorithm, and outputs the defect degree evaluation results.
[0055] Preferably, the standard model building module includes:
[0056] A standard parameter acquisition unit, used to obtain standard medicine bottle parameters and normalize the standard medicine bottle parameters;
[0057] A simulation model building unit, which builds a medicine bottle simulation model based on standard medicine bottle parameters, and uploads the medicine bottle simulation model and standard medicine bottle parameters to a standard database;
[0058] Standard database, used to store medicine bottle simulation models and standard medicine bottle parameters.
[0059] Compared with the prior art, the embodiments of the present application have the following beneficial effects:
[0060] In the embodiment of the present invention, the defect detection model constructed by deep learning combined with the YOLOV5 model can perform joint analysis and detection on the medicine bottle images based on machine vision. The defect detection model can perform two-level judgment, recognition and analysis on the medicine bottle images, thereby improving the defect detection efficiency, making the present invention applicable to the needs of rapid detection of medicine bottle defects. At the same time, the defect detection model introduces a mean filter to filter the background of the image collected by machine vision under the condition of medicine bottle reflection, thereby effectively retaining the effective information of the small-size target image. By introducing the channel self-correlation feature pyramid network, the model feature extraction capability is enhanced, the model's robustness and adaptability to the variable forms of medicine bottle defects are improved, and the accuracy of defect classification and recognition is guaranteed. It overcomes the problem that the twin defect classification network of the existing method is more sensitive to the highlight area caused by reflection in the appearance image information, and the highlight area is easy to form a strong contrast change in the image, which causes the twin defect classification network to misjudge as a defect, interfering with the accuracy of the twin defect classification network defect detection.
[0061] In an embodiment of the present invention, a lightweight detection structure SPPCSPC module is introduced into the encoder to quickly preprocess and analyze the image of the medicine bottle by optimizing the algorithm and reducing the amount of calculation, thereby realizing defect pre-judgment and improving the efficiency of defect detection.
[0062] In an embodiment of the present invention, introducing a channel self-correlation feature pyramid network after the pooling layer of the Backbone block can effectively improve the problem of insufficient multi-scale feature fusion performance of the YOLOV5 model. The channel self-correlation feature pyramid network can fuse features of different scales after being processed by the encoder, and cascade analyze the feature maps, thereby making full use of the information between features of different scales of the medicine bottle image and improving the efficiency and quality of temporal image defect detection.
[0063] In an embodiment of the present invention, a defect detection model is provided. The defect detection model uses the YOLOV5 model as the initial model, and improves and optimizes the initial model by introducing a value filter, an encoder, a channel autocorrelation feature pyramid network, and a dynamic K value K-Means++ detection head, thereby making the defect detection model suitable for small-sized and reflective medicine bottle defect detection work, and can reduce the demand for computing resources while maintaining a high accuracy rate.
[0064] In an embodiment of the present invention, when the hyperparameters of the initial model are updated based on the Adam optimizer, the hyperparameters of the Backbone block and the Neck block are iteratively updated in combination with the whale algorithm and the particle swarm optimization algorithm. This can effectively search the entire solution space and avoid falling into a local optimal solution. This avoids the problem of all hyperparameters approaching a local optimal solution during model training, which is prone to premature convergence. This improves the computational efficiency of the defect detection model and enhances the optimization capability of the defect detection model.
[0065] In the embodiment of the present invention, the background noise reduction set is Poissonized by a mean filter, and the ambient light noise value of the background noise reduction set under machine vision is analyzed, so that the defect detection model can be suitable for defect detection of medicine bottles with tiny movements. At the same time, the ambient light noise value under machine vision can be analyzed and eliminated, and irrelevant clutter and reflection phenomena can be effectively suppressed. It also facilitates the Backbone block to perform convolution fusion processing on the enhanced processing set and extract features of the defective area of the medicine bottle, thereby improving the image processing effect and efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0066] Figure 1 It is a schematic diagram of the implementation flow of the medicine bottle defect detection method based on machine vision and deep learning provided by the present invention.
[0067] Figure 2 The figure shows a schematic diagram of the implementation process of a method for building a defect detection model based on deep learning combined with the YOLOV5 model.
[0068] Figure 3 The figure shows a schematic diagram of the implementation process of the iterative training method of the defect detection model through the training set and the test set.
[0069] Figure 4 The figure shows a schematic diagram of the implementation process of the hyperparameter update optimization method of the initial model based on the Adam optimizer.
[0070] Figure 5 The figure shows the implementation process of the defect detection model combined with the medicine bottle simulation model to jointly analyze and detect the time series image set.
[0071] Figure 6 The figure shows a schematic diagram of the implementation process of the defect detection model for a defect recognition method for a time series image set.
[0072] Figure 7 It is a structural schematic diagram of the medicine bottle defect detection system based on machine vision and deep learning provided by the present invention. DETAILED DESCRIPTION
[0073] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by technicians in the technical field of this application; the terms used in the specification of the application herein are only for the purpose of describing specific embodiments and are not intended to limit this application; the terms "including" and "having" and any variations thereof in the specification and claims of this application and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of this application or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.
[0074] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0075] The existing twin defect classification network is more sensitive to the highlight area caused by reflection in the appearance image information. The highlight area is easy to form a strong contrast change in the image, which causes the twin defect classification network to misjudge it as a defect and interfere with the defect detection accuracy of the twin defect classification network. To address the above problems, we propose a medicine bottle defect detection method and system based on machine vision and deep learning. In short, when the method is implemented, a medicine bottle simulation model is constructed based on standard medicine bottle parameters, and the medicine bottle simulation model and standard medicine bottle parameters are uploaded to the standard database. A defect detection model is constructed based on deep learning combined with the YOLOV5 model, and the defect detection model is trained. At least one set of medicine bottle images based on machine vision is collected in real time to obtain a time series image set. The defect detection model combines the medicine bottle simulation model to perform joint analysis and detection on the time series image set. First, it is determined whether the medicine bottle associated with the time series image set has defects. Then the defect detection model identifies defects in the time series image set and locates the defect area of the medicine bottle. The defect type classification and labeling of the defect area of the medicine bottle are completed by short-circuiting combined with a random vector machine. Finally, the defect degree of the defect area of the medicine bottle is evaluated based on the hierarchical analysis algorithm, and the defect degree evaluation result is output. In the embodiment of the present invention, the defect detection model constructed by deep learning combined with the YOLOV5 model can perform joint analysis and detection on the medicine bottle images based on machine vision. The defect detection model can perform two-level judgment, recognition and analysis on the medicine bottle images, thereby improving the defect detection efficiency, making the present invention applicable to the needs of rapid detection of medicine bottle defects. At the same time, the defect detection model introduces a mean filter to filter the background of the image collected by machine vision under the condition of medicine bottle reflection, thereby effectively retaining the effective information of the small-size target image. By introducing the channel self-correlation feature pyramid network, the model feature extraction capability is enhanced, the model's robustness and adaptability to the variable forms of medicine bottle defects are improved, and the accuracy of defect classification and recognition is guaranteed. It overcomes the problem that the twin defect classification network of the existing method is more sensitive to the highlight area caused by reflection in the appearance image information, and the highlight area is easy to form a strong contrast change in the image, which causes the twin defect classification network to misjudge as a defect, interfering with the accuracy of the twin defect classification network defect detection.
[0076] The embodiment of the present invention provides a method for detecting defects in medicine bottles based on machine vision and deep learning. Figure 1 The following is a schematic diagram of the implementation process of a medicine bottle defect detection method based on machine vision and deep learning. The medicine bottle defect detection method based on machine vision and deep learning specifically includes:
[0077] Step S10, obtaining standard medicine bottle parameters, building a medicine bottle simulation model based on the standard medicine bottle parameters, and uploading the medicine bottle simulation model and the standard medicine bottle parameters to a standard database;
[0078] It should be noted that, in this embodiment, the model specifications of the medicine bottle include but are not limited to oral medicine bottles, vials, medical plastic bottles, and infusion bottles, and the standard medicine bottle parameters include but are not limited to the size standard (diameter, caliber, height, volume), model, type, and material (tempered, plastic, glass) of the medicine bottle. When constructing a medicine bottle simulation model, you can create a medicine bottle model in 3D modeling software (such as Maya, 3DMAX, Blender, etc.) according to the standard medicine bottle parameters to ensure that the proportion, size, and shape of the model are consistent with the standard specifications.
[0079] Step S20, building a defect detection model based on deep learning combined with the YOLOV5 model, obtaining a defect data set, dividing the defect data set into a training set and a test set, iteratively training the defect detection model through the training set and the test set, and outputting a converged defect detection model;
[0080] Step S30, collecting at least one set of machine vision-based medicine bottle images in real time to obtain a time-series image set, using the time-series image set as input, executing the defect detection model, and the defect detection model combines with the medicine bottle simulation model to perform joint analysis and detection on the time-series image set;
[0081] In this embodiment, at least one set of machine vision-based medicine bottle images are collected in real time through visual inspection equipment. The visual inspection equipment includes but is not limited to line sequence detectors, Aoi detectors, inductive magnetic ring optical screening machines, automatic detectors, size visual detectors, etc. The inspection speed of the visual inspection equipment must be greater than or equal to the production speed of the production line, and the visual inspection equipment can complete 360° all-round visual inspection of the bottle body without blind spots.
[0082] Step S40, determining whether the medicine bottle associated with the time-series image set has defects;
[0083] Step S50, if there are defects in the medicine bottles associated with the time series image set, the defect detection model identifies the defects in the time series image set, locates the defective area of the medicine bottle, and completes the defect type classification and labeling of the defective area of the medicine bottle by short-circuiting combined with a random vector machine.
[0084] Step S60, if the medicine bottle associated with the time series image set does not have defects, the medicine bottle associated with the time series image set is determined to be qualified, and the medicine bottle defect detection operation is terminated;
[0085] Step S70, loading the defect type classification and labeling results of the defect area of the medicine bottle, evaluating the defect degree of the defect area of the medicine bottle based on the hierarchical analysis algorithm, and outputting the defect degree evaluation result.
[0086] It should be noted that when evaluating the degree of defects in the defective area of the medicine bottle based on the hierarchical analysis algorithm, the hierarchical analysis algorithm constructs a degree judgment matrix to calculate the weight of each element. The weight of each element can be calculated by expert scoring or empirical data. For example, a judgment matrix of the criterion layer can be constructed, in which each row represents a criterion, each column represents another criterion, and the elements in the matrix represent the importance of one criterion relative to another criterion. After the degree judgment matrix is constructed, a comprehensive evaluation can be performed by weighted summation and other methods to obtain a comprehensive score for each medicine bottle defect. This score can be used to quantify the severity of each defect.
[0087] In the embodiment of the present invention, the defect detection model constructed by deep learning combined with the YOLOV5 model can perform joint analysis and detection on the medicine bottle images based on machine vision. The defect detection model can perform two-level judgment, recognition and analysis on the medicine bottle images, thereby improving the defect detection efficiency, making the present invention applicable to the needs of rapid detection of medicine bottle defects. At the same time, the defect detection model introduces a mean filter to filter the background of the image collected by machine vision under the condition of medicine bottle reflection, thereby effectively retaining the effective information of the small-size target image. By introducing the channel self-correlation feature pyramid network, the model feature extraction capability is enhanced, the model's robustness and adaptability to the variable forms of medicine bottle defects are improved, and the accuracy of defect classification and recognition is guaranteed. It overcomes the problem that the twin defect classification network of the existing method is more sensitive to the highlight area caused by reflection in the appearance image information, and the highlight area is easy to form a strong contrast change in the image, which causes the twin defect classification network to misjudge as a defect, interfering with the accuracy of the twin defect classification network defect detection.
[0088] The embodiment of the present invention provides a method for building a defect detection model based on deep learning combined with the YOLOV5 model. Figure 2 The schematic diagram of the implementation process of the method for building a defect detection model based on deep learning combined with the YOLOV5 model is shown. The method for building a defect detection model based on deep learning combined with the YOLOV5 model specifically includes:
[0089] Step S101, using the YOLOV5 model as the initial model of the defect detection model, the YOLOV5 model consists of an input layer, a Backbone block, a Neck block, and an output layer, the input layer is connected to the Backbone block, the Backbone block is connected to the Neck block, the Backbone block includes three groups of convolutional layers, a pooling layer, and an activation function, and the Neck block consists of two convolutional layers and an upsampling layer;
[0090] It should be noted that the activation function of the Backbone block is the ReLU function, the three groups of convolutional layers use asymmetric convolution kernels, and the convolution kernel sizes of the three groups of convolutional layers are 1×3, 3×1, and 3×3 respectively, and the pooling layer uses maximum pooling, that is, taking the maximum value of the local area of the convolved features to extract the most important feature information; at the same time, downsampling is used to speed up the calculation and control overfitting.
[0091] Step S102, a mean filter and an encoder are introduced into the input layer of the initial model, the mean filter is connected to the encoder, the mean filter filters the temporal image set and performs background noise reduction, the encoder re-encodes the temporal image set after filtering and background noise reduction, and a lightweight detection structure SPPCSPC module is introduced into the encoder;
[0092] In the embodiment of the present invention, the lightweight detection structure SPPCSPC module introduced in the encoder can quickly pre-process and analyze the medicine bottle image by optimizing the algorithm and reducing the amount of calculation, realize defect pre-judgment, and thus improve the efficiency of defect detection. This is particularly important for production lines that need to process a large number of medicine bottle images, which can effectively shorten the detection time and improve production efficiency.
[0093] Step S103, improving the Backbone block of the initial model, introducing a channel self-correlation feature pyramid network after the pooling layer of the Backbone block, and the channel self-correlation feature pyramid network is used for lightweight feature extraction of temporal image sets;
[0094] In an embodiment of the present invention, introducing a channel self-correlation feature pyramid network after the pooling layer of the Backbone block can effectively improve the problem of insufficient multi-scale feature fusion performance of the YOLOV5 model. The channel self-correlation feature pyramid network can fuse features of different scales after being processed by the encoder, and cascade analyze the feature maps, thereby making full use of the information between features of different scales of the medicine bottle image and improving the efficiency and quality of temporal image defect detection.
[0095] Step S104, freezing the upsampling layer of the Neck block, replacing the upsampling layer with a weighted bidirectional feature pyramid network to obtain an improved Neck block, the weighted bidirectional feature pyramid network is used to perform feature fusion on the lightweight feature extraction result, the weighted bidirectional feature pyramid network has 5 input nodes, 3 groups of intermediate nodes, and 5 output nodes, and the connection modes of the output nodes, intermediate nodes, and output nodes are top-down and bottom-up;
[0096] In the embodiment of the present invention, a weighted bidirectional feature pyramid network is designed based on the Neck block to enhance the model's utilization of channel information and improve the model's detection accuracy. The weighted bidirectional feature pyramid network performs feature fusion on lightweight feature extraction results through top-down and bottom-up node connection methods, so that the model can better utilize these features for calculation. This enables the defect detection model to adapt to irregular shape defects.
[0097] Step S105, the BiFormer attention mechanism is integrated into the output layer, and the dynamic K value K-Means++ detection head is used to label the defect type of the defect area of the medicine bottle, completing the construction of the initial model of the defect detection model.
[0098] In an embodiment of the present invention, a defect detection model is provided. The defect detection model uses the YOLOV5 model as the initial model, and improves and optimizes the initial model by introducing a value filter, an encoder, a channel autocorrelation feature pyramid network, and a dynamic K value K-Means++ detection head, thereby making the defect detection model suitable for small-sized and reflective medicine bottle defect detection work, and can reduce the demand for computing resources while maintaining a high accuracy rate.
[0099] The embodiment of the present invention provides a method for iteratively training a defect detection model through a training set and a test set. Figure 3 The schematic diagram of the implementation process of the iterative training method of the defect detection model through the training set and the test set is shown. The iterative training method of the defect detection model through the training set and the test set specifically includes:
[0100] Step S201, obtaining a defect data set and enhancing the defect data set, wherein the defect data set includes scratches, bulges, dents, cracked bottoms, bubbles, impurities, wrinkles, oil stains, black spots, size defects, and bottle mouth defects of the medicine bottles, and the defect data set is enhanced by adding Gaussian noise, random flipping, Mosaic processing, random scaling, and random cropping;
[0101] In this embodiment, the defect data set is obtained based on network retrieval and on-site collection. The defect data set contains 368 images in total. The resolution of the defect data set is 1280×800. Each group of images in the defect data set includes at least one defect instance. At the same time, 100 defect-free medicine bottle images are additionally introduced as negative samples during model training to help the model improve its generalization performance.
[0102] Step S202, dividing the defect data set into a training set and a test set at a ratio of 3:1, wherein defects in the training set and the test set are annotated using Labelimg software;
[0103] Step S203, loading the initial model of the defect detection model, and initializing the learning rate, hyperparameters, loss function, activation function, image batch size, and iteration rounds of the initial model;
[0104] In the embodiment of the present invention, the learning rate of the initial model is set to 0.001, the training rounds are set to 200-250, the image batch size is 5-15, and the activation function of the initial model is the Tanh function.
[0105] Step S204, obtaining a training set, using the training set to iteratively train the initial model, calculating the loss function of the initial model in each round of iterative training, and using Bayesian optimization to update and optimize the hyperparameters of the initial model;
[0106] Step S205, iterative training is performed based on a preset number of iterations until convergence is terminated, and the best model obtained during the training process is saved as the initial model;
[0107] Step S206, obtaining a test set, inputting the test set into the trained initial model, generating defect test results of the initial model based on multiple perspectives, and outputting defect detection results;
[0108] Step S207, determining whether the defect detection result meets the preset test accuracy;
[0109] In this embodiment, the preset test accuracy is set to 0.95-0.958.
[0110] In this embodiment, mean absolute error MAE, mean absolute percentage error MAPE, root mean square error RMSE and root mean square logarithmic error RMSLE are selected as evaluation criteria for the quality of the model. The smaller these four indicators are, the closer the predicted value is to the true value, which proves that the model performance is better and the detection accuracy is higher.
[0111] Step S208, if the preset test accuracy is met, output a converged defect detection model;
[0112] Step S209: If the preset test accuracy is not met, the hyperparameters of the initial model are updated and optimized based on the Adam optimizer, and the process returns to step S206.
[0113] It should be noted that during model training, the CPU model is Intel® Core™ i5-8259U CPU @ 2.3 GHz, the memory is 64 GB, the operating system is the Linux visual operating system, the development language is Python 3, the development environment is PyCharm, and the database is the Halcon function library.
[0114] The embodiment of the present invention provides a method for optimizing the hyperparameter update of the initial model based on the Adam optimizer. Figure 4The figure shows a schematic diagram of the implementation process of the hyperparameter update optimization method for the initial model based on the Adam optimizer, and the hyperparameter update optimization method for the initial model based on the Adam optimizer specifically includes:
[0115] Step S301, identify the hyperparameters of the Backbone block and the Neck block in the initial model, and calculate the optimal position of the individual whale and the global optimal position by combining the whale algorithm and the fitness function, where the fitness function is expressed as:
[0116] (1)
[0117] in, Indicates the number of dimensions of the whale population. In this embodiment, the number of dimensions can be 3-8, and the number of whales can be 20-30. represents the dimension of the whale individual in the global search space, Respectively Wei, The position of individual whales in the global search space, is the position vector of the individual whale during global search, is the individual update convergence vector, is the spiral shape control parameter of the whale algorithm. In this embodiment, the spiral shape control parameter may be 0.1-0.3;
[0118] Step S302, iteratively searching for optimal hyperparameters of Backbone block and Neck block based on particle swarm optimization algorithm. When the particle swarm optimization algorithm iteratively searches, the iterative calculation formula is expressed as:
[0119] (2)
[0120] (3)
[0121] in, Indicates Particles in The hyperparameters for the iterations, is the inertia weight coefficient of the hyperparameter, are the individual optimal position and the global optimal position respectively, is a uniform random number, which can be a random number between 0 and 1. is the number of iterative searches, Indicates the total number of iterative searches, which can be 100-120 times. represents the search acceleration factor, Represents the initial search coefficient, which can be 0.2-1. For the The current position of each particle;
[0122] Step S303: Load the optimal hyperparameters of the Backbone block and the Neck block. The Adam optimizer uses a stochastic gradient descent function with momentum update parameters to iteratively update the hyperparameters of the Backbone block and the Neck block.
[0123] The hyperparameter update expression is:
[0124] (4)
[0125] where are the momentums of the -th and -th iterative updates respectively, represent the learning rate hyperparameter and the momentum update parameter respectively, is the gradient of the stochastic gradient descent function.
[0126] In the embodiment of the present invention, when updating the hyperparameters of the initial model based on the Adam optimizer, the hyperparameters of the Backbone block and the Neck block are iteratively updated by combining the whale algorithm and the particle swarm optimization algorithm, which can effectively search in the entire solution space, avoid falling into local optimal solutions, thereby avoiding the problem that all hyperparameters tend to a certain local optimal solution during model training and being prone to premature convergence, improving the operation efficiency of the defect detection model, and enhancing the optimization ability of the defect detection model.
[0127] The embodiment of the present invention provides a method for jointly analyzing and detecting a temporal image set by combining a defect detection model with a medicine bottle simulation model. Figure 5 Fig. shows a schematic implementation flowchart of the method for jointly analyzing and detecting a temporal image set by combining a defect detection model with a medicine bottle simulation model. The method for jointly analyzing and detecting a temporal image set by combining a defect detection model with a medicine bottle simulation model specifically includes:
[0128] Step S401: Load the temporal image set. The temporal image set is input into a mean filter, and the mean filter filters the temporal image set and performs background noise reduction to obtain a background noise reduction set.
[0129] In the embodiment of the present invention, a mean filter is used to filter the temporal image set and perform background noise reduction. The mean filter smooths the image by calculating the average value of the neighborhood around each pixel, thereby effectively removing random noises in the temporal image set, such as Gaussian noise and salt-and-pepper noise. This has a good effect on noise processing of temporal image sets affected by various environmental factors (such as light changes, camera jitters, etc.).
[0130] Step S402: Load the background noise reduction set. The mean filter performs Poissonization processing on the background noise reduction set, analyzes the ambient light noise value of the background noise reduction set based on machine vision, and outputs an enhanced processing set.
[0131] Step S403, the encoder re-encodes the light intensity processing set, and the lightweight detection structure SPPCSPC module combines with the medicine bottle simulation model to determine whether the medicine bottle associated with the time series image set has defects.
[0132] In this embodiment, the ambient light noise value is calculated by the following formula:
[0133] (5)
[0134] (6)
[0135] in, represents the ambient light noise value, is the gray value of the background noise reduction set, They are respectively the background noise reduction set , No. The ambient light probability value of a group of temporal images, Represents the optical quantum efficiency of the sequential image acquisition device, are the background light intensity value and the mean light intensity, Indicates the light intensity value of natural light.
[0136] In the embodiment of the present invention, the background noise reduction set is Poissonized by a mean filter, and the ambient light noise value of the background noise reduction set under machine vision is analyzed, so that the defect detection model can be suitable for defect detection of medicine bottles with tiny movements. At the same time, the ambient light noise value under machine vision can be analyzed and eliminated, and irrelevant clutter and reflection phenomena can be effectively suppressed. It also facilitates the Backbone block to perform convolution fusion processing on the enhanced processing set and extract features of the defective area of the medicine bottle, thereby improving the image processing effect and efficiency.
[0137] The embodiment of the present invention provides a method for a defect detection model to identify defects in a time series image set. Figure 6 The schematic diagram of the implementation process of the defect detection model for the defect recognition method of the time series image set is shown. The method of the defect detection model for the defect recognition method of the time series image set specifically includes:
[0138] Step S501, obtaining an enhanced processing set, the Backbone block performs convolution fusion processing on the enhanced processing set, and transmits the result after the convolution fusion processing to the pooling layer, and the pooling layer performs pooling processing on the result after the convolution fusion processing;
[0139] Step S502, the channel self-correlation feature pyramid network performs sub-pixel edge extraction on the defective area of the medicine bottle in the enhanced processing set, roughly defines the defective area of the medicine bottle using the minimum circumscribed rectangle, extracts features of the defective area of the medicine bottle, and outputs a defect feature map;
[0140] Step S503, the dynamic K value K-Means++ detection head completes the defect type classification and labeling of the defect area of the medicine bottle by short-circuiting and combining with the random vector machine method.
[0141] In this embodiment, after feature extraction, the defect feature map is short-circuited with the original image or other auxiliary information, which can enhance the representation ability of the defect detection enhancement model. A random vector machine (RVFLD) is used as a classifier. It can process high-dimensional data and provide good generalization performance. Finally, the dynamic K value K-Means++ detection head is used to classify and annotate the defect type of the defect area of the medicine bottle. This can be achieved by drawing bounding boxes, labels or other visual markers on the image, and using the dynamic K value detection K-Means++ algorithm to cluster the defect areas of the medicine bottles, so that anchor boxes that are more in line with different target scales can be obtained, thereby improving the accuracy of the annotation of the defect areas of the medicine bottles.
[0142] The embodiment of the present invention provides a medicine bottle defect detection system based on machine vision and deep learning. Figure 7 The schematic diagram of the structure of the medicine bottle defect detection system based on machine vision and deep learning is shown. The medicine bottle defect detection system based on machine vision and deep learning specifically includes:
[0143] The standard model building module 100 is used to obtain standard medicine bottle parameters, build a medicine bottle simulation model based on the standard medicine bottle parameters, and upload the medicine bottle simulation model and the standard medicine bottle parameters to the standard database;
[0144] The detection model construction module 200 builds a defect detection model based on deep learning combined with the YOLOV5 model, obtains a defect data set, divides the defect data set into a training set and a test set, iteratively trains the defect detection model through the training set and the test set, and outputs a converged defect detection model;
[0145] The defect judgment module 300 is used to collect at least one set of machine vision-based medicine bottle images in real time to obtain a time-series image set, and execute the defect detection model with the time-series image set as input. The defect detection model combines the medicine bottle simulation model to perform joint analysis and detection on the time-series image set to determine whether the medicine bottle associated with the time-series image set has defects;
[0146] The defect recognition module 400 performs defect recognition on a time-series image set based on a defect detection model, locates the defective area of the medicine bottle, completes the defect type classification and labeling of the defective area of the medicine bottle by short-circuiting combined with a random vector machine, loads the defect type classification and labeling results of the defective area of the medicine bottle, evaluates the defect degree of the defective area of the medicine bottle based on a hierarchical analysis algorithm, and outputs the defect degree evaluation result.
[0147] In the embodiments of the present invention, the medicine bottle defect detection system based on machine vision and deep learning, the standard model construction module 100, the detection model construction module 200, the defect judgment module 300, and the defect recognition module 400 correspond to the above-mentioned medicine bottle defect detection method based on machine vision and deep learning. The explanations, examples, beneficial effects, etc. of the relevant contents can refer to the corresponding contents in the medicine bottle defect detection method based on machine vision and deep learning, and will not be repeated here.
[0148] In this embodiment, the standard model building module 100 includes:
[0149] A standard parameter acquisition unit 110 is used to obtain standard medicine bottle parameters and normalize the standard medicine bottle parameters;
[0150] A simulation model building unit 120 builds a medicine bottle simulation model based on standard medicine bottle parameters, and uploads the medicine bottle simulation model and standard medicine bottle parameters to a standard database;
[0151] The standard database 130 is used to store medicine bottle simulation models and standard medicine bottle parameters.
[0152] In summary, the present invention provides a method and system for detecting defects in medicine bottles based on machine vision and deep learning. In the embodiment of the present invention, a defect detection model is constructed by combining deep learning with the YOLOV5 model to jointly analyze and detect medicine bottle images based on machine vision. The defect detection model can perform two-level judgment, recognition and analysis on medicine bottle images, thereby improving the efficiency of defect detection, making the present invention applicable to the needs of rapid detection of medicine bottle defects. At the same time, the defect detection model introduces a mean filter to filter the background of images collected under machine vision under the condition of medicine bottle reflection, thereby effectively retaining the effective information of small-sized target images. By introducing a channel self-correlation feature pyramid network, the model feature extraction capability is enhanced, the model's robustness and adaptability to the variable forms of medicine bottle defects are improved, and the accuracy of defect classification and recognition is guaranteed. It overcomes the problem that the twin defect classification network of the existing method is more sensitive to the highlight area caused by reflection in the appearance image information, and the highlight area is easy to form a strong contrast change in the image, which causes the twin defect classification network to misjudge as a defect and interferes with the accuracy of defect detection of the twin defect classification network.
[0153] It should be noted that, for the above-mentioned embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should know that the present invention is not limited by the described order of actions, because according to the present invention, some steps may be performed in other orders or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present invention.
[0154] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the scope of protection of the invention. Obviously, the described embodiments are only some embodiments of the present invention, rather than all embodiments. Based on these embodiments, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention. Although the present invention has been described in detail with reference to the above embodiments, ordinary technicians in this field can still combine, add, delete or make other adjustments to the features in the various embodiments of the present invention according to the circumstances without conflict, without making creative work, so as to obtain different other technical solutions that do not deviate from the concept of the present invention in essence, and these technical solutions also belong to the scope of protection of the present invention.
Claims
1. A medicine bottle defect detection method based on machine vision and deep learning, characterized in that: The method for detecting defects in medicine bottles based on machine vision and deep learning includes: Obtain standard medicine bottle parameters, build a medicine bottle simulation model based on the standard medicine bottle parameters, and upload the medicine bottle simulation model and standard medicine bottle parameters to a standard database; A defect detection model is built based on deep learning combined with the YOLOV5 model. A defect data set is obtained, and the defect data set is divided into a training set and a test set. The defect detection model is iteratively trained through the training set and the test set, and a converged defect detection model is output; At least one set of machine vision-based medicine bottle images is collected in real time to obtain a time-series image set, and the defect detection model is executed with the time-series image set as input. The defect detection model performs joint analysis and detection on the time-series image set in combination with the medicine bottle simulation model to determine whether the medicine bottle associated with the time-series image set has defects; If there are defects in the medicine bottles associated with the time-series image set, the defect detection model identifies the defects in the time-series image set, locates the defective area of the medicine bottle, and completes the defect type classification and labeling of the defective area of the medicine bottle by short-circuiting combined with a random vector machine. The defect detection model combines the medicine bottle simulation model to perform a joint analysis and detection method on the time series image set, specifically including: Loading a time series image set, inputting the time series image set into a mean filter, filtering the time series image set with the mean filter and performing background noise reduction processing to obtain a background noise reduction set; Load the background noise reduction set, use the mean filter to Poissonize the background noise reduction set, analyze the ambient light noise value of the background noise reduction set based on machine vision, and output the enhanced processing set; The encoder re-encodes the light intensity processing set, and the lightweight detection structure SPPCSPC module combines with the medicine bottle simulation model to determine whether the medicine bottle associated with the time series image set has defects; The defect detection model performs defect recognition on a time series image set, specifically including: Obtain the enhanced processing set, the Backbone block performs convolution fusion processing on the enhanced processing set, and transmits the result of the convolution fusion processing to the pooling layer, and the pooling layer performs pooling processing on the result of the convolution fusion processing; The channel self-correlation feature pyramid network performs sub-pixel edge extraction on the defective area of the medicine bottle in the enhanced processing set, roughly defines the defective area of the medicine bottle using the minimum circumscribed rectangle, extracts features of the defective area of the medicine bottle, and outputs a defect feature map; The dynamic K-value K-Means++ detection head completes the defect type classification and labeling of the defective area of the medicine bottle by short-circuiting combined with a random vector machine.
2. The method for detecting defects in medicine bottles based on machine vision and deep learning as claimed in claim 1, characterized in that: The method for detecting defects in medicine bottles based on machine vision and deep learning also includes: Load the defect type classification and labeling results of the defect area of the medicine bottle, evaluate the defect degree of the defect area of the medicine bottle based on the hierarchical analysis algorithm, and output the defect degree evaluation results.
3. The method for detecting defects in medicine bottles based on machine vision and deep learning as claimed in claim 1, characterized in that: The method for building a defect detection model based on deep learning combined with the YOLOV5 model specifically includes: The YOLOV5 model is used as the initial model of the defect detection model. The YOLOV5 model consists of an input layer, a Backbone block, a Neck block, and an output layer. The input layer is connected to the Backbone block, and the Backbone block is connected to the Neck block. The Backbone block includes three groups of convolutional layers, pooling layers, and activation functions. The Neck block consists of two convolutional layers and an upsampling layer. A mean filter and an encoder are introduced into the input layer of the initial model. The mean filter is connected to the encoder. The mean filter filters the temporal image set and performs background noise reduction. The encoder re-encodes the temporal image set after filtering and background noise reduction. A lightweight detection structure SPPCSPC module is introduced into the encoder. The Backbone block of the initial model is improved by introducing a channel self-correlation feature pyramid network after the pooling layer of the Backbone block. The channel self-correlation feature pyramid network is used to extract lightweight features from temporal image sets. The upsampling layer of the Neck block is frozen and replaced by a weighted bidirectional feature pyramid network to obtain an improved Neck block. The weighted bidirectional feature pyramid network is used to perform feature fusion on the lightweight feature extraction results. The weighted bidirectional feature pyramid network has 5 input nodes, 3 groups of intermediate nodes, and 5 output nodes. The connection modes of the output nodes, intermediate nodes, and output nodes are top-down and bottom-up. The BiFormer attention mechanism is integrated into the output layer, and the dynamic K value K-Means++ detection head is used to annotate the defect type of the defect area in the medicine bottle to complete the construction of the initial model of the defect detection model.
4. The method for detecting defects in medicine bottles based on machine vision and deep learning as claimed in claim 3, characterized in that: The method for iteratively training the defect detection model through the training set and the test set specifically includes: Obtain defect data sets and enhance the defect data sets, where the defect data sets include scratches, bulges, dents, cracked bottoms, bubbles, impurities, wrinkles, oil stains, black spots, size defects, and bottle mouth defects of medicine bottles. The defect data sets are enhanced by adding Gaussian noise, random flipping, Mosaic processing, random scaling, and random cropping. The defect data set is divided into a training set and a test set in a ratio of 3:
1. The defects in the training set and the test set are annotated using Labelimg software. Load the initial model of the defect detection model, and initialize the learning rate, hyperparameters, loss function, activation function, image batch size, and iteration rounds of the initial model; Obtain a training set, use the training set to iteratively train the initial model, calculate the loss function of the initial model in each round of iterative training, and use Bayesian optimization to update and optimize the hyperparameters of the initial model; Iterate the training based on the preset iteration rounds until the termination convergence, and save the best model obtained during the training process as the initial model; Obtain a test set, input the test set into the trained initial model, generate defect test results of the initial model based on multiple perspectives, output defect detection results, and determine whether the defect detection results meet the preset test accuracy; If the preset test accuracy is met, a converged defect detection model is output; If the preset test accuracy is not met, the hyperparameters of the initial model are updated and optimized based on the Adam optimizer.
5. The method for detecting defects in medicine bottles based on machine vision and deep learning as claimed in claim 4, characterized in that: The method for optimizing the hyperparameter update of the initial model based on the Adam optimizer specifically includes: Identify the hyperparameters of the Backbone block and the Neck block in the initial model, and calculate the optimal position of the individual whale and the global optimal position by combining the whale algorithm and the fitness function. The fitness function is expressed as: (1) in, represents the number of dimensions of the whale population, represents the dimension of the whale individual in the global search space, Respectively Wei, The position of individual whales in the global search space, is the position vector of the individual whale during global search, is the individual update convergence vector, Control parameters for the spiral shape of the whale algorithm; The optimal hyperparameters of Backbone block and Neck block are iteratively searched based on the particle swarm optimization algorithm. When the particle swarm optimization algorithm iteratively searches, the iterative calculation formula is expressed as: (2) (3) in, Indicates Particles in The hyperparameters for the iterations, is the inertia weight coefficient of the hyperparameter, are the individual optimal position and the global optimal position respectively, is a uniform random number, is the number of iterative searches, Represents the total number of iterative searches, represents the search acceleration factor, represents the initial search coefficient, For the The current position of each particle; Load the optimal hyperparameters of the Backbone block and the Neck block. The Adam optimizer uses the stochastic gradient descent function with momentum update parameters to iteratively update the hyperparameters of the Backbone block and the Neck block. The hyperparameter update expression is: (4) in, Respectively sequence The momentum of the iteration update, denote the learning rate hyperparameter and momentum update parameter respectively, is the gradient of the stochastic gradient descent function.
6. The method for detecting defects in medicine bottles based on machine vision and deep learning as claimed in claim 3, characterized in that: The ambient light noise value is calculated by the following formula: (5) (6) in, Represents the ambient light noise value, is the gray value of the background noise reduction set, They are respectively the background noise reduction set , No. The ambient light probability value of a group of temporal images, Represents the optical quantum efficiency of the sequential image acquisition device, are the background light intensity value and the mean light intensity, Indicates the light intensity value of natural light.
7. A medicine bottle defect detection system based on machine vision and deep learning, used to implement the medicine bottle defect detection method based on machine vision and deep learning as described in any one of claims 1 to 6, characterized in that: The medicine bottle defect detection system based on machine vision and deep learning includes: A standard model building module is used to obtain standard medicine bottle parameters, build a medicine bottle simulation model based on the standard medicine bottle parameters, and upload the medicine bottle simulation model and standard medicine bottle parameters to a standard database; The detection model construction module builds a defect detection model based on deep learning combined with the YOLOV5 model, obtains a defect data set, divides the defect data set into a training set and a test set, iteratively trains the defect detection model through the training set and the test set, and outputs a converged defect detection model; A defect judgment module is used to collect at least one set of machine vision-based medicine bottle images in real time to obtain a time-series image set, and to execute the defect detection model with the time-series image set as input. The defect detection model combines the medicine bottle simulation model to perform joint analysis and detection on the time-series image set to determine whether the medicine bottle associated with the time-series image set has defects; The defect recognition module identifies defects in a time-series image set based on a defect detection model, locates the defective area of the medicine bottle, completes the defect type classification and labeling of the defective area of the medicine bottle by short-circuiting and combining it with a random vector machine, loads the defect type classification and labeling results of the defective area of the medicine bottle, evaluates the defect degree of the defective area of the medicine bottle based on a hierarchical analysis algorithm, and outputs the defect degree evaluation results.
8. The medicine bottle defect detection system based on machine vision and deep learning as claimed in claim 7, characterized in that: The standard model building blocks include: A standard parameter acquisition unit, used to obtain standard medicine bottle parameters and normalize the standard medicine bottle parameters; A simulation model building unit, which builds a medicine bottle simulation model based on standard medicine bottle parameters, and uploads the medicine bottle simulation model and standard medicine bottle parameters to a standard database; Standard database, used to store medicine bottle simulation models and standard medicine bottle parameters.
Citation Information
Patent Citations
A comprehensive method for detecting appearance defects in medicine bottles
CN113324993B
Transparent part surface defect detection method and system based on deep learning algorithm
CN117437186A
Food glass bottle packaging defect detection method and system
CN119067933A