Background: Unmanned aerial vehicles (UAVs) are being widely used in many fields, such as national economy, social development, national defense, and security. Currently, the number of registered UAVs in China is far less than that of flying UAVs-the frequent occurrence of unsafe incidents. Objective: The phenomenon of UAVs flying undeclared and unapproved has caused more serious troubles to social public order and people's production and life. Methods: In this paper, to assist the public security department in detecting the phenomenon of UAV black flying, our team conducts a series of research based on the deep learning YOLOv5 (You Only Look Once) algorithm. Results: Firstly, the Vision Transformer mechanism is integrated to enhance the robustness of the model. Secondly, depth-separable convolution is introduced to reduce parameter redundancy. Finally, the SimAM attention-free mechanism and CBAM attention-free mechanism are combined to enhance the attention of small target UAVs. Conclusion: Through the analysis of UAV targets in video surveillance, the rapid identification of black-flying UAVs can be realized, the monitoring and early warning ability of UAVs in a specific area can be improved, and the loss of life and property of people can be reduced or saved as much as possible.