Aiming at the problem that existing convolutional neural network models are large in size and high in computation, which results in not being able to consider both detection rate and accuracy of power inspection UAVs, an ED-YOLO network based on model compression is proposed to achieve the target detection algorithm for UAV obstacle avoidance. The target detection algorithm is based on YOLOv4, which firstly adds a channel attention mechanism to the backbone network to improve detection accuracy without increasing the amount of computation. Secondly, the depth separable convolution is used to replace the traditional convolution in the feature pyramid part to reduce the amount of convolutional computation. Finally, the model compression strategy is used to trim the redundant channels in the network to reduce the model size and improve the model detection speed. Tests were conducted on the dataset independently constructed with 9 600 flight obstacles of power inspection UAV, the obstacle target average detection accuracy for ED-YOLO is reduced only by 1. 4% compared with that for YOLOv4, while the model size is reduced by 94. 9% , the amount of floating point operations is reduced by 82. 1% and the prediction speed is increased by 2. 3 times. Experiment results show that compared with various other existing methods, the ED-YOLO target detection algorithm based on model compression proposed in this paper has the advantages of high accuracy, small size and fast detection speed, and meets the requirements of obstacle avoidance detection for power inspection UAVs.