Endoscope video anomaly detection method based on normalized stream

Through the endoscopic video anomaly detection method based on normalized flow, the spatio-temporal aware encoder and the normalized flow are used to process video features, which solves the problems of insufficient utilization of temporal relationships and high data labeling cost in the existing technology, and achieves high accuracy. Video anomaly detection.

CN118658097AActive Publication Date: 2024-09-17SHANGHAI-CHONGQING ARTIFICIAL INTELLIGENCE RES INST

Patent Information

Application Number
CN202410794910.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-19
Publication Date
2024-09-17
Estimated Expiration
2044-06-19

AI Technical Summary

Technical Problem

Existing medical image anomaly detection methods are mainly based on a single image and cannot effectively utilize the temporal relationships in video data, resulting in reduced accuracy of prediction results, and the model is not robust enough to unseen new categories and edge cases, and high-quality labeling Data acquisition is expensive.

Method used

An endoscopic video anomaly detection method based on normalized flow is adopted, by obtaining the endoscopic video for preprocessing, using an encoder with spatiotemporal awareness to extract the video feature vector, and combining the bottleneck module formed by the reversible regularized flow to process the feature vector. The likelihood loss and reconstruction loss are calculated, and an anomaly score is obtained to determine whether the video is abnormal.

Benefits of technology

This method can effectively make use of the temporal relationship in the video, improve the accuracy of the detection results, and reduce the problem of imbalance in the ratio of positive and negative samples. It only requires negative sample training and is suitable for data sets with a small incidence rate. It has high detection accuracy and is widely used. Wider scope.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118658097A
    Figure CN118658097A
Patent Text Reader

Abstract

The invention discloses an endoscope video anomaly detection method based on a normalized stream, and particularly relates to the technical field of video anomaly detection. Comprising the following steps: preprocessing a video to obtain preprocessed video data, and learning and extracting input information by using an encoder with space-time perception capability to obtain a video feature vector; processing the video feature vector by using a bottleneck module formed by a reversible normalized stream to obtain a normalized feature vector, and calculating a likelihood loss and a likelihood score; inputting the normalized feature vector into a decoder to obtain reconstructed video data, and calculating reconstruction loss and a reconstruction score; performing weighted calculation on the total loss and the abnormal score; judging whether the video data is abnormal or not according to the abnormal score, and obtaining an endoscope video abnormal detection result; according to the method, positive samples are not needed, only large-scale negative samples are used for training, and the method has high detection accuracy under the conditions that the morbidity is small, a data set is difficult to form or data is rare.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of video anomaly detection, and in particular relates to an endoscope video anomaly detection method based on normalized flow. Background Art

[0002] Deep learning methods have shown great potential in many fields such as medical image processing, disease diagnosis, and real-time monitoring. Endoscopes play an important auxiliary role in gastrointestinal disease examinations. The goal of applying deep learning methods to auxiliary medical treatment on endoscopic images is to reduce the workload of doctors and even replace the work of doctors reading endoscopic images. The auxiliary medical tasks based on endoscopic images currently include the following tasks: lesion recognition, lesion target detection, lesion area segmentation, etc.

[0003] The lesion recognition task aims to automatically identify and classify whether there are abnormalities or abnormal types in the endoscopic image, such as polyps, tumors, etc. This task requires binary labels or multi-class labels. The lesion target detection task aims to select the abnormal area in the image and give the lesion label to the selected target. This task requires the bounding box annotation of the abnormal area in the image. The lesion area segmentation task hopes to identify the disease at the pixel level to obtain the current lesion area. This task requires semantic segmentation annotation or instance segmentation annotation of the image.

[0004] Models that implement the above tasks usually require a large amount of lesion data and professionals to label the lesion data, making it expensive to obtain high-quality medical labeled data. In addition, even if trained with high-quality data, the model may still not be robust enough for new categories or edge cases that have not been seen, resulting in an increase in the misdiagnosis rate.

[0005] In addition, the data obtained by the endoscope is often in the form of images or videos with a temporal relationship. However, the current anomaly detection methods in medical imaging are basically based on a single image. If the data is only an independently input image or a single frame captured in a video, the network will not be able to obtain the temporal relationship in the overall data, thereby losing the important information it carries, and thus reducing the accuracy of the prediction results in the task. Summary of the invention

