Objective To address the challenges in detecting tomato leaf diseases and pests, such as complex environments, small goals, low precision, redundant parameters, and high computational complexity, a novel lightweight, high-precision, real-time detection model was proposed called YOLOv10n-YS. This model aims to accurately identify diseases and pests, thereby providing a solid scientific basis for their prevention and management strategies. Methods The dataset was collected using mobile phones to capture images from multiple angles under natural conditions, ensuring complete and clear leaf images. It included various weather conditions and covered nine types: early blight, leaf mold, mosaic virus, septoria, spider mites damage, yellow leaf curl virus, late blight, leaf miner disease, and healthy leaves, with all images having a resolution of 640×640 pixels. In the proposed YOLOv10n-YS model, firstly, the C2f in the backbone network was replaced with C2f_RepViTBlock, thereby reducing the computational load and parameter volume and achieving a lightweight design. Secondly, through the introduction of a sliced operation SimAM attention mechanism, the Conv_SWS module was formed, which enhanced the extraction capability of small target features. Additionally, the DySample lightweight dynamic up sampling module was used to replace the up sampling module in the neck network, concentrating sampling points on target areas and ignoring backgrounds, thereby effectively identifying defects. Finally, the efficient channel attention (ECA) was improved by performing average pooling and max pooling on the input layer to aggregate features and then adding them together, which further enhanced global perspective information and features of different scales. The improved module, known as efficient channel attention with cross-channel interaction (EMCA) attention, was introduced, and the pyramid spatial attention (PSA) in the backbone network was replaced with the EMCA attention mechanism, thereby enhancing the feature extraction capability of the backbone network. Results and Discussions After introducing the C2f_RepViTBlock, the model's parameter volume and computational load were reduced by 12.3% and 9.7%, respectively, with mAP@0.5 and F1-Score each increased by 0.2 percentage and 0.3 percentage. Following the addition of the Conv_SWS and the replacement of the original convolution, mAP@0.5 and F1-Score were increased by 1.2 percentage and 2 percentage, respectively, indicating that the Conv_SWS module significantly enhanced the model's ability to extract small target features. After the introduction of DySample, mAP@0.5 and F1-Score were increased by 1.8 percentage and 2.6 percentage, respectively, but with a slight increase in parameter volume and computational load. Finally, the addition of the EMCA attention mechanism further enhanced the feature extraction capability of the backbone network. Through these four improvements, the YOLOv10n-YS model was formed. Compared with the YOLOv10n algorithm, YOLOv10n-YS reduced parameter volume and computational load by 13.8% and 8.5%, respectively, with both mAP@0.5 and F1-Score increased. These improvements not only reduced algorithm complexity but also enhanced detection accuracy, making it more suitable for industrial real-time detection. The detection accuracy of tomato diseases and pests using the YOLOv10n-YS algorithm was significantly better than that of comparative algorithms, and it had the lowest model parameter volume and computational load. The visualization results of detection by different models showed that the YOLOv10n-YS network could provide technical support for the detection and identification of tomato leaf diseases and pests. To verify the performance and robustness of the YOLOv10n-YS algorithm, comparative experiments were conducted on the public Plant-Village-9 dataset with different algorithms. The results showed that the average detection accuracy of YOLOv10n-YS on the Plant-Village dataset reaches 91.1%, significantly higher than other algorithms. Conclusions The YOLOv10n-YS algorithm is not only characterized by occupying a small amount of space but also by possessing high recognition accuracy. On the tomato leaf dataset, excellent performance was demonstrated by this algorithm, thereby verifying its broad applicability and showcasing its potential to play an important role in large-scale crop pest and disease detection applications. Deploying the model on drone platforms and utilizing multispectral imaging technology can achieve real-time detection and precise localization of pests and diseases in complex field environments.