Lightweight Transformer-Enhanced YOLOv11 for Real-Time Fabric Defect Detection: A Systematic Comparison with DETR-Based Architectures
Fabric defect detection is a critical task in automated textile quality inspection, where both high localization accuracy and fast inference are required, especially for small and irregular defects. Although recent YOLO-based detectors offer a favorable balance of speed and accuracy, their convolutional architectures primarily capture local features and are less effective at detecting defects that require broader contextual understanding. Transformer-based detectors improve global context modeling but typically introduce higher computational complexity. To balance this trade-off, this study proposes a lightweight hybrid detector, YOLOv11-Transformer, which integrates multi-head self-attention (MHSA) modules into the backbone and neck of YOLOv11. The model was evaluated on a fabric defect dataset of 4375 images covering four defect categories: holes, cuts, thread errors, and metallic contamination. Comparative experiments were conducted against YOLOv5, YOLOv8, YOLOv9, YOLOv10, YOLOv11, YOLOv11-DETR, and RT-DETR under unified training conditions, with additional efficiency benchmarks against YOLOv6 and YOLOv7-Tiny. The proposed model achieved the best mAP50-95 of 94.50%, outperforming the baseline YOLOv11 by 2.40 percentage points, while maintaining efficient inference at 14.2 ms per image (approximately 70 FPS) on an NVIDIA RTX 4060 GPU. These results indicate that lightweight attention integration can improve fine-grained defect localization while preserving a practical accuracy-efficiency trade-off for automated textile inspection.