[0006] In view of the shortcomings of the prior art, the present invention proposes an endoscope video anomaly detection method based on normalized flow, which comprises: obtaining an endoscope video to be detected and inputting it into a trained endoscope video anomaly detection model to obtain a model processing result; calculating an anomaly score according to the model processing result and obtaining an endoscope video anomaly detection result according to the anomaly score;

[0007] The training process of the endoscope video anomaly detection model includes:

[0008] S1: Acquire the endoscope video and preprocess it to obtain preprocessed video data;

[0009] S2: Use an encoder with spatiotemporal awareness to process the preprocessed video data to obtain a video feature vector;

[0010] S3: The bottleneck module formed by the reversible normalized flow processes the video feature vector to obtain a normalized feature vector;

[0011] S4: Calculate the likelihood loss and likelihood score of the normalized feature vector according to the video feature vector and the normalized feature vector;

[0012] S5: input the normalized feature vector into the decoder for processing to obtain reconstructed video data;

[0013] S6: Calculate the reconstruction loss and the reconstruction score according to the reconstructed video data and the preprocessed video data;

[0014] S7: Calculate the total model loss according to the likelihood loss and the reconstruction loss; Calculate the anomaly score according to the likelihood score and the reconstruction score; Determine whether the video data is abnormal according to the anomaly score, and finally obtain the endoscope video anomaly detection result;

[0015] S8: Adjust the model parameters according to the total model loss, save the optimal parameters, and obtain the trained endoscope video anomaly detection model.

[0016] Preferably, the process of preprocessing the endoscopic video includes: setting the number of frames, dividing the endoscopic video data into multiple segments of video data with a specified number of frames, and discarding data with less than the specified number of frames; normalizing the video data to obtain normalized data with a value range of [0,1]; and performing Z-Score standardization on the normalized data with a mean and standard deviation of 0.5 to obtain preprocessed video data.

[0017] Preferably, the encoder with spatiotemporal perception capability processes the preprocessed video data as:

[0018] z=Encoder(x)

[0019] Among them, z is the video feature vector extracted by the encoder, x represents the preprocessed data, and Encoder represents the encoder with spatiotemporal awareness.

[0020] Preferably, the bottleneck module formed by the reversible normalized flow processes the video feature vector as follows:

[0021] z′=Bottleneck(z)

[0022] Among them, z′ is the normalized feature vector, z is the video feature vector, and Bottleneck is the bottleneck module formed by the reversible normalized flow.

[0023] Preferably, the formula for calculating the likelihood loss is:

[0024]

[0025] in, represents the likelihood loss, represents the negative log-likelihood of z, represents the negative log-likelihood of z′, |det·| represents the absolute value of the matrix determinant, z represents the video feature vector, z′ represents the normalized stream feature vector, represents the video feature vector space, represents the normalized eigenvector space.

[0026] Preferably, the formula for calculating the likelihood score is:

[0027]

[0028] Among them, S flow represents the likelihood score, represents the normalized eigenvector space, represents the negative log-likelihood of z′.

[0029] Preferably, the formula for calculating the reconstruction score is:

[0030]

[0031] Among them, S recon represents the reconstruction score, SSIM(·) represents the calculated structural similarity, x represents the preprocessed video data, x′ represents the reconstructed video data, μ x and μ x′ Represent the means of preprocessed video data and reconstructed video data, respectively. and are the variances of the preprocessed video data and the reconstructed video data, σ xx′ represents the covariance of the preprocessed video data and the reconstructed video data, and C1 and C2 are the first and second small constants added to avoid the denominator being zero.

[0032] Preferably, the formula for calculating the reconstruction loss is:

[0033]

[0034] in, represents the reconstruction loss, F represents the number of frames, M represents the width and height of each frame data, and C represents the number of channels. MSE(·) represents the mean square error, xc,f,i,j and x′ c,f,i,j They respectively represent the values ​​of the coordinates (i, j) of the preprocessed video data and the reconstructed video data in the f-th frame of the c channel.

[0035] Preferably, the formula for calculating the total loss of the model is:

