A fire warning method based on YOLOv7 network and linear support vector machine SVM

By combining the YOLOv7 network and linear support vector machine (SVM), a fire detection method with multi-dimensional feature vectors is constructed, which solves the problems of limited resources and poor adaptability in existing technologies and achieves efficient and accurate fire detection.

CN117253076BActive Publication Date: 2026-01-02HUAIYIN INSTITUTE OF TECHNOLOGY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311150573.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-09-07
Publication Date
2026-01-02
Estimated Expiration
2043-09-07

AI Technical Summary

Technical Problem

Existing fire detection methods are difficult to deploy in resource-limited environments and have poor accuracy under factors such as changes in lighting, obstruction, and noise, failing to effectively solve this problem. In particular, existing methods suffer from false alarms and missed alarms, and there are technical problems with existing fire detection methods.

Method used

By combining the YOLOv7 network and the linear support vector machine (SVM), multidimensional feature vectors are constructed through image processing and feature extraction. The model is then trained using a dataset to perform fire detection, reducing the probability of false alarms and false negatives, and improving adaptability and generalization ability.

Benefits of technology

It improves the accuracy and adaptability of fire detection and reduces the probability of false alarms and missed alarms under limited computing resources, making it suitable for fire detection tasks in different scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117253076B_ABST
    Figure CN117253076B_ABST
Patent Text Reader

Abstract

The application discloses a fire warning method based on a YOLOv7 network and a linear support vector machine SVM, which comprises the following steps: collecting video images about fire; performing target detection on the images by using the YOLOv7 network, and outputting the position of a target bounding box; screening the target bounding box to construct a multi-dimensional feature vector; labeling the images; arranging the labels of all the images and the constructed multi-dimensional feature vectors into a data set, and training and verifying the linear support vector machine SVM to obtain an anomaly detection model; and performing fire detection and warning on the real-time collected video or image by using the anomaly detection model. The application solves the problems of large amount of calculation, difficulty in obtaining samples, false alarm or missed alarm in the prior art.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of fire warning, in particular to a fire warning method based on a YOLOv7 network and a linear support vector machine SVM. BACKGROUND

[0002] For commercial buildings, residential buildings, warehouses and other places where people or goods are concentrated, it is necessary to set up a fire warning system, which can quickly issue an alarm at the initial stage of a fire, improve the efficiency of fire emergency handling, and reduce personnel casualties and property losses caused by fires.

[0003] Existing fire detection methods mainly include some detectors such as smoke detectors, heat detectors, and flame detectors, but smoke detectors have false positives and false negatives in cases where the smoke concentration is low or the detector is improperly positioned; heat detectors need some time to respond to temperature changes and may not be sensitive enough to quickly occurring fires; flame detectors may not be sensitive enough to small fires or fires in smoke.

[0004] In recent years, with the development of artificial intelligence technology, some fire detection methods based on video image analysis technology and deep learning and machine learning have also emerged, such as convolutional neural networks (CNN), recurrent neural networks (RNN), etc. These methods can learn from existing data to build warning models to improve the accuracy and efficiency of fire detection. However, these models usually require a large amount of labeled data for training to learn the characteristics and patterns of fires, and collecting and labeling a large amount of data is time-consuming and labor-intensive, especially for actual fire scene data where resources are scarce. Deep learning and machine learning models require a large number of matrix operations and parameter adjustments during training, which requires powerful computing resources and storage capacity, which can limit the deployment and practical application of the model, especially in resource-limited environments. In addition, changes in data distribution in specific environments can also lead to a decrease in the generalization ability of the model, and there may be robustness problems when facing complex real-world scenarios. Factors such as changes in lighting, occlusion, and noise can affect the accuracy of the model, leading to false positives or false negatives. SUMMARY

[0005] The purpose of the present application is to provide a fire warning method based on a YOLOv7 network and a linear support vector machine SVM that is accurate, real-time, and suitable for fire detection tasks in different scenarios.

[0006] Technical solution: To achieve the above purpose, the fire warning method based on a YOLOv7 network and a linear support vector machine SVM according to the present application comprises the following steps:

[0007] Step 1: Collect videos about fire and convert the videos into continuous frame images;

