
Introduction
The current practice of anomaly detection in the textile industry predominantly relies on visual inspection by skilled workers, which, while effective, is subject to human error due to vision fatigue and inattention. The industry has been exploring alternative methods such as spectrum-based, statistics-based, and combined approaches to enhance efficiency and accuracy. However, these methods often come with stringent sample requirements and may not be suitable for all types of textiles. Despite the progress, the industry continues to face challenges in generalizing these systems across the vast range of fabric types and colors, and in integrating them seamlessly into the existing production lines without disrupting the workflow. In the pursuit of excellence in textile manufacturing, the detection of visual anomalies is crucial. This project is dedicated to developing a machine learning-based visual anomaly detection system to identify defects in fabrics, which can range from subtle pattern inconsistencies to noticeable flaws. The system is trained to learn from good samples to detect anomalies, offering a promising solution to the challenges of manual inspection and the limitations of other automated methods.Hardware Setup
For this project, we will use the latest Raspberry Pi 5 and the Raspberry Pi High-Quality Camera with a 6mm 3MP Wide Angle Lens. Fabrics can have a wide range of anomalies, from tiny pinholes to subtle variations in texture or color. High-resolution cameras provide detailed images that can improve the accuracy of defect detection algorithms, reducing false positives and negatives.







Data Collection
We are using a set of dust cloths as the fabric.

Data Collection Demo
Uploading Data to Edge Impulse Studio
We need to create a new project to upload data to Edge Impulse Studio.

Training
Go to the Impulse Design > Create Impulse page, click Add a processing block, and then choose Image, which preprocesses and normalizes image data, and optionally reduces the color depth. Also, on the same page, click Add a learning block, and choose FOMO-AD (Images), which finds outliers in new data, extracts visual features using a pre-trained model on the data, and a Gaussian mixture model (GMM). A Gaussian Mixture Model represents a probability distribution as a mixture of multiple Gaussian (normal) distributions. Each Gaussian component in the mixture represents a cluster of data points with similar characteristics. Thus, GMMs work using the assumption that the samples within a dataset can be modeled using different Gaussian distributions. Anomaly detection using GMM involves identifying data points with low probabilities. If a data point has a significantly lower probability of being generated by the mixture model compared to most other data points, it is considered an anomaly; this will output a high anomaly score. We are using an image size of 640x640, which is required for better model accuracy. Now click on the Save Impulse button.





Testing

Model Deployment
Next, navigate to the Deployment page, select Linux (AARCH64) as the deployment target, and click on Build at the bottom of the page. An eim model (an Edge Impulse packaged model) will be downloaded to the computer.