[0036]

[0037] in, represents the total loss of the model, α represents the first loss weight, β represents the second loss weight, represents the likelihood loss, represents the reconstruction loss.

[0038] Preferably, the formula for calculating the anomaly score is:

[0039] S=γ*S flow +δ*S recon

[0040] Among them, S represents the anomaly score, γ represents the first score weight, δ represents the second score weight, S flow represents the likelihood score, S recon Represents the reconstruction score.

[0041] The beneficial effects of the present invention are as follows: the present invention only needs negative samples for training, and can utilize negative samples that account for a large proportion of all images but cannot be fully utilized by conventional methods, so there is no need to worry about the imbalance of positive and negative samples or multi-sample ratios; even for cases with a small incidence rate that are difficult to form a data set or data anomalies, there will be a higher detection accuracy; an encoder with spatiotemporal perception is used to allow the encoder to learn the temporal relationship between the frames in the video, and the present invention solves the problem of image-based methods without temporal information; the present invention uses a normalized flow method to solve unsupervised anomaly detection, which has a wider range of applications than existing methods. The scoring function simultaneously considers the computable probability density in the feature and the consistency of the visual structure in the image domain, thereby improving the accuracy of the detection results. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] Figure 1 It is a flowchart of the training process of the endoscope video anomaly detection model in the present invention;

[0043] Figure 2 A comparison diagram of the spatiotemporal attention separation structure (Divided Space-TimeAttention) used by TimeSFormer in the present invention and the attention mechanism of the original Transformer;

[0044] Figure 3 It is a schematic diagram of the overall network architecture of a preferred embodiment of the present invention;

[0045] Figure 4 It is a schematic diagram of actual detection results of a preferred embodiment of the present invention. DETAILED DESCRIPTION

[0046] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0047] The present invention proposes a method for detecting abnormalities in endoscope videos based on normalized flow, such as Figure 1 , Figure 2 As shown, the method includes the following contents: obtaining the endoscope video to be detected and inputting it into a trained endoscope video anomaly detection model to obtain an endoscope video anomaly detection result.

[0048] The training process of the endoscope video anomaly detection model includes:

[0049] S1: Acquire endoscope video and preprocess it to obtain preprocessed video data.

[0050] Preprocess the endoscopic video: the user specifies the number of frames according to their own task requirements and computer hardware performance. Preferably, the frame number F is set to 8, and the video data will be divided into multiple 8-frame videos with the specified number of frames. The remaining frames less than 8 frames will be discarded, so that each video segment is processed into a small video block with 8 frames and RGB three channels with a length and width of 224×224; each segment of endoscopic video data is read as an integer value of 0-255, and the video data is normalized, specifically, each value in the video data is divided by 255 to obtain normalized data with a value range of [0,1]; the normalized data is Z-Score standardized with a mean and standard deviation of 0.5, specifically, each value in the normalized data is subtracted from the standard deviation, and the difference is divided by the mean as the preprocessed video data Its value range is [-1,1], where H represents height, W represents width, C represents the number of channels, and F represents the number of frames of each video segment after division. In this example, H, W, C, and F are 224, 224, 3, and 8 respectively.

[0051] S2: Use an encoder with spatiotemporal perception capabilities to process the preprocessed video data to obtain a video feature vector.

[0052] Preferably, the encoder with time-space perception capability is a TimeSFormer model; the TimeSFormer model is essentially a Transformer model, and its main improvements over the original Transformer model are described below:

[0053] 1. For patch processing, TimeSFormer takes into account the information of the time dimension. Transformer divides the data into Patch construction sequences, where the number of patches per frame is Here P represents the size of the patch. After expansion, it is represented as a vector

[0054] 2. For position embedding processing, there are:

[0055]

[0056] in represents the initial data embedding, represents a learnable matrix,

[0057] represents a learnable spatial encoding.

[0058] 3.TimeSFormer as a whole consists of multiple layers of coding blocks. For each coding block, Figure 3 As shown, its self-attention mechanism is:

[0059]

[0060] Among them, (l,a) specifies the ath attention head currently operating in layer l, D h It represents the dimension of each attention head. and represents different weights, and LN represents layer normalization operation.

