To address the typical structural defects that are prone to occur during the preparation and storage processes of thermal battery, experiments of battery image acquisition were designed based on X-ray computed tomography system. An improved Yolov5s network was employed to achieve high-precision automatic detection of typical defects. Through the discharge experiment of thermal battery, discharge performance curves of normal batteries and three defective batteries were constructed. The impact and mechanisms of different defects on the discharge performance were analyzed based on the voltage curve. By designing an automatic stitching scheme, the phenomenon of interlayer information overlap caused by the increase of cone angle in digital radiography images was suppressed. To address the issues of low image contrast and limited defect data in thermal battery imaging, the defect dataset was expanded using the designed image preprocessing steps and improving the contrast of the images. For subtle defects that are difficult to identify, the introduced multi-head self-attention mechanism in Transformer and the use of Focal Loss instead of cross-entropy loss function were employed to improve the recognition accuracy of subtle defects while ensuring the detection speed. The comparative experiment shows that the improved network model has higher recognition accuracy compared to Faster R-CNN, SSD, Cascade R-CNN, EfficientDet and the original Yolov5s network. The recognition accuracy of typical defects in thermal batteries can reach 98.7%.