[0008] Step 2: Perform target detection on the images using a YOLOv7 network, output the target bounding box position, and the target bounding box includes flame images or smoke images or misjudgment images;

[0009] Step 3: Screen the target bounding box to exclude target bounding boxes containing misjudgment images, and obtain candidate bounding boxes; extract features of flame or smoke images from the candidate bounding boxes to construct a multi-dimensional feature vector, including color, shape and motion features;

[0010] Step 4: Screen the images of step 1, if the image contains the candidate bounding box of step 3, the image label is set to 1, indicating an abnormal situation, otherwise the image label is set to 0, indicating a normal situation, the abnormal situation is that the image includes flame or smoke;

[0011] Step 5: Organize the labels of all images and the constructed multi-dimensional feature vectors into a data set D, if the image is normal, the multi-dimensional feature vector of the image is set to zero; use the data set D to train and verify the linear support vector machine SVM to obtain an anomaly detection model for determining abnormal situations in videos or images;

[0012] Step 6: Use the anomaly detection model to detect and warn of fire in real-time collected videos or images.

[0013] The target detection method of step 2 is: segmenting the image into multiple grid images, using the YOLOv7 network to forward propagate each grid image through a series of convolutional layers and pooling layers to form feature grid images of different levels, while the YOLOv7 network performs target detection tasks on feature grid images of different levels to output the position of the target bounding box; Wherein the shallow level feature grid image is used to detect small targets, and the deeper level feature grid image is used to detect larger targets; the misjudgment image is an image containing other images except flame or smoke images; the target bounding box position includes: center point coordinates (x, y), bounding box width w, height h and class probability, the class includes flame, smoke.

[0014] The screening method of step 3 is: setting a confidence score Score for each target bounding box, if the confidence score Score of the target bounding box is greater than the set screening threshold Score max , it is considered that the target bounding box contains flame images or smoke images.

[0015] The color feature extraction method of step 4 is: extracting the pixel channel value of each color in the image in the candidate bounding box, and then calculating the mean and standard deviation of each color channel, the calculation process is:

[0016]

[0017] where Mean_RGB represents the mean value of each color channel, RGB i represents the color channel value of the i-th pixel, N RGB represents the number of pixels, and StdDev_RGB represents the standard deviation of each color channel.

[0018] The shape feature extraction method is: obtaining the width w and height h of the candidate bounding box, calculating the aspect ratio AR of the candidate bounding box, and calculating the width ratio WIR of a single candidate bounding box to the entire image, and the calculation process is:

[0019]

[0020] where w image represents the width of the entire image.

[0021] The motion feature extraction method is: comparing the center point position changes of the candidate bounding box between consecutive image frames to determine the motion direction and speed of the flame or smoke, and the calculation process is:

[0022]

[0023] where dx represents the horizontal position change, dy represents the vertical position change, (x1, y1) and (x2, y2) are the center points of the candidate bounding box of the consecutive two image frames, Angle represents the motion direction, and Speed represents the motion speed.

[0024] The multi-dimensional feature vector expression is:

[0025] Feature=[Mean_RGB,StdDev_RGB,AR,WIR,Speed]。

[0026] The expression form of the data set D in step 5 is: D={(s1,Tab1),(s2,Tab2),...(s n ,Tab n )}, n is the number of images; Tab represents the label, taking the value 1 or 0, where 1 represents an abnormal situation and 0 represents a normal situation; s is the feature vector, representing the multi-dimensional feature vector contained in the n-th image,

[0027] m represents the number of multi-dimensional feature vectors in an image.

[0028] The data set D described in step 5 is divided into a training sample D1 and a test sample D2, and the linear support vector machine SVM is trained using the training sample D1, and the trained linear support vector machine SVM is tested using the test sample D2;

[0029] Wherein the sample quantity of the training sample is A, and A < n, D1 = {(s a , Tab a ), a = 1, 2, … A}; n is the image quantity, that is, the total number of samples in the data set D; Tab a represents a label, taking the value 1 or 0, wherein 1 represents an abnormal situation, and 0 represents a normal situation; s a is a feature vector, representing a multi-dimensional feature vector contained in the a-th image.

