To address concerns regarding walnut shell damage and inadequate sorting precision during the mechanized sorting of walnuts, a walnut automatic sorting machine was designed based on deep learning and experimental research. Initially, the rationality of the design was verified through experiment. Then, three deep learning semantic segmentation algorithms, namely PSPnet, U-net, and Deeplabv3+, were selected to train walnut detection models. Results indicated that the U-net algorithm proved to be the most effective, achieving a Mean Intersection over Union of 96.71% and a Mean Pixel Accuracy value of 98.52%. Finally, performance tests were conducted on the prototype machine, yielding results with an average sorting efficiency of 51.70 kg/h, an average loss rate of 6.50%, and an average accuracy of sorting walnuts of 92.98%. The findings can provide insights for future structural improvements and operational parameter optimization of walnut automatic sorting machines.