A flame image classification method based on ensemble learning
Through the combination of integrated learning and HOG features, the problem of insufficient accuracy in flame image classification by a single machine learning classifier is solved, and the accuracy of flame image classification and model robustness is achieved, which is suitable for fire prevention systems.
Patent Information
- Application Number
- CN202110577002.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-05-26
- Publication Date
- 2025-01-10
- Estimated Expiration
- 2041-05-26
AI Technical Summary
In the prior art, a single machine learning classifier is difficult to effectively capture high-latitude correlation features, resulting in insufficient classification accuracy of flame image, and traditional sensors have problems in detecting distance and environmental interference in fire warning.
Using the flame image classification method based on ensemble learning, the equalization vector data set is generated through image preprocessing, and the SVM, logistic regression, decision tree and Bayesian classifier are trained in parallel. The voting coefficient is calculated using the F1 score, and the weighted average is used. and symbolic functions generate the final result, combined with HOG features to enhance classifier performance.
It improves the accuracy of flame image classification, enhances the robustness and accuracy of the model, meets the needs of fire prevention systems, overcomes the disadvantages of a single classifier model and the shortcomings of traditional sensors.
Smart Images

Figure CN113591873B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a flame image classification method based on ensemble learning, belonging to the technical field of machine learning image classification. Background Art
[0002] Flame detection has always played a vital role in the early prevention of fires, especially the uncontrollability of fire after its spread and the huge threat to human life and property safety, making early detection of flames more and more critical. For a long time, traditional fire warning methods have mainly used sensors, such as temperature-sensing, smoke-sensing and photosensitive sensors, etc., which have the following three main disadvantages: First, the physical space and distance detected by the sensor are limited. When the flame of the fire is far away, the sensor cannot sense it; second, due to its detection principle, the sensor is seriously affected by the environment. The principle of the sensor is to set a certain threshold under the premise of physical sensor data collection. When the collected value reaches a certain deviation, a corresponding warning signal is sent to the background. For example, abnormal lighting will cause the report accuracy of the photosensitive sensor to fluctuate greatly. The fire prevention system based on traditional sensors is difficult to meet the increasingly high fire prevention requirements.
[0003] In contrast, the recently developed fire image detection technology based on image processing technology has specifically overcome the main weaknesses of traditional fire detection technology. In terms of acquisition, because the video resolution is increasing year by year, the collector does not need to maintain a close physical distance from the fire source, ensuring that the flame recognition based on image technology can have a higher accuracy rate. The popularity of video surveillance equipment in public places also makes it easier to collect data sets. Since the birth of machine learning algorithms, the discussion of regression, classification, and clustering has never stopped. Fire image recognition technology obtains the static or dynamic characteristics of the flame itself through image preprocessing technology, and combines one or more geometric or quantifiable characteristics based on the color characteristics, shape characteristics, texture characteristics, etc. of the flame, and uses Bayesian classifiers, clustering and other machine learning algorithms for analysis, which can achieve better results than using sensors to detect flames.
[0004] However, machine learning classification algorithms also have certain defects. Compared with the excellent classification performance of machine learning classification algorithms in discrete or one-dimensional tasks, images have two-dimensional features and pixels have strong correlations. Often, a single machine learning classifier can capture the relationship between such high-dimensional correlation features very well. At the same time, an important branch of machine learning, ensemble learning, is often used to divide data sets. Under the premise of the same type of machine learning algorithm principle, multiple similar learners are generated through repeated learning through the prior independence of data, and decision theory is used to enhance the classification ability of machine learning classifiers or feedback to adjust the sample ratio to improve the model. However, due to the advantages and disadvantages of the machine learning algorithm principles and the upper limit of learning, the enhancement effect is not obvious. Summary of the invention
[0005] Invention problem: In view of the above-mentioned deficiencies of the prior art, the purpose of the present invention is to provide a flame image classification method based on ensemble learning that combines optimized flame image feature extraction, multiple traditional machine learning algorithms and voting decision theory, so as to avoid the disadvantages of a single classifier model and achieve better flame image classification accuracy.
[0006] Technical solution: In order to achieve the above-mentioned invention object, the present invention adopts the following steps:
[0007] The flame image classification method based on ensemble learning includes the following steps:
[0008] (1) The flame image is preprocessed by normalization, grayscale, etc., and converted into a 1*n balanced vector data set.
[0009] (2) The flame image converted dataset is divided into a test set and a validation set. Four classifiers based on SVM, logistic regression, decision tree, and Bayesian classification are trained in parallel on the same test set.
[0010] (3) The F1 scores of the four classifiers are calculated based on the validation set and normalized as the voting coefficients for soft decision voting.
[0011] (4) For each input flame data, the individual classification results of the four classifiers are weighted averaged to calculate the probability that the image contains flames. Finally, the result is generated through a symbolic function and repeatedly input into the validation set to calculate the accuracy and loss function.
[0012] In a preferred embodiment, the image preprocessing step in step (1) comprises:
[0013] (1.1) To ensure the consistency of image input dimensions and more efficient learning of machine learning classification, the image is normalized and grayscaled. Grayscale means taking the average of the grayscale values on the RGB channels.
[0014] (1.2) Calculate the image gradient. For the obtained grayscale matrix, calculate the gradient of each pixel in the horizontal and vertical directions to obtain the gradient direction value of the position; the calculation method is as follows:
[0015] dx(i,j)=[I(i+1,j)-I(i-1,j)] / 2
[0016] dy(i,j)=[I(i,j+1)-I(i,j-1)] / 2
[0017] (1.3) The image area is divided into different fine-grained units and encoded at one time. Taking a square fine-grained unit containing 6*6 pixels as an example, 9 histograms are used as storage values of statistical gradient information, and the gradient of the fine-grained unit is divided into 9 directional blocks at 360 degrees.
[0018] (1.4) After normalizing the gradient intensity, different fine-grained units are connected into blocks, and the feature vectors of all fine-grained units are concatenated to describe the block and normalized. In the R-HOG block, three parameters are used to characterize the block features: the number of fine-grained units in each block, the number of pixels in each fine-grained unit, and the number of histogram channels in each fine-grained unit. The HOG features are then combined into the final feature vector for classification.
[0019] In the optimized implementation scheme, the method for obtaining the voting coefficient in step (3) is as follows:
[0020] The data set is split, and the test set is fed into the support vector machine, Bayesian classifier, decision tree and logistic regression classifier in parallel, and the F1 score of the generated classifier performance is calculated with the remaining same validation set. The F1 score of each classifier is used as its voting coefficient.
[0021] F1 is determined by both precision and recall. Precision refers to the non-false positive rate for images containing flames: Recall rate means the rate of non-missing images containing flames: TP represents the number of times a sample with flame is judged as containing, and FN represents the number of times a sample without flame is judged as not containing; FP represents the number of times a sample without flame is judged as containing, and TN represents the number of times a sample with flame is judged as not containing.
[0022] In an optimized embodiment, the step of generating an enhanced classifier in step (4) comprises:
[0023] (4.1) Using the voting coefficient α generated by the classifier iNormalize it,
[0024] (4.2) For the input sample x, for the i-th classifier, the classifier's generating function or the probability of judging that it contains flame is f(x i ), using the soft voting-decision theory, the final judgment result is weighted averaged for the classification of flame images:
[0025]
[0026] (4.3) Through the result of the sign function y = sgn(H(x)), the output y is used as the quantitative basis for judging whether there is flame. +1 means there is flame, and -1 means there is no flame.
[0027] (4.4) Input a multi-sample validation set into the integrated strong classifier and calculate the accuracy and loss function.
[0028] Beneficial effect: Compared with the prior art, the advantages of the present invention are: using the flame image classification algorithm involved in the present invention, the HOG algorithm based on the grayscale matrix is used to preprocess the flame image of the two-dimensional image pixels. The preprocessing algorithm can effectively discard the shadow interference in the grayscale image and retain the effective information of the image features; and the integrated learning soft voting-decision scheme retains the advantages of multiple machine learning classifiers, the fast response and advantageous information gain characteristics of the decision tree, the excellent binary classification effect of the support vector machine, etc., and controls the final influence of multiple machine learning classifiers on the strong classifier through the F1 score, weakens the influence of inferior samples, and enhances the influence of superior samples. Compared with the voting principle relying on the majority, the soft voting-decision ensures the robustness and accuracy of the system. Compared with the prior art, the method of the present invention improves the accuracy of flame image classification, thereby meeting the needs of applications such as fire prevention systems. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 It is a schematic diagram of the overall process in an embodiment of the present invention;
[0030] Figure 2 It is a schematic diagram of the flame image preprocessing and single machine learning classifier training process in an embodiment of the present invention;
[0031] Figure 3 It is a schematic diagram of the flame image grayscale and conversion matrix in the present invention;
[0032] Figure 4 This is a schematic diagram of the classification of the SVM algorithm of the machine learning algorithm in the embodiment of the present invention;
[0033] Figure 5 A schematic diagram of a Logistic function of a machine learning algorithm in an embodiment of the present invention;
[0034] Figure 6 The figure is a schematic diagram of the voting decision-making principle flow in an embodiment of the present invention. DETAILED DESCRIPTION
[0035] The present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0036] like Figure 1 As shown, the present invention discloses a flame image classification method based on ensemble learning, using Python 3 as programming language, Anaconda as development IDE, Win10 as development environment, and using OpenCV, Skicit-learn, and NumPy library functions to accelerate machine learning. The test and verification data sets are 651, including 150 flame images, and the data sets are segmented according to a ratio of 7:3.
[0037] The present invention adopts the following steps:
[0038] The flame image classification method based on ensemble learning includes the following steps:
[0039] (1) The flame image is preprocessed by normalization and grayscale, and the 256*256 grayscale matrix is converted into a 1*65536 balanced vector data set.
[0040] (2) Figure 2 As shown in the figure, the flame image converted data set is divided into a test set and a validation set. Four classifiers based on SVM, logistic regression, decision tree, and Bayesian classification are trained in parallel under the same test set. The general classification effect and function graph of SVM and logistic regression are shown in Figure 4 and Figure 5 middle.
[0041] (3) The F1 scores of the four classifiers are calculated based on the validation set and normalized as the voting coefficients for soft decision voting.
[0042] (4) For each input flame data, the individual classification results of the four classifiers are weighted averaged to calculate the probability that the image contains flames. Finally, the result is generated through a symbolic function and repeatedly input into the validation set to calculate the accuracy and loss function.
[0043] The image preprocessing step in step (1) is as follows: Figure 3 Shown include:
[0044] (1.1) To ensure the consistency of image input dimensions and more efficient learning of machine learning classification, the image is normalized and grayscaled. Grayscale means taking the average of the grayscale values on the RGB channels. Figure 2This is an example of a grayscale image and matrix.
[0045] (1.2) Calculate the image gradient. For the obtained grayscale matrix, calculate the gradient of each pixel in the horizontal and vertical directions to obtain the gradient direction value of the position; the calculation method is as follows:
[0046] dx(i,j)=[I(i+1,j)-I(i-1,j)] / 2
[0047] dy(i,j)=[I(i,j+1)-I(i,j-1)] / 2
[0048] (1.3) The image area is divided into different fine-grained units and encoded at one time. Taking a square fine-grained unit containing 6*6 pixels as an example, 9 histograms are used as storage values of statistical gradient information, and the gradient of the fine-grained unit is divided into 9 directional blocks at 360 degrees.
[0049] (1.4) After normalizing the gradient intensity, different fine-grained units are connected into blocks, and the feature vectors of all fine-grained units are concatenated to describe the block and normalized. In the R-HOG block, three parameters are used to characterize the block features: the number of fine-grained units in each block, the number of pixels in each fine-grained unit, and the number of histogram channels in each fine-grained unit. The HOG features are then combined into the final feature vector for classification.
[0050] In step (3):
[0051] The data set is split, and the test set is fed into the support vector machine, Bayesian classifier, decision tree and logistic regression classifier in parallel, and the F1 score of the generated classifier performance is calculated with the remaining same validation set. The F1 score of each classifier is used as its voting coefficient.
[0052] F1 is determined by both precision and recall. Precision refers to the non-false positive rate for images containing flames: Recall rate means the rate of non-missing images containing flames: TP represents the number of times a sample with flame is judged as containing, and FN represents the number of times a sample without flame is judged as not containing; FP represents the number of times a sample without flame is judged as containing, and TN represents the number of times a sample with flame is judged as not containing.
[0053] Among them, the algorithm for generating enhanced classifier in step (4) is as follows Figure 6 As shown, the steps include:
[0054] (4.1) Using the voting coefficient α generated by the classifier iNormalize it,
[0055] (4.2) For the input sample x, for the i-th classifier, the classifier's generating function or the probability of judging that it contains flame is f(x i ), using the soft voting-decision theory, the final judgment result is weighted averaged for the classification of flame images:
[0056]
[0057] (4.3) Through the result of the sign function y = sgn(H(x)), the output y is used as the quantitative basis for judging whether there is flame. +1 means there is flame, and -1 means there is no flame.
[0058] (4.4) Input a multi-sample validation set into the integrated strong classifier and calculate the accuracy and loss function.
[0059] A single training example is as follows: In the original weak classifier, the decision tree has an accuracy of 0.7022900763358, a precision of 0.18518518518518517, a recall of 0.18518518518518517, and an F1 score of 0.2040816326530613; the SVM has an accuracy of 0.8854961832061, a precision of 0.88888888888888, and a recall of 0.36363636363636365. The F1 score is 0.5161290322580644; the accuracy of logistic regression is 0.8778625954198, the precision is 0.8, the recall is 0.3636363636363636365, and the F1 score is 0.36363636363636365; the accuracy of Bayesian classifier is 0.87022900763, the precision is 0.870229007635878, the recall is 0.7727272727272727, and the F1 score is 0.66666666666666667.
[0060] The newly generated classifier has achieved 0.898625954198473, 0.9, 0.772727272727272727, and 0.829269610888554 in accuracy, precision, recall, and F1 parameters. Compared with all the original basic classifiers, it not only combines the advantages of all classifiers, but also improves the accuracy and precision by 1.46% and 1.25%, and F1, an important parameter for measuring model performance, has increased by 22%. This shows that ensemble learning has a certain ability to improve the classification effect of multiple classifiers.
[0061] The above description is only a preferred embodiment of the present invention, and the protection scope of the present invention is not limited to the above embodiment. Any equivalent modifications or changes made by ordinary technicians in this field based on the contents disclosed by the present invention should be included in the protection scope recorded in the claims.
Claims
1. A flame image classification method based on ensemble learning, characterized in that: The method comprises the following steps: (1) Preprocess the flame image and convert it into a 1*n balanced vector data set, where n represents the vector dimension of the grayscale matrix; (2) The flame image converted dataset was divided into a test set and a validation set, and four classifiers based on SVM, logistic regression, decision tree, and Bayesian classification were trained in parallel on the same test set; (3) Calculate the F1 scores of the four classifiers based on the validation set and use them as the voting coefficients for soft decision voting and normalize them; (4) For each input flame data, the individual classification results of the four classifiers are weighted averaged to calculate the probability that the image contains flames. Finally, the result is generated through the symbolic function, repeatedly input into the validation set, and the accuracy and loss function are calculated; In step (3), F1 is determined by both precision and recall. Precision indicates the non-false positive rate for images containing flames: Recall indicates the non-missing rate for images containing flames: TP represents the number of times a sample with flame is judged as containing, and FN represents the number of times a sample without flame is judged as not containing; FP represents the number of times a sample without flame is judged as containing, and TN represents the number of times a sample with flame is judged as not containing; Step (4) comprises: (4.1) Using the voting coefficient α generated by the classifier i Normalize it, (4.2) For the input sample x, for the i-th classifier, the classifier's generating function or the probability of judging that it contains flame is f(x i ), using the soft voting-decision theory, the final judgment result is weighted averaged for the classification of flame images: (4.3) Through the result of the sign function y = sgn(H(x)), the output y is used as the quantitative basis for judging whether there is flame, +1 means there is flame, and -1 means there is no flame; (4.4) Input a multi-sample validation set into the integrated strong classifier and calculate the accuracy and loss function.
2. The flame image classification method based on ensemble learning according to claim 1 is characterized in that: in step (1), normalization and graying are adopted in the pre-processing of the flame image and features are effectively extracted by the HOG algorithm, and the steps are as follows: (1.1) Normalize the size of the flame image and grayscale it. Grayscale is to average the grayscale values of the three RGB channels to obtain a grayscale matrix; (1.2) Calculate the image gradient; for the obtained grayscale matrix, calculate the gradient of each pixel in the horizontal and vertical directions to obtain the gradient direction value of the corresponding pixel position; the calculation method is as follows: dx(i,j)=[I(i+1,j)-I(i-1,j)] / 2 dy(i,j)=[I(i,j+1)-I(i,j-1)] / 2 x(i,j), y(i,j) represent the corresponding pixel positions, I(i,j) represents the channel value of the pixel point with the horizontal coordinate i and the vertical coordinate j; (1.3) Divide the flame image area into different fine-grained units and encode them at one time; (1.4) After normalizing the gradient direction value, different fine-grained units are connected into blocks, and the feature vectors of all fine-grained units are concatenated to describe the block and normalized; In the R-HOG block, three parameters are used to characterize the block features: the number of fine-grained units in each block, the number of pixels in each fine-grained unit, and the number of histogram channels in each fine-grained unit; And combine the HOG features into the final feature vector for classification.
Citation Information
Patent Citations
Insulator abnormal automatic detection method based on ensemble classifier online learning
CN108765373A
Video flame detection method based on fusion of multiple classifiers
CN108898069A