Multi-scale vehicle-mounted foreign matter detection method

By improving the Faster RCNN object detection network with residual units and replacing two-dimensional convolutions with depthwise separable convolutions, the detection capability for multi-scale foreign objects is enhanced, solving the problem of missed detection of foreign objects in existing technologies and achieving higher detection accuracy and efficiency.

CN117911749BActive Publication Date: 2026-07-24HARBIN KEJIA GENERAL MECHANICAL & ELECTRICAL CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
HARBIN KEJIA GENERAL MECHANICAL & ELECTRICAL CO LTD
Filing Date
2023-12-22
Publication Date
2026-07-24

Smart Images

  • Figure CN117911749B_ABST
    Figure CN117911749B_ABST
Patent Text Reader

Abstract

The multi-scale vehicle-mounted foreign matter detection method solves the problem that the current method is difficult to realize high-precision detection of foreign matters of different sizes at the same time, and belongs to the field of truck fault detection. The method comprises the following steps: S1, constructing an image sample data set of truck foreign matters; S2, establishing a vehicle-mounted foreign matter detection model, wherein the vehicle-mounted foreign matter detection model is realized by using a Faster RCNN target detection network, the Faster RCNN target detection network uses a residual unit based on a deep separable convolution as a backbone network, and the residual unit based on the deep separable convolution is obtained by replacing two-dimensional convolution in an existing residual unit with a deep separable convolution on the basis of the existing residual unit; S3, training the vehicle-mounted foreign matter detection model by taking an image of a truck foreign matter as input and taking whether a foreign matter exists in the input image as output; and S4, acquiring a passing vehicle image, inputting the passing vehicle image into the trained vehicle-mounted foreign matter detection model for detection, and outputting a detection result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to a multi-scale vehicle-mounted foreign object detection method, belonging to the field of truck fault detection. Background Technology

[0002] Foreign object debris (FOD) faults are a common type of truck malfunction. Initially, these faults were detected manually, which was costly in terms of manpower and time, and prone to false positives and false negatives due to operator fatigue. Therefore, deep learning-based fault detection methods with higher accuracy and efficiency have emerged.

[0003] Current methods use stacked residual units as the backbone of Faster R-CNN to construct object detection models for foreign object detection, achieving good results. However, the size and aspect ratio of foreign objects in vehicle images are uncertain, making it difficult for current methods to simultaneously achieve high-precision detection of foreign objects of different sizes, resulting in the risk of missed detections and posing a safety hazard to vehicles. Therefore, improving the multi-scale detection capability of object detection models is particularly important. Summary of the Invention

[0004] To address the problem that current methods struggle to achieve high-precision detection of foreign objects of different sizes simultaneously, this invention provides a multi-scale vehicle-mounted foreign object detection method based on improved residual units.

[0005] The present invention provides a multi-scale vehicle-mounted foreign object detection method, comprising:

[0006] S1. Construct an image sample dataset of foreign objects in trucks;

[0007] S2. Establish a vehicle-mounted foreign object detection model. The vehicle-mounted foreign object detection model is implemented using a Faster RCNN object detection network. The Faster RCNN object detection network uses depthwise separable convolution-based residual units as the backbone network. The depthwise separable convolution-based residual units are based on existing residual units, where depthwise separable convolution replaces the two-dimensional convolution in the existing residual units.

[0008] S3. Use the image of foreign objects in the truck as input and the presence or absence of foreign objects in the input image as output for training.

[0009] S4. Acquire images of passing vehicles, input these images into the trained vehicle-mounted foreign object detection model for detection, and output the detection results.

[0010] As a preferred option, the process of depthwise separable convolution is as follows:

[0011] The input features from m channels are convolved to obtain D. k,l,a =K i,j,M *X h,w,a ;

[0012] D of the m channels after convolution k,l,a By fusion, we obtain Y. k,l,N =P M (D k,l,a );

[0013] The input feature vector X has m channels. h,w,a K represents the input feature of a feature vector X with dimensions h×w, where the number of channels is a, and a = 1, 2, ..., m; i,j,M P represents a convolution kernel with dimensions i×j and number of channels M; M Y is the pointwise convolution mapping function. k,l,N This is the output of a depthwise separable convolution.

