The study takes the target detection algorithm based on convolutional neural network (YOLOv5) as the optimization object, for the problem of limited sensory field existing in the standard convolution, a mask module conforming to the characteristics of the distribution of the effective sensory field is designed to adjust the convolutional kernel weights, and a kind of improved deformable convolution (MDC) is proposed, and the MDCYOLO detection model is constructed. Small and large target detection experiments are performed on the insulator dataset and Vis Drone2019-DET dataset, respectively. The experimental results show that the detection accuracy of MDCYOLO is greatly improved compared to Y0L0v5 using standard convolution, which also reduces the computation of the detection model and improves the detection speed. The detection accuracy of the MDCYOLO model outperforms that of other mainstream models, regardless of whether it performs small target detection or large target detection. The target detection optimization method based on improved convolutional neural network structure designed in this paper has obvious advantages in detection accuracy and speed.