[0061] and Specify the query vector, key vector, and value vector for the position respectively.

[0062] 4. Self-attention based on video data requires calculation of the temporal dimension, which is expressed as:

[0063]

[0064]

[0065] Among them, (l,a) indicates that the current operation is located in the a-th attention head of the l-th encoding block. is the spatial self-attention weight for the specified data at position p and time t, Softmax(·) represents SoftMax activation, A specific query vector representing a specific location. and are the global key at the specified position and the key vector at the p' (from 1 to F) position, D h is the dimension of each attention head. represents the output representation for position p and time t in the specified position, represents the attention weight between the query point (p, t) and the key point (p′, t′) in the specified position.

[0066] After merging each attention head, we use linear projection on it and feed it into a multi-layer perceptron to get:

[0067]

[0068] in, Indicates that this is the intermediate output of layer l at position (p, t), represents the final output of the lth layer at position (p, t), W o is the matrix integrating the outputs of all attention heads A, which are stacked into a column vector; It is the output inherited from the previous layer l-1. MLP refers to multi-layer perceptron.

[0069] Its self-attention mechanism is replaced by a paradigm with time-space perception. The structure of divided space-time attention is adopted here. Its self-attention mechanism adopts two-step calculation, first calculating the time self-attention, and then calculating the space self-attention, that is:

[0070]

[0071]

[0072] in It is the spatial self-attention weight and temporal self-attention weight of the a-th attention head in the l-th coding block at position p and time t. The parameters of the two weight calculations are not shared. represents the key vector at different time points t′ for a given spatial position p under layer l and attention head a.

[0073] After using the above improvements, TimeSFormer gains the ability to perceive spatiotemporal information in video processing.

[0074] In this example, the TimeSFormer model parameters are set to the parameters of ViT-Base, that is, the patch is set to 16×16, the number of stacking layers is 12, the hidden layer size is 768, the MLP is set to 3072, and the number of attention heads is 12. TimeSFormer processes the preprocessed video data, discards the cls-token feature vector after obtaining the output, and obtains the video feature vector:

[0075] z=TimeSFormer(x)

[0076] Among them, the input is the preprocessed data x, and the output video feature vector is Where nf and f represent the number of rows and columns of the feature vector. In this example, nf and f are 1568 and 768 respectively.

[0077] The video data processed by the encoder with spatiotemporal awareness is expressed as:

[0078] z=Encoder(x)

[0079] Among them, z is the video feature vector extracted by the encoder, x represents the preprocessed data, and Encoder represents the encoder with spatiotemporal awareness.

[0080] S3: The bottleneck module formed by the reversible normalized flow is used to process the video feature vector to obtain a normalized feature vector.

[0081] The bottleneck module formed by the reversible regularized flow is a flow model composed of deep learning modules. The probability density of the extracted feature vector z can be obtained explicitly Its input is the video feature vector z, and its output is the normalized feature vector z′. The bottleneck module formed by the reversible normalized flow in this example consists of 8 convolution blocks in series. The convolution block is a normalized flow architecture composed of a convolution layer and an activation function layer. Each convolution block includes two one-dimensional convolutions. The two convolution kernels are of the same size, and only the number of channels of the data is changed in the data shape. The number of convolution kernels in the first convolution is 4 times the number of channels of the input data, and the number of channels of the second convolution is the number of channels of the input data. Therefore, the input and output shapes of each convolution block are the same. The convolution kernel size in the eight convolution blocks is 3 or 1. After being processed by eight convolution blocks, the final output result has the same shape as the input result, that is, and Where nf' and f' represent the number of rows and columns of the reversible normalized eigenvector, respectively, which are equal to the values ​​of nf and f, and are 1568 and 768 in this example.

[0082] The model of this flow architecture is trained by maximizing the log-likelihood of normal image data. In the prediction stage, the probability of normal data (negative samples) is high, while the probability of abnormal data (positive samples) is low. Positive samples have different features from negative samples. These features are difficult to pass through the bottleneck module and thus difficult to be restored by the decoder. Therefore, the output of the bottleneck formed by the reversible normalized flow and the reconstructed video data can be used to detect abnormalities in the video.