[0030] The training method of the linear support vector machine SVM using the training sample D1 is: inputting the multi-dimensional feature vector sample contained in the training sample D1 into the linear support vector machine SVM, finding a best separating hyperplane to separate the normal and abnormal images by minimizing an optimization problem with a constraint condition, in order to reduce the complexity of the problem, converting the optimization problem with the constraint condition into an optimization problem without the constraint condition, and calculating the classification decision function f(s) by introducing the Lagrange multiplier, to determine the accuracy of the multi-dimensional feature vector according to the value of the classification decision function; specifically including the following steps:

[0031] Step 501: The linear support vector machine SVM separates the normal and abnormal images using a best separating hyperplane, wherein the calculation method of the hyperplane is:

[0032] ω T S a +b = 0;

[0033] Wherein, ω represents the normal vector of the separating hyperplane direction, T represents the matrix rank conversion, and b represents the bias term of the linear support vector machine SVM, that is, the distance between the hyperplane and the origin;

[0034] Step 502: Find the best separating hyperplane described in step 501 by minimizing an optimization problem with a constraint condition, so that the distance of all samples to the separating hyperplane is maximized, wherein the sample is (s a , Tab a ), and the optimization problem with the constraint condition is expressed as:

[0035]

[0036] Wherein, the constraint condition is Tab a (ω T s a +b) ≥ 1, and is applicable to all samples (sa ,Tab a ), the goal of the constrained optimization problem is to find a normal vector ω and a bias term b such that all the samples closest to the separating hyperplane satisfy the constraint while obtaining the smallest norm to get a flatter separating hyperplane;

[0037] Step 503: Introduce a Lagrange multiplier for each sample's constraint, and convert the constrained optimization problem into an unconstrained optimization problem by using the Lagrange function to reduce the complexity of the problem, and the calculation process is:

[0038]

[0039] Wherein, L(ω, b, β) represents the Lagrange function, β a represents the Lagrange multiplier;

[0040] Step 504: Use the duality of the Lagrange function to calculate the Lagrange multiplier β a , and the calculation formula is:

[0041]

[0042] Wherein, z, d represent the positions of different samples to distinguish the dual numbers of the Lagrange function;

[0043] Step 505: According to the Lagrange multiplier β i , the classification decision function f(s) is calculated, and the accuracy of the multi-dimensional feature vector is judged by the classification decision function value, and the calculation process is:

[0044]

[0045] Wherein, c1, c2, c3 are used to adjust the weight of color, shape and motion features in the model, Score color (s a ), Score shape (s a ), Score motion (s a ) respectively represent the color, shape and motion feature scores of the sample; Mean_RGB, StdDev_RGB represent the mean and standard deviation of the color channel; AR, WIR represent the aspect ratio of the candidate bounding box, the width ratio of the single candidate bounding box to the whole image; Speed represents the motion speed;

[0046] The output value of f(s) represents the accuracy value of the input feature vector s a , and the feature vector s aThe decision function output value represents the confidence degree of the multi-dimensional feature vector being classified as an anomaly, and if the output value of f(s) is greater than a set threshold value, the sample is determined as an anomaly.

[0047] The method for testing the trained linear support vector machine SVM with the test set samples is: according to the actual value of the test set samples and the output value of the sample inputting the trained linear support vector machine SVM for prediction, calculating the performance evaluation parameters of the trained linear support vector machine SVM, including: precision, recall, F1 score;

[0048] Wherein:

[0049] TP represents the number of samples correctly predicted as an anomaly, FP represents the number of normal samples incorrectly predicted as an anomaly, and FN represents the number of anomaly samples incorrectly predicted as normal; the higher the F1 score, the better balance between precision and recall the model achieves, and at this time the trained linear support vector machine SVM as an anomaly detection model.

[0050] The method for the anomaly detection model to detect fire in real-time collected video or image is: the anomaly detection model outputs a classification decision function value according to the input feature vector, the feature vector contains a multi-dimensional feature vector constructed from the video or image, and the decision function value represents the confidence degree of the multi-dimensional feature vector being classified as an anomaly; if the output classification decision function value is greater than a set threshold value, the image or video is determined as an anomaly.

