Fabric anomaly detection is a crucial application in the industry. This study identifies the optimal YOLO (You Only Look Once) algorithm from a selection of YOLO versions for detecting fabric anomalies, including defect identification and region localization. Recent YOLO models, including YOLOv5, YOLOv7, YOLOv8, and YOLOv9, are evaluated with batch sizes of 4, 8, and 16. Additionally, computation times for detection are compared. The dataset is generated from numerous images extracted from a fabric video, with test images categorized as normal, line defect, or hole defect. Experimental results show that YOLOv9 batch 4 achieves the highest F1-score for defect detection, while YOLOv8 batch 16 offers a balance of optimal mAP and reduced training time. Larger batch sizes consistently enhance training efficiency across all models. Further experiments can extend this approach to other fabric datasets to detect various types of defects.