[0083] The bottleneck module formed by the reversible normalized flow processes the video feature vector as follows:

[0084] z′=Bottleneck(z)

[0085] Among them, z′ is the normalized feature vector, z is the video feature vector, and Bottleneck is the bottleneck module formed by the reversible normalized flow.

[0086] S4: Calculate the likelihood loss and the likelihood score according to the video feature vector and the normalized feature vector.

[0087] Calculate the likelihood loss:

[0088]

[0089] Where z represents the video feature vector, z′ represents the normalized stream feature vector, represents the video feature vector space, represents the normalized eigenvector space, represents the likelihood loss value, represents the negative log-likelihood of z, represents the negative log-likelihood of z′, and |det·| represents the absolute value of the matrix determinant.

[0090] Compute the likelihood score:

[0091]

[0092] Among them, S flow represents the likelihood score.

[0093] S5: Input the normalized feature vector into the decoder for processing to obtain reconstructed video data.

[0094] The decoder can use a convolutional neural network or a network that can be used to reconstruct data. In this example, the decoder is set to four three-dimensional convolutions, with a convolution kernel size of 3×3×3 and a number of channels of 64, 32, 16, and 8 respectively. Each convolution layer is followed by a batch normalization layer, an upsampling layer, and an activation layer. Each upsampling layer changes the input data shape to (3,28,28), (3,56,56), (3,112,112), and (3,224,224), respectively. The activation layer uses the GeLU activation function. In order to successfully decode in this example, the data will be dimensionally transformed before entering the decoder. Where h′, w′, c′, and f′ are 16, 16, 3, and 1568 respectively. After the decoder completes the convolution, the reconstructed data is x′∈R H’×W’×F’×C’ At this time, the F' and C' dimensions of the reconstructed data x' are exchanged to make x' conform to the data format of x, and finally the reconstructed video data is obtained In this example, H', W', C', and F' represent the height, width, number of channels, and number of frames of the reconstructed video data, which are 224, 224, 3, and 8, respectively.

[0095] The above representation is that the decoder processes the normalized feature vector and outputs the reconstructed video data, and finally obtains the result with a value range of [-1,1] through the Tanh activation function:

[0096] x'=Tanh(Decoder(z'))

[0097] Among them, x′ represents the reconstructed video data, z′ represents the normalized feature vector, Tanh(·) represents the activation through the Tanh activation function, and Decoder(·) represents the output obtained by inputting the decoder data.

[0098] S6: Calculate the reconstruction loss and the reconstruction score based on the reconstructed video data and the preprocessed video data.

[0099] Calculate the reconstruction loss:

[0100]

[0101] Among them, L recon represents the reconstruction loss, x represents the preprocessed video data, x′ represents the reconstructed video data, MSE(·) represents the calculated mean square error, C represents the number of channels, F represents the number of frames, and M represents the width and height of each frame. c,f,i,j and x′ c,f,i,j They respectively represent the values ​​of the coordinates (i, j) of the preprocessed video data and the reconstructed video data in the f-th frame of the c channel.

[0102] Calculate the reconstruction score:

[0103]