[0014] As a preferred embodiment, the Faster RCNN object detection network includes a backbone network, an RPN region proposal network, a RoiPooling layer, and a classification and regression network.

[0015] The image is input into the backbone network for feature extraction. The extracted features are then input into the Region Proposal Network (RPN) to filter candidate boxes. The selected candidate boxes are then input into the Roi Pooling layer for coordinate mapping. The mapped features are then classified using a regression network.

[0016] As a preferred method, the RPN (Region Proposal Network) method for filtering candidate boxes includes:

[0017] (1) For each ground truth candidate region, the anchor box with the largest overlap area with the ground truth candidate region among the extracted features is the foreground;

[0018] (2) For the remaining anchor frames in (1), if the area ratio of its overlap with a ground truth candidate region is greater than 0.7, it is recorded as the foreground; if the area ratio of its overlap with any ground truth candidate region is less than 0.3, it is recorded as the background.

[0019] (3) Discard the remaining anchors in (1) and (2) as well as the anchors that cross the image boundary.

[0020] As a preferred method, the coordinate mapping method for the Roi Pooling layer is as follows:

[0021] Each candidate box is divided into multiple sub-regions, and max pooling is performed on each sub-region to obtain a fixed-length feature vector, which is then mapped to the region where the target is located in the input image.

[0022] As preferred methods, classification and regression networks for classification include:

[0023] For classification tasks, Softmax is used for target classification; for regression tasks, fully connected layers are used.

[0024] The predicted image output by the network is compared with the real labeled image, and the loss value L is calculated:

[0025] L = L cls +L box

[0026] Among them, L cls The loss value for each candidate box's category is calculated using the cross-entropy loss function; L box The loss value for the rectangular coordinates of each candidate box is calculated by the L1 loss function and corrected for the position and size information of the candidate box in the input image.

[0027] As a preferred option, in S3, the SGD-Momentum optimizer is used for weight optimization. During the iteration process of the vehicle foreign object detection model, the loss function and the optimizer guide the model to update the weight coefficients, thereby completing the current training iteration. The vehicle foreign object detection model repeats the above process under a set learning rate, completing a fixed number of iterations on all truck foreign object images in the training set, updating only under weights with lower loss functions, until the optimal weight coefficients are found and the results are output, thus completing the training.

[0028] Preferably, S1 includes:

[0029] S11. Obtain images of passing vehicles as background images, collect images of foreign objects from trucks, remove background information from the passing vehicle images using Photoshop to obtain foreign object material, which is used as foreground targets; randomly paste the foreign object material into the background image; label the foreign object area as the "foreground" category; label the top left corner of the cropped passing vehicle image with a set size as the "normal" category and set it as the background; after the foreground and background targets are labeled, the original dataset is formed.

[0030] S12. Apply random data augmentation methods to the original dataset to obtain more datasets containing two categories of labels: foreign objects and normal objects.

[0031] S13. For images in the augmented dataset that are mislabeled, missing, or do not meet the requirements for high-precision training due to background interference, check and clean their label files, and then reconstruct the original dataset.

[0032] The beneficial effects of this invention are that it uses depthwise separable convolution to divide the input features into multiple groups according to channels, and each group is calculated using a single-channel convolution kernel, which can enhance the network's adaptability to multi-scale targets, thereby improving the detection accuracy of foreign object faults of different sizes, shapes, and aspect ratios. This invention adopts a parallel feature processing method, which can reduce feature redundancy extraction and save time and cost for model training and logical reasoning. Attached Figure Description

[0033] Figure 1 This is a schematic diagram of the model training process of the present invention;

[0034] Figure 2 This is a schematic diagram of the basic network structure of Faster RCNN;

[0035] Figure 3 This is a schematic diagram of a residual unit based on depthwise separable convolution;

[0036] Figure 4 This is a schematic diagram of a depthwise separable convolutional structure;

