Skip to main content
European Digital Innovation Hubs Network

AI System for Anomaly Detection and Quality Control of Fabrics

AI System for Anomaly Detection and Quality Control of Fabrics banner
AI System for Anomaly Detection and Quality Control of Fabrics
Published at 14 October 2025 | Italy

General details

EDIHs involved

Customer

EDIH logo
Customer type: SME
Customer size: Small (10-49)
Customer turnover: € 6,5 Million

Services provided
Test before invest
Technologies
Artificial Intelligence & Decision support
Sensors & Vision Processing Systems
Sectors
Textiles

Challenges

The company Staff Jersey is interested in implementing anomaly detection systems for quality control of fabrics intended for sportswear, both large and small-diameter, with the goal of improving product quality, optimizing production processes and avoiding waste, while ensuring high performance and material reliability through continuous and automated monitoring.

Quality control is crucial in the textile sector because it ensures that materials meet high standards, avoiding defects that would compromise aesthetics and functionality. An effective system reduces costs, waste and returns, while also protecting the brand’s reputation.

Traditional inspection methods, which are predominantly manual, have numerous limitations: the activity is monotonous, subject to loss of attention and influenced by environmental conditions, leading to errors and low reproducibility. Even standard automatic systems, based on fixed rules or vision techniques not supported by AI, prove to be not so flexible and hardly adaptable to the variety and dynamism that characterize fabrics.

In recent years, AI has opened new perspectives: convolutional neural networks and deep learning techniques, that make it possible to detect and localize defects with greater accuracy. However, applying these to textiles is complex: the frequent variation of materials and patterns makes the concept of “normality” unstable, while the creation of annotated datasets represents a costly and poorly scalable obstacle.

Solutions

The main solutions studied by ER2Digit through the technology provider Centro Qualità Tessile (CQT) are:

  • Semi-synthetic data generation: to overcome the scarcity of annotated data, an algorithm capable of synthetically and automatically generating defective samples from images of compliant fabrics was employed; this procedure does not require manual labeling.
  • Dynamic updating of normality: the system addresses the challenges posed by the extreme variability of materials, textures, and fabric patterns using a reference-based approach. For each fabric change, an operator confirms that the first section of the fabric is compliant; the system then uses this section as a reference and dynamically updates its concept of normality; once updated, it can analyze the fabric in real time without further input from the operator.

Other peculiar features of the system provided by CQT include the ability to process ultra-high-resolution images in real time using a sliding window approach and the possibility of multi-scale processing to handle size-variability in the possible defects.

A simplified diagram of the analysis process for a single fabric patch through the proposed AI system is shown below (highlighting the inputs and outputs of the system for the analysis of a single window). The patch to be analyzed (query) is compared with reference patches derived from compliant fabrics, producing as output a map that allows the localization of any anomalies present.

Staff Jersey AI tool

A crucial phase is the definition of a test acquisition system that met the requirements of practicality and ease of installation, while at the same time ensuring an image quality sufficient enough to capture the main types of defects.

Results and Benefits

Through the implementation of this experimental TBI, the company has been able to quantify the concrete benefits provided by the AI-based tool in terms of speed, efficiency, and reduction of manual inspection hours, which can now be reallocated to other key tasks. Early results show an improvement in productivity and a reduction of repetitive, low value-added activities for operators.

The company has also assessed the potential for integrating an AI-based prototype into a pilot production line. The solution can be further tested and refined until it reaches a higher reliability level, making it suitable for large-scale deployment.

In addition, the creation of libraries of compliant and defective fabric patches has enabled the development of a structured knowledge base. This resource not only supports the company in ongoing quality control activities, but can also be shared with CQT to build a common database aimed at continuously improving the performance and scalability of the AI solution over time.

Preliminary experiments demonstrated that the system is capable of detecting anomalies with higher accuracy and at an earlier stage than traditional inspection methods. This translates into reduced production waste, fewer rejected lots, and improved consistency in product quality, generating both economic and environmental benefits.

Below are some examples of compliant patches extracted from images of compliant fabrics.

Staff Jersey fabric sample

Below are some examples of patches with synthetic anomalies, taken from compliant fabric images to which a synthetic defect has been applied.

Staff Jersey fabric sample

Furthermore, real defect examples were also analyzed, allowing the refinement of synthetic generation to make it more aligned with actual characteristics observed in fabrics.

