###### Abstract
They sorted defective beans from 72.5% (broken bean) to 98.7% (black bean) accuracies, and the difference in the accuracy rate of detection in defective beans led to poor generalization of the model. [PERSON] et al. [9] used a lightweight model with knowledge distillation (KD) and improved the accuracy of the training method to 91%, with the model parameters at only 256, 779. [PERSON] et al. [10] extracted 1000 pleasant coffee beans and 1000 defective coffee beans and used image processing and data augmentation to deal with the data. Next, they applied YoloV3 to divide good and bad beans which had a recognition rate of 94.63%. [PERSON] et al. [11] employed the CNN model based on KD, spatial-wise attention module (SAM), and SpinalNet [12] to achieve an accuracy rate of 96.54% on the F1 score. The recent progress in AI technology enables the labeling of data and the use of neural network design to allow the machine to automatically learn the data and the neural network to predict and make decisions based on the characteristics of the learned data. Although a deep convolutional neural network (DCNN) can accurately classify the images, it cannot be easily applied in embedded systems because its large Giga floating-point operations per second (GFLOPS) is the most popular method for model compression. Quantization [13] and pruning technology are the most popular methods for model compression. Quantization converts the weight of a floating-point type into an integer type to reduce the amount of model parameters and computing while maintaining the accuracy of the model. In [14], a model architecture design that reduces the amount of model parameters and computation and also uses quantization technology and has a good compression effect while maintaining the accuracy of the model is proposed. However, there are many pruning-related methods, but they are rarely compared with other methods, or these methods have better results depending on the dataset. Therefore, in [15], the effect of different pruning on past research data is measured, as results show that pruning can sometimes improve the accuracy but the effect is usually not more stable than when using a better model architecture. [PERSON] et al. [16] proposed an automatic pruning method, which does not need to set pruning standards and parameters. It is suitable for various neural network architectures and compares with other pruning methods that can effectively improve the compression ratio and reduce FLOPs. In [17], a network pruning method that can identify structural redundancy in CNNs and prune filters in selected layers with the most redundancy is proposed. Generally, accuracy or evaluation indicators are very important for model efficiency when using DCNN for prediction and decision-making. Furthermore, explainable AI (XAI) will be lacking when DL technology is utilized. Hence, when using DL in models with high accuracy, the complexity may be high, while the correlation and hidden information cannot be explained through accuracy. Thus, scholars usually have difficulty understanding the correlation between input and output and how the model achieves its purpose. As a result, the uncertainty remains if people blindly believe in the model's prediction. To solve this problem, XAI should be introduced to determine whether the prediction and evaluation of the decision making of the model based on certain characteristics are reasonable. Only in this way can the reliability of the model and quality detection be ensured in the future. To deal with the above issues, this paper proposes a lightweight deep convolutional neural network (LDCNN) to detect the quality of green coffee beans. First, the features of defective coffee beans through RGB images were extracted, and the model was employed to classify the beans. Next, rectified Adam (RA), lookahead (LA), and gradient centralization (GC) were utilized to train the optimization methods to improve the accuracy of the model, enabling the model to operate in embedded systems.