[0037] Figure 5 This is a flowchart of the fault identification procedure. Detailed Implementation

[0038] 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, and 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.

[0039] It should be noted that, unless otherwise specified, the embodiments and features described in the present invention can be combined with each other.

[0040] The present invention will be further described below with reference to the accompanying drawings and specific embodiments, but this is not intended to limit the scope of the invention.

[0041] This implementation method, based on an improved residual unit-based multi-scale vehicle-mounted foreign object detection method, enhances the multi-scale foreign object target detection capability, thereby reducing the risk of false alarms and missed alarms. It includes the following steps:

[0042] Step 1: Construct an image sample dataset of foreign objects in trucks;

[0043] Normal vehicle passing images captured by a high-definition camera are acquired and used as the background; foreign objects are extracted from vehicle passing images containing foreign objects and used as source material. The foreign object source material is randomly pasted onto the normal vehicle passing images. LabelImg is used for labeling: the foreign object region is labeled as the "foreign object" category, and the region with dimensions (32,32) at the top left corner of the vehicle passing image is labeled as the "normal" category. After labeling, data augmentation and data cleaning operations are used to filter the data labels, resulting in the training and testing datasets.

[0044] Step 2: Establish a vehicle-mounted foreign object detection model. The vehicle-mounted foreign object detection model is implemented using the Faster RCNN object detection network. The Faster RCNN object detection network uses depthwise separable convolution-based residual units as the backbone network. The depthwise separable convolution-based residual units are based on existing residual units, where depthwise separable convolution replaces the two-dimensional convolution in the existing residual units.

[0045] A multi-scale foreign object detection method based on improved residual units is proposed by replacing the two-dimensional convolution in the residual units with depthwise separable convolution. This method uses depthwise separable convolution to process features in each channel with a single-channel convolution kernel. It enhances the perception of local spatial information under interference from unrelated feature channels, thereby improving multi-scale detection capabilities.

[0046] Step 3: Using the image of the foreign object in the truck as input and the presence or absence of a foreign object in the input image as output, train the vehicle-mounted foreign object detection model and obtain the model weights and configuration file.

[0047] Step 4: Acquire images of passing vehicles and input them into the trained vehicle-mounted foreign object detection model for detection. Output the detection results. If a foreign object is detected, the vehicle is considered to have a foreign object fault; otherwise, it is considered normal. An alarm is uploaded for images containing foreign objects. Inspection personnel will handle the alarmed area accordingly based on the principle of manual prior assessment.

[0048] This implementation uses depthwise separable convolution to replace the two-dimensional convolution in the residual unit, and uses a multi-path parallel channel-by-channel feature processing method to enhance the extraction of spatial structure and edge contour information in the image. This method can better capture and combine features of different scales, and reduce the probability of missed and false alarms when there are foreign objects of different sizes in the same vehicle passing image.

[0049] In a preferred embodiment, step 1 of this implementation specifically includes three parts: data acquisition and annotation, data cleaning, and data augmentation.

[0050] Step 11: Data Acquisition and Construction of the Original Dataset

[0051] The original dataset mentioned in this embodiment refers to vehicle images containing both foreign objects and normal objects, acquired by a high-definition imaging device and not subjected to data augmentation processing. Its construction details are as follows:

[0052] (1) Background image acquisition: High-definition imaging equipment is set up around and under the railway freight car track. After the freight car passes by, the passing image is acquired and cropped to a length and width of (1400, 512) as the background image.

[0053] (2) Foreign object material acquisition: Collect images of foreign objects from trucks, and remove the background information from the truck images using Photoshop to obtain foreign object materials as foreground targets;

[0054] (3) Dataset creation: Randomly paste the foreign object material into the background image in (1). Mark the foreign object area as the "foreground" category and set it as the foreground; mark the box with a size of (32,32) at the top left corner of the cropped vehicle image as the "normal" category and set it as the background; after the foreground and background targets are marked, the original dataset is formed.

[0055] Step 12: Data Augmentation and Construction of Augmented Dataset