[0051] The pre-warning method is: the anomaly detection model delivers the detection result to the pre-warning system, and the pre-warning system is a system that gives corresponding instructions according to the input detection result information, including: displaying normal, displaying anomaly pre-warning warning;

[0052] When displaying the anomaly pre-warning warning, the pre-warning system calculates the fire influence degree and the fire spread influence degree as pre-warning auxiliary information according to the environmental temperature and the wind direction, and the calculation process is:

[0053]

[0054] Wherein, FireScore represents the fire influence degree score, Area target represents the target area, Area all represents the total area of the environment, wherein the target area is calculated according to the length and width of the candidate boundary box; Temp target represents the current environmental temperature, Temp ref represents the reference temperature, which is used to calibrate the influence of the environmental temperature; SpreadFire represents the fire spread influence degree, Windtarget represents the current wind direction, Wind ref represents the reference wind direction.

[0055] Beneficial effects: The present application has the following advantages: 1. The method combines YOLOv7 network with linear support vector machine SVM, can more comprehensively utilize the feature information of video images, construct multi-dimensional feature vectors, still has high practicability under the condition of limited calculation resources and collected data, improves the efficiency of fire warning; 2. The method can process images of different scales, rotations, scaling and other deformations, reduces the probability of false positives and false negatives, improves the accuracy of fire warning, and can also better adapt to different scenes, improves the adaptability and generalization ability of the model. BRIEF DESCRIPTION OF DRAWINGS

[0056] Figure 1 is a flowchart of the method. DETAILED DESCRIPTION

[0057] The technical solutions of the present application will be described in detail below in combination with embodiments and drawings.

[0058] As Figure 1 shown, a fire warning method based on YOLOv7 network and linear support vector machine SVM includes the following steps:

[0059] Step 1: Collect videos about fire, and convert the videos into continuous frame images;

[0060] Step 2: Use YOLOv7 network to detect targets in the images, output target bounding box positions, and the target bounding box includes flame images or smoke images or misjudgment images;

[0061] Step 3: Screen the target bounding boxes to exclude target bounding boxes containing misjudgment images, and obtain candidate bounding boxes; extract features of flame or smoke images from the candidate bounding boxes to construct multi-dimensional feature vectors, the features including color, shape and motion features;

[0062] Step 4: Screen the images of step 1, if the images contain the candidate bounding boxes of step 3, the image label is set to 1, indicating an abnormal situation, otherwise the image label is set to 0, indicating a normal situation, the abnormal situation is that the images include flame or smoke;

[0063] Step 5: Organize the labels of all images and the constructed multi-dimensional feature vectors into a data set D, if the image is normal, the multi-dimensional feature vector of the image is set to zero; use the data set D to train and verify the linear support vector machine SVM to obtain an anomaly detection model for determining abnormal situations in videos or images;

[0064] Step 6: Fire detection and early warning of real-time collected video or image by using the anomaly detection model.

[0065] The target detection method of step 2 is: dividing the image into multiple groups of grid images, using the YOLOv7 network to forward propagate each group of grid images through a series of convolution layers and pooling layers to form feature grid images of different levels, and at the same time, the YOLOv7 network performs target detection tasks on feature grid images of different levels to output the position of the target bounding box; wherein the shallow level feature grid image is used to detect small targets, and the deeper level feature grid image is used to detect larger targets; the misjudgment image is an image containing other images except flame or smoke images; the target bounding box position includes: center point coordinates (x, y), bounding box width w, height h and class probability, and the class includes flame, smoke.

[0066] The screening method of step 3 is: setting a confidence score Score for each target bounding box, if the confidence score Score of the target bounding box is greater than the set screening threshold Score max , it is considered that the target bounding box contains flame image or smoke image.

[0067] The color feature extraction method of step 4 is: extracting the pixel channel value of each color in the image in the candidate bounding box, and then calculating the mean and standard deviation of each color channel, the calculation process is:

[0068]

[0069] Wherein, Mean_RGB represents the mean of each color channel, RGB i represents the color channel value of the i-th pixel, N RGB represents the number of pixels, and StdDev_RGB represents the standard deviation of each color channel.

[0070] The shape feature extraction method is: obtaining the width w and height h of the candidate bounding box, calculating the aspect ratio AR of the candidate bounding box, and calculating the width ratio WIR of the single candidate bounding box and the whole image, the calculation process is:

