A method and device for detecting damage to a train battery box
By uniformly segmenting the battery box image and processing it with an encoder model, the problems of difficulty and low accuracy in battery box damage detection in the existing technology are solved, and efficient and accurate damage classification is achieved.
Patent Information
- Application Number
- CN202510955261.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-11
- Publication Date
- 2025-10-03
- Estimated Expiration
- 2045-07-11
AI Technical Summary
In the existing technology, the method of detecting damage to train battery boxes mainly relies on manual on-site inspection and simple image classification, which makes the detection difficult and has low accuracy.
By evenly segmenting the battery box image, the segmented image blocks and position sequence information are input into a pre-trained encoder model, and the head sensor is used to perform damage classification to improve detection accuracy and efficiency.
It achieves efficient and accurate detection of battery box damage, and improves the automation level of detection and the reliability of results.
Smart Images

Figure CN120471909B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of train battery box image detection, and in particular to a method and device for detecting damage to a train battery box. Background Art
[0002] The train's battery box is a vital structure that carries and protects the train's batteries and other key components. Typically made of metal or composite materials, the battery box is exposed to complex operating environments for extended periods, making it susceptible to various types of damage. During train operation, the battery box must withstand not only mechanical stress but also environmental factors such as vibration, temperature fluctuations, humidity, and chemical corrosion. Therefore, the integrity and safety of the battery box are directly related to the train's operational safety.
[0003] At present, damage detection of battery boxes on trains mainly includes manual on-site inspections and simple classification of battery box images. Due to the complex working environment of battery box damage detection and the large number of battery box damage types, it brings great detection difficulties to inspectors. Simple classification such as cluster analysis and recognition of the collected box images reduces the accuracy and efficiency of battery box damage detection. Summary of the Invention
[0004] In view of this, the purpose of the present application is to provide a method and device for detecting damage to a train battery box, by uniformly segmenting the acquired box image corresponding to the target battery box, and inputting the segmented image blocks and the position sequence information of the image blocks into an encoder model that has previously deeply mined the high-level semantic information of the battery box damage image during the training process, and based on the box information output by the encoder model, using the head sensor to classify the box information to determine the damage category of the target battery box, thereby improving the accuracy and efficiency of damage detection on the battery box.
[0005] The present application provides a method for detecting damage to a train battery box, the method comprising:
[0006] For a target battery box among multiple battery boxes provided on the train, obtaining a box image corresponding to the target battery box;
[0007] Evenly dividing the box image according to a preset block size to obtain a plurality of image blocks divided by the box image, and determining position sequence information of each image block in the box image;
[0008] Inputting the image block and the position sequence information into a pre-trained encoder model accordingly, and obtaining box information corresponding to the box image output by the encoder model;
[0009] Based on the box information, damage classification is performed using a preset head sensor to determine the damage category corresponding to the target battery box; wherein the damage category includes mechanical damage, thermal damage, corrosion damage and no damage.
[0010] Furthermore, the step of inputting the image block and the position sequence information into a pre-trained encoder model to obtain the box information corresponding to the box image output by the encoder model includes:
[0011] Performing linear projection processing on the image blocks in sequence according to the image block order in the position sequence information to obtain a first target dimension vector corresponding to each image block;
[0012] Combining the first target dimension vector with the position sequence information of each image block to obtain a second target dimension vector corresponding to each image block;
[0013] The second target dimension vector is input into a pre-trained encoder model to obtain the box information corresponding to the box image output by the encoder model.
[0014] Furthermore, the encoder model is trained by the following steps:
[0015] Determining a first injury category and a second injury category among the injury categories, and selecting a first training image corresponding to the first injury category and a second training image corresponding to the second injury category from a preset training image dataset;
[0016] Blending pixels of the first training image and the second training image using a preset fusion formula to obtain a pixel blending result, and determining a target training image based on the pixel blending result;
[0017] performing block and mask processing on the target training image in sequence to obtain a plurality of target image blocks and a plurality of mask image blocks, and inputting the target image blocks into an encoder model to be trained to obtain an encoded image block corresponding to each target image block output by the encoder model to be trained;
[0018] Inputting the mask image block and the coded image block into a decoder model corresponding to the encoder model to be trained, and reconstructing the mask image block by the decoder model to obtain a reconstructed training image corresponding to the target training image; wherein the decoder model has a structure opposite to that of the encoder model to be trained;
[0019] A preset loss function is used to calculate the loss value between the target training image and the reconstructed training image. Based on the loss value, the model parameters of the encoder model to be trained are updated, and the model parameters are iteratively updated until the preset training conditions are met, thereby obtaining an encoder model that learns the image information in the training image dataset.
[0020] Furthermore, the target training image is sequentially sliced and masked to obtain a plurality of target image blocks and a plurality of mask image blocks, and the target image blocks are input into the encoder model to be trained to obtain an encoded image block corresponding to each target image block output by the encoder model to be trained, including:
[0021] Evenly dividing the target training image according to a preset block size to obtain a plurality of training image blocks obtained by dividing the target training image;
[0022] Determining, based on the total number of the training image blocks and a preset masking rate, the number of targets that need to be masked in the training image blocks, and arbitrarily selecting training image blocks from the training image blocks according to the target number for masking, to obtain a plurality of masked image blocks and a plurality of target image blocks that are not masked in the training image blocks;
[0023] The target image block is input into the encoder model to be trained to obtain an encoded image block corresponding to each target image block output by the encoder model to be trained.
[0024] Furthermore, the step of inputting the mask image block and the coded image block into a decoder model corresponding to the encoder model to be trained, and obtaining a reconstructed training image corresponding to the target training image by speculating and reconstructing the mask image block through the decoder model includes:
[0025] Respectively determining position information of each target image block and each mask image block in the target training image to determine position information corresponding to each encoded image block;
[0026] linearly arranging the target image block and the mask image block according to the arrangement order corresponding to the position information to obtain a mask self-decoding image sequence corresponding to the target training image;
[0027] Inputting the masked self-decoding image sequence into a decoder model corresponding to the encoder model to be trained, so that the decoder model infers image information corresponding to the masked image block based on the target image block, and obtaining a decoded image sequence corresponding to the masked self-decoding image sequence output by the decoder model;
[0028] Based on the position information and the decoded image sequence, a reconstructed training image corresponding to the target training image is obtained through image reconstruction.
[0029] Furthermore, the calculating a loss value between the target training image and the reconstructed training image using a preset loss function, and updating a model parameter of the encoder model to be trained based on the loss value, includes:
[0030] Based on the real image information sequence corresponding to the target training image and the predicted image information sequence corresponding to the reconstructed training image, a loss value between the target training image and the reconstructed training image is calculated using a preset loss function;
[0031] For each output layer of the encoder model to be trained, calculating, based on the loss value, a first gradient value of the loss function with respect to each output layer, and propagating the first gradient value from back to front in the output layer using the chain rule to determine a second gradient value of the loss function with respect to a model parameter of the encoder model to be trained;
[0032] Based on the second gradient value, the parameters of the encoder model to be trained and a preset learning rate, the model parameters are updated using a preset gradient descent method to obtain updated model parameters of the encoder model to be trained.
[0033] Furthermore, the repeatedly iteratively updating the model parameters until a preset training condition is satisfied, thereby obtaining an encoder model that learns the image information in the training image dataset, includes:
[0034] Repeatedly iteratively updating the model parameters, and after each update of the model parameters, determining whether the number of iterative updates reaches a preset number of iterations;
[0035] If the number of iterative updates reaches a preset number of iterations, determining whether the loss value shows convergence;
[0036] If the loss value shows convergence, it is determined that the iterative update meets the preset training condition, and the encoder model to be trained updated in the current iterative cycle is determined as the encoder model for learning the image information in the training image data set;
[0037] If the number of iterative updates does not reach the preset number of iterations or the loss value does not show convergence, the iterative update of the model parameters of the encoder model to be trained continues.
[0038] The present application also provides a device for detecting damage to a train battery box, the device comprising:
[0039] An image acquisition module is used to acquire a box image corresponding to a target battery box among multiple battery boxes provided on the train;
[0040] An image segmentation module is used to evenly segment the box image according to a preset segmentation size to obtain a plurality of image blocks segmented from the box image, and determine position sequence information of each image block in the box image;
[0041] A model processing module, configured to input the image block and the position sequence information into a pre-trained encoder model in correspondence, and obtain box information corresponding to the box image output by the encoder model;
[0042] An information classification module is used to perform damage classification based on the box information using a preset head sensor to determine the damage category corresponding to the target battery box; wherein the damage category includes mechanical damage, thermal damage, corrosion damage and no damage.
[0043] Furthermore, when the model processing module is used to input the image block and the position sequence information into a pre-trained encoder model correspondingly to obtain the box information corresponding to the box image output by the encoder model, the model processing module is used to:
[0044] Performing linear projection processing on the image blocks in sequence according to the image block order in the position sequence information to obtain a first target dimension vector corresponding to each image block;
[0045] Combining the first target dimension vector with the position sequence information of each image block to obtain a second target dimension vector corresponding to each image block;
[0046] The second target dimension vector is input into a pre-trained encoder model to obtain the box information corresponding to the box image output by the encoder model.
[0047] Furthermore, when the model processing module is used to train the encoder model, the model processing module is used to:
[0048] Determining a first injury category and a second injury category among the injury categories, and selecting a first training image corresponding to the first injury category and a second training image corresponding to the second injury category from a preset training image dataset;
[0049] Blending pixels of the first training image and the second training image using a preset fusion formula to obtain a pixel blending result, and determining a target training image based on the pixel blending result;
[0050] performing block and mask processing on the target training image in sequence to obtain a plurality of target image blocks and a plurality of mask image blocks, and inputting the target image blocks into an encoder model to be trained to obtain an encoded image block corresponding to each target image block output by the encoder model to be trained;
[0051] Inputting the mask image block and the coded image block into a decoder model corresponding to the encoder model to be trained, and reconstructing the mask image block by the decoder model to obtain a reconstructed training image corresponding to the target training image; wherein the decoder model has a structure opposite to that of the encoder model to be trained;
[0052] A preset loss function is used to calculate the loss value between the target training image and the reconstructed training image. Based on the loss value, the model parameters of the encoder model to be trained are updated, and the model parameters are iteratively updated until the preset training conditions are met, thereby obtaining an encoder model that learns the image information in the training image dataset.
[0053] Furthermore, when the model processing module is used to sequentially perform block slicing and masking processing on the target training image to obtain a plurality of target image blocks and a plurality of mask image blocks, and input the target image blocks into the encoder model to be trained to obtain an encoded image block corresponding to each target image block output by the encoder model to be trained, the model processing module is used to:
[0054] Evenly dividing the target training image according to a preset block size to obtain a plurality of training image blocks obtained by dividing the target training image;
[0055] Determining, based on the total number of the training image blocks and a preset masking rate, the number of targets that need to be masked in the training image blocks, and arbitrarily selecting training image blocks from the training image blocks according to the target number for masking, to obtain a plurality of masked image blocks and a plurality of target image blocks that are not masked in the training image blocks;
[0056] The target image block is input into the encoder model to be trained to obtain an encoded image block corresponding to each target image block output by the encoder model to be trained.
[0057] Furthermore, when the model processing module is used to input the mask image block and the encoded image block into the decoder model corresponding to the encoder model to be trained, and obtain the reconstructed training image corresponding to the target training image by speculatively reconstructing the mask image block through the decoder model, the model processing module is used to:
[0058] Respectively determining position information of each target image block and each mask image block in the target training image to determine position information corresponding to each encoded image block;
[0059] linearly arranging the target image block and the mask image block according to the arrangement order corresponding to the position information to obtain a mask self-decoding image sequence corresponding to the target training image;
[0060] Inputting the masked self-decoding image sequence into a decoder model corresponding to the encoder model to be trained, so that the decoder model infers image information corresponding to the masked image block based on the target image block, and obtaining a decoded image sequence corresponding to the masked self-decoding image sequence output by the decoder model;
[0061] Based on the position information and the decoded image sequence, a reconstructed training image corresponding to the target training image is obtained through image reconstruction.
[0062] Furthermore, when the model processing module is used to calculate the loss value between the target training image and the reconstructed training image using a preset loss function and update the model parameters of the encoder model to be trained based on the loss value, the model processing module is used to:
[0063] Based on the real image information sequence corresponding to the target training image and the predicted image information sequence corresponding to the reconstructed training image, a loss value between the target training image and the reconstructed training image is calculated using a preset loss function;
[0064] For each output layer of the encoder model to be trained, calculating, based on the loss value, a first gradient value of the loss function with respect to each output layer, and propagating the first gradient value from back to front in the output layer using the chain rule to determine a second gradient value of the loss function with respect to a model parameter of the encoder model to be trained;
[0065] Based on the second gradient value, the parameters of the encoder model to be trained and a preset learning rate, the model parameters are updated using a preset gradient descent method to obtain updated model parameters of the encoder model to be trained.
[0066] Furthermore, when the model processing module is used to repeatedly iteratively update the model parameters until a preset training condition is satisfied to obtain an encoder model for learning the image information in the training image dataset, the model processing module is used to:
[0067] Repeatedly iteratively updating the model parameters, and after each update of the model parameters, determining whether the number of iterative updates reaches a preset number of iterations;
[0068] If the number of iterative updates reaches a preset number of iterations, determining whether the loss value shows convergence;
[0069] If the loss value shows convergence, it is determined that the iterative update meets the preset training condition, and the encoder model to be trained updated in the current iterative cycle is determined as the encoder model for learning the image information in the training image data set;
[0070] If the number of iterative updates does not reach the preset number of iterations or the loss value does not show convergence, the iterative update of the model parameters of the encoder model to be trained continues.
[0071] An embodiment of the present application also provides an electronic device, comprising: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor and the memory communicate through the bus, and when the machine-readable instructions are executed by the processor, the steps of the above-mentioned method for detecting damage to a train battery box are performed.
[0072] An embodiment of the present application further provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of the above-mentioned method for detecting damage to a train battery box are executed.
[0073] The embodiments of the present application provide a method and device for detecting damage to a train battery box. The detection method includes: obtaining a box image corresponding to a target battery box among multiple battery boxes set up on a train; uniformly dividing the box image according to a preset block size to obtain multiple image blocks divided into the box image, and determining the position sequence information of each image block in the box image; inputting the image blocks and the position sequence information into a pre-trained encoder model accordingly to obtain the box information corresponding to the box image output by the encoder model; based on the box information, using a preset head sensor to perform damage classification to determine the damage category corresponding to the target battery box; wherein the damage categories include mechanical damage, thermal damage, corrosion damage and no damage.
[0074] Compared with the manual on-site inspection and simple classification method of collecting battery box images in the existing technology, the box image corresponding to the acquired target battery box is evenly segmented, and the segmented image blocks and the position sequence information of the image blocks are input into the encoder model that has previously deeply mined the high-level semantic information of the battery box damage image during the training process. Based on the box information output by the encoder model, the head sensor is used to classify the box information to determine the damage category of the target battery box, thereby improving the accuracy and efficiency of battery box damage detection.
[0075] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0076] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without creative work.
[0077] Figure 1 A flow chart of a method for detecting damage to a train battery box provided in an embodiment of the present application;
[0078] Figure 2 A schematic diagram of the training process of an encoder model provided in an embodiment of the present application;
[0079] Figure 3 A schematic diagram of a battery box image processing flow provided in an embodiment of the present application;
[0080] Figure 4 A schematic structural diagram of a train battery box damage detection device provided in an embodiment of the present application;
[0081] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0082] In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. The components of the embodiments of the present application generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application for which protection is claimed, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, each other embodiment obtained by those skilled in the art without making creative work falls within the scope of protection of the present application.
[0083] Research has found that at present, damage detection of battery boxes on trains mainly includes manual on-site inspections and simple classification of battery box images. Due to the complex working environment of battery box damage detection and the large number of battery box damage types, it brings great detection difficulty to inspectors; and simple classification such as cluster analysis and recognition of the collected box images reduces the accuracy and efficiency of battery box damage detection.
[0084] Based on this, an embodiment of the present application provides a method for detecting damage to a train battery box. The method evenly divides the acquired box image corresponding to the target battery box, and inputs the divided image blocks and the position sequence information of the image blocks into an encoder model that has previously deeply mined the high-level semantic information of the battery box damage image during training. Based on the box information output by the encoder model, the head sensor is used to classify the box information to determine the damage category of the target battery box, thereby improving the accuracy and efficiency of damage detection on the battery box.
[0085] See also Figure 1 , Figure 1 This is one of the flow charts of a method for detecting damage to a train battery box provided in an embodiment of the present application. Figure 1 As shown in , the method for detecting damage to a train battery box provided by an embodiment of the present application includes:
[0086] S100 . For a target battery box among multiple battery boxes provided on a train, obtain a box image corresponding to the target battery box.
[0087] It should be noted that the train is equipped with multiple batteries, such as hydrogen fuel cells, power batteries, auxiliary system batteries and backup batteries. Each battery will be configured with a corresponding battery box, which may include a shell, battery modules, thermal management system, electrical management system, protective devices and fixing devices, etc.
[0088] In an embodiment of the present application, the target battery box represents a battery box among multiple battery boxes provided in a train that is desired to be inspected for battery box damage, and the battery box is inspected using the train battery box damage detection method provided in an embodiment of the present application.
[0089] When acquiring the box image corresponding to the target battery box, the train may be in a running state or in a stationary maintenance state; wherein, the running state of the train may include traction, coasting, starting acceleration and braking, etc.; the stationary maintenance state indicates that the train is stopped at a station or under maintenance, etc.
[0090] In this step, for the target battery box of the train, when the train is in operation, an image acquisition device set near the target battery box is used to capture the box image corresponding to the target battery box to obtain the box image;
[0091] Here, when the train is in operation, box images captured at historical moments adjacent to the current moment may also be obtained from a preset box image database.
[0092] Furthermore, when the train is in a stationary maintenance state, an image acquisition device is used to capture a box image corresponding to the target battery box.
[0093] S200 , evenly dividing the box image according to a preset block size to obtain a plurality of image blocks obtained by dividing the box image, and determining position sequence information of each image block in the box image.
[0094] In this step, during specific implementation, first, the image size of the box image is adjusted to the calibrated image size; then, the box image is evenly divided according to the preset block size to obtain multiple image blocks of the box image; finally, the position sequence information of each image block in the box image is determined.
[0095] The calibrated image size and the preset cut-out size may be specifically calibrated according to the specific size of the box image and image detection requirements.
[0096] For example, assuming that the calibration image size is set to 224×224 pixels (length×width), the preset block size is set to 14×14 pixels (length×width), and the box image is segmented to obtain 256 image blocks with a size of 14×14 pixels.
[0097] In an embodiment of the present application, the position sequence information includes the position and order of the image blocks in the box image. The order of the image blocks in the box image can be based on the position of the image blocks in the box image, and is sorted from top to bottom and from left to right according to the sorting priority.
[0098] For example, assuming that the box image is evenly divided into 4 image blocks (A, B, C, D), the position of each image block in the box image specifically includes: image block A at the "upper left", image block B at the "upper right", image block C at the "lower left" and image block D at the "lower right"; based on the position of each image block in the box image, it can be determined that the order of each image block in the box image is sorted by priority, including: A, B, C, D.
[0099] S300 , inputting the image block and the position sequence information into a pre-trained encoder model accordingly, and obtaining box information corresponding to the box image output by the encoder model.
[0100] In an embodiment of the present application, the encoder model may include a masked autoencoder model. The masked autoencoder model (MAE) is an unsupervised learning model based on an autoencoder. The core idea is to randomly mask (mask) part of the input data, forcing the model to learn the potential representation of the data from the remaining visible part and reconstruct the masked area to help the model more deeply explore the high-level semantic information of the battery box damage image.
[0101] Here, since the convolution operation and sub-attention mechanism in image processing models such as convolution models and visual models are too complex, the model is less efficient in classifying images including images of damaged battery boxes. The encoder model described in the embodiment of the present application can mask, encode and decode based on the mixed image, and better learn the information about the damage in the box image of the battery box during the training process, thereby improving the processing efficiency and accuracy of the model detection.
[0102] In one embodiment of the present application, during specific implementation, step S300 may include:
[0103] S301. Perform linear projection processing on the image blocks in sequence according to the image block sequence in the position sequence information to obtain a first target dimension vector corresponding to each image block.
[0104] In this step, linear projection processing is performed on each image block in sequence according to the order corresponding to each image block to obtain the first target dimension vector corresponding to each image block; wherein the target dimension of the first target dimension vector can be calibrated according to specific needs.
[0105] Specifically, assuming that the box image is RGB three-channel and the preset block size is set to 14×14 pixels, each image block is flattened into a one-dimensional vector of length "16×16×3", and the one-dimensional vectors corresponding to each image block are projected to the target dimension required by the model through a linear layer (i.e., a fully connected layer) to obtain the first target dimension vector corresponding to each image block.
[0106] S302. Combine the first target dimension vector with the position sequence information of each of the image blocks to obtain a second target dimension vector corresponding to each of the image blocks.
[0107] In this step, during specific implementation, first, based on the position sequence information of each image block, the position of each image block is determined, that is, the position code of each first target dimension vector is determined; then, the position code of each first target dimension vector is correspondingly combined with each first target dimension vector to insert the position code into each first target dimension vector; finally, the second target dimension vector corresponding to each combined image block is obtained.
[0108] S303. Input the second target dimension vector into a pre-trained encoder model to obtain the box information corresponding to the box image output by the encoder model.
[0109] In this step, all second target dimension vectors are aggregated using a preset learnable classifier and input into a pre-trained encoder model. The box information corresponding to the box image output by the encoder model is obtained through processing and calculation by the encoder model.
[0110] The learnable classifier may include a tool capable of classifying information and integrating data.
[0111] In one embodiment of the present application, in a specific implementation, the step of training the encoder model in step S300 may include:
[0112] S310: Determine a first injury category and a second injury category in the injury categories, and select a first training image corresponding to the first injury category and a second training image corresponding to the second injury category from a preset training image dataset.
[0113] The damage category may include but is not limited to mechanical damage, thermal damage, corrosion damage and no damage.
[0114] In an embodiment of the present application, a preset training image data set may include multiple training images corresponding to each damage category; here, it is necessary to pre-adjust the image size of each training image to the calibration image size, and then arbitrarily select a preset number of training images and perform operations such as mirror flipping, rotation, scaling, height movement, and width movement on them, so that the data volume of the training images in the training image data set is expanded, and then the training image data set can be used to fully train the encoder model, so that the encoder model can learn more fully.
[0115] In this step, during specific implementation, first, any two damage categories are selected from damage categories such as mechanical damage, thermal damage, corrosion damage, and no damage, and these two damage categories are respectively determined as the first damage category and the second damage category; then, a first training image corresponding to the first damage category is selected from the training image dataset; finally, a second training image corresponding to the second damage category is selected from the training image dataset.
[0116] S320: Pixel-mixing the first training image and the second training image using a preset fusion formula to obtain a pixel-mixing result, and determining a target training image based on the pixel-mixing result.
[0117] Here, by mixing images of two damage categories and then using the mixed images for model training, image mixing enhancement and self-supervised learning of the encoder model are combined to fully mine the high-level semantic information in the field of battery box damage images with a small amount of labeled data; in addition, by performing image mixing between two random samples, the overfitting of the encoder model is reduced, and the generalization ability and robustness of the encoder model are improved.
[0118] The pixel mixing result may include image information of the first training image and image information of the second training image, and a composite image, ie, a target training image, may be obtained based on the pixel mixing result.
[0119] In the embodiment of the present application, the expression of the fusion formula is as follows.
[0120] .
[0121] in, Represents the weight of pixel mixing of the image ( ); Represents the pixel blending result; represents the first training image; represents the second training image.
[0122] S330. Perform block and mask processing on the target training image in sequence to obtain multiple target image blocks and multiple mask image blocks, and input the target image blocks into the encoder model to be trained to obtain encoded image blocks corresponding to each target image block output by the encoder model to be trained.
[0123] In one embodiment of the present application, during specific implementation, step S330 may include:
[0124] S331 : Evenly segment the target training image according to a preset segmentation size to obtain a plurality of training image blocks segmented from the target training image.
[0125] In this step, the target training image is evenly segmented according to a preset segmentation size to obtain a plurality of training image blocks segmented from the target training image, and position sequence information of each training image block in the target training image is determined.
[0126] S332. Based on the total number of the training image blocks and the preset mask rate, determine the number of targets that need to be masked in the training image blocks, and arbitrarily select training image blocks from the training image blocks according to the target number for masking, to obtain multiple mask image blocks and multiple target image blocks that have not been masked in the training image blocks.
[0127] In this step, during specific implementation, first, the total number of training image blocks is multiplied by the preset mask rate to obtain a product result to determine the number of targets that need to be masked in the training image blocks; then, a target number of training image blocks are arbitrarily selected from multiple training image blocks; finally, masking is performed on the selected training image blocks to obtain multiple masked image blocks and multiple target image blocks that have not been masked in the training image blocks.
[0128] Here, masking involves masking the image blocks so that the information in the original image blocks is invisible, forcing the encoder model to be trained to learn the contextual relationship of high-level semantic information in the target training image based only on the visible parts.
[0129] For example, assuming that the calibration image size is set to 224×224 pixels (length×width), the preset block size is set to 14×14 pixels (length×width), and the preset mask rate is 0.8, the target training image is segmented to obtain 256 training image blocks with a size of 14×14 pixels, among which 205 training image blocks are selected for masking processing to obtain 205 mask image blocks, and 51 target image blocks are obtained.
[0130] S333: Input the target image block into the encoder model to be trained, and obtain an encoded image block corresponding to each target image block output by the encoder model to be trained.
[0131] In this step, the target image block is input into the encoder model to be trained, and the encoder model to be trained performs encoding processing to obtain an encoded image block corresponding to each target image block output by the encoder model to be trained.
[0132] The coded image block may include image information included in each target image block.
[0133] Here, the encoder model to be trained only processes the target image blocks that are not obscured (not masked) to generate encoded image blocks including potential information representation. It usually uses a model structure including Transformer or CNN to extract high-level features.
[0134] S340. Input the mask image block and the encoded image block into the decoder model corresponding to the encoder model to be trained, and obtain a reconstructed training image corresponding to the target training image by speculatively reconstructing the mask image block through the decoder model; wherein the structure of the decoder model is opposite to that of the encoder model to be trained.
[0135] In an embodiment of the present application, the decoder model is used to reconstruct the original content of the mask image block (i.e., the masked area in the target training image), and the decoder can perform lightweight processing and only needs to focus on local reconstruction tasks.
[0136] In one embodiment of the present application, during specific implementation, step S340 may include:
[0137] S341 : Determine position information of each target image block and each mask image block in the target training image respectively, to determine position information corresponding to each encoded image block.
[0138] In this step, based on the position sequence information of each training image block in the target training image, the position information of each target image block in the target training image is determined, and the position information of each mask image block in the target training image is determined; wherein, the position information of each target image block in the target training image is, that is, the position information corresponding to each encoded image block.
[0139] S342: Linearly arrange the target image block and the mask image block according to the arrangement order corresponding to the position information to obtain a mask self-decoding image sequence corresponding to the target training image.
[0140] Here, the arrangement order corresponding to the position information may be based on the position of the target image block or the mask image block in the target training image, and may be obtained by sorting according to the sorting priority from top to bottom and from left to right.
[0141] In this step, during specific implementation, first, the arrangement order of the target image block and the mask image block is determined based on the position information corresponding to the target image block and the mask image block respectively; then, the target image block and the mask image block are linearly arranged according to the arrangement order; finally, the mask self-decoding image sequence corresponding to the target training image is obtained.
[0142] The masked self-decoding image sequence includes masked image blocks obtained by segmentation mask processing of the target training image and encoded image blocks output by the training decoder model.
[0143] S343. Input the masked self-decoding image sequence into the decoder model corresponding to the encoder model to be trained, so that the decoder model infers the image information corresponding to the masked image block based on the target image block, and obtains a decoded image sequence corresponding to the masked self-decoding image sequence output by the decoder model.
[0144] In an embodiment of the present application, the decoded image sequence is an image sequence reconstructed by a decoder model by inferring the decoded image sequence based on a mask.
[0145] S344: Obtain a reconstructed training image corresponding to the target training image through image reconstruction based on the position information and the decoded image sequence.
[0146] In this step, based on the position information of each training image block in the decoded image sequence in the target training image, the decoded image sequence is reconstructed to obtain a reconstructed training image after segmentation, masking, encoding and decoding of the target training image.
[0147] For example, see Figure 2 , Figure 2 A schematic diagram of the training process of an encoder model provided in an embodiment of the present application.
[0148] like Figure 2As shown in , first, the first training image corresponding to mechanical damage and the second training image corresponding to thermal damage are mixed to obtain a target training image; then, the target training image is segmented and masked according to a mask rate of 0.7 to obtain 8 target image blocks (with image information) and 17 mask image blocks, and the 8 target image blocks are input into the encoder model to be trained to obtain the encoded image blocks corresponding to the target image blocks; then, the target image blocks and the encoded image blocks are linearly arranged according to the position information and input into the decoder model to obtain the decoded image sequence output by the decoder model; finally, based on the position information and the decoded image sequence, the reconstructed training image corresponding to the target training image is obtained by image reconstruction.
[0149] S350. Calculate the loss value between the target training image and the reconstructed training image using a preset loss function, update the model parameters of the encoder model to be trained based on the loss value, and iteratively update the model parameters until the preset training conditions are met, thereby obtaining an encoder model that learns the image information in the training image data set.
[0150] In one embodiment of the present application, in a specific implementation, in step S350, the step of calculating the loss value between the target training image and the reconstructed training image using a preset loss function, and updating the model parameters of the encoder model to be trained based on the loss value may include:
[0151] S351. Based on the real image information sequence corresponding to the target training image and the predicted image information sequence corresponding to the reconstructed training image, a preset loss function is used to calculate the loss value between the target training image and the reconstructed training image.
[0152] In the embodiment of the present application, the expression of the loss function is as follows.
[0153] .
[0154] in, Represents the loss value between the target training image and the reconstructed training image; Represents the real image information sequence corresponding to the target training image; Represents the predicted image information sequence corresponding to the reconstructed training image.
[0155] S352. For each output layer of the encoder model to be trained, based on the loss value, calculate the first gradient value of the loss function relative to each output layer, and use the chain rule to pass the first gradient value from back to front in the output layer to determine the second gradient value of the loss function with respect to the model parameters of the encoder model to be trained.
[0156] S353. Based on the second gradient value, the parameters of the encoder model to be trained and the preset learning rate, update the model parameters using a preset gradient descent method to obtain updated model parameters of the encoder model to be trained.
[0157] In the embodiment of the present application, the calculation expression corresponding to the gradient descent method is as follows.
[0158] .
[0159] in, Represents the parameters of the encoder model to be trained; represents the learning rate; represents the updated model parameters of the encoder model to be trained; Represents the second gradient value of the loss function with respect to the model parameters of the encoder model to be trained.
[0160] In one embodiment of the present application, in a specific implementation, the step of repeatedly iteratively updating the model parameters in step S350 until a preset training condition is satisfied, and obtaining an encoder model for learning the image information in the training image dataset may include:
[0161] S354: Repeat the iterative updating of the model parameters, and after each update of the model parameters, determine whether the number of iterative updates reaches a preset number of iterations.
[0162] S355: If the number of iterative updates reaches a preset number of iterations, determine whether the loss value shows convergence.
[0163] S356. If the loss value shows convergence, it is determined that the iterative update meets the preset training conditions, and the encoder model to be trained updated in the current iterative cycle is determined as the encoder model for learning the image information in the training image data set.
[0164] S357. If the number of iterative updates does not reach the preset number of iterations or the loss value does not show convergence, continue to iteratively update the model parameters of the encoder model to be trained.
[0165] Here, since the reconstructed training image obtained in the first iteration is not good, the gap between the reconstructed training image and the target training image can be calculated by the loss function; if the loss value is found to be large, the iterative update is repeated multiple times until the loss value becomes smaller. The encoder model to be trained will be trained in the direction of smaller and smaller loss values to improve the accuracy of the encoder model to be trained.
[0166] The accuracy of the encoder model to be trained is determined by many factors, such as the number of training rounds, the setting of the mask rate, and the computer configuration. Each iterative update of the training will obtain an updated encoder model, and then the encoder model with the lowest loss value is determined to be the trained encoder model.
[0167] S400. Based on the box information, use a preset head sensor to perform damage classification to determine the damage category corresponding to the target battery box; wherein the damage category includes mechanical damage, thermal damage, corrosion damage, and no damage.
[0168] In an embodiment of the present application, the head sensor may include a classifier for classifying the battery box information into damage categories based on a preset battery box damage label.
[0169] See also Figure 3 , Figure 3 This is a schematic diagram of a processing flow of a battery box image provided by an embodiment of the present application. Figure 3 As shown in , a box image is evenly divided into multiple image blocks; then, the image blocks are linearly projected in sequence according to the image block order, and the position sequence information of each image block is embedded to obtain the second target dimension vector corresponding to each image block; then, the second target dimension vector is input into the encoder model to obtain the box information corresponding to the box image; finally, the head sensor is used to classify the damage of the box information to determine the damage category corresponding to the box image.
[0170] Furthermore, in another possible implementation of the present application, a preset test data set is used to perform performance evaluation of the train battery box damage detection method provided in the embodiment of the present application, such as accuracy, precision, sensitivity and specificity, and based on the performance evaluation results, the encoder model is continued to be trained.
[0171] The method for detecting damage to a train battery box provided in an embodiment of the present application uniformly segments the acquired box image corresponding to the target battery box, and inputs the segmented image blocks and the position sequence information of the image blocks into an encoder model that has previously mined the high-level semantic information of the battery box damage image through in-depth training, and based on the box information output by the encoder model, utilizes a head sensor to classify the box information to determine the damage category of the target battery box, thereby improving the accuracy and efficiency of damage detection on the battery box.
[0172] See also Figure 4 , Figure 4 This is a schematic diagram of the structure of a train battery box damage detection device provided in an embodiment of the present application. Figure 4As shown in , the detection device 400 includes:
[0173] An image acquisition module 410 is configured to acquire a box image corresponding to a target battery box among multiple battery boxes provided on the train;
[0174] An image segmentation module 420 is configured to evenly segment the box image according to a preset segmentation size to obtain a plurality of image blocks segmented from the box image, and determine position sequence information of each image block in the box image;
[0175] A model processing module 430 is configured to input the image block and the position sequence information into a pre-trained encoder model to obtain box information corresponding to the box image output by the encoder model;
[0176] The information classification module 440 is used to perform damage classification based on the box information using a preset head sensor to determine the damage category corresponding to the target battery box; wherein the damage category includes mechanical damage, thermal damage, corrosion damage and no damage.
[0177] Furthermore, when the model processing module 430 is used to input the image block and the position sequence information into the pre-trained encoder model correspondingly to obtain the box information corresponding to the box image output by the encoder model, the model processing module 430 is used to:
[0178] Performing linear projection processing on the image blocks in sequence according to the image block order in the position sequence information to obtain a first target dimension vector corresponding to each image block;
[0179] Combining the first target dimension vector with the position sequence information of each image block to obtain a second target dimension vector corresponding to each image block;
[0180] The second target dimension vector is input into a pre-trained encoder model to obtain the box information corresponding to the box image output by the encoder model.
[0181] Furthermore, when the model processing module 430 is used to train the encoder model, the model processing module 430 is used to:
[0182] Determining a first injury category and a second injury category among the injury categories, and selecting a first training image corresponding to the first injury category and a second training image corresponding to the second injury category from a preset training image dataset;
[0183] Blending pixels of the first training image and the second training image using a preset fusion formula to obtain a pixel blending result, and determining a target training image based on the pixel blending result;
[0184] performing block and mask processing on the target training image in sequence to obtain a plurality of target image blocks and a plurality of mask image blocks, and inputting the target image blocks into an encoder model to be trained to obtain an encoded image block corresponding to each target image block output by the encoder model to be trained;
[0185] Inputting the mask image block and the coded image block into a decoder model corresponding to the encoder model to be trained, and reconstructing the mask image block by the decoder model to obtain a reconstructed training image corresponding to the target training image; wherein the decoder model has a structure opposite to that of the encoder model to be trained;
[0186] A preset loss function is used to calculate the loss value between the target training image and the reconstructed training image. Based on the loss value, the model parameters of the encoder model to be trained are updated, and the model parameters are iteratively updated until the preset training conditions are met, thereby obtaining an encoder model that learns the image information in the training image dataset.
[0187] Furthermore, when the model processing module 430 is used to sequentially perform block slicing and masking processing on the target training image to obtain a plurality of target image blocks and a plurality of mask image blocks, and input the target image blocks into the encoder model to be trained to obtain an encoded image block corresponding to each target image block output by the encoder model to be trained, the model processing module 430 is used to:
[0188] Evenly dividing the target training image according to a preset block size to obtain a plurality of training image blocks obtained by dividing the target training image;
[0189] Determining, based on the total number of the training image blocks and a preset masking rate, the number of targets that need to be masked in the training image blocks, and arbitrarily selecting training image blocks from the training image blocks according to the target number for masking, to obtain a plurality of masked image blocks and a plurality of target image blocks that are not masked in the training image blocks;
[0190] The target image block is input into the encoder model to be trained to obtain an encoded image block corresponding to each target image block output by the encoder model to be trained.
[0191] Furthermore, when the model processing module 430 is used to input the mask image block and the encoded image block into the decoder model corresponding to the encoder model to be trained, and to obtain the reconstructed training image corresponding to the target training image by speculatively reconstructing the mask image block through the decoder model, the model processing module 430 is used to:
[0192] Respectively determining position information of each target image block and each mask image block in the target training image to determine position information corresponding to each encoded image block;
[0193] linearly arranging the target image block and the mask image block according to the arrangement order corresponding to the position information to obtain a mask self-decoding image sequence corresponding to the target training image;
[0194] Inputting the masked self-decoding image sequence into a decoder model corresponding to the encoder model to be trained, so that the decoder model infers image information corresponding to the masked image block based on the target image block, and obtaining a decoded image sequence corresponding to the masked self-decoding image sequence output by the decoder model;
[0195] Based on the position information and the decoded image sequence, a reconstructed training image corresponding to the target training image is obtained through image reconstruction.
[0196] Furthermore, when the model processing module 430 is used to calculate the loss value between the target training image and the reconstructed training image using a preset loss function and update the model parameters of the encoder model to be trained based on the loss value, the model processing module 430 is used to:
[0197] Based on the real image information sequence corresponding to the target training image and the predicted image information sequence corresponding to the reconstructed training image, a loss value between the target training image and the reconstructed training image is calculated using a preset loss function;
[0198] For each output layer of the encoder model to be trained, calculating, based on the loss value, a first gradient value of the loss function with respect to each output layer, and propagating the first gradient value from back to front in the output layer using the chain rule to determine a second gradient value of the loss function with respect to a model parameter of the encoder model to be trained;
[0199] Based on the second gradient value, the parameters of the encoder model to be trained and a preset learning rate, the model parameters are updated using a preset gradient descent method to obtain updated model parameters of the encoder model to be trained.
[0200] Furthermore, when the model processing module 430 is used to repeatedly iteratively update the model parameters until a preset training condition is satisfied and an encoder model for learning the image information in the training image dataset is obtained, the model processing module 430 is used to:
[0201] Repeatedly iteratively updating the model parameters, and after each update of the model parameters, determining whether the number of iterative updates reaches a preset number of iterations;
[0202] If the number of iterative updates reaches a preset number of iterations, determining whether the loss value shows convergence;
[0203] If the loss value shows convergence, it is determined that the iterative update meets the preset training condition, and the encoder model to be trained updated in the current iterative cycle is determined as the encoder model for learning the image information in the training image data set;
[0204] If the number of iterative updates does not reach the preset number of iterations or the loss value does not show convergence, the iterative update of the model parameters of the encoder model to be trained continues.
[0205] The train battery box damage detection device provided in the embodiment of the present application uniformly divides the acquired box image corresponding to the target battery box, and inputs the divided image blocks and the position sequence information of the image blocks into an encoder model that has previously deeply mined the high-level semantic information of the battery box damage image during the training process. Based on the box information output by the encoder model, the head sensor is used to classify the box information to determine the damage category of the target battery box, thereby improving the accuracy and efficiency of battery box damage detection.
[0206] See also Figure 5 , Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 5 As shown in FIG, the electronic device 500 includes a processor 510, a memory 520 and a bus 530.
[0207] The memory 520 stores machine-readable instructions executable by the processor 510. When the electronic device 500 is running, the processor 510 communicates with the memory 520 via the bus 530. When the machine-readable instructions are executed by the processor 510, the above-mentioned Figure 1 The steps of the method for detecting damage to the train battery box in the method embodiment shown are specifically implemented in accordance with the method embodiment and will not be described in detail here.
[0208] The embodiment of the present application also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the computer program can execute the above-mentioned Figure 1 The steps of the method for detecting damage to the train battery box in the method embodiment shown are specifically implemented in accordance with the method embodiment and will not be described in detail here.
[0209] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0210] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is merely a logical function division. There may be other division methods in actual implementation. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed may be through some communication interface, indirect coupling or communication connection of devices or units, which may be electrical, mechanical or other forms.
[0211] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0212] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0213] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes various media that can store program code, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0214] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present application, which are used to illustrate the technical solutions of the present application, rather than to limit them. The scope of protection of the present application is not limited thereto. Although the present application has been described in detail with reference to the above-mentioned embodiments, those skilled in the art should understand that any person skilled in the art can modify or easily conceive of changes to the technical solutions described in the above-mentioned embodiments within the technical scope disclosed in the present application, or perform equivalent replacements for some of the technical features thereof. These modifications, changes, or replacements do not deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the scope of protection of the present application. Therefore, the scope of protection of the present application should be based on the scope of protection of the claims.
Claims
1. A method for detecting damage to a train battery box, characterized in that: The detection method comprises: For a target battery box among multiple battery boxes provided on the train, obtaining a box image corresponding to the target battery box; Evenly dividing the box image according to a preset block size to obtain a plurality of image blocks divided by the box image, and determining position sequence information of each image block in the box image; Inputting the image block and the position sequence information into a pre-trained encoder model accordingly, and obtaining box information corresponding to the box image output by the encoder model; The encoder model is trained by the following steps: Determining a first injury category and a second injury category among the injury categories, and selecting a first training image corresponding to the first injury category and a second training image corresponding to the second injury category from a preset training image dataset; The first training image and the second training image are pixel-mixed using a preset fusion formula to obtain a pixel mixing result, and a target training image is determined based on the pixel mixing result; the expression of the fusion formula includes: ; in, Represents the weight of pixel blending of the image; represents the pixel mixing result; represents the first training image; represents the second training image; performing block and mask processing on the target training image in sequence to obtain a plurality of target image blocks and a plurality of mask image blocks, and inputting the target image blocks into an encoder model to be trained to obtain an encoded image block corresponding to each target image block output by the encoder model to be trained; Inputting the mask image block and the coded image block into a decoder model corresponding to the encoder model to be trained, and reconstructing the mask image block by the decoder model to obtain a reconstructed training image corresponding to the target training image; wherein the decoder model has a structure opposite to that of the encoder model to be trained; Calculating a loss value between the target training image and the reconstructed training image using a preset loss function, updating model parameters of the encoder model to be trained based on the loss value, and iteratively updating the model parameters until preset training conditions are met, thereby obtaining an encoder model that learns the image information in the training image dataset; Based on the box information, damage classification is performed using a preset head sensor to determine the damage category corresponding to the target battery box; wherein the damage category includes mechanical damage, thermal damage, corrosion damage and no damage.
2. The method according to claim 1, characterized in that The step of inputting the image block and the position sequence information into a pre-trained encoder model to obtain box information corresponding to the box image output by the encoder model includes: Performing linear projection processing on the image blocks in sequence according to the image block order in the position sequence information to obtain a first target dimension vector corresponding to each image block; Combining the first target dimension vector with the position sequence information of each image block to obtain a second target dimension vector corresponding to each image block; The second target dimension vector is input into a pre-trained encoder model to obtain the box information corresponding to the box image output by the encoder model.
3. The method according to claim 1, characterized in that The target training image is sequentially sliced and masked to obtain a plurality of target image blocks and a plurality of mask image blocks, and the target image blocks are input into an encoder model to be trained to obtain an encoded image block corresponding to each target image block output by the encoder model to be trained, including: Evenly dividing the target training image according to a preset block size to obtain a plurality of training image blocks obtained by dividing the target training image; Determining, based on the total number of the training image blocks and a preset masking rate, the number of targets that need to be masked in the training image blocks, and arbitrarily selecting training image blocks from the training image blocks according to the target number for masking, to obtain a plurality of masked image blocks and a plurality of target image blocks that are not masked in the training image blocks; The target image block is input into the encoder model to be trained to obtain an encoded image block corresponding to each target image block output by the encoder model to be trained.
4. The method according to claim 1, wherein The step of inputting the mask image block and the coded image block into a decoder model corresponding to the encoder model to be trained, and reconstructing the mask image block by the decoder model to obtain a reconstructed training image corresponding to the target training image, comprising: Respectively determining position information of each target image block and each mask image block in the target training image to determine position information corresponding to each encoded image block; linearly arranging the target image block and the mask image block according to the arrangement order corresponding to the position information to obtain a mask self-decoding image sequence corresponding to the target training image; Inputting the masked self-decoding image sequence into a decoder model corresponding to the encoder model to be trained, so that the decoder model infers image information corresponding to the masked image block based on the target image block, and obtaining a decoded image sequence corresponding to the masked self-decoding image sequence output by the decoder model; Based on the position information and the decoded image sequence, a reconstructed training image corresponding to the target training image is obtained through image reconstruction.
5. The method according to claim 1, wherein The calculating a loss value between the target training image and the reconstructed training image by using a preset loss function, and updating a model parameter of the encoder model to be trained based on the loss value, includes: Based on the real image information sequence corresponding to the target training image and the predicted image information sequence corresponding to the reconstructed training image, a loss value between the target training image and the reconstructed training image is calculated using a preset loss function; For each output layer of the encoder model to be trained, calculating, based on the loss value, a first gradient value of the loss function with respect to each output layer, and propagating the first gradient value from back to front in the output layer using the chain rule to determine a second gradient value of the loss function with respect to a model parameter of the encoder model to be trained; Based on the second gradient value, the parameters of the encoder model to be trained and a preset learning rate, the model parameters are updated using a preset gradient descent method to obtain updated model parameters of the encoder model to be trained.
6. The method according to claim 1, characterized in that The repeatedly iterative updating of the model parameters until a preset training condition is satisfied, thereby obtaining an encoder model for learning image information in the training image dataset, comprises: Repeatedly iteratively updating the model parameters, and after each update of the model parameters, determining whether the number of iterative updates reaches a preset number of iterations; If the number of iterative updates reaches a preset number of iterations, determining whether the loss value shows convergence; If the loss value shows convergence, it is determined that the iterative update meets the preset training condition, and the encoder model to be trained updated in the current iterative cycle is determined as the encoder model for learning the image information in the training image data set; If the number of iterative updates does not reach the preset number of iterations or the loss value does not show convergence, the iterative update of the model parameters of the encoder model to be trained continues.
7. A device for detecting damage to a train battery box, characterized in that: The detection device comprises: An image acquisition module is used to acquire a box image corresponding to a target battery box among multiple battery boxes provided on the train; An image segmentation module is used to evenly segment the box image according to a preset segmentation size to obtain a plurality of image blocks segmented from the box image, and determine position sequence information of each image block in the box image; A model processing module, configured to input the image block and the position sequence information into a pre-trained encoder model in correspondence, and obtain box information corresponding to the box image output by the encoder model; When the model processing module is used to train the encoder model, the model processing module is used to: Determining a first injury category and a second injury category among the injury categories, and selecting a first training image corresponding to the first injury category and a second training image corresponding to the second injury category from a preset training image dataset; The first training image and the second training image are pixel-mixed using a preset fusion formula to obtain a pixel mixing result, and a target training image is determined based on the pixel mixing result; the expression of the fusion formula includes: ; in, Represents the weight of pixel blending of the image; represents the pixel mixing result; represents the first training image; represents the second training image; performing block and mask processing on the target training image in sequence to obtain a plurality of target image blocks and a plurality of mask image blocks, and inputting the target image blocks into an encoder model to be trained to obtain an encoded image block corresponding to each target image block output by the encoder model to be trained; Inputting the mask image block and the coded image block into a decoder model corresponding to the encoder model to be trained, and reconstructing the mask image block by the decoder model to obtain a reconstructed training image corresponding to the target training image; wherein the decoder model has a structure opposite to that of the encoder model to be trained; Calculating a loss value between the target training image and the reconstructed training image using a preset loss function, updating model parameters of the encoder model to be trained based on the loss value, and iteratively updating the model parameters until preset training conditions are met, thereby obtaining an encoder model that learns the image information in the training image dataset; An information classification module is used to perform damage classification based on the box information using a preset head sensor to determine the damage category corresponding to the target battery box; wherein the damage category includes mechanical damage, thermal damage, corrosion damage and no damage.
8. An electronic device, characterized in that: include: A processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor and the memory communicate through the bus. When the processor is running, the machine-readable instructions execute the steps of the method for detecting damage to a train battery box as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method for detecting damage to a train battery box as claimed in any one of claims 1 to 6 are executed.
Citation Information
Patent Citations
Image processing method and device, computer equipment, storage medium and program product
CN117036377A
Helical blade thickness wear detection method and system based on machine vision
CN117237367A