Air quality grade detection method based on image recognition
By using deep transfer learning and channel attention mechanisms in air quality rating detection, the problem of lack of large data sets is solved, and the accuracy of air quality rating detection is improved.
Patent Information
- Application Number
- CN202311058212.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-22
- Publication Date
- 2025-02-25
AI Technical Summary
In the field of air quality level detection, the lack of large labeled data sets makes it difficult for deep neural networks to train and cannot effectively improve the accuracy of air quality level detection.
Using a deep transfer learning method, the ResNet18 network pre-trained on the Cifar-10 dataset is used as the backbone network, and a channel attention mechanism module is added to detect air quality levels.
Through transfer learning and channel attention mechanism, the air quality level information of the scene image is effectively detected, which improves the accuracy of air quality level detection and solves the problem of insufficient data sets.
Smart Images

Figure CN119516295A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the field of air quality level detection, in particular to an air quality level detection method based on image recognition. Background Art
[0002] Image recognition is a computer vision technology that can help computers automatically identify and classify objects, scenes or other features in images. Traditional image recognition methods mainly include two steps: feature extraction and classification. Feature extraction refers to extracting representative features from an image for subsequent classification tasks. Classification refers to matching the extracted features with predefined categories to achieve image classification. Traditional image recognition methods include image recognition methods based on feature descriptors, methods based on features such as SIFT, SURF, HOG, and methods based on machine learning (SVM, random forest, etc.).
[0003] With the development of deep learning, image recognition methods based on deep neural networks have become mainstream, such as image classification methods based on convolutional neural networks (AlexNet, VGGNet, ResNet), image recognition methods based on target detection (YOLO, SSD, Faster R-CNN, etc.), and image recognition methods based on image segmentation (FCN, U-Net, etc.). These methods have excellent image recognition accuracy, but they need to rely on large data sets and high-performance computing equipment. In the field of air quality level detection, due to the lack of large labeled data sets, it is difficult to give full play to the advantages of deep neural networks and it is difficult to improve the accuracy. Therefore, this paper proposes an air quality level detection method based on deep transfer learning. Summary of the invention
[0004] In order to improve the accuracy of air quality level detection and give full play to the role of image recognition in the field of air quality level detection, this paper proposes an air quality level detection method based on deep transfer learning. The ResNet18 network pre-trained on the Cifar-10 dataset is used as the backbone network, and then three 3*3 convolution kernels with 128 channels are used to replace the 7*7 convolution layer of ResNet18, and then a channel attention mechanism module is added as an image recognition network to detect air quality levels.
[0005] The technical solution adopted by the present invention to achieve the above-mentioned purpose is:
[0006] An air quality level detection method based on image recognition comprises the following steps:
[0007] 1) Collect image data from air quality monitoring points and preprocess them to build an air quality level detection image dataset;
[0008] 2) Build and train an air quality level detection model based on the improved ResNet18 network;
[0009] 3) The real-time collected scene image is passed into the air quality level detection model to obtain the air quality level of the current location.
[0010] The step 1) comprises the following steps:
[0011] 1.1) Modify the image data to a uniform size;
[0012] 1.2) Use the real-time air quality level information of the air quality monitoring point to annotate the image data of the site as the label of the scene image.
[0013] The step 2) comprises the following steps:
[0014] 2.1) Use the Cifar-10 dataset to train the ResNet18 network until it converges;
[0015] 2.2) Build an air quality level detection model based on the trained ResNet18 network;
[0016] 2.3) Use the air quality level detection image dataset to train the air quality level detection model, and select the model with the highest accuracy as the final air quality level detection model.
[0017] The air quality level detection model is as follows: the first 7*7 convolutional layer of the ResNet18 network is replaced with three end-to-end 3*3 convolutional layers with 128 channels, and a channel attention module is added after the last 3*3 convolutional layer.
[0018] The channel attention module is an EffectiveSE-Attention module.
[0019] The workflow of the channel attention module is:
[0020] The feature map x output by the 3*3 convolution kernel is processed by full average pooling to obtain a feature vector of size 1*1*C;
[0021] The feature vector is subjected to a 1*1 convolution operation to obtain a new feature vector of size 1*1*C;
[0022] Multiply the new feature vector by the feature map x to get a new feature map The same size as x, both are H*W*C, where H is the height of the image pixels, W is the width of the image pixels, and C is the number of convolution channels.
[0023] An air quality level detection system based on image recognition, comprising:
[0024] The image acquisition module is used to collect and preprocess the image data of air quality monitoring points to construct an air quality level detection image data set;
[0025] Detection model building module, used to build and train the air quality level detection model based on the improved ResNet18 network;
[0026] The air quality level detection module is used to pass the real-time collected scene image into the air quality level detection model to obtain the air quality level of the current location.
[0027] An air quality level detection system based on image recognition comprises a memory and a processor; the memory is used to store a computer program; the processor is used to implement the air quality level detection method based on image recognition when executing the computer program.
[0028] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the air quality level detection method based on image recognition is implemented.
[0029] The present invention has the following beneficial effects and advantages:
[0030] 1. The present invention is based on transfer learning, uses ResNet18 pre-trained on the Cifar-10 dataset as the backbone network, and uses the channel attention mechanism to retrain the air quality level dataset, which can effectively detect the air quality level information of the scene image, solves the problem that the lack of a large air quality level detection dataset makes it impossible to train a deep learning network and give full play to the advantages of the deep learning network, and improves the accuracy of air quality level detection.
[0031] 2. The present invention replaces the first 7*7 convolutional layer of the ResNet18 network with three 3*3 convolutional layers connected end to end and adds a channel attention module thereafter, thereby improving the overall accuracy of the detection model. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 is a flow chart of the method of the present invention;
[0033] Figure 2 Schematic diagram of the channel attention mechanism module structure;
[0034] Figure 3 This is a schematic diagram of the air quality level detection model structure. DETAILED DESCRIPTION
[0035] The present invention is further described in detail below in conjunction with the accompanying drawings and embodiments.
[0036] like Figure 1 As shown, a method for detecting air quality level based on deep transfer learning includes the following steps:
[0037] Step 1: Collect image data and air quality pollution information of air quality monitoring points.
[0038] Step 2: Label the image data and create an air quality level detection image dataset.
[0039] Step 3: Use the pre-trained ResNet18 as the base model and build the ESE-ResNet8d model as the classifier.
[0040] Step 4: Build an image classification network and retrain it on the air quality level image dataset. The model with the best performance on the test set will be used as the final air quality level detection model.
[0041] Step 5: The scene image taken by the user is passed into the air quality level detection model to obtain the air quality level at the user's location.
[0042] The uniform size of the scaled captured scene image information is 224*224 pixels.
[0043] The image data is labeled, specifically, using the real-time air quality level information of the monitoring site to label the scene image of the site as the label of the scene image. The air quality level image detection dataset contains a total of 2622 images and labels, with a training set, a validation set, and a test set ratio of 3:1:1.
[0044] The ResNet18 is used as a feature extractor. Specifically, the ResNet18 network is trained on the Cifar-10 dataset until convergence, the first 7*7 convolutional layer of ResNet18 is replaced with three 3*3 convolutional layers, and the number of channels is set to 128.
[0045] The channel attention module is an EffectiveSE-Attention module.
[0046] like Figure 2 As shown, the specific process of the channel attention mechanism module is as follows:
[0047] Step 1: The image is convolved through three 3*3 convolution kernels to obtain the feature map x, the size of x is H*W*C.
[0048] Step 2: The feature map x is fully averaged and pooled to obtain a 1*1*C vector.
[0049] Step 3: The vector obtained in step 2 is subjected to a 1*1 convolution operation to obtain a new vector of size 1*1*C.
[0050] Step 4: Operate the vector obtained in step 3 with the feature map x obtained in step 1 to obtain a new feature map Same size as x, both are H*W*C.
[0051] like Figure 3 As shown, the specific process of the air quality level detection model is as follows:
[0052] Step 1: The scene image passes through three 3*3 convolutional layers to obtain the feature map x.
[0053] Step 2: After the feature map passes through ESE-Attention, a feature vector is obtained.
[0054] Step 3: Operate the feature vector and the original feature map to obtain a new feature map
[0055] Step 4: Feature map Input the pre-trained resnet18 network and finally get the output air quality level.
[0056] Example:
[0057] The modeling steps of the present invention are:
[0058] Step 1: Data collection. The data of the present invention comes from an air quality monitoring station in Shenyang, and the data includes scene image data of the monitoring station and real-time air quality information.
[0059] Step 2: Data preprocessing: Clean the collected image data and air quality information, delete the data with serious missing or polluted images, and then perform alignment operations to make the image data and air quality level data correspond one to one.
[0060] Step 3: Data labeling: Label the data processed in step 2, that is, rename the image data using the air quality level information at the time of acquisition.
[0061] Step 4: Make the labeled data into a data set. Divide the data into a data set, a validation set, and a test set in a ratio of 3:1:1, and put them into three folders: train, val, and test, respectively. Put these three folders into the same directory.
[0062] Step 5: Use the ResNet18 pre-trained on the cifar-10 dataset as the backbone network. Since the ResNet18 network trained by cifar-10 is widely used, you can also directly download the pre-trained ResNet18 network from the Internet as the backbone network.
[0063] Step 6: Replace the first 7*7 convolutional layer of the pre-trained ResNet18 network with three 3*3 convolutional layers and connect a channel attention mechanism. Retrain using the air quality level detection dataset and use the best performing model on the test set as the air quality level detection model.
[0064] Step 7: When the user sends a picture that needs to be tested, it is first resized to 224*224, and then passed into the air quality level detection model. After processing, the air quality level detection model outputs the final detection result.
Claims
1. A method for detecting air quality level based on image recognition, characterized in that: The following steps are involved: 1) Collect image data from air quality monitoring points and preprocess them to build an air quality level detection image dataset; 2) Build and train an air quality level detection model based on the improved ResNet18 network; 3) The real-time collected scene image is passed into the air quality level detection model to obtain the air quality level of the current location.
2. The air quality level detection method based on image recognition according to claim 1 is characterized in that: The step 1) comprises the following steps: 1.1) Modify the image data to a uniform size; 1.2) Use the real-time air quality level information of the air quality monitoring point to annotate the image data of the site as the label of the scene image.
3. The air quality level detection method based on image recognition according to claim 1 is characterized in that: The step 2) comprises the following steps: 2.1) Use the Cifar-10 dataset to train the ResNet18 network until it converges; 2.2) Build an air quality level detection model based on the trained ResNet18 network; 2.3) Use the air quality level detection image dataset to train the air quality level detection model, and select the model with the highest accuracy as the final air quality level detection model.
4. The air quality level detection method based on image recognition according to claim 1 or 3, characterized in that: The air quality level detection model is as follows: the first 7*7 convolutional layer of the ResNet18 network is replaced with three end-to-end 3*3 convolutional layers with 128 channels, and a channel attention module is added after the last 3*3 convolutional layer.
5. The air quality level detection method based on image recognition according to claim 4 is characterized in that: The channel attention module is an EffectiveSE-Attention module.
6. The method for detecting air quality level based on image recognition according to claim 4, characterized in that: The workflow of the channel attention module is: The feature map x output by the 3*3 convolution kernel is processed by full average pooling to obtain a feature vector of size 1*1*C; The feature vector is subjected to a 1*1 convolution operation to obtain a new feature vector of size 1*1*C; Multiply the new feature vector by the feature map x to get a new feature map The same size as x, both are H*W*C, where H is the height of the image pixels, W is the width of the image pixels, and C is the number of convolution channels.
7. An air quality level detection system based on image recognition, characterized in that: include: The image acquisition module is used to collect and preprocess the image data of air quality monitoring points to construct an air quality level detection image data set; Detection model building module, used to build and train the air quality level detection model based on the improved ResNet18 network; The air quality level detection module is used to pass the real-time collected scene image into the air quality level detection model to obtain the air quality level of the current location.
8. An air quality level detection system based on image recognition, characterized in that: It comprises a memory and a processor; the memory is used to store a computer program; the processor is used to implement an air quality level detection method based on image recognition as described in any one of claims 1-6 when executing the computer program.
9. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by the processor, an air quality level detection method based on image recognition as described in any one of claims 1 to 6 is implemented.