[0056] The augmented dataset described in this embodiment refers to a dataset obtained by performing a 3-fold data augmentation operation on the original dataset using random data augmentation methods, resulting in a dataset containing two categories: foreign objects and normal objects. Specific methods include image horizontal flipping, brightness adjustment, histogram equalization, adding Gaussian noise, and adding rain / snow weather backgrounds. These methods can create new data from more scenarios, enhancing the generalization ability of the detection network and reducing the probability of model overfitting. Furthermore, this embodiment uses multiple data augmentation methods to construct the dataset, meeting the application requirements of railway data for all-weather, any-weather vehicle inspection projects.

[0057] Step 13: Data Cleaning

[0058] The data cleaning described in this embodiment involves checking and cleaning the labeled files of images in the original dataset that are mislabeled, missing, or fail to meet the high-precision training requirements due to background interference, thereby reconstructing the original dataset. The specific strategies and steps are as follows:

[0059] (1) Training phase: The augmented dataset is cropped to a size of (1400, 1024) and used as the training set for the Faster RCNN network to perform the vehicle foreign object detection training task, and the model weights and configuration files are obtained.

[0060] (2) Use the model configuration file obtained in (1) to infer and expand the dataset. If the confidence level of the foreign object obtained by inference is less than 0.5, it is determined that the image cannot meet the requirements of high-precision training, and the image data and corresponding XML tag file are deleted. At the same time, the image is examined to analyze the root cause of its low confidence level.

[0061] (3) Use the model configuration file obtained in (1) to infer and expand the dataset. If the IOU between the true value and the predicted value is greater than 0.3, but the categories are inconsistent, it is determined that the label file corresponding to the image is incorrect. The label file should be checked and relabeled if necessary.

[0062] At this point, the sample dataset applicable to the multi-scale foreign object detection method based on the improved residual unit has been completed. It is divided according to the ratio of "training set: test set: validation set = 7:2:1" to meet the needs of model training, model testing inference and validation.

[0063] This implementation uses a Faster R-CNN network with improved residual units as the vehicle-mounted foreign object detection model to detect foreign objects in passing vehicle images. The basic network structure of Faster R-CNN is as follows: Figure 2 As shown, it mainly consists of the following parts:

[0064] CNN Feature Extraction

[0065] Faster R-CNN uses a backbone network as a feature extractor for object detection, extracting approximate foreground object regions from vehicle images to provide accurate classification and detection for RPN and ROI Pooling. Currently, most Faster R-CNNs use residual units as the backbone network for feature extraction, enabling effective spatial feature extraction and reducing feature redundancy. However, the two-dimensional convolution in the residual unit simultaneously extracts and fuses features from multiple channels, making it difficult to effectively handle target information at different scales. When applied to vehicle-mounted foreign object detection, there is a risk of missing small foreign objects. Therefore, this implementation replaces the two-dimensional convolution in the residual unit with depthwise separable convolution, constructing a residual unit based on depthwise separable convolution, such as... Figure 3 As shown, using it as the backbone network of Faster R-CNN to perform detection tasks can improve the model's multi-scale foreign object detection capabilities, and improve the accuracy and precision of foreign object detection.

[0066] The residual unit based on depthwise separable convolution described in this embodiment comprises two parts: a feature preservation link and a feature enhancement link. Specifically:

[0067] (1) Feature Preservation Link

[0068] The feature preservation link described in this embodiment is the Identity branch of the residual unit. It uses a shortcut connection to artificially skip the next layer of neuron connections, so that the feature matrix is ​​spliced ​​layer by layer. This can reduce the feature redundancy caused by the stacking of multiple convolutional layers and play the role of preserving the shallow spatial structure.

[0069] (2) Feature Enhancement Link

[0070] The feature enhancement mechanism described in this embodiment uses depthwise separable convolution to replace the original two-dimensional convolution, and together with the activation function, it forms a multi-channel feature enhancement mechanism. The overall mathematical expression of this part is as follows:

[0071] X2=σ[f d [σ(f d(X1))]] (1)

[0072] Where X1 is the input feature, f d For depthwise separable convolution processing, σ(·) is the ReLU activation function, and X2 is the output feature of the feature enhancement link.

