In the actual production process of drugs, there are always surface defects such as foreign matters, lack of particles, drug body damage and other surface defects. These defects may affect the use effect of the product, or even cause huge accidents in the use process, resulting in the loss of life and property. Aiming at the problems of the application of deep learning model in the detection of surface defects of industrial products with few defect samples and low detection accuracy of small defects, one of the mainstream target detection algorithms, yolov5, is applied to drug detection scene. A one stage real-time defect detection system, RDD, with high accuracy, few labeled samples and fast detection speed, is proposed_ YOLOV5(Real-time Defects Detection_YOLOV5)。 Using the primary features of the original image for data enhancement, combined with attention mechanism and multi-scale feature fusion, the ability of backbone network to extract cross-channel semantic information is increased, and the high-level semantic information and low-level fine-grained information are fully integrated to improve the recognition effect of the model in small defect detection, and achieve high accuracy under the condition of limited samples. 6% map, 32 FPS.