Abstract:“Happy or not” is an important content of pistachio quality detection. Combined with computer vision and deep learning network, a detection method of automatic data balance was proposed to explore the influence of data balance on pistachio quality detection. Firstly, a detection method of automatic data balance was proposed to explore the influence of data balance on pistachio quality detection. According to the industry standard, pistachio data sets were divided into three categories: open, closed and quality defect. Secondly, the data was formed into two data sets, one was the data set without data balance, the other was the data set after data balance. AlexNet, GoogLeNet, ResNet50, SqueezeNet, ShuffleNet and Xception were used to classify two kinds of datasets. The results showed that the accuracy of the network was improved after data balance, the average testing accuracy rate of six networks was increased from 96.75% to 99.26%. The accuracy rate of test set of SqueezeNet was improved the most obviously, which was from 93.76% to 99.02%, ResNet50 prediction accuracy rate was the highest, reached 99.96%. The rationality of network was verified by visualizing the location of high weight regions. The data balance method constructed had the same promotion value for other agricultural products quality detection, and also had a certain reference for other image classification projects.