Raspberry Pi flame identification method using yov5m improved algorithm
By using the improved yolov5m algorithm and CBAM module on Raspberry Pi hardware, combined with the channel and spatial attention mechanism, the problem of reduced accuracy of traditional smoke detectors in large spaces is solved, and high-accuracy flame identification and fire detection are achieved Detection system performance improvements.
Patent Information
- Application Number
- CN202410807109.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-21
- Publication Date
- 2025-01-21
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Traditional smoke detectors have reduced detection accuracy due to the decrease in smoke concentration in larger spaces, making it impossible to effectively identify fires.
The improved yolov5m algorithm is used combined with the CBAM module to improve the accuracy and robustness of flame recognition through channel and spatial attention mechanisms, and is suitable for Raspberry Pi hardware.
It achieves high-accuracy flame identification in large spaces, improves the performance and stability of the fire detection system, and has broad market prospects.
Smart Images

Figure CN119339225A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the improvement and combination of embedded hardware, machine learning and some related algorithms, and specifically to a method for Raspberry Pi flame recognition using an improved yolov5m algorithm. Background Art
[0002] Traditional smoke detectors are usually suitable for detecting smoke concentration in a specific space, but when the space increases, the smoke concentration will decrease, resulting in a decrease in detection accuracy, which makes traditional smoke detectors unsuitable for larger indoor fire detection systems. In order to solve the problems of increased space and increased detection accuracy in fire detection systems, this paper adopts a flame image recognition method, which can accurately identify whether a fire has occurred while providing intuitive image information. Flame image recognition technology belongs to the field of artificial intelligence and has been a hot research topic in recent years. It is constantly penetrating and developing in various fields. At present, image recognition algorithms in academia and industry can be divided into three categories: traditional target detection algorithms (such as oriented gradient histograms and support vector machines), deep learning algorithms based on candidate region windows (such as SPP-Net and FasterR-CNN), and regression methods based on deep learning (such as SSD and YOLO). Compared with traditional target detection algorithms, these deep learning-based methods have greatly improved the recognition rate, but their complex network structure is difficult to apply in embedded devices. Therefore, it is necessary to optimize the network structure and reduce the amount of calculation to achieve the combination of recognition algorithms and embedded devices. Summary of the invention
[0003] 1. Technical issues to be resolved
[0004] In view of the shortcomings of the prior art, the present invention provides a method for Raspberry Pi flame recognition using an improved yolov5m algorithm, which solves the problem that when the existing space is increased, the smoke concentration will decrease, resulting in a decrease in detection accuracy.
[0005] (II) Technical solution
[0006] To achieve the above objectives, the present invention is implemented by the following technical solutions: a method for Raspberry Pi flame recognition using an improved yolov5m algorithm, specifically comprising the following steps:
[0007] Step 1: Connect the camera to collect and identify flame images, and connect the camera to two servo motors;
[0008] Step 2: The CBAM module is used and embedded before the prediction part, that is, added between CSP and Conv;
[0009] Step 3: By using the CBAM module, we process the input feature map through the channel attention module. The main purpose of this step is to pay attention to and weight the channel dimension of the feature map;
[0010] Step 4: By generating a channel attention map, we can determine the most important areas and features in the image, so as to perform flame recognition more effectively. The channel attention map provides a quantitative representation of the importance of each channel, helping the model focus on the channels containing the most relevant information, thereby improving the accuracy and robustness of flame recognition;
[0011] Step 5: In the CBAM module, the output features are processed by the spatial attention module to further supplement and strengthen the channel dimension. This step aims to introduce a spatial level attention mechanism so that the model can better understand and utilize the information in different regions of the feature map.
[0012] Step 6: By combining the processing of the channel and spatial attention modules, we obtain feature maps enhanced in both spatial and channel dimensions. These feature maps can not only accurately capture the key features of the flame in the image, but also effectively distinguish the flame from other background elements. The channel attention module enables the model to focus on the most important channel features, while the spatial attention module allows the model to weight different spatial positions of the feature map to emphasize the most critical areas in the image.
[0013] Step 7: We applied the collected dataset to the latest deep learning algorithm and compared it with the traditional model to refine and improve the accuracy of flame recognition. By utilizing the deep learning algorithm, we are able to better mine the complex patterns and features in the dataset, thereby improving the performance of flame recognition.
[0014] Preferably, in the step 1, the rotation of the camera with 2 degrees of freedom is achieved by controlling the duration of the high level output; c) building a Web server, using WiFi connection to form a local area network, and sending the real-time camera shooting content and recognition results to the user.
[0015] Preferably, in the step 2: by introducing the CBAM module, the accuracy and stability of flame recognition are improved, so that the model focuses on key features in the image and shows stronger performance and robustness in fire detection.
[0016] Preferably, in the step three: automatically learning and emphasizing the most important channel features in the image through the CAM model, so that the model focuses on the key features for distinguishing flames from non-flames;
[0017] In order to reduce the influence of target box selection on the target box loss function and improve convergence, CIoULoss is selected as the loss function of bounding box regression.
[0018]
[0019] Preferably, in step 4: the attention mechanism for the channel can understand and utilize the information in the image to detect and identify the fire situation.
[0020] Preferably, in step five: the importance of each spatial position in the image can be automatically learned and weighted by the SAM model, thereby improving the performance and robustness of the flame recognition task.
[0021] Preferably, in step six: this comprehensive attention mechanism enables the model to understand the image more comprehensively and extract key features related to flames therefrom.
[0022] Preferably, in step seven: compared with traditional models, deep learning models have more powerful representation and learning capabilities, can more accurately capture information in the data set, and continuously optimize the performance of the model during the training process.
[0023] (III) Beneficial effects
[0024] The present invention provides a method for Raspberry Pi flame recognition using an improved yolov5m algorithm. It has the following beneficial effects:
[0025] (1) The method of using the improved YOLOv5m algorithm to perform flame recognition on the Raspberry Pi. Using the improved YOLOv5m algorithm, we developed a Raspberry Pi flame recognition system that fully utilizes the GPIO interface and wireless function of the Raspberry Pi. This system combines image recognition algorithms and can automatically identify flames and trigger alarms in large spaces. At the same time, through the wireless function, users can manually control the recognition system to verify the authenticity of the alarm. The system has a built-in power supply and does not require external cables. It is easy to install and has two degrees of freedom, which can detect the environment in all directions. For future new large aircraft and large space applications, the system has broad market prospects. Based on YOLOv5m, we added the CBAM attention mechanism to operate on the characteristics of channels and spaces respectively. After experimental verification on the CLCXray dataset, the results show that the improved algorithm significantly improves the detection accuracy.
[0026] (2) This method of flame recognition on Raspberry Pi using the improved yolov5m algorithm, by comparing the experimental results, we can evaluate the advantages and disadvantages of the new algorithm compared with the traditional model, thereby guiding further improvements and optimizations to achieve a higher level of flame recognition accuracy.
[0027] (3) The method of using the improved YOLOv5m algorithm to perform flame recognition on the Raspberry Pi uses the improved YOLOv5m algorithm combined with the CBAM module to achieve more accurate and efficient flame recognition. By introducing channel attention and spatial attention mechanisms in the flame image acquisition and recognition process, the accuracy and performance of flame recognition are improved. At the same time, by comparing with the traditional model, the technical level of the fire monitoring and prevention system is further improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 A flowchart of a method for Raspberry Pi flame recognition using the improved yolov5m algorithm provided by the present invention;
[0029] Figure 2 A method for obtaining a data set for the method of Raspberry Pi flame recognition using the improved yolov5m algorithm provided by the present invention;
[0030] Figure 3 Flow charts of different modes of the method for Raspberry Pi flame recognition using the improved yolov5m algorithm provided by the present invention;
[0031] Figure 4 An improved YOLOv5m structure diagram of the method for Raspberry Pi flame recognition using the improved yolov5m algorithm provided by the present invention;
[0032] Figure 5 An improved CBAM module structure of the method for Raspberry Pi flame recognition using the improved yolov5m algorithm provided by the present invention;
[0033] Figure 6 Comparison of recognition effects of different models of the improved method of Raspberry Pi flame recognition using the improved yolov5m algorithm provided by the present invention.
[0034] Figure 7 It is a schematic diagram of the improved yolov5m model in the present invention. DETAILED DESCRIPTION
[0035] 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.
[0036] See also Figure 1-6 , the embodiment of the present invention provides a technical solution: Figures 1 to 6As shown, the technical solution adopted by the new invention is as follows: a method for Raspberry Pi flame recognition using the improved yolov5m algorithm, the method at least comprising the following steps:
[0037] Step 1: Connect the camera to collect and identify flame images, and connect the camera to two servo motors;
[0038] Step 2: The CBAM (Convolutional Block Attention Module) module is used and embedded before the prediction part, that is, it is added between CSP (Cross Stage Partial) and Conv (Convolutional).
[0039] Step 3: By using the CBAM (Convolutional Block Attention Module) module, we process the input feature map through the channel attention module (CAM). The main purpose of this step is to pay attention to and weight the channel dimension of the feature map.
[0040] Step 4: By generating a channel attention map, we are able to determine the most important areas and features in the image, allowing for more effective flame recognition. The channel attention map provides a quantitative representation of the importance of each channel, helping the model focus on the channels containing the most relevant information, thereby improving the accuracy and robustness of flame recognition.
[0041] Step 5: In the CBAM module, the output features are processed by the spatial attention module (SAM) to further supplement and strengthen the channel dimension. This step aims to introduce a spatial level attention mechanism so that the model can better understand and utilize information from different regions in the feature map.
[0042] Step 6: By combining the processing of channel and spatial attention modules, we obtain feature maps enhanced in both spatial and channel dimensions. These feature maps can not only accurately capture the key features of the flame in the image, but also effectively distinguish the flame from other background elements. The channel attention module (CAM) enables the model to focus on the most important channel features, while the spatial attention module (SAM) allows the model to weight different spatial locations of the feature map to emphasize the most critical areas in the image.
[0043] Step 7: We applied the collected dataset to the latest deep learning algorithm and compared it with the traditional model to refine and improve the accuracy of flame recognition. By utilizing deep learning algorithms, we are able to better mine the complex patterns and features in the dataset, thereby improving the performance of flame recognition.
[0044] In step 1: by controlling the duration of high-level output, the camera can rotate with 2 degrees of freedom; c) build a Web server, use WiFi connection to form a local area network, and send the real-time camera shooting content and recognition results to the user.
[0045] In step 2: By introducing the CBAM module in this step, we are able to effectively improve the accuracy and stability of flame recognition without affecting other modules. This adjustment allows the model to better focus on key features in the image, thereby showing stronger performance and robustness in fire detection;
[0046] In step 3: Through CAM, the model can automatically learn and emphasize the most important channel features in the image, so that the model can focus more on the key features that distinguish between flames and non-flames. This channel-level attention mechanism helps improve the performance of the model and makes it better adapted to flame recognition tasks in different scenarios and environments.
[0047] In order to reduce the influence of target box selection on the target box loss function and improve convergence, CIoU (Complete Intersection over Union) Loss is selected as the loss function of bounding box regression:
[0048]
[0049] In step 4: This channel-specific attention mechanism enables the model to better understand and utilize information in the image, thereby more reliably detecting and identifying fire situations.
[0050] In step 5: The SAM model can automatically learn and weight the importance of each spatial position in the image, thereby further improving the performance and robustness of the flame recognition task. This processing method that combines channel and spatial attention mechanisms enables the model to more comprehensively capture the key features in the image, thereby achieving more accurate and reliable flame detection and recognition.
[0051] In step six: This comprehensive attention mechanism enables the model to understand the image more comprehensively and extract key features related to flames from it, thereby achieving more accurate and reliable flame recognition.
[0052] In step seven: Compared with traditional models, deep learning models have more powerful representation and learning capabilities, can capture the information in the data set more accurately, and continuously optimize the performance of the model during the training process. By comparing the experimental results, we can evaluate the advantages and disadvantages of the new algorithm relative to the traditional model, thereby guiding further improvements and optimizations to achieve a higher level of flame recognition accuracy, such as Figure 7 .
[0053] mAP takes into account both precision (P) and recall
[0054] (recall, R) is the area under the PR (precision-recall) curve. The calculation formula of the evaluation index is as follows:
[0055]
[0056] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions.
[0057] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.
Claims
1. A method for Raspberry Pi flame recognition using the improved yolov5m algorithm, characterized in that: The specific steps include: Step 1: Connect the camera to collect and identify flame images, and connect the camera to two servo motors; Step 2: The CBAM module is used and embedded before the prediction part, that is, added between CSP and Conv; Step 3: By using the CBAM module, we process the input feature map through the channel attention module. The main purpose of this step is to pay attention to and weight the channel dimension of the feature map; Step 4: By generating a channel attention map, we can determine the most important areas and features in the image, thereby more effectively identifying flames. The channel attention map provides a quantitative representation of the importance of each channel, helping the model focus on the channels containing the most relevant information, thereby improving the accuracy and robustness of flame identification; Step 5: In the CBAM module, the output features are processed by the spatial attention module to further supplement and strengthen the channel dimension. This step aims to introduce a spatial level attention mechanism so that the model can better understand and utilize the information in different regions of the feature map. Step 6: By combining the processing of the channel and spatial attention modules, we obtain feature maps enhanced in both spatial and channel dimensions. These feature maps can not only accurately capture the key features of the flame in the image, but also effectively distinguish the flame from other background elements. The channel attention module enables the model to focus on the most important channel features, while the spatial attention module allows the model to weight different spatial positions of the feature map to emphasize the most critical areas in the image. Step 7: We applied the collected dataset to the latest deep learning algorithm and compared it with the traditional model to refine and improve the accuracy of flame recognition. By utilizing the deep learning algorithm, we are able to better mine the complex patterns and features in the dataset, thereby improving the performance of flame recognition.
2. A method for raspberry pie flame recognition using yolov5m improved algorithm according to claim 1, characterized in that: In the step 1, the rotation of the camera with two degrees of freedom is achieved by controlling the duration of the high level output; c) Build a Web server, use WiFi connection to form a local area network, and send the real-time camera shooting content and recognition results to the user.
3. A method for raspberry pie flame recognition using yolov5m improved algorithm according to claim 1, characterized in that: In the step 2: by introducing the CBAM module, the accuracy and stability of flame recognition are improved, so that the model focuses on the key features in the image and shows stronger performance and robustness in fire detection.
4. The method for raspberry pie flame recognition using yolov5m improved algorithm according to claim 1, characterized in that: In the step 3: automatically learning and emphasizing the most important channel features in the image through the CAM model, so that the model focuses on the key features for distinguishing flames from non-flames; In order to reduce the influence of target box selection on the target box loss function and improve convergence, CIoULoss is selected as the loss function of bounding box regression.
5. The method for raspberry pie flame recognition using yolov5m improved algorithm according to claim 1, characterized in that: In step 4: the channel-specific attention mechanism can understand and utilize the information in the image to detect and identify fire conditions.
6. The method for Raspberry Pi flame recognition using the improved yolov5m algorithm according to claim 1, characterized in that: In the step 5: the importance of each spatial position in the image can be automatically learned and weighted by the SAM model, thereby improving the performance and robustness of the flame recognition task.
7. The method for Raspberry Pi flame recognition using the improved yolov5m algorithm according to claim 1, characterized in that: In step 6: This comprehensive attention mechanism enables the model to understand the image more comprehensively and extract key features related to flames from it.
8. The method for Raspberry Pi flame recognition using the improved yolov5m algorithm according to claim 1, characterized in that: In step 7: Compared with traditional models, deep learning The model has stronger representation and learning capabilities and can capture the information in the data set more accurately. And continuously optimize the performance of the model during the training process.
Citation Information
Patent Citations
Fire detection algorithm based on improved YOLOv5
CN114821266A
Water surface floating object detection method and device based on Raspberry Pi and improved YOLOv5 algorithm
CN115512245A
Forest fire identification method
CN116469007A
High-voltage transmission line nest target detection method based on improved YOLOv5s
CN116563766A
Forest fire monitoring and early warning system based on deep learning
CN117197978A