Anti-collision method for CT (Computed Tomography) system
Through the combination of YOLOv8 model and EfficientAD algorithm, the time consistency training and motion estimation network are used to solve the problem of target object recognition and intermediate frame error detection in the CT system, and efficient and accurate anti-collision detection is achieved, which improves operation efficiency and accuracy.
Patent Information
- Application Number
- CN202411167387.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-23
- Publication Date
- 2024-12-31
AI Technical Summary
The existing anti-collision method of CT system requires measuring the size of the target object and adjusting the parameters, which leads to cumbersome operation. The YOLOv8 model causes intermediate frame error detection for single-frame image training, affecting accuracy.
Using YOLOv8 model and EfficientAD algorithm, through data acquisition and model training, we can identify target objects of any category and appearance, use time consistency training strategies and motion estimation network to establish the relationship between frames, combine the EfficientAD algorithm for mask detection, and judge rays. Whether the source and detector collide with the target.
It realizes the identification of any target object without adjusting parameters, solves the problem of intermediate frame error detection, improves the anti-collision accuracy and operation efficiency of the CT system, and increases the inference speed from 7FPS to 15FPS on Nvidia RTX 2060.
Smart Images

Figure CN119229084A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of anti-collision of CT systems, and in particular relates to an anti-collision method of a CT system. Background Art
[0002] The CT system anti-collision module is an important component in the CT system. It not only prevents the damage caused by the radiation source or detector colliding with the target, but also prevents the position offset caused by the collision with the target, which makes the projection image inaccurate. The existing method requires measuring the size of the target first and then outputting the size to the computer to prevent the radiation source or detector from colliding with the target. This method is very cumbersome and affects the operation efficiency.
[0003] Therefore, further improvements are made to the above problems. Summary of the invention
[0004] The main purpose of the present invention is to provide a CT system anti-collision method, which can identify targets of any category and shape without adjusting any parameters, does not require retraining of new targets, and solves the problem of intermediate frame misdetection caused by YOLOv8 model training on single frame images.
[0005] To achieve the above object, the present invention provides a CT system anti-collision method, comprising the following steps:
[0006] Step S1: perform data collection, (according to the principle of the EfficientAD algorithm) collect a training data set that does not contain the target object for training and a test data set that contains the target object for testing, and ensure that the background of the training data set and the test data set are consistent (to prevent the background object from being identified as the target object);
[0007] Step S2: Perform model training. For the YOLOv8 model, the training data set is divided into a first training set, a first validation set, and a first test set according to a preset ratio (preferably 7:2:1), and then the model formula is used for training; for the EfficientAD algorithm (model), the training data set is made into a second training set (containing only 70% of normal images) and the test data set is made into a second test set (including 30% of normal images and abnormal images), and then the algorithm formula is used for training;
[0008] Step S3: Deploy the trained YOLOv8 model and EfficientAD algorithm;
[0009] Step S4: perform anti-collision judgment, use the YOLOv8 model to detect the ray source and detector and obtain the mask, use the EfficientAD algorithm to detect the illuminated target and obtain the mask, and then judge whether a collision occurs by analyzing whether the mask of the ray source or detector overlaps with the mask of the target.
[0010] As a further preferred technical solution of the above technical solution, in step S2, the first training set is trained by the total loss function formula of the YOLOv8 model, and the formula is:
[0011] Loss total (f θ (x),y)=Loss cls (f θ (x),y)+Loss bbox (f θ (x),y)+Loss mask (f θ (x), y);
[0012] Among them, f θ (x) represents the YOLOv8 model, θ represents the learnable parameters, and the goal is to total The gradient of θ is used to update θ, Loss cls () represents the category loss function, Loss bbox () represents the bounding box loss function, Loss mask () represents the mask loss function, y represents the true label;
[0013] The parameter θ update formula is as follows:
[0014] θ t+1 =θ t -αλg t ;
[0015]
[0016] Among them, t represents the iteration to the tth step, g t Indicates the Loss of step t total The gradient of θ is and are the corrected first-order momentum and second-order momentum, respectively, divided by 1-β. t+1 Used to prevent slow update speed due to excessive β; m t+1 =β1m t +(1-β1)g t+1 , To represent the first-order momentum and the second-order momentum, respectively, so that the model parameters can be updated more quickly (to prevent oscillation), α is the learning rate, λ is the regularization coefficient, β1 and β2 are the first-order and second-order historical momentum retention rates, respectively;
[0017] Update the model parameters according to the above update process. Verify the model accuracy after the updated parameters in each step on the first validation set, find the model with the highest accuracy, and finally verify the generalization of the model on the first test set. At this time, the optimal YOLOv8 model is obtained. (The detection result of the YOLOv8 model has a jump phenomenon in the middle frame, and the background will be mistakenly detected as a detector. Part of the reason may be that the training data is insufficient. The data set is a picture taken from the video every 30 frames. The trained model cannot model the slight changes of one or two frames before and after. Another part of the reason is that the YOLOv8 model is only trained on a single picture, and the relationship between frames is not established.) Add the motion estimation network (FlowNet2) to the YOLOv8 model for joint training to establish the relationship between frames. The time consistency training strategy is:
[0018] Freeze the parameters of the motion estimation network (FlowNet2), optimize only the parameters of the YOLOv8 model, and set I t and I t+j Input the frozen motion estimation network to obtain the optical flow map OF from time t to t+k t→t+k , and then the S segmented by the YOLOv8 model t+k and OF t→t+k Perform bilinear interpolation resampling to obtain the semantic mask map from frame t+k to frame t It is used as a supervisory signal and S t To optimize the MSE loss, the formula is:
[0019]
[0020] Among them, I t Represents the picture of the tth frame, I t+k represents the picture of frame t+k, S t+k S represents the mask image obtained after the image of the t+kth frame passes through the YOLOv8 model, t represents the mask map obtained by the YOLOv8 model after the image of the t-th frame, i represents the i-th position of the semantic mask map, due to the resampling There is a deviation from the ideal semantic mask map from frame t+k to frame t. t+k The resampled with I t To compensate for the deviation, the formula is changed to:
[0021]
[0022] Finally, the total loss function formula is used to optimize the YOLOv8 model:
[0023] L total =L Cls +L Bbox +L Mask +λL TC .
[0024] As a further preferred technical solution of the above technical solution, the trained YOLOv8 model and EfficientAD algorithm are used as PT models, and then converted into an intermediate model ONNX to form a calculation graph, and then deployed on the TensorRT reasoning framework through ONNX (the post-processing module of the efficientAD model slows down the reasoning speed, and the post-processing module is added to the ONNX calculation graph together with the network structure, and half-precision quantization is used on TensorRT, and the reasoning speed on Nvidia RTX 2060 is increased from 7FPS to 15FPS).
[0025] As a further preferred technical solution of the above technical solution, step S4 is specifically implemented as follows:
[0026] Step S4.1: For the YOLOv8 model, two outputs are generated. One output is a tensor of size 1*38*8400, where the first dimension represents the number of images, the third dimension represents the number of candidate points in the image, the first four values of the second dimension represent the center position and width and height of the ray source or detector in the image, and the last two values represent the category scores of the ray source and detector respectively. For one of the candidate points, if the maximum value of the two category scores is less than the set confidence threshold, then the candidate point is considered to be background, otherwise it is considered to be foreground. After selecting the candidate points of the foreground target, the center position and width and height of the remaining candidate points are geometrically transformed into the position and width and height of the upper left corner, and the non-maximum suppression operation is performed together with the category score to obtain the remaining candidate points (in the present invention, generally 2 candidate points are selected because there are only two targets, the ray source and the detector); the last 32 dimensions represent the coefficients mc of the mask map, which are used to make a weighted sum of the second output tensor. One output is a tensor p of size 1*32*160*160. The mask map of the ray source and the detector is obtained by the formula in:
[0027] mask rd =mc T p;
[0028] in,
[0029] Take one of the mask images as an example Use the sigmoid formula to transform the mask rd,1 Mapped to the interval [0,1], as shown in the formula:
[0030]
[0031] Then put the mask rd,1 Resize it to 1*640*640, and then apply the mask rd,1 Scale to the aspect ratio of the original image, then resize it to the width and height of the original image, and then add the predicted upper left corner position and width and height to the mask. rd,1 Cut out an area, then do threshold segmentation, and put the mask rd,1 The values less than 0.5 are set to 0, and the rest are set to 1. Then, according to the predicted upper left corner position and width and height, the cropped area is mapped to the original image position. Another mask map is mask. rd,2 Also generate according to the above process;
[0032] Step S4.2: Only one output mask is generated for the EfficientAD algorithm Mask o Respectively with mask rd,1 and mask rd,2 Make an overlap judgment, and if it overlaps with one of the mask images, it is judged as a collision.
[0033] To achieve the above objectives, the present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the CT system collision avoidance method when executing the program.
[0034] To achieve the above objectives, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which implements the steps of the CT system collision avoidance method when executed by a processor. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 This is the overall network architecture diagram of the YOLOv8 model.
[0036] Figure 2 This is the network architecture diagram of the EfficientAD algorithm.
[0037] Figure 3 It is a production diagram of the training data set and the test data set of the present invention.
[0038] Figure 4It is a test result diagram of the YOLOv8 model of the present invention.
[0039] Figure 5 It is a time consistency training strategy diagram of the present invention.
[0040] Figure 6 This is a graph of the time consistency training results of the present invention.
[0041] Figure 7 It is an abnormal score graph of the EfficientAD algorithm of the present invention.
[0042] Figure 8 This is the (skip connection) network architecture diagram of the EfficientAD algorithm of the present invention.
[0043] Fig. 9 It is the (skip connection) algorithm anomaly score graph of the EfficientAD algorithm of the present invention.
[0044] Fig.10 It is a model conversion flow chart of the present invention.
[0045] Fig.11 It is a flow chart of generating mask of the present invention.
[0046] Fig.12 It is an overlap judgment flow chart of the present invention.
[0047] Fig.13 It is an illustration of the model deployment detection result of the present invention. DETAILED DESCRIPTION
[0048] The following description is used to disclose the present invention so that those skilled in the art can implement the present invention. The preferred embodiments described below are only examples, and those skilled in the art can think of other obvious variations. The basic principles of the present invention defined in the following description can be applied to other embodiments, variations, improvements, equivalents, and other technical solutions that do not deviate from the spirit and scope of the present invention.
[0049] In a preferred embodiment of the present invention, those skilled in the art should note that the YOLOv8 model and EfficientAD algorithm involved in the present invention can be regarded as prior art.
[0050] Preferred embodiments.
[0051] Considering that the category of the target object cannot be determined and it may be an arbitrary target object, two models are used to implement the anti-collision technology of the present invention. The YOLOv8 model and the EfficientAD algorithm are introduced in two parts below.
[0052] YOLOv8 is an engineering algorithm officially launched by Ultralytics, which can complete tasks such as image classification, target detection, instance segmentation, and pose estimation. Among them, instance segmentation just meets the needs of our anti-collision task. The network architecture of YOLOv8 is as follows: Figure 1 shown.
[0053] The Backbone part uses the technology of CSPnet, dividing the input features into two parts. One part is spliced with the other part in the channel dimension through the BottleNeck module, which enriches the gradient flow, enhances the model's ability to learn features, and integrates gradient changes into the feature map, reducing the amount of calculation. The Neck part uses FPN+PAN technology to generate feature maps of different scales. FPN can transmit strong semantic features from top to bottom, and PAN can transmit strong position features from bottom to top. The combination of these two parts enhances both the semantic information of the features and the texture information, which can effectively improve the performance of the model. In the segmentation task, the Head consists of the Detection Head and the Segmentation Head.
[0054] Detection Head performs convolution operations on the three scale feature maps generated by the Neck part to generate features of three scales: (4*16+nc)*20*20, (4*16+nc)*40*40, and (4*16+nc)*80*80, where nc represents the number of detected categories. Then, the Cls_Loss (Formula (1)) and Bbox_Loss (Formula (2)) loss functions are used to optimize the feature maps of these three scales respectively.
[0055]
[0056] In formula (1), N represents the total number of samples, y i represents the true label of the category, x i represents the i-th training image sample, σ(·) represents the sigmoid activation function, and f(·) represents the yolov8 network. In formula (2), y i Indicates the distance from the center position to the true bounding box, Indicates y i Round up, Indicates y i Round down, Indicates that the network outputs a vector of length 16 at position The corresponding value, Indicates that the network outputs a vector of length 16 at position The corresponding value. CIOU(·) represents the CIOU loss function, Represents the predicted bounding box, bbox irepresents the true bounding box.
[0057] Segmentation Head performs a series of convolution operations on the three scale feature maps generated by the Neck part to generate a (32*8400) size Mask coefficient (using Represented) and Mask prototype of size (32*160*160) (with Then, mc and p are optimized using formula (3).
[0058]
[0059]
[0060] in, In the actual implementation process, we used the TaskAlignedAssigner algorithm to select k anchor points (k<<8400) from 8400 anchor points. Also becomes
[0061] MVTec Software GmbH has proposed a high-precision and high-efficiency EfficientAD algorithm that can more accurately locate unknown targets in the training set, which enables better positioning of unknown targets in the CT system. The overall network architecture of the algorithm is shown in the figure. Figure 2 shown.
[0062] The EfficientAD algorithm uses three networks, where both the Teacher network and the Student network use the PDN architecture, and the AutoEncoder uses a U-shaped network. The Teacher network is pre-trained on the ImageNet dataset by minimizing the PDN output and the WideResNet-101 output. During the training phase, we freeze the parameters of the Teacher network and update the parameters of the Student and AutoEncoder. Under the general Student-Teacher network framework, increasing the number of training images will enhance the Student network's ability to mimic the Teacher network's anomaly reconstruction, which will damage the network's anomaly detection performance. However, simply reducing the number of training images will affect the network's ability to learn important features of normal images. This is similar to difficult sample mining. Inspired by difficult sample mining, the algorithm proposes a difficult feature loss, as shown in formula (4).
[0063]
[0064] Where N represents the total number of samples in the set, I represents the training image sample, T(I) represents the output of the Teacher network, S(I) represents the output of the Student network, and quantile(·) represents the quantile operator. Here, the default quantile is set to 0.999. Formula (4) can only perform backpropagation on elements with high loss in the output of the Student network, which prevents the Student network from imitating the ability of the Teacher network to reconstruct anomalies. The algorithm also introduces AutoEncoder to detect logical anomalies in images, and uses formula (5) to train AutoEncoder to predict the output of the Teacher network. The formula is shown below.
[0065]
[0066] Where A(I) represents the output of AutoEncoder, and C, W, and H represent the channel, width, and height of the output feature map, respectively. Since AutoEncoder cannot learn the fine-grained representation of the image, using the difference between the output of the Teacher network and the output of the AutoEncoder as the anomaly score will cause false detection. Therefore, an additional loss function is introduced to make the Student network predict the output of the AutoEncoder and generate a coarse-grained representation of the image. Then, the difference between the output of the Student network and the output of the AutoEncoder can be calculated to solve the false detection problem. The formula is shown in formula (6).
[0067]
[0068] This formula enables the Student network to learn the reconstruction error of AutoEncoder in normal images, and at the same time, since there is no abnormal data in the training set, it will not learn the reconstruction error of abnormal images.
[0069] The present invention discloses a CT system anti-collision method, comprising the following steps:
[0070] Step S1: Data collection: (according to the principle of EfficientAD algorithm) collect a training data set that does not contain the target object for training and a test data set that contains the target object for testing, and ensure that the background of the training data set and the test data set are consistent (in order to prevent the background object from being identified as the target object, such as Figure 3 shown);
[0071] Step S2: Perform model training. For the YOLOv8 model, Figure 3The training data set in (a) is divided into a first training set, a first validation set and a first test set according to a preset ratio (preferably 7:2:1), and then the model formula is used for training; for the EfficientAD algorithm (model), the training data set is made into a second training set (containing only 70% of normal images) and the test data set is made into a second test set (including 30% of normal images and abnormal images), and then the algorithm formula is used for training;
[0072] Step S3: Deploy the trained YOLOv8 model and EfficientAD algorithm;
[0073] Step S4: perform anti-collision judgment, use the YOLOv8 model to detect the ray source and detector and obtain the mask, use the EfficientAD algorithm to detect the illuminated target and obtain the mask, and then judge whether a collision occurs by analyzing whether the mask of the ray source or detector overlaps with the mask of the target.
[0074] Specifically, in step S2, the first training set is trained using the total loss function formula of the YOLOv8 model, which is:
[0075] Loss total (f θ (x),y)=Loss cls (f θ (x),y)+Loss bbox (f θ (x),y)+Loss mask (f θ (x), y);
[0076] Among them, f θ (x) represents the YOLOv8 model, θ represents the learnable parameters, and the goal is to total The gradient of θ is used to update θ, Loss cls () represents the category loss function, Loss bbox () represents the bounding box loss function, Loss mask () represents the mask loss function, y represents the true label;
[0077] The parameter θ update formula is as follows:
[0078] θ t+1 =θ t -αλg t ;
[0079]
[0080] Among them, t represents the iteration to the tth step, g tIndicates the Loss of step t total The gradient of θ is are the corrected first-order momentum and second-order momentum, respectively, divided by 1-β t+1 Used to prevent slow update speed due to excessive β; m t+1 =β1m t +(1-β1)g t+1 , To represent the first-order momentum and the second-order momentum respectively, so as to converge faster during the model parameter update process (to prevent oscillation), α is the learning rate, λ is the regularization coefficient, β1 and β2 are the first-order and second-order historical momentum retention rates respectively (preferably set to 0.9 and 0.999 respectively in the invention);
[0081] Update the model parameters according to the above update process, verify the model accuracy after the updated parameters on the first validation set at each step, find the model with the highest accuracy, and finally verify the generalization of the model on the first test set. At this time, the optimal YOLOv8 model is obtained. The test results are as follows: Figure 4 As shown. (by Figure 4 It was found that the YOLOv8 model detected results with jumps in the middle frame, and the background was mistakenly detected as a detector. One reason may be that the training data is insufficient. The data set is a picture taken every 30 frames in the video. The trained model cannot model the slight changes of one or two frames before and after. Another reason is that the YOLOv8 model is only trained on a single picture, and the relationship between frames is not established. The motion estimation network (FlowNet2) is added to the YOLOv8 model for joint training to establish the relationship between frames. The temporal consistency training strategy is as follows: Figure 5 As shown:
[0082] Freeze the parameters of the motion estimation network (FlowNet2), optimize only the parameters of the YOLOv8 model, and set I t and I t+k Input the frozen motion estimation network to obtain the optical flow map OF from time t to t+k t→t+k , and then the S segmented by the YOLOv8 model t+k and OF t→t+k Perform bilinear interpolation resampling to obtain the semantic mask map from frame t+k to frame t It is used as a supervisory signal and S t To optimize the MSE loss, the formula is:
[0083]
[0084] Among them, I t Represents the picture of the tth frame, I t+krepresents the picture of frame t+k, S t+k S represents the mask image obtained after the image of the t+kth frame passes through the YOLOv8 model, t represents the mask map obtained by the YOLOv8 model after the image of the t-th frame, i represents the i-th position of the semantic mask map, due to the resampling There is a deviation from the ideal semantic mask map from frame t+k to frame t. t+k The resampled with I t To compensate for the deviation, the formula is changed to:
[0085]
[0086] Finally, the total loss function formula is used to optimize the YOLOv8 model:
[0087] L total =L Cls +L Bbox +L Mask +λL TC .
[0088] In the present invention, λ is set to 0.1. The final training result is as follows Figure 6 shown.
[0089] For training the Efficient algorithm, the second training set (containing only 70% of the training set images) and the second test set (containing 30% of the training set images and the test set images) of the Efficient algorithm are made based on the collected data. The Teacher network, the Student network and the AutoEncoder are trained using formulas (4), (5) and (6) (the training process is shown in the YOLOv8 model training parameter update method). The final output abnormal score graph is shown in Figure 7 As shown. Figure 7 It can be seen that in this data with a complex background, there are still cases of false detection. Inspired by the jump connection of the U-NET network, we added jump connections to the AutoEncoder, so the network structure of the AutoEncoder is as follows Figure 8 As shown. No additional loss function is introduced, and the Teacher network, Student network and AutoEncoder are still trained using formulas (4), (5) and (6). The final result is as follows Fig. 9 shown.
[0090] More specifically, in order to make the trained YOLOv8 model and EfficientAD algorithm available, use TensorRT to deploy on the C++ platform. The model conversion process is as follows: Fig.10: The trained YOLOv8 model and EfficientAD algorithm are used as PT models, and then converted to the intermediate model ONNX to form a calculation graph, and then deployed on the TensorRT reasoning framework through ONNX (the post-processing module of the efficientAD model slows down the reasoning speed. The post-processing module and the network structure are added to the ONNX calculation graph, and half-precision quantization is used on TensorRT. The reasoning speed on Nvidia RTX 2060 is increased from 7FPS to 15FPS).
[0091] Furthermore, step S4 is specifically implemented as follows:
[0092] Step S4.1: For the YOLOv8 model, two outputs are generated. One output is a tensor of size 1*38*8400, where the first dimension represents the number of images, the third dimension represents the number of candidate points in the image, the first four values of the second dimension represent the center position and width and height of the ray source or detector in the image, and the last two values represent the category scores of the ray source and detector respectively. For one of the candidate points, if the maximum value of the two category scores is less than the set confidence threshold, then the candidate point is considered to be background, otherwise it is considered to be foreground. After selecting the candidate points of the foreground target, the center position and width and height of the remaining candidate points are geometrically transformed into the position and width and height of the upper left corner, and the non-maximum suppression operation is performed together with the category score to obtain the remaining candidate points (in the present invention, generally 2 candidate points are selected because there are only two targets, the ray source and the detector); the last 32 dimensions represent the coefficients mc of the mask map, which are used to make a weighted sum of the second output tensor. One output is a tensor p of size 1*32*160*160. The mask map of the ray source and the detector is obtained by the formula in:
[0093] mask rd =mc T p;
[0094] in,
[0095] Take one of the mask images as an example Use the sigmoid formula to transform the mask rd,1 Mapped to the interval [0,1], as shown in the formula:
[0096]
[0097] Then put the mask rd,1 Resize it to 1*640*640, and then apply the mask rd,1Scale to the aspect ratio of the original image (scaled to 1*640*360 in this invention), then resize it to the width and height of the original image, and then add the predicted upper left corner position and width and height to the mask. rd,1 Cut out an area, then do threshold segmentation, and put the mask rd,1 The values less than 0.5 are set to 0, and the rest are set to 1. Then, according to the predicted upper left corner position and width and height, the cropped area is mapped to the original image position. Another mask map is mask. rd,2 The same process is used to generate; the flow chart is as follows Fig.11 shown.
[0098] Step S4.2: Only one output mask is generated for the EfficientAD algorithm Maskr o Respectively with mask rd,1 and mask rd,2 Do an overlap check. If there is an overlap with one of the mask images, it is considered a collision. The process is as follows: Fig.12 shown.
[0099] For the present invention:
[0100] (1) Training the YOLOv8 model
[0101] Download the ultralytics algorithm package from GitHub (using version 8.0.155), and then modify the training part in the engine / trainer.py file to a time-consistent training strategy. And modify the data reading method in the load_image method in the BaseDataset class in the data / base.py file to read the current frame and the images of the previous and next frames. Finally, divide the training set, validation set, and test set using the yolov8 data set division method and train the Yolov8 model to obtain yolov8-n.pt.
[0102] (2) Training EfficientAD
[0103] Download the efficientAD algorithm from GitHub, and then use the pictures without target objects as the training set and the pictures with target objects as the test set according to the data collection method. Finally, train the efficientAD model to obtain teacher.pth, student.pth, and autoencoder.pth.
[0104] (3) Model conversion
[0105] Use the onnxruntime-gpu package to convert Yolov8-n.pt, teacher.pth, student.pth, and autoencoder.pth into onnx models. Add the predicit function in the efficientad.py file in the EfficientAD algorithm to the post-processing module, and add the post-processing process to the onnx calculation graph.
[0106] (4) Model deployment
[0107] Create a C++ project and write inference code to process the Yolov8.onnx, teacher.onnx, student.onnx, and autoencoder.onnx models in the way that tensorrt deploys deep learning models. The inference results are as follows Fig.13 shown.
[0108] Preferably, the present invention further discloses an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the CT system collision avoidance method when executing the program.
[0109] Preferably, the present invention further discloses a non-transitory computer-readable storage medium having a computer program stored thereon, and the computer program, when executed by a processor, implements the steps of the CT system collision avoidance method.
[0110] It is worth mentioning that the technical features such as the YOLOv8 model and EfficientAD algorithm involved in the patent application of this invention should be regarded as prior art. The specific structure, working principle, and possible control method and spatial layout method of these technical features can be selected according to the conventional methods in the field, and should not be regarded as the inventive point of the patent of this invention. The patent of this invention will not be further elaborated.
[0111] For those skilled in the art, it is still possible to modify the technical solutions described in the aforementioned embodiments, or to make equivalent substitutions for some of the technical features therein. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A CT system anti-collision method, characterized in that: The following steps are involved: Step S1: performing data collection, collecting a training data set that does not contain the target object for training and a test data set that contains the target object for testing, and ensuring that the background of the training data set is consistent with that of the test data set; Step S2: Perform model training. For the YOLOv8 model, divide the training data set into a first training set, a first validation set, and a first test set according to a preset ratio, and then use the model formula for training; for the EfficientAD algorithm, make the training data set into a second training set and the test data set into a second test set, and then use the algorithm formula for training; Step S3: Deploy the trained YOLOv8 model and EfficientAD algorithm; Step S4: perform anti-collision judgment, use the YOLOv8 model to detect the ray source and detector and obtain the mask, use the EfficientAD algorithm to detect the illuminated target and obtain the mask, and then judge whether a collision occurs by analyzing whether the mask of the ray source or detector overlaps with the mask of the target.
2. A CT system anti-collision method according to claim 1, characterized in that: In step S2, the first training set is trained using the total loss function formula of the YOLOv8 model, which is: Loss total (f θ (x),y)=Loss cls (f θ (x),y)+Loss bbox (f θ (x),y)+Loss mask (f θ (x),y); Among them, f θ (x) represents the YOLOv8 model, θ represents the learnable parameters, and the goal is to total The gradient of θ is used to update θ, Loss cls () represents the category loss function, Loss bbox () represents the bounding box loss function, Loss mask () represents the mask loss function, y represents the true label; The parameter θ update formula is as follows: i t+1 =θ t -alg t ; Among them, t means iteration to the tth step, g t Indicates the Loss of step t total The gradient of θ is and are the corrected first-order momentum and second-order momentum, respectively, divided by 1-β. t+1 Used to prevent slow update speed due to excessive β; m t+1 =β1m t +(1-β1)g t+1 , are the first-order momentum and the second-order momentum, respectively, which make the model parameters converge faster during the update process. α is the learning rate, λ is the regularization coefficient, β1 and β2 are the first-order and second-order historical momentum retention rates, respectively. Update the model parameters according to the above update process. Verify the model accuracy after the updated parameters on the first validation set at each step to find the model with the highest accuracy. Finally, verify the generalization of the model on the first test set. At this time, the optimal YOLOv8 model is obtained. Add the motion estimation network to the YOLOv8 model for joint training to establish the relationship between frames. The temporal consistency training strategy is: Freeze the parameters of the motion estimation network, optimize only the parameters of the YOLOv8 model, and set I t and I t+k Input the frozen motion estimation network to obtain the optical flow map OF from time t to t+k t→t+k , and then the S segmented by the YOLOv8 model t+k and OF t→t+k Perform bilinear interpolation resampling to obtain the semantic mask map from frame t+k to frame t It is used as a supervisory signal and S t To optimize the MSE loss, the formula is: Among them, I t Represents the picture of the tth frame, I t+k represents the picture of frame t+k, S t+k S represents the mask image obtained after the image of the t+kth frame passes through the YOLOv8 model, t represents the mask map obtained by the YOLOv8 model after the image of the t-th frame, i represents the i-th position of the semantic mask map, due to the resampling There is a deviation from the ideal semantic mask map from frame t+k to frame t. t+k The resampled with I t To compensate for the deviation, the formula is changed to: Finally, the total loss function formula is used to optimize the YOLOv8 model: THE total =L Cls +L Bbox +L Mask +λL TC 。 3. A CT system anti-collision method according to claim 2, characterized in that: In step S3, the trained YOLOv8 model and EfficientAD algorithm are used as PT models, and then converted into the intermediate model ONNX to form a calculation graph, and then deployed on the TensorRT reasoning framework through ONNX.
4. A CT system anti-collision method according to claim 3, characterized in that: Step S4 is specifically implemented as follows: Step S4.1: For the YOLOv8 model, two outputs will be generated. One output is a tensor of size 1*38*8400, where the first dimension represents the number of pictures, the third dimension represents the number of candidate points on the picture, the first four values of the second dimension represent the center position and width and height of the ray source or detector in the image, and the last two values represent the category scores of the ray source and the detector respectively. For one of the candidate points, if the maximum value of the two category scores is less than the set confidence threshold, then the candidate point is considered to be the background, otherwise it is considered to be a foreground target. After selecting the candidate point of the foreground target, the center position and width and height of the remaining candidate points are geometrically transformed into the position and width and height of the upper left corner, and a non-maximum suppression operation is performed together with the category score to obtain the remaining candidate points; the last 32 dimensions represent the coefficients mc of the mask map, which are used to make a weighted sum of the second output tensor. One output is a tensor p of size 1*32*160*160, and the mask map of the ray source and detector is obtained by the formula in: mask rd =mc T p; in, Take one of the mask images as an example Use the sigmoid formula to transform the mask rd,1 Mapped to the interval [0,1], as shown in the formula: Then put the mask rd,1 Resize it to 1*640*640, and then apply the mask rd,1 Scale to the aspect ratio of the original image, then resize it to the width and height of the original image, and then add the predicted upper left corner position and width and height to the mask. rd,1 Cut out an area, then do threshold segmentation, and put the mask rd,1 The values less than 0.5 are set to 0, and the rest are set to 1. Then, according to the predicted upper left corner position and width and height, the cropped area is mapped to the original image position. Another mask map is mask. rd,2 Also generate according to the above process; Step S4.2: Only one output mask is generated for the EfficientAD algorithm Mask o Respectively with mask rd,1 and mask rd,2 Make an overlap judgment, and if it overlaps with one of the mask images, it is judged as a collision.
5. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of the CT system collision avoidance method according to any one of claims 1 to 4 are implemented.
6. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the CT system collision avoidance method according to any one of claims 1 to 4 are implemented.
