Traditional methods of separating defective cucumbers are inherently labor-intensive and time-consuming. However, with the emergence of intelligent farming practices, deep learning algorithms, particularly in the fields of image processing and machine vision, have demonstrated significant potential to address this challenge. The main objective of this research study is to develop a deep learning-based algorithm capable of classifying cucumbers into three distinct categorical groups based on their visual characteristics: defective, curved, and sound (straight green). For this purpose, in addition to inspect the more accurate InceptionResNetV2 as transfer learning method, the modified convolutional neural network (MCNN) incorporating global average pooling (GAP) was proposed to streamline the architecture and minimize trainable parameters. The results demonstrate that the accuracy of CNN with GAP layer outperforming the fully connected layer (FCL). The accuracies for the proposed CNN with GAP, proposed CNN with FCL, and InceptionResNetV2 were 94.14%, 92.92%, and 91.21%, respectively, highlighting the efficiency of the CNN with GAP in cucumber classification and its potential to replace conventional grading methods. The overall results indicated that the implementation of dropout did not yield any improvements for the developed models. Rather, the best performance of the convolutional neural networks (CNNs) was achieved when utilizing 64 neurons in the hidden layer.