[31] in 2016, the YOLO algorithm revolutionized target detection by enabling classification and localization through neural networks. The YOLO series has evolved from YOLOv1 to the latest iteration, YOLOv8 [32; 33; 34]. YOLOv5 stands out for its compact size, high speed, and superior accuracy, leveraging the mature PyTorch ecosystem for deployment. The YOLOv5 family includes four variants: YOLOv5s, YOLOv5m, YOLOv5l, and YOLOv5x, with YOLOv5s6 being the lightest, at 14.4 MB [32; 33]. The main contributions of our research in this paper are  
* **The optimization of the YOLOv5s6 algorithm for yarn hairiness detection**, resulting in significant improvements in accuracy, especially for protruding and loop fibers, with a 5-6% increase in [EMAIL_ADDRESS] and an 11-12% improvement in [EMAIL_ADDRESS]:0.95. * **The integration of advanced modules** (C2f, Bot-Transformer, GeLU) for more effective defect detection, particularly in capturing and classifying complex hairiness in yarn images. * **Validation through k-fold cross-validation with 10 splits**, ensuring the model's robustness and consistent performance in detecting loops and protruding fibers. * **The complete and automatic characterization of yarn defects**, providing a comprehensive analysis and classification of defects like \"hairiness\" using advanced Deep Learning techniques. The use of AI, specifically deep learning (DL) techniques, in this work is justified by the capacity of this technology to overcome the limitations of traditional methods for detecting defects in yarns, especially for specific types of hairiness, such as loop fibers and protruding fibers. The main reasons why the automatic detection and characterization of yarn hairiness can be improved using artificial intelligence are as follows:  
* **Irregular Visual Characteristics of Hairiness Classes:** DL can handle complex features, such as the irregular shape of loop fibers and protrusion fibers, which are difficult for traditional methods. * **Accuracy and Adaptability:** DL adapts to different types of yarns, colors, and lighting conditions, offering greater flexibility than optical sensors or conventional methods. * **Simultaneous Classification:** allows the detection and classification of multiple defects (loop fibers and protruding fibers) in a single step, optimizing the time and resources. * **Superior Performance:** our improved algorithm (YOLOv5s6-Hairiness) showed significant improvements in metrics such as mAP and accuracy, outperforming commercial systems and standard YOLO variants. * **Scalability and Cost-Effectiveness:** DL-based solutions are more economical and portable than systems like USTER TESTER, which are very expensive and less flexible. * **Industrial Impact:** DL improves the quality of the final yarn and fabric, reducing defects, waste, and operational costs, in addition to enabling real-time inspection. This paper is organized as follows: Section 2 analyzes previous work on yarn and fabric analysis using improved deep learning algorithms and compares the developed system with existing ones. Section 3 describes the YOLOv5s6 architecture, the default network, and the proposed model, with a focus on the modified modules. Section 4 presents the experimental results and discussion. Finally, Section 5 provides conclusions and suggestions for future research. Below is a diagram, in Figure 3, that presents the main stages of the development of the research described in this article. The diagram ranges from the identification of the hairiness problem in textile yarns and the limitations of existing solutions, through the literature review and definition of the objectives, to the practical steps of preparing the data set, developing the optimized YOLOv5s6 algorithm, a detailed experimental analysis, and, finally, the conclusions and proposals for future work.