[0073] Among them, depthwise separable convolutional structures such as Figure 4 As shown, it comprises two parts: depthwise convolution and pointwise convolution. In this part, multiple depthwise convolution kernels are used to independently perform convolution calculations on each channel of the input features, enhancing the perception of spatial structure information and achieving feature separation and extraction of small and multi-scale targets in each channel. Since depthwise convolution is insufficient to fully utilize feature information from different channels at the same location, pointwise convolution is used to weightedly fuse features from a single channel, enriching channel relationships based on the acquisition of spatial structure information at different scales, thus ensuring the completeness of image content feature transfer.

[0074] The mathematical description of depthwise separable convolution is as follows:

[0075] D k,l,a =K i,j,M *X h,w,a (2)

[0076] Y k,l,N =P M (D k,l,a (3)

[0077] Equation (2) represents the depthwise convolution process. The feature vector X input to the depthwise separable convolution has m channels. h,w,a K represents the input feature of a feature vector X with dimensions h×w and channel a. i,j,M This represents a convolutional kernel with dimensions i×j and M channels; convolutional layers with different receptive field sizes are used to extract multi-scale spatial structure information contained in each channel to obtain more complete image detail features D. k,l,a Equation (3) represents the pointwise convolution process, P M This is a pointwise convolution mapping function. The image detail features D obtained by processing with multiple sets of filters... k,l,a As input, pointwise convolution is used to spatially fuse the features of m channels, and supervised learning is performed on different branches to enhance the intrinsic correlation of spatial structure information in each channel.

[0078] In the residual unit based on depthwise separable convolution described in this embodiment, the feature preservation link and the feature enhancement link extract the target at the same location in the image from different channel levels. The output features of the two links are fused in an additive manner, which can realize multi-scale spatial target detection while ensuring feature correlation within different channels. This lays the foundation for accurate generation of multi-scale target candidate boxes and accurate target localization and classification in Faster RCNN.

[0079] In a preferred embodiment, the Faster RCNN object detection network includes a backbone network, an RPN region proposal network, a RoiPooling layer, and a classification and regression network;

[0080] The image is input into the backbone network for feature extraction. The extracted features are then input into the Region Proposal Network (RPN) to filter candidate boxes. The selected candidate boxes are then input into the Roi Pooling layer for coordinate mapping. The mapped features are then classified using a regression network.

[0081] In a preferred embodiment, the Region Proposal Network (RPN) takes the backbone network output as input and uses a CNN convolutional neural network to determine all possible candidate boxes. The main process is as follows:

[0082] (1) For each ground truth candidate region, the anchor box with the largest overlap area with the ground truth candidate region among the extracted features is the foreground;

[0083] (2) For the remaining anchor frames in (1), if the area ratio of its overlap with a ground truth candidate region is greater than 0.7, it is recorded as the foreground; if the area ratio of its overlap with any ground truth candidate region is less than 0.3, it is recorded as the background.

[0084] (3) Discard the remaining anchors in (1) and (2) as well as the anchors that cross the image boundary.

[0085] In a preferred embodiment, Roi Pooling takes the candidate boxes filtered by RPN as input, divides each candidate box into multiple sub-regions, and performs max pooling on each sub-region to obtain a feature vector of fixed length, thereby mapping it to the region where the target is located in the input image.

[0086] In a preferred embodiment, for classification tasks, Faster R-CNN uses Softmax instead of Support Vector Machines for object classification. This method can transform the model output into a probability distribution, thereby better mapping the relative relationships between multiple categories. For the vehicle-mounted foreign object recognition module, using Softmax can provide a quantitative indicator of whether the target in the candidate box is classified as foreground or background, more clearly reflecting the model's ability to recognize each category.

[0087] For regression tasks, Faster R-CNN uses fully connected layers to refine the position and size information of candidate boxes, resulting in more accurate object detection boxes. For the vehicle-mounted foreign object detection module, this part uses fully connected layers to compress channels, enhancing spatial feature perception and thus improving the accuracy of locating foreign object detection boxes in the input image.

[0088] The predicted image output by the network is compared with the real labeled image, and the loss value is calculated:

[0089] L = L cls +L box (4)

[0090] Among them, L cls The loss value for each candidate box's category is calculated using the cross-entropy loss function; L box The loss value for the rectangular coordinates of each candidate box is calculated by the L1 loss function and corrected for the position and size information of the candidate box in the input image.

[0091] In step 3 of the preferred embodiment, the SGD-Momentum optimizer is used to optimize the weights. During the iteration process of the vehicle foreign object detection model, the loss function and the optimizer guide the model to update the weight coefficients, thereby completing the current training iteration. The vehicle foreign object detection model repeats the above process under a set learning rate, completing a fixed number of iterations on all truck foreign object images in the training set, updating only under the weights with lower loss function, until the optimal weight coefficients are found and the results are output to complete the training, thereby obtaining the model configuration file and conducting the vehicle foreign object detection test process.

[0092] Step 4 of this embodiment is vehicle-mounted foreign object fault identification, the process is as follows: Figure 5 As shown, the overall process can be broken down into the following steps:

[0093] Step 41: Vehicle passing image acquisition and data processing

[0094] High-definition imaging equipment around the railway tracks is used to acquire images of passing trains, and passing trains are filtered according to their type.

[0095] Step 42: Load the model and detect and locate the foreign object area on the vehicle.

[0096] Based on the vehicle passing information, an on-board foreign object detection model based on improved residual units is loaded to detect whether there are foreign objects in the vehicle passing images.

[0097] Step 43: Fault diagnosis and alarm

[0098] (1) If no foreign object is detected, the vehicle passing image is determined to be normal and there is no foreign object fault. Continue to the next vehicle passing image detection task.

[0099] (2) If a foreign object is detected, it is determined that there is a foreign object fault in the vehicle image, and a fault message is uploaded. The inspection personnel will proceed with the next step of processing or manual inspection based on the fault message.

[0100] Step 44: Update the vehicle images and perform a new round of detection.

[0101] After completing the fault alarm judgment and message upload for this round of vehicle passing images, update the vehicle passing images. Repeat steps 41-43 to perform a new round of vehicle-mounted foreign object detection until all vehicles have passed.

[0102] While the invention has been described herein with reference to specific embodiments, it should be understood that these embodiments are merely examples of the principles and applications of the invention. Therefore, it should be understood that many modifications can be made to the exemplary embodiments, and other arrangements can be designed without departing from the spirit and scope of the invention as defined by the appended claims. It should be understood that different dependent claims and features described herein can be combined in ways different from those described in the original claims. It is also understood that features described in conjunction with individual embodiments can be used in other described embodiments.

Claims

1. A multi-scale vehicle-mounted foreign object detection method, characterized in that, The method includes: S1. Construct an image sample dataset of foreign objects in trucks; S2. Establish a vehicle-mounted foreign object detection model. The vehicle-mounted foreign object detection model is implemented using a Faster RCNN object detection network. The Faster RCNN object detection network uses depthwise separable convolution-based residual units as the backbone network. The depthwise separable convolution-based residual units are based on existing residual units, where depthwise separable convolution replaces the two-dimensional convolution in the existing residual units. S3. Use the image of foreign objects in the truck as input and the presence or absence of foreign objects in the input image as output for training. S4. Acquire images of passing vehicles, input these images into the trained vehicle-mounted foreign object detection model for detection, and output the detection results. The residual unit based on depthwise separable convolution consists of two parts: feature preservation links and feature enhancement links. The feature preservation link is the Identity branch of the residual unit, which uses a shortcut connection to artificially skip the next layer of neuron connections, so that the feature matrix is ​​spliced ​​across layers; The feature enhancement mechanism described herein is a multi-channel feature enhancement mechanism that uses depthwise separable convolution to replace the original two-dimensional convolution, together with an activation function. The overall mathematical expression is as follows: in, For input features, This is a depthwise separable convolution process. It is the ReLU activation function. Enhance the output features of the link; The process of depthwise separable convolution is as follows: The input features from m channels are convolved to obtain... ; For the m channels after convolution By merging, we obtain ; Wherein, the input feature vector There are m channels. Indicates length and width as eigenvectors The channel is Input features, ; Indicates length and width as A convolutional kernel with M channels; For pointwise convolution mapping function, This is the output of a depthwise separable convolution.

2. The multi-scale vehicle-mounted foreign object detection method according to claim 1, characterized in that, The Faster RCNN object detection network includes a backbone network, an RPN region proposal network, a Roi pooling layer, and classification and regression networks. The image is input into the backbone network for feature extraction. The extracted features are then input into the Region Proposal Network (RPN) to filter candidate boxes. The selected candidate boxes are then input into the Roi Pooling layer for coordinate mapping. The mapped features are then classified using a regression network.

3. The multi-scale vehicle-mounted foreign object detection method according to claim 2, characterized in that, The methods used by the Region Proposal Network (RPN) to filter candidate bounding boxes include: (1) For each ground truth candidate region, the anchor box with the largest overlap area with the ground truth candidate region among the extracted features is the foreground; (2) For the remaining anchor boxes in (1), if the area ratio of its overlap with a ground truth candidate region is greater than 0.7, it is recorded as the foreground; if the area ratio of its overlap with any ground truth candidate region is less than 0.3, it is recorded as the background. (3) Discard the remaining anchors in (1) and (2) as well as the anchors that cross the image boundary.

4. The multi-scale vehicle-mounted foreign object detection method according to claim 2, characterized in that, Methods for coordinate mapping in Roi Pooling layers: Each candidate box is divided into multiple sub-regions, and max pooling is performed on each sub-region to obtain a fixed-length feature vector, which is then mapped to the region where the target is located in the input image.

5. The multi-scale vehicle-mounted foreign object detection method according to claim 2, characterized in that, Classification and regression networks are used for classification, including: For classification tasks, Softmax is used for target classification; for regression tasks, fully connected layers are used. The predicted image output by the network is compared with the real labeled image, and the loss value L is calculated: in, The loss value for the category to which each candidate box belongs is calculated using the cross-entropy loss function; The loss value for the rectangular coordinates of each candidate box is calculated by the L1 loss function and corrected for the position and size information of the candidate box in the input image.

6. The multi-scale vehicle-mounted foreign object detection method according to claim 1, characterized in that, In S3, the SGD-Momentum optimizer is used for weight optimization. During the iteration of the vehicle foreign object detection model, the loss function and the optimizer guide the model to update the weight coefficients, thereby completing the current training iteration. The vehicle-mounted foreign object detection model repeats the above process under a set learning rate, iterating through all truck images in the training set a fixed number of times, updating only with weights that have lower loss functions, until the optimal weight coefficients are found and the results are output, thus completing the training.

7. The multi-scale vehicle-mounted foreign object detection method according to claim 1, characterized in that, S1 includes: S11. Obtain images of passing vehicles as background images, collect images of foreign objects from trucks, remove background information from the passing vehicle images using Photoshop to obtain foreign object material, which is used as foreground targets; randomly paste the foreign object material into the background image; label the foreign object area as the "foreground" category; label the top left corner of the cropped passing vehicle image with a set size as the "normal" category and set it as the background; after the foreground and background targets are labeled, the original dataset is formed. S12. Apply random data augmentation methods to the original dataset to obtain more datasets containing two categories of labels: foreign objects and normal objects. S13. For images in the augmented dataset that are mislabeled, missing, or do not meet the requirements for high-precision training due to background interference, check and clean their label files, and then reconstruct the original dataset.

8. A computer-readable storage device storing a computer program, characterized in that, When the computer program is executed, it implements the multi-scale vehicle-mounted foreign object detection method as described in any one of claims 1 to 7.

9. A multi-scale vehicle-mounted foreign object detection device, comprising a storage device, a processor, and a computer program stored in the storage device and executable on the processor, characterized in that, The processor executes the computer program to implement the multi-scale vehicle-mounted foreign object detection method as described in any one of claims 1 to 7.