The quality and efficiency of photovoltaic power generation are closely related to the excellent performance of solar panels.Using defective panels may reduce power generation efficiency and product lifespan, and even lead to serious safety accidents .Therefore, strict defect detection is necessary before the photovoltaic panels leave the factory.This paper proposes a detection algorithm based YOLOv5 for Photovoltaic panel inspection.By combining a linear bottleneck inverted residual structure with an efficient pyramid split attention module called EPSA, the computational and parameter requirements are reduced. Additionally, by enhancing the optimization of Ghost convolution and deep convolution, the computational load is further reduced. The balanced cross-entropy loss function and non-maximum suppression method are combined to investigate multiple small target defect detections. Comparison experiment results on the defect dataset of photovoltaic cells demonstrate that the accuracy (P) of the enhanced algorithm has increased by 6.30%, and the average accuracy (mAP) has increased by 9.40%.The proposed model effectively identifies photovoltaic cell defects, fulfilling the criteria for photovoltaic panel inspection, and showing promising application prospects.