[0071]

[0072] Wherein, w image represents the width of the whole image.

[0073] In the extraction process of shape features, multiple key shape attributes are comprehensively analyzed for each candidate box to deeply understand the geometric features of the flame and smoke targets; by calculating the width and height of each candidate box, the size information of the target in the image is obtained. The width and height reveal the spatial distribution of the target in the image plane; on the basis of calculating the width and height, the aspect ratio is further calculated, and the ratio reflects the horizontal and vertical proportion of the target, which helps to understand the stretching or compression degree of the target and the shape of the target; a larger aspect ratio may imply significant stretching of the target in a certain dimension. In order to compare in different size images, the ratio of width to image width is calculated. By standardizing the width value to a relative value, the size difference can be eliminated, making the shape features between different images comparable and helping to compare the target features in different size images.

[0074] The motion feature extraction method is to compare the position changes of the center points of the candidate bounding boxes between consecutive image frames to determine the motion direction and speed of the flame or smoke, and the calculation process is as follows:

[0075]

[0076] where dx represents the horizontal position change, dy represents the vertical position change, (x1, y1) and (x2, y2) are the center points of the candidate bounding boxes of the two consecutive image frames; Angle represents the motion direction, and Speed represents the motion speed.

[0077] The multi-dimensional feature vector expression is as follows:

[0078] Feature=[Mean_RGB,StdDev_RGB,AR,WIR,Speed].

[0079] The expression form of the data set D in step 5 is as follows: D={(s1,Tab1),(s2,Tab2),...(s n ,Tab n )}, n is the number of images; Tab represents the label, which takes the value 1 or 0, where 1 represents an abnormal situation and 0 represents a normal situation; s is the feature vector, which represents the multi-dimensional feature vector contained in the nth image,

[0080] m represents the number of multi-dimensional feature vectors in an image.

[0081] The data set D in step 5 is divided into training samples D1 and test samples D2, and the linear support vector machine SVM is trained using the training samples D1, and the trained linear support vector machine SVM is tested using the test samples D2;

[0082] Wherein the sample quantity of the training sample is A, and A < n, D1 = {(s a , Tab a ), a = 1, 2, … A};n is the image quantity, that is, the total quantity of samples in the data set D;Tab a represents the label, taking the value 1 or 0, wherein 1 represents an abnormal situation, and 0 represents a normal situation;s a is a feature vector, representing a multi-dimensional feature vector contained in the a-th image.

[0083] The training method of the linear support vector machine SVM by using the training sample D1 is as follows: inputting the multi-dimensional feature vector sample contained in the training sample D1 into the linear support vector machine SVM, finding a best separating hyperplane to separate the normal and abnormal images by minimizing an optimization problem with a constraint condition, in order to reduce the complexity of the problem, converting the optimization problem with the constraint condition into an optimization problem without the constraint condition, and calculating the classification decision function f(s) by introducing a Lagrange multiplier, so as to judge the accuracy of the multi-dimensional feature vector according to the value of the classification decision function;specifically comprising the following steps:

[0084] Step 501: the linear support vector machine SVM separates the normal and abnormal images by using a best separating hyperplane, wherein the calculation method of the hyperplane is as follows:

[0085] ω T S a +b = 0;

[0086] Wherein, ω represents the normal vector of the separating hyperplane direction, T represents the matrix rank, and b represents the bias term of the linear support vector machine SVM, that is, the distance between the hyperplane and the origin;

[0087] Step 502: find the best separating hyperplane in step 501 by minimizing an optimization problem with a constraint condition, so that the distance of all samples to the separating hyperplane is maximized, wherein the sample is (s a , Tab a ), and the optimization problem with the constraint condition is expressed as:

[0088]

[0089] Wherein, the constraint condition is Tab a (ω T s a +b) ≥ 1, and is applicable to all samples (s a , Tab a ), and the optimization problem with the constraint condition aims to find a normal vector ω and a bias term b, so that all samples closest to the separating hyperplane satisfy the constraint condition, and the minimum norm is obtained, so as to obtain a more flat separating hyperplane.

