Foreign object detection and identification method, system and electronic device
By combining the yolov8 detection model and the 3D time series detection model, using local and global information, calculating the error rate of each model and assigning weights, the problem of poor foreign object detection in the existing technology is solved, and higher detection accuracy and efficiency are achieved. .
Patent Information
- Application Number
- CN202411111474.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-14
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2044-08-14
AI Technical Summary
The pantograph foreign object detection model in the prior art has a poor detection effect on foreign object intrusion, is prone to false positives and false negatives, and is difficult to achieve very high detection requirements.
Using the foreign object detection and identification method that combines the yolov8 detection model and the 3D time series detection model, by obtaining the local and global information of the image, the error rate of each detection model is calculated and given different weights, and the final intrusion probability is calculated based on the weights to improve detection accuracy. .
It improves the accuracy and efficiency of foreign object intrusion detection, reduces false positives and false negatives, and can more accurately determine whether there is foreign object intrusion in the image.
Smart Images

Figure CN118628725B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of pantograph safety monitoring in railway systems, and in particular to a foreign object detection and identification method, system and electronic equipment. Background Art
[0002] The pantograph is a key component installed on the top of a high-speed EMU train to obtain electricity from the contact network. Since its body is exposed to the air, it will inevitably be disturbed by various external factors. When the pantograph is invaded by foreign objects (plastic bags, sky lanterns, branches, etc.), it will cause the pantograph to get stuck, the net to be pulled, the line to catch fire, and other faults. It is directly related to the overall smooth and safe operation of the train. Traditional pantograph detection relies on railway staff to observe the video transmitted by the roof video box in real time, which is a great test of the staff's energy. At the same time, a special person is required to check in real time whether there are foreign objects. If foreign objects are not checked in time, it will have a great impact on railway safety.
[0003] In the prior art, for example, patent publication number CN115272830A proposes a pantograph foreign object detection method based on deep learning, first training the pantograph foreign object detection model: obtaining multiple pantograph images in a normal state, and preprocessing each image; performing convolution processing on the local area to obtain a feature vector; the fully connected layer cascades and transforms the dimensions of each feature vector, outputs a three-dimensional feature vector corresponding to the local area, and records it as a spatial coordinate; calculates the loss function and determines whether it is less than a threshold value A. If so, saves the network parameters and completes the model training; if not, uses the loss function as the objective function, uses the optimization method to iterate the optimized deep learning model, saves the network parameters, and completes the model training.
[0004] However, the actual situation is very complicated. It is easy to have false positives and false negatives when only training a single target detection method. For example, when the threshold is set relatively high, the model will have many missed detections; if the threshold is set relatively low, there will be many false positives. These are the main problems faced by a single model. If you want to achieve very high detection requirements, you need to collect a lot of data that includes all possible foreign body intrusion scenarios to train the model, which is difficult to achieve in reality. The detection effect of actual foreign body intrusion is limited. Summary of the invention
[0005] In view of the deficiencies in the prior art, the present invention provides a foreign body detection and identification method, system and electronic device, which solves the problem that the target detection model in the prior art has poor detection effect on foreign body intrusion.
[0006] At least one embodiment of the present invention provides a foreign body detection and identification method, including:
[0007] Acquire at least one frame of image, and input the at least one frame of image into a first target detection model to determine a first probability corresponding to each frame of image, wherein the first probability represents a probability of a foreign object existing in each frame of image;
[0008] Taking the weighted average of the first probabilities as the second probability;
[0009] Inputting at least one frame of image into a second target detection model to obtain a third probability, wherein the third probability represents a probability of foreign objects existing in all images;
[0010] Obtaining a first error rate of the first target detection model tested on the test set, and a second error rate of the second target detection model tested on the test set;
[0011] Using the first error rate, assigning a first weight to the second probability to obtain a first true value, and using the second error rate, assigning a second weight to the third probability to obtain a second true value;
[0012] The first true value and the second true value are combined to obtain a fourth probability, and whether there is foreign body intrusion in all images is determined according to the fourth probability.
[0013] The technical solution disclosed in the present invention has at least the following beneficial effects:
[0014] The present invention combines two detection models to further improve the detection effect of foreign body intrusion, and the two detection models complement each other rather than being simply stacked, and can accurately determine whether there is foreign body intrusion in the image.
[0015] In a foreign object detection and identification method provided by one embodiment of the present invention, at least one frame of image is acquired, and at least one frame of image is input into a first target detection model to determine a first probability corresponding to each frame of image, including:
[0016] Reading video stream information, inputting any frame of image therein as a first target image into the first target detection model, and obtaining a first probability corresponding to the first target image;
[0017] If the first probability is greater than a first preset threshold, extracting images every other frame starting from the first target image according to the video stream information to obtain multiple frames of the second target image;
[0018] Input a plurality of frames of the second target image into the first target detection model to obtain a first probability corresponding to each of the second target images.
[0019] The technical solution disclosed in the present invention has at least the following beneficial effects:
[0020] By using the first target detection model to detect a frame of image, it is possible to roughly and quickly determine whether there is a possibility of foreign object intrusion in the frame image, and then quickly filter out images that are unlikely to have foreign object intrusion, thereby reducing the subsequent calculation burden.
[0021] In a foreign object detection and identification method provided by one of the embodiments of the present invention, the first target detection model is a yolov8 detection model, and the second target detection model is a 3D time series detection model.
[0022] The technical solution disclosed in the present invention has at least the following beneficial effects:
[0023] The yolov8 detection model can fully consider the local information of each frame image, while the 3D time series detection model is used to fully consider the global information of each image. By combining the two, this method can more accurately determine whether there is foreign body intrusion in the image.
[0024] In a foreign body detection and identification method provided in one embodiment of the present invention, the 3D time series detection model includes a Bi-LSTM layer and three 3D-CNN layers, wherein:
[0025] The 3D-CNN layer is used to extract preset features of foreign body intrusion in the image, and the Bi-LSTM layer is used to obtain a third probability according to the preset features.
[0026] The technical solution disclosed in the present invention has at least the following beneficial effects:
[0027] By capturing the preset features through three 3D-CNN layers and inputting them into the Bi-LSTM layer at the same time, this 3D time series detection model has higher accuracy than directly using the original image features.
[0028] In a foreign body detection and identification method provided by one embodiment of the present invention, obtaining a first error rate of the first target detection model tested on a test set and a second error rate of the second target detection model tested on a test set includes:
[0029] Obtain historical image data as a test set, input the test set into the yolov8 detection model, and determine the first error rate of the yolov8 detection model based on the obtained test results and the true results;
[0030] The test set is input into the 3D timing detection model, and the second error rate of the 3D timing detection model is determined based on the comparison between the obtained test result and the real result.
[0031] The technical solution disclosed in the present invention has at least the following beneficial effects:
[0032] By calculating the error rates of the two detection models, the accuracy of the corresponding detection models when applied to pantograph foreign object detection can be obtained, which makes it easier to assign different weights to different detection models to improve detection accuracy.
[0033] In a foreign body detection and identification method provided in one embodiment of the present invention, the calculation formula of the fourth probability is as follows:
[0034] ,
[0035] in, represents the fourth probability, represents the first truth value, represents the second truth value, is the first weight, is the second probability, is the second weight, is the third probability.
[0036] The technical solution disclosed in the present invention has at least the following beneficial effects:
[0037] By using the above formula, the first true value and the second true value can be combined, so that the method can fully consider the local information and global information of the image to judge the intrusion of foreign objects, thereby improving the detection accuracy of the intrusion of foreign objects.
[0038] In a foreign body detection and identification method provided in one embodiment of the present invention, the calculation formulas of the first weight and the second weight are as follows:
[0039] ,
[0040] Among them, when When expressed as the first weight, Expressed as the first error rate; when When expressed as the second weight, It is expressed as the second error rate.
[0041] The technical solution disclosed in the present invention has at least the following beneficial effects:
[0042] Using the above formula, different weights can be assigned to the yolov8 detection model and the 3D time series detection model according to the first error rate and the second error rate.
[0043] At least one embodiment of the present invention further provides a foreign body detection and identification system, including:
[0044] A first detection module, acquiring at least one frame of image, and inputting at least one frame of image into a first target detection model to determine a first probability corresponding to each image, wherein the first probability represents a probability of a foreign object existing in the corresponding frame of image;
[0045] A first processing module, taking a weighted average of the first probabilities as a second probability;
[0046] A second detection module inputs at least one frame of image into a second object detection model to obtain a third probability, wherein the third probability represents a probability of foreign objects existing in all images;
[0047] A second processing module obtains a first error rate of the first target detection model tested on the test set, and a second error rate of the second target detection model tested on the test set;
[0048] a truth value calculation module, using the first error rate to assign a weight to the second probability to obtain a first truth value, and using the second error rate to assign a weight to the third probability to obtain a second truth value;
[0049] The judgment module combines the first true value and the second true value to obtain a fourth probability, and judges whether there is foreign body invasion on the image according to the fourth probability.
[0050] In a foreign body detection and identification system provided by one embodiment of the present invention, the first detection module specifically includes:
[0051] Reading video stream information, inputting any frame of image therein as a first target image into the first target detection model, and obtaining a first probability corresponding to the first target image;
[0052] If the first probability is greater than a first preset threshold, extracting images every other frame starting from the first target image according to the video stream information to obtain multiple frames of the second target image;
[0053] Input a plurality of frames of the second target image into the first target detection model to obtain a first probability corresponding to each of the second target images.
[0054] The present invention also provides an electronic device, comprising a memory, a processor, and a program stored in the memory and running on the processor, wherein the processor implements the steps of the above-mentioned foreign body detection and identification method when executing the program. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] Figure 1 A schematic diagram of a flow chart of a foreign body detection and identification method according to the present invention;
[0056] Figure 2A logic diagram of a foreign body detection and identification method according to the present invention;
[0057] Figure 3 The present invention is a flow chart of a foreign body detection and identification system. DETAILED DESCRIPTION
[0058] The principles and features of the present invention are described below. The examples given are only used to explain the present invention and are not used to limit the scope of the present invention.
[0059] In addition, those skilled in the art may combine and associate different embodiments or examples and features of different embodiments or examples described in this specification without mutual contradiction.
[0060] The present invention provides a foreign body detection and identification method, please refer to Figure 1 As shown, including:
[0061] Acquire at least one frame of image, and input the at least one frame of image into a first target detection model to determine a first probability corresponding to each frame of image, wherein the first probability represents a probability of a foreign object existing in each frame of image;
[0062] Taking the weighted average of the first probabilities as the second probability;
[0063] Inputting at least one frame of image into a second target detection model to obtain a third probability, wherein the third probability represents a probability of foreign objects existing in all images;
[0064] Obtaining a first error rate of the first target detection model tested on the test set, and a second error rate of the second target detection model tested on the test set;
[0065] Using the first error rate, assigning a first weight to the second probability to obtain a first true value, and using the second error rate, assigning a second weight to the third probability to obtain a second true value;
[0066] The first true value and the second true value are combined to obtain a fourth probability, and whether there is foreign body intrusion in all images is determined according to the fourth probability.
[0067] Specifically, at least one frame of image, in this embodiment, refers to 7 images. Of course, the present invention is not limited to this number, and the number of images can be increased or decreased accordingly according to the difficulty of foreign body intrusion judgment;
[0068] In order to enhance the accuracy of the present invention in detecting foreign objects in the pantograph at the same time, the above 7 images are all images extracted at alternate frames under the same video stream information;
[0069] The present invention combines two detection models to further improve the detection effect of foreign body intrusion, and the two detection models complement each other rather than being simply stacked, and can accurately determine whether there is foreign body intrusion in the image.
[0070] Specifically, obtaining at least one frame of image and inputting at least one frame of image into a first target detection model to determine a first probability corresponding to each image includes:
[0071] Read the video stream information, input any frame of the image as the first target image into the first target detection model, and obtain a first probability corresponding to the first target image;
[0072] If the first probability is greater than a first preset threshold, extracting images every other frame from the first target image according to the video stream information to obtain multiple frames of second target images;
[0073] The plurality of frames of the second target image are fed into the first target detection model to obtain a first probability corresponding to each second target image.
[0074] By using the first target detection model to detect a frame of image, it is possible to roughly and quickly determine whether there is a possibility of foreign object invasion in the frame image, and then quickly filter out images that are unlikely to have foreign object invasion, reducing the subsequent calculation burden;
[0075] It should be understood that in the above solution, when the target detection model in the prior art detects foreign body intrusion, if the threshold is set relatively high, the model will have many missed detections; if the threshold is set relatively low, there will be many false alarms;
[0076] The first preset threshold of the present invention can be set lower. For example, if the conventional target detection model threshold is set to 0.8, the first preset threshold in the present application can be set to 0.5, thereby avoiding missed detection.
[0077] At the same time, in the above, any one frame of the image is used as the first target image, and 6 images are continuously extracted from the first target image as the second target image. It should be understood that in the same video stream, the time interval for extracting the first target image can be set according to the length of the video stream information and the need of the pantograph detection frequency;
[0078] For example, a frame of image may be extracted as the first target image every one minute, or a frame of image may be extracted as the first target image every 10 minutes or one hour for determination; or the first target image may be extracted only once in a video flow information;
[0079] If the extracted first target image is put into the first target detection module and the obtained first probability is lower than the first preset threshold, it can be considered that there is no foreign body intrusion in the time period, and the process can jump to the next moment and extract the first target image for judgment;
[0080] If the first probability is higher than the first preset threshold, it can be considered that there may be foreign body intrusion during the time period, and subsequent judgment is performed.
[0081] Specifically, the first target detection model is the yolov8 detection model, and the second target detection model is the 3D time series detection model.
[0082] Yolov8 is a SOTA model that builds on the historical versions of the Yolo series and introduces new features and improvements to further improve performance and flexibility, making it the best choice for tasks such as target detection, image segmentation, and pose estimation. Its specific innovations include a new backbone network, a new Ancher-Free detection head, and a new loss function. Backbone part: It borrows the idea of the CSP module, but replaces the C3 module in Yolov5 with the C2f module to achieve further lightweighting. At the same time, it uses the SPPF module in Yolov5 and carefully fine-tunes models of different scales, which greatly improves model performance. Neck part: It continues to use the idea of PAN, but YOLOv8 removes Downsampling layer. Head part: Compared with YOLOv5, Yolov8 has changed to the current mainstream decoupled head structure (Decoupled-Head), separating the classification and detection heads, and also changed from Anchor-Based to Anchor-Free. Loss calculation: Use VFL Loss as the classification loss and DFL Loss+CIOU Loss as the regression loss.
[0083] Specifically, the 3D time series detection model includes a Bi-LSTM layer and three 3D-CNN layers, where:
[0084] The three 3D-CNN layers are used to extract the preset features of foreign body intrusion in the image, and the Bi-LSTM layer is used to obtain the third probability based on the preset features.
[0085] The 3D time series detection model is as follows: first, the image is normalized to a fixed size. Then it is input into the 3D-CNN layer. In the intrusion identification task, kd represents the time dimension, that is, the number of consecutive frames processed by each 3D convolution kernel. In the 3D convolution calculation, kd consecutive frames are first combined into a 3D image sequence, and then the convolution calculation is performed in the image sequence. The 3D convolution kernel slides on kd consecutive frames. Each time it slides, the elements in the corresponding positions in the kd consecutive frames must be multiplied and added with the parameters in the convolution kernel, and finally a value in the output feature map is obtained. In the 3D-CNN layer, 3D convolution is used to extract features for the presence of foreign objects. The network has only 3 convolution layers, 1 fully connected layer, and 2 pooling layers. Among them, the first two convolution layers are 3D convolution layers, and the convolution kernel sizes are 7×7×3 and 7×6×3, which means that each convolution kernel processes 7×7 and 7×6 areas in 3 consecutive frames. The foreign body intrusion recognition model uses 3D convolution, which allows it to extract features from the spatial and temporal dimensions, thereby capturing information from multiple consecutive frames. The features extracted by the detection model are stacked in chronological order into a fixed-length feature, which is then input into the model (Bi-LSTM). Because the temporal model uses the features extracted by the 3D-CNN layer, the model's accuracy is higher than that of directly using the original image features.
[0086] The yolov8 detection model can fully consider the local information of each frame image, while the 3D time series detection model is used to fully consider the global information of each image. By combining the two, this method can more accurately determine whether there is foreign body intrusion in the image.
[0087] By capturing the preset features through three 3D-CNN layers and inputting them into the Bi-LSTM layer at the same time, this 3D time series detection model has higher accuracy than directly using the original image features.
[0088] Specifically, obtaining a first error rate of misjudgment of intrusion foreign body detection by the first target detection model and a second error rate of misjudgment of intrusion foreign body detection by the second target detection model includes:
[0089] Obtain historical image data as a test set, input the test set into the yolov8 detection model, and determine the first error rate of the yolov8 detection model based on the comparison of the obtained test results with the actual results;
[0090] The test set is input into the 3D timing detection model, and the second error rate of the 3D timing detection model is determined based on the comparison between the obtained test result and the real result.
[0091] By calculating the error rates of the two detection models, the accuracy of the corresponding detection models when applied to pantograph foreign object detection can be obtained, which makes it easier to assign different weights to different detection models to improve detection accuracy.
[0092] Specifically, using the first error rate to assign a weight to the second probability to obtain the first true value, and using the second error rate to assign a weight to the third probability to obtain the second true value, including:
[0093] According to the first error rate, a first weight is assigned to the corresponding yolov8 detection model, and a first true value is obtained according to the first weight and the second probability;
[0094] According to the second error rate, a second weight is assigned to the corresponding 3D timing detection model, and a second true value is obtained according to the second weight and the third probability.
[0095] By calculating the first true value and the second true value, the dependence between the yolov8 detection model and the 3D timing detection model in the detection process can be obtained, and based on this, it can be judged whether there is foreign body intrusion.
[0096] Specifically, the calculation formula of the fourth probability is as follows:
[0097] ,
[0098] in, represents the fourth probability, represents the first truth value, represents the second truth value, is the first weight, is the second probability, is the second weight, is the third probability.
[0099] By using the above formula, the first true value and the second true value can be combined, so that the method can fully consider the local information and global information of the image to judge the intrusion of foreign objects, thereby improving the detection accuracy of the intrusion of foreign objects.
[0100] Specifically, the calculation formulas of the first weight and the second weight are as follows:
[0101] ,
[0102] Among them, when When expressed as the first weight, Expressed as the first error rate; when When expressed as the second weight, It is expressed as the second error rate.
[0103] Using the above formula, different weights can be assigned to the yolov8 detection model and the 3D time series detection model according to the first error rate and the second error rate.
[0104] In summary, please refer to Figure 2 As shown, the core of the present invention in foreign body intrusion detection is:
[0105] The core technical methods and steps of this solution are:
[0106] ① Draw ROI on the camera image to filter the non-pantograph part, obtain the camera, read the video stream information in time sequence, and get a frame of image.
[0107] ② Input the frame of image into the yolov8 detection model, and obtain the model detection result, that is, the first probability, through the yolov8 detection model. If the first probability is higher than the first preset threshold, it is considered that there may be foreign matter and enter ③, otherwise wait for 10 minutes and re-enter ①.
[0108] ③ Starting from the above frame, extract alternate frames to obtain 6 consecutive frames of images, 2 frames per second, plus the first frame, a total of 7 frames of images are obtained.
[0109] ④ Use the yolov8 detection model to detect the newly acquired 6 frames of images and obtain 6 first probabilities; if multiple intruding foreign objects are detected in one image, obtain the detection result with the highest probability in the model output results. If no target is detected, the probability is 0. Calculate the weighted average of the first probabilities corresponding to the output of these 7 frames of images: the second probability P1, and save the coordinate information of the target with the highest probability.
[0110] ⑤Use the 3D time series detection model, input these 7 frames of images into the 3D-CNN layers at the same time, obtain the output results of the 3D-CNN layers, that is, extract the 3D, motion, border, texture and other features related to the intrusion foreign matter in the input image, and then input the extracted features into the Bi-LSTM model to obtain the classification result of the model: the third probability P2, where the range of P2 is [0-1], indicating the probability of the existence of intrusion foreign matter in these 7 frames of images. 0 means no intrusion foreign matter exists, and the larger the P2, the higher the possibility of the existence of intrusion foreign matter.
[0111] ⑥ Calculate the first weight of the yolov8 detection model respectively and the second weight of the 3D temporal detection model The two weights are calculated based on the data collected from the test set. The error rate on the test set is 1 and 2. 1 means that the test set data is input into the yolov8 detection model, and the test results are compared with the real results to determine the first error rate. 1. Similarly, input the test set data into the 3D time series detection model, compare the test results with the actual results, and determine the second error rate 2. Calculate the weights of different models based on the error rate of the model and , the calculation formula is:
[0112] ,
[0113] Among them, when When expressed as the first weight, Expressed as the first error rate; when When expressed as the second weight, It is expressed as the second error rate.
[0114] ⑦ According to the model weight calculated by ⑥, the fourth probability of truth is calculated by combining the second probability P1 obtained by the yolov8 detection model obtained by ④ and the third probability P2 obtained by the 3D time series detection model obtained by ⑤ , where the fourth probability The calculation formula is as follows:
[0115] ,
[0116] if If it is greater than the set threshold, it indicates that there is foreign object intrusion and an alarm is generated.
[0117] After adopting the above solution:
[0118] First: the present invention can also achieve good recognition effect even for the non-ideal situation in which some intrusion objects have various shapes and types in foreign body intrusion detection.
[0119] Second: The present invention proposes a multi-result adaptive weighting scheme, which uses an adaptive combination of the detection results of the yolov8 detection model and the classification results of the 3D time series detection model, reducing the unreasonableness caused by artificially set parameters and effectively improving the effect.
[0120] Third: The input of the Bi-LSTM model in the present invention is the features extracted by the 3D-CNN layer, which fully extracts the information of intrusion objects at different angles. While improving the utilization of the model, it also improves the classification accuracy of the 3D time series detection model and reduces the complexity of the 3D time series detection model.
[0121] Fourth: The present invention creatively combines the 3D time series detection model and the yolov8 detection model to determine whether there is foreign body intrusion. The 3D time series detection model can fully consider the global information, and the yolov8 detection model can fully consider the local information. It can more accurately determine whether there is foreign body intrusion.
[0122] The present invention also provides a foreign body detection and identification system, please refer to Figure 3 As shown, including:
[0123] A first detection module acquires at least one frame of image and inputs the at least one frame of image into a first target detection model to determine a first probability corresponding to each image, wherein the first probability represents a probability that a foreign object exists in the corresponding frame of image;
[0124] A first processing module uses a weighted average of the first probabilities as a second probability;
[0125] The second detection module inputs at least one frame of the image into a second target detection model to obtain a third probability, wherein the third probability represents a probability of the existence of foreign objects in all images;
[0126] A second processing module obtains a first error rate of the first target detection model tested on the test set, and a second error rate of the second target detection model tested on the test set;
[0127] A truth value calculation module, using the first error rate to assign a first weight to the second probability to obtain a first truth value, and using the second error rate to assign a second weight to the third probability to obtain a second truth value;
[0128] The judgment module combines the first true value and the second true value to obtain a fourth probability, and judges whether there is foreign matter intrusion on the image according to the fourth probability.
[0129] Furthermore, the first detection model specifically includes:
[0130] Read the video stream information, input any frame of the image as the first target image into the first target detection model, and obtain a first probability corresponding to the first target image;
[0131] If the first probability is greater than a first preset threshold, extracting images every other frame from the first target image according to the video stream information to obtain multiple frames of second target images;
[0132] The plurality of frames of the second target image are fed into the first target detection model to obtain a first probability corresponding to each second target image.
[0133] Furthermore, the first target detection model in the first detection module is a yolov8 detection model, and the second target detection model in the second detection module is a 3D time series detection model.
[0134] Furthermore, the 3D time series detection model in the second detection module includes a Bi-LSTM layer and three 3D-CNN layers, wherein:
[0135] The three 3D-CNN layers are used to extract the preset features of foreign body intrusion in the image, and the Bi-LSTM layer is used to obtain the third probability based on the preset features.
[0136] Furthermore, the second processing module specifically includes:
[0137] Obtain historical image data as a test set, input the test set into the yolov8 detection model, and determine the first error rate of the yolov8 detection model based on the comparison of the obtained test results with the actual results;
[0138] The test set is input into the 3D timing detection model, and the second error rate of the 3D timing detection model is determined based on the comparison between the obtained test result and the real result.
[0139] Furthermore, the truth value calculation model specifically includes:
[0140] According to the first error rate, a first weight is assigned to the corresponding yolov8 detection model, and a first true value is obtained according to the first weight and the second probability;
[0141] According to the second error rate, a second weight is assigned to the corresponding 3D timing detection model, and a second true value is obtained according to the second weight and the third probability.
[0142] Furthermore, the calculation formula of the fourth probability in the judgment module is as follows:
[0143] ,
[0144] in, represents the fourth probability, represents the first truth value, represents the second truth value, is the first weight, is the second probability, is the second weight, is the third probability.
[0145] Furthermore, the calculation formulas of the first weight and the second weight in the truth value calculation module are as follows:
[0146] ,
[0147] Among them, when When expressed as the first weight, Expressed as the first error rate; when When expressed as the second weight, It is expressed as the second error rate.
[0148] The present invention also provides an electronic device, including a memory, a processor, and a program stored in the memory and running on the processor. When the processor executes the program, the steps of the above-mentioned foreign body detection and identification method are implemented.
[0149] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may change, modify, replace and vary the above embodiments within the scope of the present invention.
Claims
1. A foreign body detection and identification method, characterized in that: include: Acquire at least one frame of image, and input the at least one frame of image into a first target detection model to determine a first probability corresponding to each frame of image, wherein the first probability represents a probability of a foreign object existing in each frame of image; Taking the weighted average of the first probabilities as the second probability; Inputting at least one frame of image into a second target detection model to obtain a third probability, wherein the third probability represents a probability of foreign objects existing in all images; Obtaining a first error rate of the first target detection model tested on the test set, and a second error rate of the second target detection model tested on the test set; Using the first error rate, assigning a first weight to the second probability to obtain a first true value, and using the second error rate, assigning a second weight to the third probability to obtain a second true value; The first true value and the second true value are combined to obtain a fourth probability, and whether there is foreign body intrusion in all images is determined according to the fourth probability.
2. A foreign body detection and identification method according to claim 1, characterized in that: Acquiring at least one frame of image and inputting the at least one frame of image into a first target detection model to determine a first probability corresponding to each frame of image, including: Reading video stream information, inputting any frame of image therein as a first target image into the first target detection model, and obtaining a first probability corresponding to the first target image; If the first probability is greater than a first preset threshold, extracting images every other frame from the first target image according to the video stream information to obtain multiple frames of second target images; Input a plurality of frames of the second target image into the first target detection model to obtain a first probability corresponding to each of the second target images.
3. A foreign body detection and identification method according to claim 1 or 2, characterized in that: The first target detection model is a yolov8 detection model, and the second target detection model is a 3D time series detection model.
4. A foreign body detection and identification method according to claim 3, characterized in that: The 3D time series detection model includes a Bi-LSTM layer and three 3D-CNN layers, wherein: The 3D-CNN layer is used to extract preset features of foreign body intrusion in the image, and the Bi-LSTM layer is used to obtain a third probability according to the preset features.
5. A foreign body detection and identification method according to claim 3, characterized in that: Obtaining a first error rate of the first target detection model tested on the test set and a second error rate of the second target detection model tested on the test set, including: Obtain historical image data as a test set, input the test set into the yolov8 detection model, and determine the first error rate of the yolov8 detection model based on the obtained test results and the true results; The test set is input into the 3D timing detection model, and the second error rate of the 3D timing detection model is determined based on the comparison between the obtained test result and the real result.
6. A foreign body detection and identification method according to claim 5, characterized in that: The calculation formula of the fourth probability is as follows: , in, represents the fourth probability, represents the first truth value, represents the second truth value, is the first weight, is the second probability, is the second weight, is the third probability.
7. A foreign body detection and identification method according to claim 6, characterized in that: The calculation formulas of the first weight and the second weight are as follows: , Among them, when When expressed as the first weight, Expressed as the first error rate; when When expressed as the second weight, It is expressed as the second error rate.
8. A foreign body detection and identification system, characterized in that: include: A first detection module, acquiring at least one frame of image, and inputting at least one frame of image into a first target detection model to determine a first probability corresponding to each frame of image, wherein the first probability represents a probability of a foreign object existing in each frame of image; A first processing module, taking a weighted average of the first probabilities as a second probability; A second detection module inputs at least one frame of image into a second object detection model to obtain a third probability, wherein the third probability represents a probability of foreign objects existing in all images; A second processing module obtains a first error rate of the first target detection model tested on the test set, and a second error rate of the second target detection model tested on the test set; a truth value calculation module, using the first error rate to assign a weight to the second probability to obtain a first truth value, and using the second error rate to assign a weight to the third probability to obtain a second truth value; The judgment module combines the first true value and the second true value to obtain a fourth probability, and judges whether there is foreign body invasion on the image according to the fourth probability.
9. A foreign body detection and identification system according to claim 8, characterized in that: The first detection module specifically includes: Reading video stream information, inputting any frame of image therein as a first target image into the first target detection model, and obtaining a first probability corresponding to the first target image; If the first probability is greater than a first preset threshold, extracting images every other frame from the first target image according to the video stream information to obtain multiple frames of second target images; Input a plurality of frames of the second target image into the first target detection model to obtain a first probability corresponding to each of the second target images.
10. An electronic device comprising a memory, a processor, and a program stored in the memory and running on the processor, characterized in that: When the processor executes the program, the steps of a foreign body detection and identification method as described in any one of claims 1 to 7 are implemented.
