# Classification of Defective Fabrics Using Capsule Networks
## 1 Introduction  
Quality and inspection of the fabric in the textile sector is a particular phase in terms of cost and time. The quality of the fabric requires the fabric to be flawless. In this connection, defective fabrics significantly affect the quality. Fabric is fabricated from textile fibers, a commonly used material in the textile industry. Over a hundred defect types can occur in the manufactured respective fabric material [1]. Defective fabrics increase the cost price by 45-60% [2]. Due to increasing costs, textile industries are forced to create new solutions such as automatic fabric defect inspection systems that reduce fabric defects to significantly lower rates. Traditional methods for automatic fabric defect detection explain the models in which fabric feature sets rely on human senses. Traditional methods show promising results for a particular fabric type. However, these models need to be redesigned for new fabric types. Traditional methods require expertise as they are based on human inspection. Since human-based determination has a limited capacity, traditional fabric defect detection methods result in relatively high error rates and loss of time. As an alternative to traditional approaches, modern quality inspection systems that make use of approaches such as machine learning, deep learning, and most machine vision systems have been attracting considerable attention in the scientific field, as well as the textile industry itself. These systems are generally able to provide better accuracy rates [3]. Modern quality inspection approaches have succeeded in accomplishing great results and have demonstrated their convenience for the detection of fabric defects. Deep learning algorithms, mainly Convolutional Neural Networks (CNN), have a powerful learning ability that can learn the key depth features both adaptively and intelligently. This ability makes fabric defect detection systems more suitable for various defect types. The deep structure of CNN stores the entire input information that represents the defective fabric image. Storing entire representative information contributes to the detection of defect types with higher output performance. Although CNN has many advantages, it can still have shortcomings that sometimes affect the output. For example, it does not store important information such as orientation, rotation, dependency in related internal feature transfer, or spatial information in the image at the desired level. To overcome these shortcomings, the [PERSON] group invented Capsule Networks (CapsNets), a new model that develops the model hierarchical relationships inside the internal knowledge of network representation [4]. Since their introduction in 2017, there has been an increase in deep learning employing CapsNets as their core building blocks. The popular version of CapsNets uses routing by agreement algorithms between different layers. This algorithm replaces pooling in CNNs and a vector output replacing scalar outputs in CNNs. The magnitude of the output vector represents the likelihood that a feature being represented by the capsule exists in the input image, whereas the orientation of the entity represents the instantiation parameter values. CapsNets are promising in terms of improving our socio-economic activities as they can be deployed to solve real-life problems in autonomous cars [5], machine translation [6], text recognition [7], and image recognition [8]. In this paper, the main purpose is to use CapsNets algorithm in the detection of fabric defects. Depending on this purpose, CapsNets [4; 9] is used to classify fabric defects as non-defective, holes, thread, stain, weave, shaded, knitting. The main contributions of this study are summarized as follows:  
* We proposed the use of CapsNets for fabric defect detection purposes, which has the advantage of storing whole information about the input. * In a similar research domain, CapsNets can be applied for various types of textures and fabric defects.