With the development of technology, unmanned aerial vehicles (UAVs) are playing an increasingly important role in the inspection of high-voltage power transmission line. The traditional inspection method relies on the operator to manually control the drone for inspection. Although many companies are using real-time dynamic carrier phase differencing technology to achieve high-precision positioning of UAVs, when UAVs fly autonomously at high altitudes to photograph specific objects, the objects tend to deviate from the center of the picture. To address this error, in this paper, an autonomous UAV inspection system based on object detection is designed. (1) To detect inspection objects, the corresponding dataset is established on the basis of the UAV autonomous inspection task. (2) To obtain the position information of the target object, a lightweight object detector based on the YOLOX network model is designed. First, the backbone is replaced with MobileNetv3. Next, in the neck structure, the Ghost module is introduced and depthwise convolution is applied instead of normal convolution. Then, to embed the location information into the channel attention, coordinate attention is introduced after the output feature layer of the backbone, enabling the lightweight network to operate on a larger area of focus. Finally, to improve the accuracy of the bounding box regression, the α-DIOU loss function is introduced. (3) To obtain the best image acquisition position, the results of object detection combined with the real-time status of the UAV are used. (4) To enable the UAV to complete the final corrections, position control and altitude control are used. Compared to the original YOLOX tiny, the new model improves the mAP_0.5:0.95 metric by about 2 percentage points, with a significant reduction in the number of parameters and computation, while running at 56 FPS on Nvidia NX. This system can effectively solve the problem of the target deviating from the center of the picture when the UAV takes pictures during a high-altitude autonomous inspection, verified by many actual flight experiments.