Portfolio  ›  Research  ›  MS Thesis
MS Thesis Computer Vision Deep Learning Python

Fabric Defect Detection
using Deep Learning

A deep learning approach to automated textile quality control. By synthesising the defect data that factories cannot practically collect, the method reaches above 98% accuracy across ten defect classes — outperforming SVM, Random Forest and a baseline CNN on the same task.

Author: Irfana Aslam  ·  Reg: CIIT/FA21-RCS-023/SWL
Supervisor: Dr. Muhammad Shoaib, Assistant Professor, Department of Computer Science
Institution: COMSATS University Islamabad, Sahiwal Campus  ·  Submitted: July 2023
>98%Detection accuracy
100,000Images generated
10Defect classes
3Baselines outperformed
📄 Request the Full Thesis 📝 Publication Status
The Problem

Human inspectors cannot win this task

Textile quality control still depends largely on people watching fabric travel past on a production line. The thesis opens on the reason this fails: fatigue and inattentiveness are structural, not occasional. An inspector's accuracy degrades over a shift regardless of skill or diligence, and fabric does not slow down to accommodate it.

The cost of a miss is disproportionate. A defect that slips through does not affect one metre — it propagates through an entire roll, and the loss lands directly on the manufacturer's margin. That asymmetry is what makes automated inspection economically compelling, and it is why the problem has attracted two decades of computer vision research.

🔍 The real obstacle: the data, not the model

Reviewing prior work (auto-encoders, Fisher-criterion encoders, AlexNet transfer learning, regional CNNs, U-Net, multi-scale CNNs, attention mechanisms) surfaced a consistent pattern: strong reported accuracies, but each constrained to a narrow set of defect classes or a single fabric pattern. The binding constraint was rarely the architecture — it was the dataset. Defects are rare by definition, so real-world collections are small, imbalanced and inconsistently labelled. You cannot train a general defect classifier on data that barely contains defects.

The Approach

Generate the rare cases you cannot collect

Rather than accept a small imbalanced dataset, the thesis inverts the problem: build a generator that injects realistic synthetic defects into pristine fabric images, with controlled variation across defect type, size, shape, orientation and environmental conditions. This produces labelled data at a scale and balance that real collection cannot reach — 100,000 images across ten defect classes, with ground-truth labels free by construction.

The ten classes cover the failure modes that matter commercially in textile production — structural breaks, surface wear, colour faults and weave irregularities. (The exact class taxonomy and generation parameters are withheld pending publication.)

🧪 Dataset Generation

  • Synthetic defects injected into clean template fabric images
  • Controlled variation: type, size, shape, orientation, lighting
  • 100,000 labelled images across 10 defect classes
  • Labels are exact by construction — no annotation noise
  • Evaluated against a held-out set containing real fabric images too

⚙️ Preprocessing

  • Fixed-size resizing and channel normalisation
  • Geometric augmentation to broaden the training distribution
  • Standardises input and introduces the variation needed to generalise
  • Exact parameters withheld pending publication

📐 Training Setup

  • Standard train/test split with a held-out evaluation set
  • Adaptive gradient optimisation with weight decay
  • Dropout regularisation to control overfitting
  • Loss tracked per epoch across training
  • Exact hyperparameters withheld pending publication
Publication Status

Method & results held back

📝 Journal manuscript in preparation

A paper based on this thesis is currently being prepared for submission. Publishing the full method and results here first would count as prior disclosure and could compromise the submission — so this page deliberately stops short of them.

Withheld until publication: the model architecture, hyperparameters and preprocessing pipeline; the benchmark comparison table; per-class precision, recall and F1 figures; all thesis figures; and the full thesis document.

Shared here: the problem, why the data was the real obstacle, the shape of the approach, and an honest account of the limitations — enough to judge the work without giving it away.

Supervisors, reviewers and prospective employers are welcome to the complete thesis and results — request access and I'll send them directly.

What can be said about the outcome

The trained model exceeded 98% detection accuracy across all ten defect classes, outperforming Support Vector Machine, Random Forest and a baseline convolutional network evaluated on the same task and the same data.

Performance held up consistently across classes rather than being carried by a few easy ones. The hardest class was wrinkle — unsurprising, since wrinkles deform the underlying pattern rather than adding a discrete artefact, which makes them difficult to separate from legitimate fabric drape. Localised structural breaks with sharp boundaries were the easiest to detect.

Honest Assessment

Limitations & what I would do differently

The synthetic-to-real gap

Limitation

The dataset's greatest strength is also its central caveat. Synthetic defects are generated from a parameterised model of what a defect looks like, so the classifier learns that model — not necessarily the full messiness of real production faults. Evaluation included real fabric images, but a rigorous domain-gap study measuring performance on real-only data at scale would strengthen the claim considerably.

What I would do now

Report real-only and synthetic-only test accuracy separately, and add a domain adaptation stage. If I were revisiting this today I would also compare against a diffusion-based defect generator rather than parametric injection.

Class balance and metric choice

Limitation

The underlying problem is heavily imbalanced — non-defective fabric vastly outnumbers defective in reality. Accuracy is a weak metric under imbalance, which is why precision, recall and F1 are reported per class. Even so, a precision-recall curve and confusion matrix would communicate the failure modes more honestly than a single headline number.

What I would do now

Lead with per-class PR curves and a confusion matrix, and report the operating threshold explicitly. In an industrial setting, recall on defects matters far more than overall accuracy — a false alarm costs a second look, a miss costs a roll.

Scope of fabric types

Limitation

The template-matching stage assumes a known reference pattern. That works well for repeating printed designs but is less applicable to irregular weaves, stretch fabrics under tension, or fabrics whose pattern legitimately varies.

What I would do now

Move toward a reference-free anomaly detection formulation — reconstruct the expected texture and flag deviation — so the method generalises past patterned fabric.

No deployment measurement

Limitation

The work establishes offline accuracy but does not measure inference latency on production hardware or validate throughput against real line speeds. A model that is accurate but too slow for the conveyor is not a solution.

What I would do now

Benchmark inference time per frame, quantise the model, and state the maximum sustainable line speed — the number a factory actually needs before it will consider adopting anything.

Technologies

Tools used

Deep Learning
PythonCNNDropoutData augmentation
Computer Vision
Image preprocessingTemplate matchingTexture analysis
Baselines
SVM (RBF)Random ForestCross-validation
Evaluation
Precision / Recall / F1Per-class metricsCSV reporting

Research collaboration?

This thesis is where my computer vision work began. I'm open to PhD opportunities and research collaboration in computer vision, anomaly detection, generative data synthesis and multi-agent LLM systems.