Marigold, as an important traditional Chinese medicinal plant renowned for its therapeutic attributes in heat dissipation, detoxification, liver protection, facial enhancement, and promotion of eye health, has witnessed a surge in demand. The demand for marigold is steadily rising, necessitating the inevitable shift toward mechanized harvesting in the industrialization of marigold cultivation. Consequently, this study endeavors to assemble a novel dataset in southern Xinjiang, China, crucial for marigold production. The focus is on improving the YOLOv7 model by lightweighting and proposing a set of detection models applicable to marigold. Through the elimination of superfluous object detection layers in the YOLOv7 model, substitution of conventional backbone network convolution with DSConv, replacement of the SPPCSPC module with Simplified SPPF, and subsequent model pruning and then retraining. This study aims to address challenges related to the deployment of mobile devices on the marigold-picking robot and the realization of high real-time detection. The experimental results demonstrate that the enhanced YOLOv7 model exhibited exceptional precision and mAP0.5 in marigold detection, achieving 93.9% and 97.7%, respectively, surpassing the performance of the original YOLOv7 model. Notably, the GFLOPs are a mere 2.3, representing only 2.2% of the computational load of the original model. Moreover, the parameter has been reduced to 15.04M, representing only 41.2% of the original model. The attained FPS, reaching 166.7, signifies a noteworthy enhancement of 26.7% compared to the original model. This showcases exceptional precision and speed in marigold detection, providing a strong technical foundation for the efficient harvesting of marigolds.