In recent years, with the increasing demand for high-quality Dendrobii caulis decoction piece, the identification of D. caulis decoction piece species has become an urgent issue. However, the current methods are primarily designed for professional quality control and supervision. Therefore, ordinary consumers should not rely on these methods to assess the quality of products when making purchases. This research proposes a deep learning network called improved YOLOv5 for detecting different types of D. caulis decoction piece from images. In the main architecture of improved YOLOv5, we have designed the C2S module to replace the C3 module in YOLOv5, thereby enhancing the network’s feature extraction capability for dense and small targets. Additionally, we have introduced the Reparameterized Generalized Feature Pyramid Network (RepGFPN) module and Optimal Transport Assignment (OTA) operator to more effectively integrate the high-dimensional and low-dimensional features of the network. Furthermore, a new large-scale dataset of Dendrobium images has been established. Compared to other models with similar computational complexity, improved YOLOv5 achieves the highest detection accuracy, with an average mAP@.05 of 96.5%. It is computationally equivalent to YOLOv5 but surpasses YOLOv5 by 2 percentage points in terms of accuracy.