This study proposes a method for improving the performance of CNN models by adding branches based on the number of classes in the dataset. Three popular CNN models, VGG16, Inception10, and ResNet18, are used as the base models for our approach. Experiments are conducted on the CIFAR-10, CIFAR-100, and DB-MHDI Dataset to validate the feasibility and effectiveness of the proposed method. Results show that, on the CIFAR-10 dataset, the performance of the branch-added models is comparable to that of the original VGG16 model, while the accuracy of the ResNet18 and Inception10 models is improved by 1.799% and 3.981%, respectively. On the CIFAR-100 dataset, the accuracy of the ResNet18 and Inception10 models is improved by 6.671% and 0.399%, respectively. On the DB-MHDI Dataset, our method also achieves improvements in classification performance. These results demonstrate that our approach can effectively enhance the classification performance of CNNs and has broad application prospects. This study provides new ideas for the design of CNNs for image classification tasks and can serve as a reference and inspiration for future research in deep learning.