Aiming at the problem of crop pests and diseases in agricultural production, this paper implements an identification algorithm of crop pests and diseases based on improved DenseNet model to achieve real-time detection of crop pests and diseases and early warning. Based on the DenseNet neural network, the crop dataset is first subjected to image processing and augmentation such as Canny edge detection, flipping, convolution and blurring, and the resulting dataset is used to train the DenseNet model. Moreover, the innovative addition of a pooling layer and a fully-connected layer to the DenseNet allows the model to obtain accurate identification results of crop health conditions with corresponding probabilities. The algorithm was tested on Plant Pathology 2020 - FGVC7, and the experimental results show that it is faster than traditional recognition algorithms, with a correct recognition rate of 96.7%, which can quickly and accurately diagnose crop pests and diseases and effectively improve crop yield and quality.