Yolov5-based smoking behavior detection method
By combining YOLOv5 with models such as PaddleClas, PaddleSeg, SlowFast FasterRCNN, it solves the problem of low accuracy of smoking behavior detection in complex scenarios, achieves higher recognition accuracy and robustness, and is suitable for real-time monitoring in complex scenarios.
Patent Information
- Application Number
- CN202410755218.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-12
- Publication Date
- 2024-09-03
AI Technical Summary
Existing smoking behavior detection systems have low detection accuracy in complex scenes and are prone to misdetection and misjudgment, especially when the light is insufficient, the obstruction is severe, or the target is far away, and it is difficult to distinguish smoking behavior from non-smoking behavior.
A multi-task learning method based on YOLOv5 is used, combined with PaddleClas for preliminary screening and PaddleSeg for detailed image segmentation. The PP-LCNetV2 model is used to optimize the model to run on mobile devices. The SlowFast FasterRCNN model is used to capture the spatiotemporal characteristics of smoking behavior and face recognition. and database backups to optimize system performance.
It improves the accuracy and robustness of smoking behavior detection, enhances the ability to identify small targets, reduces the false detection rate, and is suitable for real-time monitoring in complex scenarios.
Smart Images

Figure CN118587772A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of smoking behavior detection, and in particular to a smoking behavior detection method based on yolov5. Background Art
[0002] The smoking detection system is a system used to monitor and identify smoking behavior in real time. The system is mainly based on video surveillance and artificial intelligence technology. It captures images or videos of the target area through surveillance cameras and uses deep learning algorithms to analyze the images or videos to identify smoking behavior. The smoking detection system can be applied to various public places, such as schools, hospitals, stations, airports, etc., to help managers detect and deal with smoking behavior in a timely manner and maintain the hygiene and safety of the public environment.
[0003] Due to the diverse and subtle movements involved in smoking behavior, and the performance of cigarettes as small target objects in video surveillance, the detection accuracy is limited to a certain extent, especially in complex scenes, such as insufficient light, severe occlusion or long target distance, the detection accuracy will be further reduced. And due to the similarity of smoking behavior, such as hand movements, smoke, etc., it often leads to misdetection with other non-smoking behaviors. In addition, some objects similar to cigarettes, such as water pipes, brooms, etc., are often misjudged as cigarettes, further increasing the false detection rate. Therefore, we propose a smoking behavior detection method based on yolov5 to solve the above problems. Summary of the invention
[0004] The purpose of the present invention is to provide a smoking behavior detection method based on yolov5 to solve the problems in the current market raised by the above background technology.
[0005] To achieve the above object, the present invention provides the following technical solutions:
[0006] A smoking behavior detection method based on yolov5, comprising the following steps:
[0007] S1. Use PaddleClas for preliminary screening, perform detection based on multi-task learning of YOLOv5, and use PaddleSeg for detailed image segmentation;
[0008] Among them, in the preliminary screening, PP-LCNetV2 was used as the main model. The PP-LCNetV2 model has the following characteristics in terms of speed, accuracy, and model size:
[0009] Lightweight design: PP-LCNetV2 is designed to provide efficient deep learning models on mobile and edge computing devices. It achieves low-latency model inference through optimized network structure and computing methods.
[0010] Real-time performance: PP-LCNetV2 is designed with the focus on improving processing speed and reducing computing resource consumption, making it very suitable for application scenarios that require real-time processing.
[0011] Applicable to resource-constrained environments: Due to its efficient performance, PP-LCNetV2 is suitable for devices with limited computing power, such as smartphones, embedded devices, etc.
[0012] S2. The SlowFast network in the SlowFast FasterRCNN model based on spatiotemporal information samples the video frames at different rates to capture the fast movements in the smoking behavior and the slow features of the entire smoking process, and FasterRCNN is used to locate the smoking behavior and related objects in the image.
[0013] S3, detecting faces by training a neural network, aligning the face parts so that all face images are processed under the same standard, using an algorithm to extract features of the face, and comparing the extracted features with features in the database;
[0014] S4. Preprocess the identified face image data, identify structured face vectors, create indexes based on face feature vectors or attributes, encrypt and protect face image data, regularly back up the face image data in the database through a cloud backup system, use monitoring tools to monitor the performance and health status of the storage system in real time, and optimize it;
[0015] S5. Deploy the model file on the Raspberry Pi 4B in onnx mode, configure the inference engine, and use QtDesigner to design a GUI interface with real-time detection of key components. Finally, integrate and test the entire system.
[0016] As a further optimization scheme of the present invention, in step S1, the specific steps of using PaddleClas for preliminary screening are:
[0017] S101: Allow running Linux environment on Windows through Windows Subsystem for Linux, use Linux tools and command line in Windows operating system, and use Ubuntu as Linux system. Install Remote WSL extension in VisualStudio Code to allow running VSCode in WSL, and develop and debug in Linux environment.
[0018] S102: 1600 original images are used as the dataset, of which 800 images belong to the smoking category and 800 images belong to the non-smoking category. The dataset is scanned in a search engine by entering multiple keywords, and a specific degree of inter-class confusion is created by using common images in the two categories. The images are initially screened using the PP-LCNetV2 model.
[0019] As a further optimization scheme of the present invention, in step S1, the specific steps of using multi-task learning based on YOLOv5 for detection are:
[0020] S103: Preprocess the data set, use the preprocessed image data to train the PP-YOLOE-SOD and YOLOv5 models respectively, extract features from the feature layers close to the output layer of PP-YOLOE-SOD and YOLOv5, fuse these features, use the fused features to train a new classifier, and generate the final recognition result;
[0021] S104: For the same input image, PP-YOLOE-SOD and YOLOv5 are used for prediction respectively, and a voting mechanism is used to determine the final recognition result. The confidence scores of the two models for the same target are averaged as the final confidence score, and the category with the highest score is selected as the recognition result;
[0022] Among them, YOLOv5 is one of the most widely used object detection models, known for its excellent balance between speed and accuracy. It can provide reliable detection results in a variety of scenarios and has strong small object detection capabilities. In addition, the YOLOv5 community supports strong, easy to obtain optimization and debugging resources.
[0023] PP-YOLOE-SOD: A model optimized for small target detection, suitable for accurate detection in complex scenarios. Combining PP-YOLOE-SOD with YOLOv5 can further enhance the system's ability to recognize small targets in smoking behavior (such as a cigarette in a distant hand).
[0024] By fusing YOLOv5 and PP-YOLOE-SOD, we can combine the advantages of YOLOv5 in terms of speed and accuracy, and PP-YOLOE-SOD's expertise in detecting small targets in complex scenarios, to achieve a fast, accurate, and adaptable smoking behavior recognition system. At the same time, the model is optimized through model pruning, quantization, and other technologies to reduce the computational burden and maintain good real-time performance of the fused model. This multimodal fusion strategy can provide more comprehensive performance, especially when dealing with various complex detection scenarios, it can show greater advantages.
[0025] S105: extract features from the feature layers close to the output layer of PP-YOLOE-SOD and YOLOv5, fuse these features, and use the fused features to train a new classifier or detector to generate the final recognition result;
[0026] S106: Weighting the results according to the prediction confidence of each model, and making a final decision based on the weighted results.
[0027] As a further optimization scheme of the present invention, in step S1, the specific steps of using PaddleSeg to perform detailed image segmentation are:
[0028] S107: Select the SlowFast FasterRCNN model as the basis and adjust the model structure. Use the two-stream structure of the SlowFast network to extract dynamic features in the video, capture the fast action of smoking behavior through the fast path, and capture the slow context information of the entire smoking process through the slow path;
[0029] S108: Apply FasterRCNN for accurate target detection to locate the smoking individual in the video, and combine the features extracted by SlowFast network for behavior classification to distinguish smoking from non-smoking behavior;
[0030] S109: Train the model on a labeled dataset and evaluate the model's performance, improve the model's performance through optimization strategies, evaluate the model's effectiveness on an independent test set, and analyze the model's performance under different conditions.
[0031] Compared with the prior art, the present invention has the following beneficial effects:
[0032] The present invention realizes a multi-stage, multi-model fusion detection system by combining PaddleClas for preliminary screening, multi-task learning based on YOLOv5 for detection, and detailed image segmentation by PaddleSeg. This multi-model fusion approach can give full play to the advantages of different models and improve the accuracy and robustness of detection.
[0033] The present invention adopts the SlowFast FasterRCNN model based on spatiotemporal information. The SlowFast network samples video frames at different rates, which can simultaneously capture the fast movements in smoking behavior and the slow features of the entire smoking process, and can effectively improve the recognition rate of smoking behavior.
[0034] The above summary is for illustrative purposes only and is not intended to be limiting in any way. In addition to the illustrative aspects, embodiments and features described above, further aspects, embodiments and features of the present invention will be readily apparent by reference to the accompanying drawings and the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 is a flowchart of step S1 in the smoking behavior detection method of the present invention;
[0036] Figure 2 It is the network structure of the YOLOv5 model in the present invention;
[0037] Figure 3 This is the abnormal behavior detection technology route in the present invention;
[0038] Figure 4 This is a flowchart of the multi-target personnel tracking technology in the present invention;
[0039] Figure 5 A flowchart of the database building technology in the present invention;
[0040] Figure 6 It is a flowchart of the integrated deployment technology in the present invention. DETAILED DESCRIPTION
[0041] 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.
[0042] Embodiment 1
[0043] See also Figure 1-Figure 6 , a smoking behavior detection method based on yolov5, comprising the following steps:
[0044] S1, such as Figure 1 As shown, PaddleClas is used for preliminary screening, and detection is performed based on multi-task learning of YOLOv5 (as shown in Figure 2 As shown), use PaddleSeg for detailed image segmentation;
[0045] S101. Use PaddleClas for preliminary screening. First, use Windows Subsystem for Linux to allow running Linux environment on Windows, use Linux tools and command lines in Windows operating system, and use Ubuntu as Linux system. Install Remote WSL extension in Visual Studio Code to allow VSCode to run in WSL and develop and debug in Linux environment.
[0046] S102, Dataset Selection: 1600 original images are used as the dataset, of which 800 images belong to the smoking category and the remaining 800 images belong to the non-smoking category. The dataset is scanned through various search engines by inputting multiple keywords such as smoking, smoker, person, cough, inhaler, person on the phone, drinking water, etc. Common images are used in both categories to create a specific degree of inter-class confusion, that is, the smoking category consists of images of smokers from multiple angles and with various gestures. In addition, the images of the non-smoking category contain images of non-smokers whose gestures are slightly similar to those of the smoking images, such as people drinking water, using inhalers, picking up mobile phones, biting nails, etc.
[0047] The dataset for smoking behavior recognition contains smoking pictures in various scenarios. The smoking behaviors in these pictures may vary greatly due to factors such as distance, angle, occlusion, and ambient lighting. Therefore, the Random Erasing technology is needed to identify smoking behaviors, which has the following advantages:
[0048] Improve the ability to handle occlusions: In real scenes, smoking behavior may be partially obscured by other objects, such as hands blocking the face or smoke. Random Erasing can simulate this occlusion and train the model to still recognize smoking behavior even when some information is missing.
[0049] Enhance the model's adaptability to illumination changes: Random erasing can indirectly simulate the impact of illumination changes on images and help the model learn to extract effective features under different illumination conditions.
[0050] Reduce overfitting and improve generalization ability: Since the dataset for smoking behavior recognition is relatively limited, using RandomErasing to increase data diversity helps the model perform well in a wider range of scenarios.
[0051] After conventional preprocessing of the smoking dataset, Random Erasing is introduced as an additional data enhancement method. After applying Random Erasing, the model can better handle common problems in real scenes such as occlusion and lighting changes, thereby showing higher robustness and accuracy in practical applications.
[0052] By using the PP-LCNetV2 model for initial image screening, potential smoking behavior images can be identified in an efficient manner, and the PP-LCNetV2 model can achieve an average accuracy of 78% in smoking behavior recognition.
[0053] Multimodal fusion, that is, selecting the multi-task learning of the YOLOv5+PP-YOLOE-SOD model for detection. The specific steps are as follows:
[0054] S103: Preprocess the data set, use the preprocessed image data to train the PP-YOLOE-SOD and YOLOv5 models respectively, extract features from the feature layers close to the output layer of PP-YOLOE-SOD and YOLOv5, fuse these features, use the fused features to train a new classifier, and generate the final recognition result;
[0055] Specifically, obtain the pre-trained model of PP-YOLOE-SOD from the PaddlePaddle model library, obtain the pre-trained model of YOLOv5 from Ultralytics, modify the input image size, anchor point size, number of categories and other data on the model, and read and process the smoking behavior image dataset through the data loader.
[0056] The pre-trained model is used to initialize the PP-YOLOE-SOD and YOLOv5 models, and multi-task learning is added during the training process. In addition to smoking behavior detection, the model is also trained for face detection and smoke detection tasks.
[0057] The model is trained using the localization loss and the training dataset, and the model weights are optimized through multiple iterations.
[0058] In multi-task learning, a shared feature extractor is used to extract useful features from the input image. After the shared feature extractor, a specific layer is added for each task, and the shared features will be further processed according to the needs of each task.
[0059] A loss function is defined for each task to measure the prediction error of the model on the task. For classification tasks, the cross entropy loss function is used; for positioning tasks, the smooth L1 loss function is used, and the loss functions of each task are weighted combined through the total loss function.
[0060] The model is trained simultaneously using a multi-task loss function, and in each iteration, the loss of all tasks is optimized simultaneously by gradient descent.
[0061] Finally, the interaction between different tasks is analyzed. That is, when detecting smoking behavior, the information provided by face detection will help to accurately identify smokers, while other tasks may interfere with each other. The problem of mutual interference is solved by adopting a dynamic weight strategy during the training process.
[0062] S104, voting mechanism: For the same input image, PP-YOLOE-SOD and YOLOv5 are used for prediction respectively, and then a voting mechanism is used to determine the final recognition result. When the recognition results of the two models for an object are consistent, the result is accepted; if they are inconsistent, the result with higher confidence is selected. The confidence scores of the two models for the same target are averaged as the final confidence score, and the category with the highest score is selected as the recognition result.
[0063] S105, Feature Extraction: Extract features from a certain layer of PP-YOLOE-SOD and YOLOv5, and then fuse these features. Use the fused features to train a new classifier or detector to generate the final recognition result.
[0064] S106, Confidence Weighting: Weight the results according to the prediction confidence of each model, and then make the final decision based on the weighted results. Through continuous experimentation and adjustment of the fusion of PP-YOLOE-SOD and YOLOv5, a more accurate and robust recognition result is provided than a single model, thus improving the recognition accuracy.
[0065] S3. Detailed image segmentation using PaddleSeg
[0066] In order to achieve accurate image segmentation in the smoking behavior detection project, PaddleSeg, developed based on the PaddlePaddle framework, is used. PaddleSeg is an efficient and powerful image segmentation library that provides a wide range of model selections and pre-trained models to support various image segmentation tasks. Among the many available models, the DeepLabV3+ model is used for fine segmentation of the smoking area.
[0067] DeepLabV3+ is an advanced end-to-end semantic segmentation model that effectively improves segmentation accuracy and boundary clarity by adopting a dilated convolution strategy and encoder-decoder structure.
[0068] DeepLabV3+ has demonstrated excellent performance on multiple public image segmentation datasets, such as PASCAL VOC 2012 and Cityscapes. It is suitable for object segmentation tasks in complex backgrounds and can accurately identify and segment key elements in smoking behavior, such as smoke.
[0069] Smoking behavior includes a series of actions, such as raising the hand to the mouth, using a lighter, and blowing smoke, which are often not allowed in public places. For this specific abnormal behavior detection task, traditional monitoring methods often cannot accurately identify the smoking behavior of an individual among many pedestrians, especially in a dynamic and complex environment. Smoking behavior includes but is not limited to action sequences such as raising the hand to the mouth, holding tobacco products, and using a lighter. These behaviors often last for a short time and may be difficult to identify in space due to occlusion and angle problems.
[0070] S2. Based on the above considerations, the SlowFast_FasterRCNN model based on spatiotemporal information is adopted. The SlowFast network can capture the fast movements in smoking behavior and the slow features of the entire smoking process by sampling video frames at different rates. At the same time, FasterRCNN, as a powerful target detection framework, can accurately locate smoking behavior and related objects in the image, such as tobacco products and lighters. Figure 3 shown.
[0071] Specifically, we collect a large amount of video data that contains various forms of smoking behavior. We annotate the data, including key frames of smoking actions and negative samples of non-smoking. We also perform data augmentation to simulate different monitoring conditions, such as lighting changes, occlusion, etc.
[0072] The SlowFast_FasterRCNN model is selected as the basis, and the model structure is adjusted, including changing the network layer parameters and selecting different skeleton networks to adapt to specific data sets and task requirements.
[0073] The two-stream structure of the SlowFast network is used to extract dynamic features in the video. The fast path captures the fast movements of smoking behavior, such as raising the hand to the mouth. The slow path captures the slow contextual information of the entire smoking process.
[0074] FasterRCNN is used for accurate target detection to locate the smoking individual in the video. The features extracted by SlowFast network are combined for behavior classification to distinguish smoking from non-smoking behavior.
[0075] Train the model on the labeled data set and use methods such as cross-validation to evaluate the performance of the model. Implement various optimization strategies such as sample balancing strategy and loss function optimization to improve model performance.
[0076] Evaluate the model's performance on an independent test set to ensure that the model detects and tracks smoking behavior with high accuracy and low false positives. Analyze the model's performance under different conditions, such as detection capabilities under different lighting and angles.
[0077] S3. The identified smokers need to be matched accurately with each other through face recognition technology. Face recognition technology has the following steps:
[0078] The neural network is trained to detect faces and distinguish them from other objects in the image. The labels are common facial features such as eyes, nose, mouth, eyebrows, etc.
[0079] Align the facial parts, that is, align the eyes, nose, mouth and other feature points in the facial image, so that all facial images are processed under the same standard for subsequent recognition.
[0080] The features of the face are extracted through algorithms such as geometric methods or photometric statistics methods. These features can be some geometric characteristics of the face or the brightness of the face under different lighting conditions.
[0081] The extracted features are compared with the features in the database to determine which person in the database the recognized face belongs to.
[0082] S4. Multi-target personnel tracking
[0083] In public places, people often smoke in crowds, or continue to smoke in other places after being dissuaded. After identifying whether the target is smoking in cigarette detection, the smoker's facial information is recorded in the database so that multiple recognition devices can accurately identify the smoker; secondly, the optical flow method is used to estimate the movement of the smoker to achieve the purpose of long-term monitoring; finally, the MOT algorithm is used to achieve multi-target tracking. The data generated is associated and the trajectory is maintained, and corresponding improvements and optimizations are made through the evaluation of its real-time performance and performance. Figure 4 As shown, the specific steps are as follows:
[0084] Use target matching algorithms between different frames to associate the detection results of the same target, such as Hungarian algorithm, nearest neighbor matching, Kalman filter, etc. Fusion of target detection, appearance features, motion information, etc. to improve the accuracy and robustness of matching.
[0085] Use optical flow, visual inertial odometry and other technologies to estimate the target's trajectory. Combine motion models, such as constant velocity model and constant acceleration model, to predict the target's future position.
[0086] Maintain the motion trajectory information of each target, including position, speed, acceleration, etc., and continuously update the trajectory information to ensure the accuracy of tracking.
[0087] Use filters such as Kalman filter and extended Kalman filter to smooth and predict the trajectory.
[0088] Use multi-object tracking, multi-target Kalman filtering, particle filtering and other multi-target tracking algorithms to achieve simultaneous tracking of multiple targets. And consider the relationship between targets and scene constraints to improve tracking accuracy.
[0089] Evaluate the performance of the system, including accuracy, robustness, real-time performance, etc. Tune the algorithm and parameters according to actual needs to meet the requirements of specific scenarios and applications.
[0090] Use GPU acceleration, distributed computing and other technologies to optimize system performance, improve processing speed and parallel performance. Optimize algorithms and models to adapt to different hardware platforms and resource constraints.
[0091] Use large-scale, high-quality datasets for model training and evaluation to improve the generalization and robustness of the system. Perform continuous supervised learning and updates on the model to adapt to changing scenarios and goals.
[0092] like Figure 5 As shown in the figure, for the construction of the database, through data preprocessing, the recognized face images are aligned, cropped, resized, etc. to ensure the consistency of the image, reduce the difficulty of storage, identify the structured face vector, and use a relational database for storage. During the storage process, an index is established based on the face feature vector or other attributes to facilitate the rapid retrieval and recognition of the face in the later stage. The face image data is encrypted and protected to ensure the security of data transmission and storage. The face image data of the database is regularly backed up by using a cloud backup system. At the same time, we will use monitoring tools to monitor the performance and health status of the storage system in real time and optimize it to improve the reliability of data processing.
[0093] Deploy and configure the selected storage engine, including setting up storage clusters, network configuration, security settings, etc. Perform capacity planning for large data volumes to ensure that the storage system can meet future expansion needs.
[0094] Use image processing algorithms to pre-process the acquired images, including face detection, alignment, cropping, etc.
[0095] Store the pre-processed face image data in the selected database to ensure data security and integrity. Build indexes based on face feature vectors or other attributes to support fast data retrieval and recognition.
[0096] Encrypt and protect the stored facial image data to ensure the security of data transmission and storage. Anonymize or de-identify the data to protect the user's privacy information.
[0097] Design and implement regular backup strategies to ensure that data can be restored in time in case of data loss or corruption. Use distributed backup systems or cloud backup services to back up data and test the reliability and recovery of backups.
[0098] Use the monitoring tool Prometheus to monitor the performance and health status of the storage system in real time, and tune and optimize according to the monitoring indicators. Regularly evaluate the performance and stability of the storage system, and adjust the storage architecture and configuration according to needs.
[0099] S5. Integration and deployment of IoT devices: Deploy the model file on the Raspberry Pi 4B in onnx mode and configure the inference engine. Then use Qt Designer to design the real-time detection GUI interface including key components such as the video stream display window, control buttons, and detection result display area. Finally, integrate and test the entire system to ensure the collaboration between the GUI interface and model reasoning. Through testing in actual scenarios, verify the real-time detection performance and accuracy of the system, and make necessary optimizations and adjustments based on feedback.
[0100] Specifically, Figure 6 As shown in the figure, Raspberry Pi 4B is selected as the deployment platform of the YOLOv5 smoking image recognition system. Raspberry Pi 4B is equipped with a powerful processor and large-capacity memory, which can meet the computing needs of real-time reasoning of the YOLOv5 model and ensure the accuracy and fast response of smoking image recognition. At the same time, Raspberry Pi 4B has good scalability and rich interfaces, supports the connection of various cameras and other peripherals, and facilitates the realization of diversified application scenarios. In addition, Raspberry Pi 4B has a large user community and rich development resources, which reduces the difficulty of development and deployment and speeds up the progress of the project. A micro camera is configured to capture real-time video streams and appropriate power and heat dissipation equipment to ensure that Raspberry Pi 4B remains stable during long-term operation.
[0101] Install the latest Raspberry Pi OS on the Raspberry Pi 4B, update the system software package, and install Python 3, OpenCV, NumPy and other libraries. At the same time, to optimize the YOLOv5 model reasoning, install deep learning reasoning frameworks such as TensorFlow Lite or OpenVINO.
[0102] Deploy the model file to the Raspberry Pi 4B and ensure that the path and permissions of the model file are set correctly. Write Python code to use OpenCV to capture the real-time video stream of the camera and pass the video frames to the model for inference.
[0103] Create a GUI interface using Qt Designer, add components such as video display window, control buttons, and detection result display area. Set the properties of each component, such as size, position, and style, to provide a good user experience.
[0104] Integrate the YOLOv5 inference code with the GUI interface designed by Qt Designer to ensure that they can communicate and collaborate normally. Run the integrated system on the Raspberry Pi 4B to perform real-time detection tests to verify whether the system's functions and performance meet the requirements. Finally, tune and improve the system based on the test results, including optimizing the model inference speed and improving the responsiveness of the GUI interface.
[0105] Deploy the tested and optimized system to actual application scenarios, such as factories, schools, or homes that require real-time monitoring. Customize and expand the system according to actual needs, such as adding other sensor inputs and implementing remote monitoring functions. And regularly maintain and update the system to adapt to changing needs and environmental changes. At the same time, pay attention to the development of new technologies and new methods, and promptly apply the latest technologies to the system to improve performance and user experience.
[0106] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code that includes one or more executable instructions for implementing the steps of a specific logical function or process, and the scope of the preferred embodiments of the present invention includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by those skilled in the art to which the embodiments of the present invention belong.
[0107] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, which can be embodied in any computer-readable medium for use by an instruction execution system, apparatus or device (such as a computer-based system, a system including a processor or other system that can fetch instructions from an instruction execution system, apparatus or device and execute instructions), or used in combination with these instruction execution systems, apparatuses or devices.
[0108] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, a plurality of steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0109] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.
[0110] In addition, each functional unit in each embodiment of the present invention may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.
[0111] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may change, modify, replace and vary the above embodiments within the scope of the present invention.
Claims
1. A smoking behavior detection method based on yolov5, characterized in that: The following steps are involved: S1. Use PaddleClas for preliminary screening, perform detection based on multi-task learning of YOLOv5, and use PaddleSeg for detailed image segmentation; S2. The SlowFast network in the SlowFast FasterRCNN model based on spatiotemporal information samples the video frames at different rates to capture the fast movements in the smoking behavior and the slow features of the entire smoking process, and FasterRCNN is used to locate the smoking behavior and related objects in the image. S3, detecting faces by training a neural network, aligning the face parts so that all face images are processed under the same standard, using an algorithm to extract features of the face, and comparing the extracted features with features in the database; S4. Preprocess the identified face image data, identify structured face vectors, create indexes based on face feature vectors or attributes, encrypt and protect face image data, regularly back up the face image data in the database through a cloud backup system, use monitoring tools to monitor the performance and health status of the storage system in real time, and optimize it; S5. Deploy the model file on the Raspberry Pi 4B in onnx mode, configure the inference engine, and use QtDesigner to design a GUI interface with real-time detection of key components. Finally, integrate and test the entire system.
2. The smoking behavior detection method based on yolov5 according to claim 1, characterized in that: In step S1, the specific steps of using PaddleClas for preliminary screening are: S101: Allow running Linux environment on Windows through Windows Subsystem for Linux, use Linux tools and command line in Windows operating system, and use Ubuntu as Linux system. Install Remote WSL extension in VisualStudio Code to allow running VSCode in WSL, and develop and debug in Linux environment. S102: 1600 original images are used as the dataset, of which 800 images belong to the smoking category and 800 images belong to the non-smoking category. The dataset is scanned in a search engine by entering multiple keywords, and a specific degree of inter-class confusion is created by using common images in the two categories. The images are initially screened using the PP-LCNetV2 model.
3. The smoking behavior detection method based on yolov5 according to claim 1, characterized in that: In step S1, the specific steps of using multi-task learning based on YOLOv5 for detection are: S103: Preprocess the data set, use the preprocessed image data to train the PP-YOLOE-SOD and YOLOv5 models respectively, extract features from the feature layers close to the output layer of PP-YOLOE-SOD and YOLOv5, fuse these features, use the fused features to train a new classifier, and generate the final recognition result; S104: For the same input image, PP-YOLOE-SOD and YOLOv5 are used for prediction respectively, and a voting mechanism is used to determine the final recognition result. The confidence scores of the two models for the same target are averaged as the final confidence score, and the category with the highest score is selected as the recognition result; S105: extract features from the feature layers close to the output layer of PP-YOLOE-SOD and YOLOv5, fuse these features, and use the fused features to train a new classifier or detector to generate the final recognition result; S106: Weighting the results according to the prediction confidence of each model, and making a final decision based on the weighted results.
4. The smoking behavior detection method based on yolov5 according to claim 1, characterized in that: In step S1, the specific steps of using PaddleSeg to perform detailed image segmentation are: S107: Select the SlowFast FasterRCNN model as the basis and adjust the model structure. Use the two-stream structure of the SlowFast network to extract dynamic features in the video, capture the fast action of smoking behavior through the fast path, and capture the slow context information of the entire smoking process through the slow path; S108: Apply FasterRCNN for accurate target detection to locate the smoking individual in the video, and combine the features extracted by SlowFast network for behavior classification to distinguish smoking from non-smoking behavior; S109: Train the model on a labeled dataset and evaluate the model's performance, improve the model's performance through optimization strategies, evaluate the model's effectiveness on an independent test set, and analyze the model's performance under different conditions.
