A lightweight real-time target detection and privacy protection method based on YOLOv8n-MobileNet fusion architecture
By using the YOLOv8n-MobileNet fusion architecture, the problems of large number of parameters in pedestrian detection models and crude privacy protection mechanisms on edge devices are solved, achieving low-latency and efficient pedestrian detection and privacy protection, meeting the requirements of real-time performance and privacy protection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- 杨振宇
- Filing Date
- 2026-03-23
- Publication Date
- 2026-06-05
AI Technical Summary
Existing technologies for pedestrian detection on edge devices suffer from excessively large numbers of parameters in the model, crude privacy protection mechanisms, an inability to balance facial desensitization and background availability, and a lack of dynamic scene adaptability and edge deployment verification.
By adopting the YOLOv8n-MobileNet fusion architecture, combined with lightweight model construction, bimodal PSNR evaluation system, dynamic desensitization processing and scene-aware inference, we can reduce the number of model parameters, improve the strength of privacy protection, and meet real-time requirements.
Low-latency real-time detection and efficient privacy protection are achieved on Raspberry Pi devices, meeting real-time and privacy protection requirements and complying with relevant standards and laws.
Smart Images

Figure CN122156593A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of computer vision, edge computing and privacy protection technology, and more specifically, to a low-power real-time pedestrian detection and dynamic desensitization integrated method for community security scenarios. Background Technology
[0002] Currently, with the rapid advancement of smart community construction, security monitoring systems are generating massive amounts of video data, making real-time processing at the edge increasingly urgent. Existing technical solutions have the following significant shortcomings: 1. Insufficient model lightweighting: Mainstream detection models such as YOLOv5 / v7 / v8 generally have more than 5MB of parameters, resulting in inference latency exceeding 100ms / frame on ARM architecture edge devices such as Raspberry Pi, making it difficult to meet the 25fps real-time requirement; while the MobileNet series, although lightweight, suffers from a significant decrease in detection accuracy, with mAP50 typically below 0.75.
[0003] 2. Inadequate privacy protection mechanisms: Traditional Gaussian blurring or mosaic uses fixed parameters, and global PSNR evaluation cannot distinguish between facial privacy strength and background availability. Experimental data shows that when the global PSNR is 25dB, the face can still be recognized by the ArcFace algorithm with an accuracy of over 85%, while the background is excessively blurred, causing the pedestrian detection mAP50 to drop by more than 15%.
[0004] 3. Poor adaptability to dynamic scenes: Differentiated model configurations and desensitization strengths are required for day and night lighting changes and scenes with dense / sparse pedestrians. Static parameters cannot balance detection accuracy and privacy protection strength.
[0005] 4. Lack of edge deployment verification: More than 90% of existing research focuses on server-side simulation and has not verified memory usage, power consumption, and multi-threaded concurrency stability on real Raspberry Pi / Jetson Nano devices.
[0006] This invention is proposed to overcome the shortcomings of the prior art. Summary of the Invention
[0007] To overcome the shortcomings of existing technologies, the main technical problem solved by this invention is to provide a lightweight real-time object detection and privacy protection method based on the YOLOv8n-MobileNet fusion architecture, which can solve the problems of excessive parameters, crude privacy protection mechanisms, and inability to balance face desensitization and background usability in existing models.
[0008] To address the aforementioned technical problems, one technical solution adopted by this invention is: to provide a lightweight real-time target detection and privacy protection method based on the YOLOv8n-MobileNet fusion architecture, comprising the following steps: S1. Construct a lightweight detection model: Retain the CSPDarknet feature extraction backbone network of the YOLO series network, replace the original detection head with the MobileNetV4 ConvLarge lightweight structure, and fuse the Conv-BN-ReLU layer through reparameterization technology to obtain the YOLOv8n-MobileNet fusion model with ≤3M model parameters and inference latency ≤60ms / frame. S2. Model Compression and Quantization Optimization: Automatic structured pruning and mixed-precision dynamic quantization are applied to the fusion model. The optimal pruning rate is automatically determined through Bayesian hyperparameter search under the constraint of accuracy loss ≤8%, reducing the number of model parameters to 1.52M, GFLOPs to ≥50%, and mAP50 to 0.801. The sensitivity-accuracy balance function is used to automatically allocate the quantization bit width, compressing the model size to ≤15MB. S3. Construct a bimodal PSNR privacy assessment system: Separate the region of interest (ROI) and the background region from the input image, calculate Face-PSNR and Background-PSNR respectively, and establish the privacy strength objective function Privacy_Score = α×(1 / PSNR_roi) + β×(1 / PSNR_global), where α=0.6 and β=0.4. The optimal parameter combination satisfies Face-PSNR≈20dB and Background-PSNR∈[35,45]dB; S4. Dynamic desensitization processing: Gaussian blur and mosaic dual desensitization are adopted. Based on deformable convolution, an offset Δp is introduced to adaptively adjust the shape of the blur mask, and the blur area of occluded and side face samples is expanded by 15%. The optimal hyperparameter combination (k,σ,b,ε) is searched through Bayesian optimization. The objective function is Objective(k,σ,b,ε) = w1×mAP50 + w2×(1 / PSNR_roi) + w3×Speed^(-1), where w1=0.5, w2=0.3, and w3=0.2. S5. Scene-Aware Dynamic Reasoning: Deploy a MobileNetV3-small gated network to extract scene features, dynamically switching between YOLOv8n-base and YOLOv8n-enhance model configurations based on day / night and dense / sparse scenes. The gate threshold is determined by... Online learning updates automatically; S6. Edge Device Deployment: The optimized model is converted to ONNX / TensorRT format, and ThreadPoolExecutor is used to implement a four-stage asynchronous pipeline for video acquisition, privacy desensitization, object detection, and result archiving. On a Raspberry Pi 4B 2GB version, the FP16 inference latency is ≤45ms / frame, memory usage is ≤200MB, power consumption is ≤3W, and 16 concurrent video streams are supported with an average latency of ≤180ms.
[0009] The beneficial effects of this invention are: 1. The number of parameters was reduced by 56.6% to 1.52M, and the inference latency was improved by 57.3% to 42.7ms / frame, achieving real-time detection of 23.4fps on the Raspberry Pi. 2. Privacy protection strength reaches 98.7% with an unidentifiable rate, and the success rate against ArcFace recognition attacks decreases by 96.8%; 3. A bimodal PSNR evaluation model is proposed, filling the gap in the field of privacy strength quantification. The correlation coefficient between Face-PSNR and attack success rate reaches 0.92. 4. Completed end-to-end deployment verification of Raspberry Pi 4B, meeting the real-time requirements of the Ministry of Public Security's GB / T 28181 standard, and complying with the "de-identification" requirement of Article 51 of the Personal Information Protection Law. Attached Figure Description
[0010] In the picture: 1. Input Image 2. CSPDarknet Backbone Network 3. PAN-FPN Feature Pyramid 4. MobileNetV4 UIB Detector Head 5. Detection Box Output Module 6. Bimodal PSNR Evaluation Module 7. ROI Extraction Unit 8. Face-PSNR Calculation Unit 9. Background-PSNR Calculation Unit 10. Privacy Score Calculation Unit 11. Raspberry Pi 4B Processor 12. NCS2 Accelerator Stick 13. CSI Camera Interface 14. HDMI Display Interface 15. MicroSD Memory Card 16. Gated Network Classifier 17. Daytime Sparse Scene Determination Unit 18. Nighttime Dense Scene Determination Unit 19. Model Switching Control Unit 20. Deformable Convolution Offset Calculation Unit 21. Blur Mask Generation Unit 22. Gaussian Blur Processing Unit 23. Mosaic Processing Unit 24. Video Acquisition Thread 25. Desensitization Processing Thread 26. Object Detection Thread 27. Result Archiving Thread 28. Dynamic Batch Size Adjuster The present invention will be further described below with reference to the accompanying drawings and embodiments.
[0011] Figure 1This is a summary diagram of the present invention, which covers the overall process of the YOLOv8n-MobileNet fusion architecture. In the diagram: the input image (1) first enters the CSPDarknet backbone network (2) for feature extraction, and after multi-scale fusion by the PAN-FPN feature pyramid (3), the original YOLO detection head is replaced by the MobileNetV4 UIB detection head (4). The detection result is obtained through the detection box output module (5), and finally the privacy quality is evaluated through the bimodal PSNR evaluation module (6).
[0012] Figure 2 This is a schematic diagram of the bimodal PSNR evaluation system of the present invention. In the figure: the input image enters the ROI extraction unit (7) and the Background-PSNR calculation unit (9) in parallel; the ROI extraction unit (7) uses the Haar detector to locate the face and expands the bounding box by 1.5 times, and the Face-PSNR is obtained by the Face-PSNR calculation unit (8) to approximately 20dB; the Background-PSNR calculation unit (9) calculates the background region PSNR to obtain the background-PSNR ∈ [35,45]dB; finally, the Privacy Score is calculated by the Privacy Score calculation unit (10) based on α=0.6 and β=0.4.
[0013] Figure 3 This is a diagram of the Raspberry Pi 4B deployment architecture of the present invention. In the diagram: the CSI camera interface (13) inputs a 1080p@25fps video stream to the Raspberry Pi 4B processor (11), which is connected to the NCS2 accelerator stick (12) via USB3.0 for FP16 inference acceleration. The processed video is output as a real-time monitoring screen via the HDMI display interface (14), and the detection results and logs are stored on the MicroSD memory card (15).
[0014] Figure 4 This is the scene-aware gating network decision logic diagram of the present invention. In the diagram: After the MobileNetV3-small gating network (16) extracts scene features, the daytime sparse scene determination unit (17) selects the YOLOv8n-base model when the light intensity is >120 lux and the number of people is <5; the nighttime dense scene determination unit (18) selects the YOLOv8n-enhance model when the light intensity is <50 lux or the number of people is >20; finally, the model switching control unit (19) performs the switching, with a switching delay of <5ms.
[0015] Figure 5 This is a diagram illustrating the dynamic desensitization effect of the deformable convolution of the present invention. In the diagram: the deformable convolution offset calculation unit (20) calculates Δp∈R^(H×W×18) based on the pose key points, and the occluded sample is enlarged by 15% by the blur mask generation unit (21). After the domain, the data is processed by the Gaussian blur processing unit (22) with 61×61 kernels (σ=18) and the mosaic processing unit (23) with 7×7 block size.
[0016] Figure 6 This is a diagram of the asynchronous pipelined parallel mechanism of the present invention. In the diagram: the video acquisition thread (24) acquires the raw frame from the CSI camera, the desensitization processing thread (25) performs the S4 step for privacy protection, the target detection thread (26) runs YOLOv8n inference, and finally the result is saved by the result archiving thread (27); the dynamic batch_size adjuster (28) monitors memory usage and reduces the batch_size from 4 to 2 when it is >200MB. Detailed Implementation
[0017] Please see Figures 1 to 6 The embodiments of the present invention include: Example 1: Construction of a Lightweight Detection Model The input image (1) first enters the CSPDarknet backbone network (2) for feature extraction. This network adopts a cross-stage local connection structure, which improves the feature reuse rate by 50%. The extracted features are fused at multiple scales through the PAN-FPN feature pyramid (3) and then reach the detection head replacement point. Here, the original YOLO detection head is replaced with the MobileNetV4 UIB detection head (4). This detection head includes pointwise expanding convolution, depthwise separable convolution and Squeeze-and-Excitation channel attention mechanism. After the replacement, the number of model parameters is reduced from 3.01M to 2.41M and the inference latency is reduced from 78.8ms to 58.3ms. After the detection boxes generated by the YOLOv8n-MobileNet fusion model output detection box output module (5) are generated, privacy evaluation is performed by the bimodal PSNR evaluation module (6).
[0018] Example 2: Bimodal PSNR Privacy Assessment and Dynamic De-identification The input image is processed in parallel by the ROI extraction unit (7) and the background separation unit. The ROI extraction unit (7) uses an OpenCV Haar cascade detector to locate the face region and expands the face bounding box by 1.5 times to define the ROI. The Face-PSNR calculation unit (8) calculates the peak signal-to-noise ratio of the ROI region, and the Background-PSNR calculation unit (9) calculates the peak signal-to-noise ratio of the non-ROI region. The calculation formula is PSNR_global = 10log 10(MAX² / MSE_global), where MAX=255. The privacy score calculation unit (10) calculates the final privacy score according to the formula Privacy_Score = 0.6×(1 / PSNR_roi) + 0.4×(1 / PSNR_global). The optimal parameter combination satisfies Face-PSNR≈20dB and Background-PSNR∈[35,45]dB.
[0019] In another embodiment, after the input image is detected, the deformable convolution offset calculation unit (20) calculates the offset Δp∈R^(H×W×18) based on the pedestrian pose key points. The blur mask generation unit (21) adaptively adjusts the shape of the blur region based on the offset, expanding the blur region of the occluded sample by 15%. The Gaussian blur processing unit (22) applies a 61×61 kernel (σ=18) Gaussian blur, and the mosaic processing unit (23) superimposes 7×7 size mosaics. Tests show that the fixed mask causes a 2.1% decrease in mAP50, while the deformable mask only decreases by 0.8%.
[0020] Example 3: Scene Awareness and Edge Deployment The CSI camera interface (13) connects to a 1080p camera, inputting the video stream to the Raspberry Pi 4B processor (11). The Raspberry Pi 4B connects to the NCS2 accelerator stick (12) via a USB 3.0 interface to offload TensorRT inference tasks. The processed video stream is output as a real-time monitoring image via an HDMI display interface (14), and the detection logs and desensitized videos are stored on a MicroSD memory card (15). The average power consumption of the entire system is 2.1W (5V×0.42A), meeting the ≤3W requirement.
[0021] In another embodiment, after the MobileNetV3-small gated network classifier (16) extracts scene features, the daytime sparse scene determination unit (17) selects the YOLOv8n-base model (delay 42.7ms) when the light intensity is >120 lux and the number of people is <5; the nighttime dense scene determination unit (18) selects the YOLOv8n-enhance model (mAP50 improved by 3.2%) when the light intensity is <50 lux or the number of people is >20; the model switching control unit (19) performs the switching operation with a switching delay of <5ms.
[0022] In another embodiment, the video acquisition thread (24) acquires raw frames from the CSI camera, the desensitization processing thread (25) performs privacy protection in step S4, the object detection thread (26) runs YOLOv8n model inference, and the result archiving thread (27) saves the detection results and logs. The dynamic batch_size adjuster (28) monitors memory usage and automatically reduces the batch_size from 4 to 2 when it exceeds 200MB to prevent OOM errors. The four threads work in parallel to achieve 16 concurrent video streams with an average latency of ≤180ms.
[0023] Example 4: Comprehensive Application Case Taking a 1080p@25fps surveillance video from a campus community as an example, the single-frame processing flow is as follows: After the camera captures the video, the gating network determines it to be a sparse daytime scene and loads the YOLOv8n-base model (2.41M parameters). Deformable convolution detects 3 pedestrians (including 1 occluder), and adaptively expands the blurred area of the occluded pedestrian by 15%. Bimodal PSNR evaluation shows Face-PSNR=19.3dB, Background-PSNR=42.1dB, and the privacy score meets the standard. TensorRT inference latency is 42.7ms, memory usage is 198MB, and power consumption is 2.1W. 1000-frame continuous testing shows that mAP50 is stable at 0.801, and the attack success rate is <5%, meeting all technical indicators.
Claims
1. A lightweight real-time object detection and privacy protection method based on the YOLOv8n-MobileNet fusion architecture, comprising a CSPDarknet backbone network, a feature pyramid network, and a detection head, characterized in that, The detection head is MobileNetV4. ConvLarge lightweight architecture; the method includes the following steps: S1. Construct a lightweight detection model: Retain the CSPDarknet feature extraction backbone network of the YOLO series network, replace the original detection head with the MobileNetV4 ConvLarge lightweight structure, and fuse the Conv-BN-ReLU layer through reparameterization technology to obtain the YOLOv8n-MobileNet fusion model with ≤3M model parameters and inference latency ≤60ms / frame. S2. Model Compression and Quantization Optimization: Automatic structured pruning and mixed-precision dynamic quantization are applied to the fusion model. The optimal pruning rate is automatically determined through Bayesian hyperparameter search under the constraint of accuracy loss ≤8%, reducing the number of model parameters to 1.52M, GFLOPs to ≥50%, and mAP50 to 0.
801. The sensitivity-accuracy balance function is used to automatically allocate the quantization bit width, compressing the model size to ≤15MB. S3. Construct a bimodal PSNR privacy assessment system: Separate the region of interest (ROI) and the background region from the input image, calculate Face-PSNR and Background-PSNR respectively, and establish the privacy strength objective function Privacy_Score = α×(1 / PSNR_roi) + β×(1 / PSNR_global), where α=0.6 and β=0.
4. The optimal parameter combination satisfies Face-PSNR≈20dB and Background-PSNR∈[35,45]dB; S4. Dynamic desensitization processing: Gaussian blur and mosaic dual desensitization are adopted. Based on deformable convolution, an offset Δp is introduced to adaptively adjust the shape of the blur mask, and the blur area of occluded and side face samples is expanded by 15%. The optimal hyperparameter combination (k,σ,b,ε) is searched through Bayesian optimization. The objective function is Objective(k,σ,b,ε) = w1×mAP50 + w2×(1 / PSNR_roi)+ w3×Speed^(-1), where w1=0.5, w2=0.3, and w3=0.
2. S5. Scene-aware dynamic reasoning: Deploy MobileNetV3-small gated network to extract scene features, dynamically switch between YOLOv8n-base or YOLOv8n-enhance model configurations based on day / night and dense / sparse scenes, and automatically update the gate threshold through online learning. S6. Edge Device Deployment: The optimized model is converted to ONNX / TensorRT format, and ThreadPoolExecutor is used to implement a four-stage asynchronous pipeline for video acquisition, privacy desensitization, object detection, and result archiving. On a Raspberry Pi 4B 2GB version, the FP16 inference latency is ≤45ms / frame, memory usage is ≤200MB, power consumption is ≤3W, and 16 concurrent video streams are supported with an average latency of ≤180ms.
2. The method according to claim 1, characterized in that, The YOLOv8n-MobileNet fusion model in S1 is as follows: the backbone adopts the YOLOv8n CSPDarknet structure, the neck adopts the PAN-FPN feature pyramid, and the detection head is replaced with the MobileNetV4 ConvLarge UIB general inverse bottleneck structure. The number of parameters in the fusion model is 2.41M, and mAP50=0.859 on the WiderPerson dataset.
3. The method according to claim 1, characterized in that, The automatic structured pruning in S2 determines the optimal pruning rate through Bayesian hyperparameter search, reducing the number of model parameters to 1.52M and GFLOPs to ≥50% under the constraint of accuracy loss ≤8%.
4. The method according to claim 1, characterized in that, In S2, the dynamic quantization with mixed precision uses a sensitivity-precision balance function to automatically allocate the bit width, so that the backbone is quantized to 4 bits and the detection head is quantized to 8 bits, and the model size is compressed to ≤15MB.
5. The method according to claim 1, characterized in that, The bimodal PSNR evaluation system in S3 uses an OpenCV Haar cascade detector to locate the face ROI. The success rate against ArcFace recognition attacks is less than 5% when Face-PSNR≈20dB, as verified by testing with 1000 samples.
6. The method according to claim 1, characterized in that, In S4, the deformable convolutional dynamic desensitization introduces an offset Δp∈R^(H×W×18) into the standard 3×3 convolution kernel, reducing the mAP50 attenuation rate of occluded samples from 2.1% to 0.8%.
7. The method according to claim 1, characterized in that, The scene-aware dynamic inference in S5 uses MobileNetV3-small as the gating network with only 0.38MB of parameters. In sparse daytime scenes, the YOLOv8n-base model is selected to reduce power consumption to 1.4W, while in dense nighttime scenes, the YOLOv8n-enhance model is selected to improve mAP50 by 3.2%.
8. The method according to claim 1, characterized in that, The edge device deployment in the S6 adopts an asynchronous pipeline four-thread architecture. The video acquisition thread (24), the desensitization processing thread (25), the target detection thread (26), and the result archiving thread (27) are executed in parallel. The dynamic batch_size adjuster (28) monitors memory usage and automatically reduces the batch_size from 4 to 2 when it exceeds 200MB.