[0104] Among them, S recon represents the reconstruction score, SSIM(x,x') represents the structural similarity between the preprocessed video data and the reconstructed video data, x represents the preprocessed video data, x' represents the reconstructed video data, μ x and μ x’ represents the mean of the preprocessed video data and the reconstructed video data, and is the variance of the preprocessed video data and the reconstructed video data, σ xx’ represents the covariance of the preprocessed video data and the reconstructed video data, the calculation window is 11 by default, C1 and C2 are the first and second small constants added to avoid the denominator being zero, and are 0.0001 and 0.0009 respectively in this example.

[0105] The present invention takes into account the existence of key information before and after the time of video data, adopts a network model with spatiotemporal perception to extract feature vectors containing spatiotemporal features, and uses the difference between positive and negative samples in the output distribution of the normalized flow model as an important criterion for distinguishing data, and obtains reconstruction information by comparing the difference in data between preprocessed data and reconstructed data, as a supplementary criterion for distinguishing positive and negative samples, thereby improving the accuracy of the model output results. The advantage of the present invention is that it does not require positive samples, and can only be trained using large-scale negative samples; it will also have a higher detection accuracy rate when faced with a small incidence rate, difficulty in forming a data set, or rare data.

[0106] S7: Calculate the total model loss based on the likelihood loss and the reconstruction loss; calculate the anomaly score based on the likelihood score and the reconstruction score, and determine whether the video data is abnormal based on the anomaly score to obtain the endoscope video anomaly detection result.

[0107] The reconstruction loss and likelihood loss are weighted summed to obtain the total model loss:

[0108]

[0109] in, Represents the total loss of the model, α represents the user-defined loss weight, which usually requires multiple experiments to determine and is used to set the weights of different losses in the total loss. Preferably, α is set to 0.6.

[0110] Calculate the anomaly score:

[0111] S=γ*S flow +δ*S recon

[0112] Where S represents the total anomaly score, γ represents the first score weight, and δ represents the second score weight. The two weights are specified by the user based on experimental results or experience and are used to control the weights of different scores in the total anomaly score. Preferably, in this example, δ = 0.1 and γ = 0.9; S flow represents the likelihood score, S recon Represents the reconstruction score.

[0113] A suitable threshold is taken for the anomaly score to distinguish between positive and negative samples. The anomaly score value that can obtain the maximum F1 score based on the verification data is used as the threshold for judgment. For video data, if its anomaly score is greater than or equal to the threshold, it will be identified as a negative sample, that is, the video does not have anomalies. On the contrary, if its anomaly score is less than the threshold, it will be identified as a positive sample, that is, the video has anomalies.

[0114] S8: Adjust the model parameters according to the total model loss, save the optimal parameters, and obtain the trained endoscope video anomaly detection model.

[0115] Back propagation is performed according to the total loss of the model to adjust the model parameters. When the total loss is minimized or the preset maximum number of iterations is reached, the model parameters are saved to obtain the optimal endoscope video anomaly detection model.

[0116] The endoscope video to be detected is obtained and input into the optimal endoscope video anomaly detection model to obtain the endoscope video anomaly detection result.

[0117] Evaluation of the present invention:

[0118] The verification results of this example on the PolypDiag dataset are shown in Table 1.

[0119] Table 1 Result indicators

[0120]

[0121] The actual detection effect of a preferred embodiment of the present invention is as follows Figure 4 As shown in Table 1 and Figure 4 It can be seen that the present invention has good performance and high detection accuracy.

[0122] In summary, the present invention completes unsupervised anomaly detection. Compared with existing methods, the scoring function simultaneously considers the computable probability density in the features and the consistency of the visual structure in the image domain, thereby improving the accuracy of the detection results. In medical tasks, it can assist doctors in making real-time diagnoses of medical images such as gastroscopy and colonoscopy online, and doctors can use the anomaly score as a reference. In offline situations, such as capsule endoscopy, doctors can first locate the video time period where the lesion exists by the present invention, thereby avoiding misdiagnosis or missed diagnosis caused by fatigue from long-term film reading from beginning to end.

[0123] The above embodiments further illustrate the purpose, technical solutions and advantages of the present invention in detail. It should be understood that the above embodiments are only preferred implementation modes of the present invention and are not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made to the present invention within the spirit and principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for detecting anomalies in endoscope videos based on normalized flow, characterized in that: include: Obtain the endoscope video to be detected and input it into the trained endoscope video anomaly detection model to obtain the endoscope video anomaly detection result; The training process of the endoscope video anomaly detection model includes: S1: Acquire the endoscope video and preprocess it to obtain preprocessed video data; S2: Use an encoder with spatiotemporal awareness to process the preprocessed video data to obtain a video feature vector; S3: Process the video feature vector using a bottleneck module formed by a reversible normalized flow to obtain a normalized feature vector; S4: Calculate the likelihood loss and likelihood score of the normalized feature vector according to the video feature vector and the normalized feature vector; S5: input the normalized feature vector into the decoder for processing to obtain reconstructed video data; S6: Calculate the reconstruction loss and the reconstruction score according to the reconstructed video data and the preprocessed video data; S7: Calculate the total model loss according to the likelihood loss and the reconstruction loss; Calculate the anomaly score according to the likelihood score and the reconstruction score; Determine whether the video data is abnormal according to the anomaly score, and finally obtain the endoscope video anomaly detection result; S8: Adjust the model parameters according to the total model loss, save the optimal parameters, and obtain the trained endoscope video anomaly detection model.

2. The method for detecting anomalies in endoscope videos based on normalized flow according to claim 1, characterized in that: The process of preprocessing the endoscopic video includes: setting the number of frames, dividing the endoscopic video data into multiple segments of video data with a specified number of frames, and discarding data with less than the specified number of frames; normalizing the video data to obtain normalized data with a value range of [0,1]; and performing Z-Score standardization on the normalized data with a mean and standard deviation of 0.5 to obtain the preprocessed video data.

3. The method for detecting anomalies in endoscope videos based on normalized flow according to claim 1, characterized in that: The video data processed by the encoder with spatiotemporal awareness is expressed as: z=Encoder(x) Among them, z is the video feature vector extracted by the encoder, x represents the preprocessed data, and Encoder represents the encoder with spatiotemporal awareness.

4. The method for detecting anomalies in endoscope videos based on normalized flow according to claim 1, characterized in that: The bottleneck module formed by the reversible normalized flow processes the video feature vector as follows: z′=Bottleneck(z) Among them, z′ is the normalized feature vector, z is the video feature vector, and Bottleneck is the bottleneck module formed by the reversible normalized flow.

5. The method for detecting anomalies in endoscope videos based on normalized flow according to claim 1, characterized in that: The formula for calculating the likelihood loss is: in, represents the likelihood loss, represents the negative log-likelihood of z, represents the negative log-likelihood of z′, |det·| represents the absolute value of the matrix determinant, z represents the video feature vector, z′ represents the normalized stream feature vector, represents the video feature vector space, represents the normalized eigenvector space.

6. The method for detecting anomalies in endoscope videos based on normalized flow according to claim 1, characterized in that: The formula for calculating the likelihood score is: Among them, S flow represents the likelihood score, represents the normalized eigenvector space, represents the negative log-likelihood of z′.

7. The method for detecting anomalies in endoscope videos based on normalized flow according to claim 1, characterized in that: The formula for calculating the reconstruction score is: Among them, S recon represents the reconstruction score, SSIM(·) represents the calculated structural similarity, x represents the preprocessed video data, x′ represents the reconstructed video data, μ x and μ x′ Represent the means of preprocessed video data and reconstructed video data, respectively. and are the variances of the preprocessed video data and the reconstructed video data, σ xx′ represents the covariance of the preprocessed video data and the reconstructed video data, and C1 and C2 are the first and second small constants added to avoid the denominator being zero.

8. The method for detecting anomalies in endoscope videos based on normalized flow according to claim 1, characterized in that: The formula for calculating the reconstruction loss is: in, represents the reconstruction loss, F represents the number of frames, M represents the width and height of each frame data, MSE(·) represents the mean square error, C represents the number of channels, and x c,f,i,j and x′ c,f,i,j They respectively represent the values ​​of the coordinates (i, j) of the preprocessed video data and the reconstructed video data in the f-th frame of the c channel.

9. The method for detecting anomalies in endoscope videos based on normalized flow according to claim 1, characterized in that: The formula for calculating the total loss of the model is: in, represents the total loss of the model, α represents the first loss weight, β represents the second loss weight, represents the likelihood loss, represents the reconstruction loss.

10. The method for detecting anomalies in endoscope videos based on normalized flow according to claim 1, characterized in that: The formula for calculating the anomaly score is: S=γ*S flow +δ*S recon Among them, S represents the anomaly score, γ represents the first score weight, δ represents the second score weight, S flow represents the likelihood score, S recon Represents the reconstruction score.

Citation Information

Patent Citations

  • Abnormity detection method and system for esophageal endoscope image, medium and equipment

    CN116091446A

  • Self-supervised anomaly detection method based on comparative learning

    CN117456272A

Cited By

  • Multi-modal medical image-oriented cross-domain anomaly detection method

    CN121564378A

  • Cross-domain anomaly detection method for multi-modal medical images

    CN121564378B

  • Surgical skill intelligent evaluation method based on endoscope video

    CN121662295A