There is also the possibility of combining images of real defects with compliant fabrics, thereby obtaining more realistic and representative samples. Below, there is a patch of compliant fabric in the first column, a patch of another fabric containing a real defect in the second column, and the result of the combination in the third column.

Staff Jersey fabric sample

Perceived social/economic impact

Economic impact:

  • Lower costs in the fabric inspection phase, since the operator is only involved when the automatic system is uncertain whether an anomaly should be tracked or tolerated.
  • Less material waste: the system continuously monitors fabrics during production. This reduces the risk of having to discard the entire batch, which can occur when inspection is delayed until after the machine has finished.
  • Greater precision in documenting the position of the detected anomaly: manually only the height of the defect along the fabric is recorded, whereas the automatic system also documents the position across the width of the fabric. This allows a better optimization of fabric use even if defects are present in some areas.

Environmental impact: reduced material waste and lower energy consumption; since anomalies are detected during production, it is possible to stop production earlier if a defect continuously reoccurs.

Social impact: possibility of eliminating low value-added activities from textile inspection.

Measurable data

Below is a list of the hardware equipment used:

  • Camera: GoPro HERO13 Black
  • Lens: Macro lens mod
  • Remote control: Remote camera controller

The camera was initially positioned in the center, far from the fabric, and then about 15 cm away from it, to frame an illuminated portion of material. For this purpose, the illuminator (an existing lamp within the system) was oriented in alignment with the camera so as to minimize shadows and undesired effects. The installation was carried out near the core of the machinery, thereby reducing visual artifacts due to fabric transparency, which would otherwise reveal external elements, such as operators, objects, and the surrounding environment.
The use of the macro lens allowed close-up shots (range 11–75 cm), ensuring adequate resolution for defect inspection. The camera was fixed to a structural part of the machine anchored to the ground, thus not subject to the rotation of the tubular machine. In this way, the fabric itself moves around the field of view, allowing the use of a single camera to capture the entire surface in real time.
The use of the remote control made it possible to take photos independently, while through the GoPro Quick app it was possible to configure the camera, check the framing, and download images in real time, even after the installation.
For automatic acquisition, the time-lapse mode at regular 5-second intervals was used, which allowed continuous sampling of production.

The automatic dataset generation process, essential for training the described model, follows a pipeline with the following main steps.

  • Extraction of compliant patches: multiple anomaly-free patches are derived from each acquired image of compliant fabric.
  • Introduction of synthetic defects: artificial defects are applied to some patches, generated by randomizing parameters such as shape, color, and texture, to simulate realistic anomalies, which are then realistically merged into the patches.
  • Automatic annotation creation: since the defects are inserted in a controlled manner, the corresponding segmentation mask (target) is automatically produced, without the need for manual labeling.

This strategy made it possible to obtain large, high-quality datasets with significantly reduced time and costs compared to a traditional annotation process, thus constituting a key element for the scalability of the proposed solution.

System Evaluation and Results

To evaluate the system's performance, we built a test dataset comprising 200 image crops (256x256 pixels). These crops were extracted exclusively from images not used during the model's training phase. The test set is composed of:

  • 100 defective samples (BAD Class): manually selected crops, each containing at least one real visual defect (e.g., tears, stains, irregularities in the fabric pattern, …); see Figure 1.
  • 100 normal samples (GOOD Class): visually intact fabric crops, representing standard production quality; see Figure 2.

 Figure 1. Some BAD samples from the test set.Figure 2. Some GOOD samples from the test set.

For each test sample, the model outputs an anomaly map with values ranging from 0 to 1. This map has the same dimensions as the input crop (256x256 pixels), where each pixel's value is proportional to the estimated probability of an anomaly in that specific region. High values indicate areas the model considers anomalous, while low values point to normal areas. To condense this two-dimensional map into a single numerical value, necessary for classifying the sample as defective (BAD) or not (GOOD), we calculate a specific percentile of the map's values. For the tests detailed in this document, we used the 97.5th percentile.

Classifying a sample as BAD or GOOD requires setting a threshold on the anomaly score: samples scoring above this threshold are flagged as defective, while the rest are considered intact. However, the optimal threshold heavily depends on the specific application context and system requirements (e.g., the acceptable trade-off between false negatives and false positives).