[0090] Step 503: Introduce a Lagrange multiplier for each sample constraint, and convert the optimization problem with constraints into an unconstrained optimization problem through the Lagrange function to reduce the complexity of the problem, the calculation process is:

[0091]

[0092] Wherein, L(ω, b, β) represents the Lagrange function, β a represents the Lagrange multiplier;

[0093] Step 504: Calculate the Lagrange multiplier β a using the duality of the Lagrange function, the calculation formula is:

[0094]

[0095] Wherein, z, d represent the positions of different samples to distinguish the dual number of the Lagrange function;

[0096] Step 505: Calculate the classification decision function f(s) according to the Lagrange multiplier β i , and judge the accuracy of the multi-dimensional feature vector through the value of the classification decision function, the calculation process is:

[0097]

[0098] Wherein, c1, c2, c3 are used to adjust the weight of color, shape and motion features in the model, Score color (s a ), Score shape (s a ), Score motion (s a ) respectively represent the color, shape and motion feature scores of the sample; Mean_RGB, StdDev_RGB represent the mean and standard deviation of the color channel; AR, WIR represent the aspect ratio of the candidate bounding box, the width ratio of the single candidate bounding box to the whole image; Speed represents the motion speed;

[0099] The output value of f(s) represents the accuracy value of the input feature vector s a , and the feature vector s a contains a multi-dimensional feature vector, that is, the output value of the decision function represents the confidence degree of the multi-dimensional feature vector being classified as abnormal. If the output value of f(s) is greater than the set threshold value, the sample is determined to be abnormal.

[0100] The method for testing the trained linear support vector machine SVM with the test set samples is: according to the actual value of the test set samples and the output value of the trained linear support vector machine SVM predicted by inputting the sample, the performance evaluation parameters of the trained linear support vector machine SVM are calculated, including: precision, recall, F1 score;

[0101] Wherein:

[0102] TP represents the number of samples correctly predicted as abnormal, FP represents the number of normal samples incorrectly predicted as abnormal, and FN represents the number of abnormal samples incorrectly predicted as normal; the higher the F1 score, the better balance between precision and recall the model achieves, at which time the trained linear support vector machine SVM is used as an abnormality detection model.

[0103] The method for the abnormality detection model to detect fire in real-time collected video or image is: the abnormality detection model outputs a classification decision function value according to inputted feature vectors, the feature vectors including multi-dimensional feature vectors constructed from the video or image, the decision function value representing the confidence degree of the multi-dimensional feature vectors being classified as abnormal, and if the outputted classification decision function value is greater than a set threshold value, the image or video is determined as abnormal.

[0104] The pre-warning method is: the abnormality detection model delivers the detection result to a pre-warning system, and the pre-warning system is a system for making corresponding instructions according to inputted detection result information, including: displaying normal, displaying abnormal pre-warning warning.

[0105] When displaying the abnormal pre-warning warning, the pre-warning system calculates the fire influence degree and the fire spread influence degree as pre-warning auxiliary information according to the environmental temperature and the wind direction, and the calculation process is:

[0106]

[0107] Wherein, FireScore represents the fire influence degree score, Area target represents the area of the target, Area all represents the total area of the environment, wherein the target area is obtained according to the length and width of the candidate boundary box; Temp target represents the current environmental temperature, Temp ref represents the reference temperature, which is used to calibrate the influence of the environmental temperature; SpreadFire represents the fire spread influence degree, Wind target represents the current wind direction, Wind ref represents the reference wind direction.

Claims

