Automatic detection method, system, equipment and storage medium for damaged cement packaging bags
This paper presents a method for detecting damaged cement packaging bags by combining a YOLOv5 target recognition network and a focus loss function with an efficiency learning strategy. This method achieves automated detection of cement packaging bags, solves the problem of low efficiency in manual quality inspection in existing technologies, improves detection accuracy and production efficiency, and reduces costs.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-09
- Publication Date
- 2026-03-10
AI Technical Summary
In existing technologies, it is difficult to automate the detection of broken cement packaging bags, resulting in low efficiency of manual quality inspection and difficulty in accurately identifying substandard packaging, leading to a waste of manpower and management costs.
This paper adopts the S-model of the Yolov5 target recognition network, combined with the focus loss function and the efficient learning sample strategy, to achieve automatic detection of broken cement packaging bags by training a highly efficient network model. It utilizes real-time video acquisition and detection models for online detection and provides multiple methods for handling broken bags.
This technology has improved the automation level of cement packaging bag breakage detection, reduced labor costs, enhanced detection accuracy and production efficiency, simplified the operation process, and reduced the impact of broken bags on subsequent processes.
Smart Images

Figure CN115439414B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of text recognition, and particularly relates to a cement packaging bag breakage automatic detection method and system, computer equipment and a storage medium. BACKGROUND
[0002] The cement packaging bag is a main packaging container for containing cement, and the condition of the cement packaging bag determines the transportation safety and storage effectiveness of the cement product. The breakage of the cement packaging bag during the filling process in the factory will seriously affect the subsequent loading, transportation and storage processes. Therefore, an artificial quality inspection process is arranged between the filling and loading in the cement production process, mainly to remove the broken cement bag by workers before loading to ensure that the packaging quality is qualified for the loading process. Since the breakage rate is very low, about several per thousand, the arrangement of artificial quality inspection causes great waste of manpower, and it is difficult to accurately detect unqualified cement bags in the case of breakage. Therefore, if automatic breakage detection can be realized, the cement filling and transportation process will be further efficient, saving a large amount of manpower and management costs, and the cement bag breakage detection technology based on neural network is the most advanced and most promising image processing technology at present. The cement bag breakage detection based on neural network has strong robustness and can adapt to certain environmental changes, illumination changes, scaling, displacement and other forms of distortion, and can be popularized in different scenes, having strong universal applicability. SUMMARY
[0003] In order to solve the above problems of the prior art, the application provides a cement packaging bag breakage automatic detection method, system, computer equipment and storage medium, which has the advantages of high training efficiency by using an efficient learning sample strategy, and high recognition accuracy in a sample imbalance state by using the combination of the s model of Yolov5 and the focal loss function.
[0004] The first object of the application is to provide a cement packaging bag breakage automatic detection method.
[0005] The second object of the application is to provide a cement packaging bag breakage automatic detection system.
[0006] The third object of the application is to provide a computer equipment.
[0007] The fourth object of the application is to provide a storage medium.
[0008] The first object of the application can be achieved by adopting the following technical solutions:
[0009] A cement packaging bag breakage automatic detection method, the method comprising:
[0010] Obtain videos of cement bags and generate a dataset based on the videos; the dataset includes sample images of cement bags, each sample image containing labeled bounding boxes and categories;
[0011] The network model is initially trained using a portion of the cement bag sample images in the dataset to obtain the initially trained network model; the remaining samples in the dataset are automatically labeled using the initially trained network model, and the automatically labeled cement bag sample images are added to the dataset as a sample dataset; wherein, the network model is the S-model of the Yolov5 object recognition network.
[0012] The network model, which had been initially trained, was retrained using a sample dataset to obtain a packet breach detection model. The focus loss function was used as the loss function. An efficient learning sample strategy was adopted during the retraining process.
[0013] Real-time acquisition of cement bag videos; based on the cement bag videos, real-time online detection of cement bag breakage using a breakage detection model;
[0014] If the test result indicates a broken cement bag, the output will be displayed according to the user's requirements.
[0015] Furthermore, the focus loss function is:
[0016]
[0017] in, Given that the cement bag sample image is labeled with category y, the probability that the initially trained network model will predict that the labeled category is y′ is the probability that the cement bag will be labeled with category y. y is 1 or 0, which represent the labeled categories of normal cement bags and broken cement bags, respectively. y′ is 1 or 0, which represent the predicted labeled categories of normal cement bags and broken cement bags, respectively. "Otherwise" means y′=0, α∈[0,1] is a balancing factor, and γ>0 is an adjustable factor.
[0018] Furthermore, the sample dataset is divided into a training set and a test set;
[0019] The retraining process employs an efficient learning sample strategy, including:
[0020] Set the total number of iterations T and the size of the training batch, and fix the size of the cement bag sample images;
[0021] If the current iteration number t is the set number of rounds, then:
[0022] The training sample set D t Let D be the total sample set, i.e., D t =D, and jump to the training sample set D. tThe samples in the training set will be used to continue subsequent operations; the total sample set refers to all cement bag sample images in the training set.
[0023] otherwise:
[0024] Based on the results of training round t-1, calculate the sample set D of training round t-1. t-1 The probability p of all samples participating in this round of training (t) (x i ):
[0025]
[0026] in, For the sample set D t-1 medium sample x i In the true score, For the sample set D t-1 medium sample x i The highest score in the non-realistic class and All values are located in the interval [0, 1]; σ is an adjustable parameter;
[0027] With the normalized probability p (t) (x i ) as the sample set D t-1 The weights of each sample in D t-1 The sample set D for this training is obtained by sampling. t ;
[0028] Training sample set D t The samples in the dataset are used to obtain the scores S of all samples x across all categories through forward propagation. t (x) and calculate the loss function, then update the parameters in the network model through backpropagation and stochastic gradient descent for the next training;
[0029] If t reaches the maximum number of iterations T, the trained network model is obtained, which is used as the packet breaking detection model; otherwise, t = t + 1, and if the current iteration number t is the set number of rounds, continue to execute the subsequent operations.
[0030] Furthermore, the set number of rounds is the first 10 rounds or a number of rounds divisible by 10.
[0031] Furthermore, the step of detecting cement bag breakage in real time online using a breakage detection model based on cement bag video includes:
[0032] Image of cement bag obtained from video of cement bag;
[0033] Input the image of the cement bag into the damaged cement bag detection model to obtain an image of the cement bag with labeled rectangles and categories, which is used as the detection result;
[0034] Set the upper bound H for detection u and lower bound H d Detection results with bounding boxes below the upper detection bound and above the lower detection bound are retained; all other detection results are excluded. Where H... u and H d These are the vertical distances from the upper and lower bounds to the top edge of the image, respectively.
[0035] If the detection results for multiple consecutive frames are all of type 0, the bag is determined to be a broken cement bag; otherwise, it is determined to be a normal cement bag.
[0036] Furthermore, if the detection result indicates a broken cement bag, the output will be processed according to the user's requirements, including:
[0037] Display images and text information of the damaged package on the monitor and record the relevant information in a log file;
[0038] Alternatively, alarm voice messages can be played through a loudspeaker;
[0039] Alternatively, a level signal can be output at the I / O port pin of a computer device to control the baggage dropper.
[0040] Furthermore, the step of outputting a level signal at the I / O port pin of the computer device to control the package dropper includes:
[0041] The broken cement bag is tracked by comparing the overlap of the rectangular boxes in the cement bag images between two adjacent frames. If the overlap of the rectangular boxes between two frames is greater than a set threshold, the two rectangular boxes are considered to be successfully matched.
[0042] Record the moment t0 when the broken cement bag reaches the edge of the frame;
[0043] Based on the conveyor belt speed v and the distance d between the detection range and the bag dropper, the time difference Δt = d / v is calculated as the cement bag is conveyed from the edge of the screen to the bag dropper.
[0044] The time when the cement bag arrives at the unloading machine is t = t0 + Δt, which is taken as the start time of the unloading machine;
[0045] After the time Δt′ required for the bag-dropping machine to remove one bag of cement, the pin outputs a level signal to stop the bag-dropping machine and restore its original state.
[0046] Furthermore, the step of obtaining the cement bag video and generating a dataset based on the cement bag video includes:
[0047] Preliminary sample images of cement bags are obtained by periodically capturing images from the video of cement bags.
[0048] The images of cement bags were manually screened, retaining only those where the cement bag was clearly centered in the image.
[0049] The selected images were manually annotated, with the area containing the cement bag marked with a rectangle and its category labeled.
[0050] All labeled images constitute the dataset.
[0051] The second objective of this invention can be achieved by adopting the following technical solution:
[0052] An automatic detection system for damaged cement packaging bags, the system comprising:
[0053] The dataset acquisition module is used to acquire cement bag videos and obtain a dataset based on the cement bag videos; the dataset includes cement bag sample images, and the cement bag sample images include labeled rectangles and categories;
[0054] The first training module is used to perform preliminary training on the network model using the sample dataset to obtain the pre-trained network model; the network model is the S-model of the Yolov5 target recognition network.
[0055] The new dataset generation module is used to automatically label the remaining samples in the dataset using the pre-trained network model, and add the automatically labeled cement bag sample images to the dataset to obtain the sample dataset.
[0056] The second training module is used to retrain the initially trained network model using the sample dataset to obtain the packet breach detection model. The focus loss function is used as the loss function. An efficient learning sample strategy is adopted during the retraining process.
[0057] The online detection module is used to acquire real-time video of cement bags on the cement conveyor belt; based on the cement bag video, the module uses a bag breakage detection model to detect broken cement bags in real time online.
[0058] The broken bag result output module is used to output the result according to the user's requirements if the detection result is a broken cement bag.
[0059] The third objective of this invention can be achieved by adopting the following technical solution:
[0060] A computer device includes a processor and a memory for storing a processor-executable program, wherein when the processor executes the program stored in the memory, it implements the above-described automatic detection method for broken cement packaging bags.
[0061] The fourth objective of this invention can be achieved by adopting the following technical solution:
[0062] A storage medium storing a program, which, when executed by a processor, implements the above-described automatic detection method for damaged cement packaging bags.
[0063] The present invention has the following advantages over the prior art:
[0064] 1. The network model provided by this invention learns the essential features of a broken cement bag from a large number of different positive and negative sample images, and has a certain robustness in recognizing changes in ambient lighting, a certain degree of displacement, scaling and other forms of distortion in images.
[0065] 2. This invention improves existing neural networks by employing a focus loss function, which enables the network to achieve better training results when dealing with imbalanced data. It also adopts an efficient learning sample strategy, which allows the network to pay more attention to samples that are difficult to distinguish or misclassified at that time during each training round, and less attention to samples that are easy to classify correctly or very difficult to classify correctly, thereby improving the training efficiency of the network.
[0066] 3. The method provided by this invention has a high degree of automation in cement packaging production and inspection, high production efficiency, simple operation, and low operating cost because the broken package detection process does not require manual intervention.
[0067] 4. The method provided by this invention offers multiple ways to handle or alarm for broken cement bags, enabling semi-automatic or fully automatic removal of broken cement bags and reducing their impact on subsequent processes. Attached Figure Description
[0068] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the structures shown in these drawings without creative effort.
[0069] Figure 1 This is a flowchart illustrating the automatic detection method for damaged cement packaging bags in Example 1.
[0070] Figure 2 This is a schematic diagram of the automatic detection method for damaged cement packaging bags in Example 1.
[0071] Figure 3(a) is a schematic diagram of the manually selected positive samples to be labeled in Example 1 of this embodiment.
[0072] Figure 3(b) is a schematic diagram of the manually screened negative samples to be labeled in Example 1 of this embodiment.
[0073] Figure 4 This is a schematic diagram of the process of training the efficiency learning sample strategy in Embodiment 1.
[0074] Figure 5(a) is a diagram of the effect of automatic monitoring of a normal cement bag in this embodiment 1.
[0075] Figure 5(b) shows the effect of automatic monitoring of broken cement bags in this embodiment 1.
[0076] Figure 6 This is a schematic diagram illustrating the acquisition of the broken cement bag video and the removal of the broken cement bag by dropping it in this embodiment 1.
[0077] Figure 7 This is a structural block diagram of the automatic detection system for damaged cement packaging bags according to Embodiment 2 of the present invention.
[0078] Figure 8 This is a structural block diagram of the computer device according to Embodiment 3 of the present invention. Detailed Implementation
[0079] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention. It should be understood that the specific embodiments described are merely used to explain this application and are not intended to limit this application.
[0080] Example 1:
[0081] like Figure 1 , 2 As shown, the automatic detection method for damaged cement packaging bags provided in this embodiment includes two parts: offline and online. The offline part provides a network model to the online part, and the online part performs continuous online damage detection based on the network model trained in the offline part. Specifically, it includes the following steps:
[0082] S101. Obtain the video of the cement bag and get the dataset based on the video of the cement bag.
[0083] Furthermore, step S101 includes:
[0084] (1) Obtain a video of the cement bag and obtain a sample image of the cement bag based on the video.
[0085] Obtain a video of the cement bag, and periodically extract images from the video to obtain preliminary sample images of the cement bag.
[0086] This embodiment obtains video of cement bags by setting up a camera above the cement bag conveyor belt to record video.
[0087] (2) Preprocess the cement bag sample images to obtain the dataset.
[0088] The cement bag sample images were manually screened, retaining only those images where the cement bag was clearly centered in the image. The screened samples are as follows: Figure 3(a) and 3(b) As shown, positive samples are images of normal cement bags, and negative samples are images of cement bags with broken bags.
[0089] The selected samples were manually labeled, and the areas containing the cement bags were marked with rectangles to indicate their categories. All labeled samples constituted the dataset.
[0090] S102. Use a portion of the samples in the dataset to perform preliminary training on the network model, obtain the preliminarily trained network model, and then obtain the sample dataset.
[0091] The network model is the S-model of the Yolov5 target recognition network.
[0092] A subset of samples from the dataset is used to initially train the network model, resulting in a pre-trained model. This pre-trained model is then used to automatically label the remaining samples in the dataset. The network model automatically identifies cement bags in images and outputs their bounding boxes and category information. After manual review, these are added to the dataset as new samples, forming the complete sample dataset used to train the damaged bag detection network model.
[0093] The cement bag sample images labeled with categories are divided into training set, validation set and test set according to a certain ratio.
[0094] In this embodiment, the sample dataset is divided into training set, validation set and test set in a ratio of 6:2:2, with a total sample size of more than 10,000 images.
[0095] S103. Use the sample dataset to train the initially trained network model to obtain the packet breaking detection model.
[0096] Furthermore, step S103 includes:
[0097] (1) To address the imbalanced sample problem, the Focal Loss function is used as the loss function:
[0098]
[0099] in, Given that the cement bag sample image is labeled with category y, the network predicts the probability that the labeled category is y′; the positive and negative samples are labeled with categories 1 and 0, respectively; otherwise, y′ = 0, that is, the predicted negative sample; y′ = 1, that is, the predicted positive sample; α∈[0,1] is the balance factor, which is 0.25 in this embodiment; γ>0 is the adjustable factor, which is 1.5 in this embodiment.
[0100] (2) In order to reduce training costs, an efficient learning sample strategy is adopted to train the network model after initial training.
[0101] like Figure 4 As shown, step (2) specifically includes:
[0102] (2-1) Initialize the relevant parameters.
[0103] In this embodiment, the total number of iterations T = 200, the training batch size is 64, and the input size of the cement bag sample image is 640×640 pixels.
[0104] (2-2) If the current iteration number t is a specific round (in this embodiment, the specific round is the first 10 iterations and the number of iterations divisible by 10), then the sample set D for this training is... t Let D be the total sample set, i.e., D t =D, jump to step (5); if the current iteration number t is a normal number, continue to execute steps (3)-(4) to complete the selection of the training sample set; where the total sample set refers to all samples in the training set;
[0105] (2-3) Based on the results of the previous training round, calculate the previous training set D. t-1 The probability of all samples participating in this round of training is given by the formula:
[0106]
[0107] in, For sample x in the (t-1)th round of training i In the true score, This is the highest score among the non-realistic classes. and All are located in the interval [0, 1]; σ is an adjustable parameter, which is 0.75 in this embodiment.
[0108] (2-4) Using the normalized probability p (t) (x i ) as the weight of each sample in the set, for D t-1 A certain proportion of samples are sampled to obtain the new training set D. t The sampling ratio used in this embodiment is 50%.
[0109] (2-5) Training D t The samples in the dataset are used to obtain the scores S of all samples x across all categories through forward propagation. t (x) and calculate the loss function, then update the model parameters through backpropagation and stochastic gradient descent for the next training iteration;
[0110] (2-6) Repeat steps (2-2) to (2-5) until the maximum number of iterations is reached, thus obtaining the packet breaking detection model.
[0111] S104. Acquire real-time video of cement bags on the cement conveyor belt, and detect cement bag breakage in real-time online using a breakage detection model based on the cement bag video.
[0112] Furthermore, step S104 includes:
[0113] (1) The video of the cement bag was acquired in real time using a camera. It is said that the video of the cement bag was automatically detected online using a broken bag detection model to obtain the target box and its category.
[0114] (2) Set the upper limit of detection H u and lower bound H d To ensure the target is in the optimal detection area, H u and H d These are the vertical distances from the upper and lower detection boundaries to the top boundary of the image, respectively. Only results where the target bounding box is below the upper detection boundary but above the lower detection boundary are retained; results where the target bounding box is above the upper detection boundary or below the lower detection boundary are excluded.
[0115] In this embodiment, the screen height is 640 pixels, and the upper boundary H is detected. u For 192 pixels, detect the lower bound H. d It is 576 pixels.
[0116] (3) Continuous statistical analysis of package breakage improves detection accuracy.
[0117] If 3 or more frames out of 5 consecutive frames are identified as broken packets, then a broken cement bag is determined to have occurred. The detection result is as follows: Figure 5(a) and 5(b) As shown.
[0118] S105. Output the results of packet breach identification according to the method required by the user.
[0119] Furthermore, step S105 includes:
[0120] (1) Display the image and text information of the damaged package on the monitor and record the relevant information in the log document file;
[0121] (2) Play alarm voice information through a loudspeaker;
[0122] (3) Output a level signal at the IO port pin of the computer device to control the bag drop machine.
[0123] Furthermore, step (3) specifically includes:
[0124] (3-1) After determining that a broken cement bag has appeared in step S103, the broken cement bag is then tracked by comparing the intersection over Union (IoU) of the cement bag target boxes between two adjacent frames. The two target boxes with an IoU greater than the threshold between the two frames are considered to be successfully matched.
[0125] In this embodiment, the IoU threshold is set to 0.25. If the cement bag target is successfully tracked, it will be tracked until it reaches the edge of the screen.
[0126] (3-2) such as Figure 6 As shown, the time t0 when the broken cement bag reaches the edge of the screen is recorded. Based on the conveyor belt speed v and the distance d between the camera's detection range and the bag-dropping machine, the time difference Δt = d / v between the cement bag's travel time from the edge of the screen to the bag-dropping machine is calculated. Therefore, the time t when the cement bag arrives at the bag-dropping machine is t = t0 + Δt, which is the start time of the bag-dropping machine. At time t, a level signal is output from the pin to start the bag-dropping machine.
[0127] (3-3) After the time Δt′ required for the bag-dropping machine to remove one bag of cement, the pin outputs a level signal to stop the bag-dropping machine and restore it.
[0128] Those skilled in the art will understand that all or part of the steps in the methods of the above embodiments can be implemented by a program instructing related hardware, and the corresponding program can be stored in a computer-readable storage medium.
[0129] It should be noted that although the method operations of the above embodiments are described in a specific order in the accompanying drawings, this does not require or imply that these operations must be performed in that specific order, or that all the operations shown must be performed to achieve the desired result. On the contrary, the order of execution of the described steps may be changed. Additionally or alternatively, certain steps may be omitted, multiple steps may be combined into one step, and / or one step may be broken down into multiple steps.
[0130] Example 2:
[0131] like Figure 7 As shown, this embodiment provides an automatic detection system for damaged cement packaging bags. The system includes a dataset acquisition module 701, a first training module 702, a new dataset generation module 703, a second training module 704, an online detection module 705, and a damaged bag result output module 706, wherein:
[0132] The dataset acquisition module 701 is used to acquire cement bag videos and obtain a dataset based on the cement bag videos; the dataset includes cement bag sample images, and the cement bag sample images include labeled rectangles and categories;
[0133] The first training module 702 is used to perform preliminary training on the network model using the sample dataset to obtain the pre-trained network model; the network model is the S-model of the Yolov5 target recognition network.
[0134] The new dataset generation module 703 is used to automatically label the remaining samples in the dataset using the pre-trained network model, and add the automatically labeled cement bag sample images to the dataset to obtain the sample dataset.
[0135] The second training module 704 is used to retrain the initially trained network model using the sample dataset to obtain the packet breach detection model; the focus loss function is used as the loss function; and an efficient learning sample strategy is adopted during retraining.
[0136] The online detection module 705 is used to acquire cement bag videos in real time and detect cement bag damage in real time using a bag damage detection model based on the cement bag videos.
[0137] The broken bag result output module 706 is used to output the result according to the user's requirements if the detection result is a broken cement bag.
[0138] The specific implementation of each module in this embodiment can be found in Embodiment 1 above, and will not be repeated here. It should be noted that the system provided in this embodiment is only illustrated by the division of the above functional modules. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure can be divided into different functional modules to complete all or part of the functions described above.
[0139] Example 3:
[0140] This embodiment provides a computer device, which can be a computer, such as... Figure 8 As shown, the system bus 801 connects a processor 802, a memory, an input device 803, a display 804, and a network interface 805. The processor provides computing and control capabilities. The memory includes a non-volatile storage medium 806 and internal memory 807. The non-volatile storage medium 806 stores the operating system, computer programs, and a database. The internal memory 807 provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. When the processor 802 executes the computer program stored in the memory, it implements the automatic detection method for broken cement packaging bags in Embodiment 1, as follows:
[0141] Obtain videos of cement bags and generate a dataset based on the videos; the dataset includes sample images of cement bags, each sample image containing labeled bounding boxes and categories;
[0142] The network model is initially trained using a portion of the cement bag sample images in the dataset to obtain the initially trained network model; the remaining samples in the dataset are automatically labeled using the initially trained network model, and the automatically labeled cement bag sample images are added to the dataset as a sample dataset; wherein, the network model is the S-model of the Yolov5 object recognition network.
[0143] The network model, which had been initially trained, was retrained using a sample dataset to obtain a packet breach detection model. The focus loss function was used as the loss function. An efficient learning sample strategy was adopted during the retraining process.
[0144] Real-time acquisition of cement bag videos; based on the cement bag videos, a cement bag breakage detection model is used to detect cement bag breakage in real time online.
[0145] If the test result indicates a broken cement bag, the output will be displayed according to the user's requirements.
[0146] Example 4:
[0147] This embodiment provides a storage medium, which is a computer-readable storage medium, storing a computer program. When the computer program is executed by a processor, it implements the automatic detection method for broken cement packaging bags in Embodiment 1 above, as follows:
[0148] Obtain videos of cement bags and generate a dataset based on the videos; the dataset includes sample images of cement bags, each sample image containing labeled bounding boxes and categories;
[0149] The network model is initially trained using a portion of the cement bag sample images in the dataset to obtain the initially trained network model; the remaining samples in the dataset are automatically labeled using the initially trained network model, and the automatically labeled cement bag sample images are added to the dataset to obtain the sample dataset; wherein, the network model is the S-model of the Yolov5 object recognition network.
[0150] The network model, which had been initially trained, was retrained using a sample dataset to obtain a packet breach detection model. The focus loss function was used as the loss function. An efficient learning sample strategy was adopted during the retraining process.
[0151] Real-time acquisition of cement bag videos; based on the cement bag videos, a cement bag breakage detection model is used to detect cement bag breakage in real time online.
[0152] If the test result indicates a broken cement bag, the output will be displayed according to the user's requirements.
[0153] It should be noted that the computer-readable storage medium in this embodiment can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof.
[0154] The above description is merely a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope disclosed in the present invention, based on the technical solution and inventive concept of the present invention, shall fall within the scope of protection of the present invention.
Claims
1. A method for automatically detecting a broken bag of a cement packaging bag, characterized by, The method comprises: Obtaining a cement bag video, and obtaining a data set according to the cement bag video; the data set comprises cement bag sample pictures, the cement bag sample pictures are of a fixed size, and comprise labeled rectangular frames and categories; Part of the cement bag sample pictures in the data set are used to preliminarily train a network model, to obtain a preliminarily trained network model; the preliminarily trained network model is used to automatically label the remaining samples in the data set, and the automatically labeled cement bag sample pictures are added to the data set as a sample data set; the network model is an s model of a Yolov5 target recognition network; the sample data set is divided into a training set and a test set; The preliminarily trained network model is retrained by using the sample data set, to obtain a broken bag detection model; a focal loss function is used as a loss function; when retraining, an efficient learning sample strategy is used; Real-time cement bag videos are obtained, and the broken bag detection model is used to real-time online detect broken cement bags according to the real-time cement bag videos; If the detection result is a broken cement bag, a user-required mode is used for output; When retraining, the efficient learning sample strategy comprises: S1: if the current iteration number t is a set number of rounds, then: The sample set of this training The total sample set That is And jump to step S4, continue to perform subsequent operations; wherein, the total sample set refers to all cement bag sample pictures in the training set Otherwise: S2: According to the result of t-1 round training, calculate the sample set of t-1 round training Probability of all samples participating in this round of training : ; wherein, is a set of samples is a sample is the score of the sample in the real class, is a set of samples is a sample is the highest score of the sample in the non-real class, and are located in interval; is an adjustable parameter; S3: the normalized probability as the sample set the weight of each sample in the set, and the sample set for this training is obtained by sampling ; S4: training sample set all samples in S4 are forward propagated to get all samples scores of all classifications and calculate the loss function, update the parameters in the network model by back propagation and stochastic gradient descent method for the next training; S5: if t reaches the maximum number of iterations, a trained network model is obtained, i.e., as a broken packet detection model; otherwise, S4: if the loss function value is less than the preset threshold, the training of the network model is completed, and the trained network model is obtained, i.e., as a broken packet detection model; otherwise, and return to step S1 to continue subsequent operations.
2. The automatic detection method for cement bag breakage according to claim 1, characterized in that, The focal loss function is: ; wherein, is the probability that the network model predicts the class of the cement bag sample picture as under the premise that the class of the cement bag sample picture is labeled as ; is 1 or 0, respectively representing the labeled class of the normal cement bag and the broken bag cement bag; is 1 or 0, respectively representing the labeled class of the predicted normal cement bag and the broken bag cement bag; otherwise represents , is a balance factor; is an adjustable factor.
3. The method of claim 1, wherein the method comprises: The set number of rounds is the first 10 rounds or a number of rounds that can be divided by 10.
4. The automatic detection method for cement bag breaking according to claim 1, characterized in that, The broken bag detection model is used to real-time online detect broken cement bags according to the real-time cement bag videos, which comprises: Cement bag pictures are obtained according to the cement bag videos; The cement bag pictures are input into the broken bag detection model, to obtain cement bag pictures with labeled rectangular frames and categories as detection results; Setting a detection upper bound and a detection lower bound , retaining the detection results whose rectangular frames are lower than the detection upper bound and higher than the detection lower bound, and excluding the rest of the detection results; wherein, and are the vertical distances between the detection upper bound and lower bound and the upper boundary of the picture, respectively. If the categories of the detection results obtained by a plurality of frames in a continuous set of frames are all 0, it is determined that the cement bags are broken, otherwise, it is determined that the cement bags are normal.
5. The automatic detection method for cement bag breaking according to claim 1, characterized in that, If the detection result is a broken cement bag, a user-required mode is used for output, which comprises: Broken bag images and text information are displayed in a display, and relevant information is recorded in a log document file; Or alarm voice information is played through a loudspeaker; Or a level signal is output at a computer device IO port pin to control a broken bag machine.
6. The method of claim 5, wherein the method is characterized by: The level signal is output at the computer device IO port pin to control the broken bag machine, which comprises: The broken cement bags are tracked by comparing the rectangular frame overlap degrees in the cement bag pictures of adjacent two frames; if the rectangular frame overlap degrees between two frames are greater than a set threshold, the two rectangular frames are matched successfully. Recording the moment when a broken bag of cement reaches the edge of the picture ; According to the running speed of the conveyor belt and the distance from the detection range to the bag drop machine , the time difference for the cement bag to be conveyed from the edge of the screen to the bag drop machine is calculated ; the time at which the cement bag arrives at the drop-off machine i.e. as the start time of the drop-off machine; Time required to remove a bag of cement from the drop chutes After the pin output level signal stops the drop chute operation and restores.
7. The method according to any one of claims 1 to 6, wherein The cement bag video is obtained, and the data set is obtained according to the cement bag video, which comprises: Pictures are obtained by periodically intercepting the cement bag video; Only the pictures in which the cement bags are clearly located in the central area of the picture are reserved by manually screening the cement bag sample pictures; The areas where the cement bags are located are labeled by rectangular frames, and categories are labeled by manually labeling the screened pictures; All the labeled pictures constitute the data set.
8. A system for automatically detecting a broken cement bag, for implementing the method for automatically detecting a broken cement bag according to any one of claims 1 to 7, characterized in that, The system comprises: A data set acquisition module is configured to obtain a cement bag video, and obtain a data set according to the cement bag video; the data set comprises cement bag sample pictures, and the cement bag sample pictures comprise labeled rectangular frames and categories. A first training module is configured to perform preliminary training on the network model by using a sample data set, and obtain a preliminarily trained network model; the network model is an s model of a Yolov5 target recognition network; A new data set generation module is configured to perform automatic labeling on the remaining samples in the data set by using the preliminarily trained network model, and add the automatically labeled cement bag sample pictures into the data set as a sample data set; A second training module is configured to perform re-training on the preliminarily trained network model by using the sample data set, and obtain a broken bag detection model; wherein, a focal loss function is used as a loss function; when performing the re-training, an efficient learning sample strategy is used; An online detection module is configured to obtain a cement bag video in real time, and perform real-time online detection on the cement bag broken bag by using the broken bag detection model according to the cement bag video; A broken bag result output module is configured to output according to a user required mode if the detection result is a broken bag cement bag.
9. A storage medium storing a program, characterized by comprising: The program is executed by the processor to implement the cement bag broken bag automatic detection method in any one of claims 1-7.
Citation Information
Patent Citations
Parcel defect identification method and device, equipment and storage medium
CN113192017A
SAR target identification method based on supervised minimization deep learning model
CN113468939A