Therefore, we chose to evaluate the model's performance using threshold-independent metrics, which describe the system's behavior across all possible thresholds. The selected metrics are AUROC and AUPRC:

  • AUROC (Area Under the ROC Curve): The ROC curve plots the True Positive Rate (TPR, the fraction of correctly identified defective samples) against the False Positive Rate (FPR, the fraction of intact samples incorrectly flagged as defective) across various thresholds. The AUROC is the area under this curve, ranging from 0 to 1. A value of 0.5 corresponds to a random classifier (equivalent to a coin toss), whereas 1.0 indicates perfect class separation. Practically, AUROC can be interpreted as the probability that the system assigns a higher score to a randomly chosen defective sample than to a randomly chosen intact one.
  • AUPRC (Area Under the Precision-Recall Curve): The Precision-Recall curve illustrates the trade-off between precision (the fraction of samples flagged as defective that actually are) and recall (the fraction of actual defects successfully identified by the system) across different thresholds. The AUPRC is the area under this curve and also assumes values between 0 and 1. This metric is particularly insightful for real-world applications, as it provides a single-number summary of the system's ability to simultaneously minimize both false positives and false negatives.

The system recorded an AUROC of 99.93% and an AUPRC of 99.93%. These results indicate the model's capability to separate the two classes, assigning higher anomaly scores to defective samples while minimizing both false positives and false negatives across potential operational thresholds.

While threshold-independent metrics are our primary focus, we also evaluated the system's performance at a specific operational point using secondary metrics. We used the default threshold of 0.5 (since the anomaly score ranges from 0 to 1). Applying this threshold yields an accuracy of 99.50%.

Figure 3 shows two additional plots that are useful for effectively understanding the model's performance on the test set.

  • Figure 3 (a) illustrates the trends of the True Positive Rate (TPR) and True Negative Rate (TNR) as the anomaly threshold varies. Analyzing this curve helps identify the system's optimal operating point based on specific operational requirements.

Figure 3 (b) displays a boxplot of the anomaly score distributions for the two test dataset classes. This visualization intuitively highlights the separability between GOOD and BAD samples. The further apart and less overlapping the two distributions are, the better the system can sharply discriminate between intact and defective fabric.

Figure 3. (a) TPR & TNR over threshold on the anomaly score; (b) boxplot of the distribution of the anomaly scores for GOOD and BAD samples.

Figure 4 presents qualitative results for selected samples from the test set. For each displayed sample, the following elements are provided:

  • The original input image, marked with a red dot in the top-left corner if the ground truth is BAD, or green if it's GOOD.
  • The anomaly map (using the magma colormap) overlaid transparently on the input image.
  • The system's anomaly score as a percentage (0%–100%).

Figure 4. Some qualitative results on the test set. The first 3 rows show a total of 6 BAD samples, while the last row shows 2 GOOD samples.

DMA score and results - Stage 0

Staff Jersey’s average score shows it is already at a moderately advanced stage of its digital transformation process, outperforming above SMEs of the textile sector across Italy and Europe. The company’s current investments in digital technologies cover a wide range of business operations, with some space to increase its level of preparedness (in terms of plans and resources) in order to accommodate more sophisticated solutions. Staff Jersey uses most of the available mainstream technologies for its operations and looks forward to adopting disruptive technologies (i.e. AI), which is the core element of the EDIH service it applied for.

The company’s personnel has an increased level of digital skills, but needs a well planned and executed training programme and IT specialised professionals to support its potential. Data management capacities and data security are advanced but could further benefit from digital technologies that would bring the business intelligence needed in order to outperform competition.

Lessons learned

Do’s:

  • Aim for generalization early on. Designing algorithms that can adapt to different materials, lighting conditions, and defect types reduces the need for frequent retraining.
  • Start with a diverse dataset. Building the initial dataset with high variability (different textures, colors, and defect shapes) improves robustness and scalability.
  • Leverage synthetic data generation. Controlled creation of realistic anomalies is an effective way to expand datasets and reduce labeling costs.
  • Ensure modularity and flexibility in the acquisition setup. Easily adjustable hardware (camera position, illumination, etc.) simplifies deployment in different production environments.
  • Collaborate closely with operators. Their practical insights are essential to correctly define “normal” fabric behavior and validate system output.

Don’ts:

  • Don’t underestimate the importance of calibration. Variations in camera setup or lighting can dramatically affect performance if not standardized.
  • Don’t skip validation phases. Continuous testing on new fabrics ensures that the model remains accurate as production changes.

Other Information

Need support?

Consult our catalogue to locate the Eupopean Digital Innovation Hub nearest to you and accelerate your company's digital transformation.

Find my nearest EDIH