1. A fire warning method based on a YOLOv7 network and a linear support vector machine SVM, characterized in that, The method comprises the following steps: Step 1: Collecting a video about a fire and converting the video into continuous frame images; Step 2: Using a YOLOv7 network to perform target detection on the images, outputting target bounding box positions, and the target bounding box containing flame images or smoke images or misjudgment images; Step 3: Screening the target bounding box to exclude the target bounding box containing misjudgment images, obtaining a candidate bounding box; extracting features of the flame or smoke images from the candidate bounding box to construct a multi-dimensional feature vector, the features including color, shape and motion features; Step 4: Screening the images of step 1, if the images contain the candidate bounding box of step 3, the image label is set to 1, indicating an abnormal situation, otherwise the image label is set to 0, indicating a normal situation, the abnormal situation being that the image contains flame or smoke; Step 5: Arranging the labels of all images and the constructed multi-dimensional feature vectors into a data set D, if the image is normal, the multi-dimensional feature vector of the image is set to zero; Training and verifying a linear support vector machine SVM using the data set D to obtain an anomaly detection model for determining abnormal situations in videos or images; Step 6: Using the anomaly detection model to detect and warn of a fire in real-time collected videos or images; The linear support vector machine SVM training method using the training samples is: inputting the multi-dimensional feature vector samples contained in the training samples into the linear support vector machine SVM, minimizing an optimization problem with a constraint condition to find a best separating hyperplane to separate the normal and abnormal images, converting the optimization problem with the constraint condition into an optimization problem without the constraint condition, and calculating a classification decision function through an introduced Lagrange multiplier judging the accuracy of the multi-dimensional feature vector according to the classification decision function value; Specifically comprising the following steps: Step 501: A linear support vector machine SVM uses an optimal separating hyperplane to separate normal and abnormal images, wherein the hyperplane is calculated as follows: ; wherein, denotes a normal vector of the separating hyperplane direction, T denotes a matrix transpose, denotes a bias term of the linear support vector machine SVM, i.e. the distance of the hyperplane to the origin; Step 502: Find the optimal separating hyperplane described in step 501 by minimizing an optimization problem with constraints such that the distance of all samples to the separating hyperplane is maximized, where the samples are (s a , Tab a ), the optimization problem with constraints is formulated as: ; where the constraint is , and is applied to all samples (s a , Tab a ), the goal of the optimization problem with constraints is to find a normal vector and a bias term such that all samples closest to the separating hyperplane satisfy the constraint while obtaining a minimized norm for a flatter separating hyperplane; Step 503: A Lagrange multiplier is introduced for the constraint condition of each sample, and a Lagrange function is used to convert the optimization problem with a constraint condition into an optimization problem without a constraint condition, the calculation process being as follows: ; wherein, denotes the Lagrangian function, denotes the Lagrange multiplier; Step 504: Calculate the Lagrange multiplier by using the duality of the Lagrange function The calculation formula is: , Wherein z and d represent the positions of different samples to distinguish the dual numbers of the Lagrange function; Step 505: According to the Lagrange multiplier , the classification decision function is calculated, and the accuracy of the multi-dimensional feature vector is determined by the classification decision function value, and the calculation process is as follows: , wherein, , , for adjusting the weights of color, shape and motion features in the model, respectively represent the color, shape and motion feature scores of the sample; , represent the mean and standard deviation of the color channel; AR, WIR represent the aspect ratio of the candidate bounding box, the width ratio of the single candidate bounding box to the whole image; represent the motion speed; the output value of the decision function represents the input feature vector s a the accurate value of the decision function, the feature vector s a contains a multi-dimensional feature vector, i.e. the output value of the decision function represents the confidence degree of the multi-dimensional feature vector being classified as abnormal, if the output value of the decision function is greater than a set threshold value, the sample is determined as abnormal.

2. The fire warning method based on YOLOv7 network and linear support vector machine SVM according to claim 1, characterized in that, The target detection method described in step 2 is: dividing the image into multiple groups of grid images, using the YOLOv7 network to forward propagate each group of grid images through a series of convolution layers and pooling layers to form feature grid images at different levels, and at the same time, the YOLOv7 network performs a target detection task on the feature grid images at different levels to output the position of the target bounding box; wherein the shallow level feature grid image is used to detect smaller targets, and the deeper level feature grid image is used to detect larger targets; the misjudged image is an image containing other images except flame or smoke images; the target bounding box position includes: center point coordinates (x, y), bounding box width , height , and class probability, and the class includes flame, smoke.

3. The fire warning method based on YOLOv7 network and linear support vector machine SVM according to claim 1, characterized in that, The screening method described in step 3 is: setting a confidence score for each target bounding box If the confidence score of the target bounding box is greater than the set screening threshold , it is considered that the target bounding box includes a flame image or a smoke image.

4. The fire warning method based on YOLOv7 network and linear support vector machine SVM according to claim 1, characterized in that, The color feature extraction method of step 4 is to extract the pixel channel values of each color in the image within the candidate bounding box, and then calculate the mean and standard deviation of each color channel, the calculation process being as follows: ; wherein, denotes the mean value of each color channel, denotes the color channel value of the i-th pixel, denotes the number of pixels, denotes the standard deviation of each color channel; The shape feature extraction method is: acquiring the width of the candidate boundary box , height , calculating the aspect ratio AR of the candidate boundary box, and the width ratio WIR of a single candidate boundary box and the entire image, and the calculation process is: ; wherein represents the entire image width; The motion feature extraction method is to compare the changes in the center point positions of the candidate bounding box between consecutive image frames to determine the motion direction and speed of the flame or smoke, the calculation process being as follows: , ; wherein, represents a horizontal position change, represents a vertical position change, (x1, y1) and (x2, y2) are respectively the center points of the candidate bounding boxes of two continuous image frames; represents a motion direction, represents a motion speed; The expression of the multi-dimensional feature vector is as follows: 。 5. The fire warning method based on YOLOv7 network and linear support vector machine SVM according to claim 1, characterized in that, The expression form of the data set D described in step 5 is: , n is the number of images; Tab represents a label, taking a value of 1 or 0, wherein 1 represents an abnormal situation and 0 represents a normal situation; s is a feature vector, representing a multi-dimensional feature vector contained in the nth image, , and m represents the number of multi-dimensional feature vectors in an image.

6. The fire warning method based on YOLOv7 network and linear support vector machine SVM according to claim 1, characterized in that, The data set D of step 5 is divided into training samples D1 and test samples D2, and the linear support vector machine SVM is trained using the training samples D1, and the trained linear support vector machine SVM is tested using the test samples D2; wherein the sample quantity of the training sample is A, and A < n, D1= {(s a , Tab a ), a = 1, 2, … A};n is the image quantity, that is, the total sample quantity in the data set D;Tab a represents the label, taking the value 1 or 0, wherein 1 represents an abnormal situation, and 0 represents a normal situation;s a is a feature vector, representing a multi-dimensional feature vector contained in the a-th image.

7. The fire warning method based on YOLOv7 network and linear support vector machine SVM according to claim 6, characterized in that, The method for testing the trained linear support vector machine SVM with the test set samples is: according to the actual value of the test set samples and the output value of the sample input trained linear support vector machine SVM, the performance evaluation parameters of the trained linear support vector machine SVM are calculated, including: precision , recall , F1 score; wherein: , , ; the number of samples correctly predicted as abnormal, the number of normal samples incorrectly predicted as abnormal; the number of abnormal samples incorrectly predicted as normal; the higher the F1 score, the better balance the model achieves between precision and recall, at which the trained linear support vector machine SVM serves as an anomaly detection model.

8. The fire warning method based on YOLOv7 network and linear support vector machine SVM according to claim 1, characterized in that, The method for the anomaly detection model to detect a fire in real-time collected videos or images is that the anomaly detection model outputs a classification decision function value according to an input feature vector, the feature vector containing a multi-dimensional feature vector constructed from the video or image, the decision function value representing the confidence degree of the multi-dimensional feature vector being classified as abnormal, if the output classification decision function value is greater than a set threshold, the image or video is determined to be abnormal.

9. The fire warning method based on YOLOv7 network and linear support vector machine SVM according to claim 1, characterized in that, The warning method is that the anomaly detection model delivers the detection result to a warning system, the warning system being a system that gives corresponding instructions according to the input detection result information, including displaying normal and displaying abnormal warning warnings. When the abnormal early warning is displayed, the early warning system calculates the fire influence degree and the fire spread influence degree as the early warning auxiliary information according to the environmental temperature and the wind direction, and the calculation process is as follows: ; wherein, represents a fire influence score, represents an area of the target, represents a total area of the environment region, wherein the target area is obtained according to a length and a width of the candidate bounding box; represents a current environment temperature, represents a reference temperature, for calibrating the influence of the environment temperature; represents a fire spread influence, represents a current wind direction, represents a reference wind direction.

Citation Information

Patent Citations

  • Method for drawing fire risk level distribution diagram

    CN112308292A

  • Video image processing and identifying system

    CN115147775A