Building practical AI
Deepak Kumar Tiwari

Deepak Kumar Tiwari

Technology & AI Leader · Building practical systems

Multimodal inspection / Guide 96

Garment Visual Inspection Must Separate Fabric Defects from Capture Errors

Build garment visual quality inspection with controlled color, calibrated seam measurements, panel coverage, and uncertainty before a reviewer assigns rework.

Illustrative engineering guide. Examples are not client deployments, production-ready integrations, or evidence of measured results. Validate the design with your domain and security owners.

Reference workflow: Garment and capture manifest; Candidate surface defects; Color and seam measurements; Panel coverage harness; Quality reviewer disposition.
Reference workflow. Steps identify responsibilities, not necessarily separate agents. Branches and recovery paths are explained below. Open full-size diagram.

A hypothetical jacket inspection image contains a dark patch near the sleeve seam. An assistant labels it a dye defect and recommends rejecting the garment. In the next image, the patch moves because it was a shadow from a folded panel. The workflow has mistaken capture conditions for product quality. A reliable inspection packet separates possible defects from evidence that actually measures the relevant property.

Begin with candidate observations such as loose thread, seam waviness, missing button, or apparent shade variation. Each candidate needs a feature-specific measurement method and a human disposition. RGB images cannot establish fiber composition, tensile strength, hidden seam damage, or colorfastness. The goal is to help a quality reviewer locate and investigate issues, not to certify the garment from a photograph.

Fix the Capture Conditions

Identify style, size, colorway, production lot, specimen token, pattern revision, and approved reference sample. A legitimate contrast panel should not be treated as mismatched dye. The reference must be a released sample under a documented capture procedure, not the brightest catalog photograph available. Record whether the garment is flat, hanging, tensioned, steamed, or worn on a form.

Preserve camera and lens identity, lighting setup, exposure, white balance, image digest, capture time, and processing history. For conveyor video, retain presentation timestamps and extraction provenance through the FFprobe inspection facilities. Adjacent frames of one jacket are correlated; they do not increase the number of garments sampled from a lot. A missing conveyor interval should remain visible in the batch coverage report.

For spatial overlays, define top-left image pixels and a flat-table frame in millimeters, with axes along and across the garment’s declared orientation. OpenCV’s calibration tutorial distinguishes physical object points from image coordinates. A scale marker supports dimensions only under the relevant geometry assumptions. Folds, stretch, and height above the table can invalidate a simple planar conversion.

Color Management Is Not Color Measurement

Record the image encoding and the exact transform configuration used for viewing. OpenColorIO’s usage guide describes configuration-driven transforms and warns that configuration checking cannot verify that transforms are correct. A technically valid transform cannot recover clipped channels or infer the original illuminant. Consistent viewing is necessary for review but insufficient for a physical shade acceptance claim.

Use controlled illumination, reference targets, and an appropriate calibrated instrument when contractual shade evaluation requires one. If a specialist returns a color difference, store the named formula, illuminant, observer convention, sampling locations, and uncertainty. Do not label an arbitrary RGB Euclidean distance as a standardized color difference. The first harness can simply abstain on shade when those dependencies are absent.

For seams, a measurement adapter can estimate distance from the approved seam path after registering the flat panel. Record which path segments were visible and how uncertainty includes localization, scale, and fabric placement repeatability. A folded segment is unknown, not straight. Pattern registration should not nonrigidly warp every observed seam onto the reference and thereby erase the defect being measured.

A Panel-Level Measurement Fixture

This self-contained Python example tests the HARNESS with synthetic structured measurements and metadata. It does not test a trained vision model, camera, color instrument, CAD engine, or real garment inspection performance. The two millimeter seam budget is an illustrative policy value. Color readiness is represented only as provenance metadata, not a computed color-quality score.

from math import isfinite

required = {"front", "back", "left-sleeve", "right-sleeve"}
base = dict(style="J4-r2", capture="light-A-v3", color_known=True,
            visible=required.copy(), seam_mm=0.8, bound_mm=0.3)

def inspect(row):
    if row["style"] != "J4-r2" or row["capture"] != "light-A-v3":
        return "capture-review"
    if not row["color_known"]:
        return "shade-unknown"
    if not required <= row["visible"]:
        return "coverage-unknown"
    d, u = row["seam_mm"], row["bound_mm"]
    if not all(isfinite(v) and v >= 0 for v in (d, u)):
        return "measurement-unknown"
    if d - u > 2:
        return "seam-review"
    return "packet-ready" if d + u <= 2 else "uncertain"

assert inspect(base) == "packet-ready"
assert inspect(dict(base, color_known=False)) == "shade-unknown"
assert inspect(dict(base, visible={"front", "back"})) == "coverage-unknown"
assert inspect(dict(base, seam_mm=3)) == "seam-review"
assert inspect(dict(base, seam_mm=1.9)) == "uncertain"
assert inspect(dict(base, capture="phone-auto")) == "capture-review"
print("six synthetic garment checks passed")

Packet readiness means the example’s required metadata and seam interval are available, not that shade or overall quality passed. The visibility set is deliberately small; a production inspection plan should subdivide panels into meaningful regions and include closures, labels, lining, and seams where required. A whole-panel visibility flag is insufficient if a pocket obscures the exact feature being inspected.

All numerical measurements require a documented uncertainty method. The supplied bound is not derived from a model confidence score. Repeat placement of the same garment can change seam geometry, so quantify fixture repeatability rather than assuming a single calibration target solves the entire problem. Unknown calibration, motion blur, and clipped highlights should produce explicit recapture reasons.

Rework Is a Separate Decision

The reviewer sees original and normalized views, reference sample identity, measurement intervals, and a coverage map. They can distinguish a loose thread suitable for local repair from a suspected shade issue requiring another method. Never automatically reject an entire lot because several frames of one garment show the same candidate. Lot-level decisions require an approved sampling plan and accountable quality ownership.

Scope access server side to the brand, supplier, and inspection role. Images may contain workers or customer-specific designs; minimize unrelated personal content and prohibit identity or productivity judgments. OCR from labels is untrusted input. The assistant may draft a finding but cannot alter supplier payment, inventory availability, or a rework order without approval and an authenticated business workflow.

On a timed-out ticket write, reconcile by specimen, region, reference revision, and evidence digest before retrying. A replacement image should supersede, not erase, the earlier observation. Retail replenishment workflows need accurate availability, but they should consume an authorized inventory disposition rather than a visual model’s unsupported reject label.

Acceptance Tests and Evaluation

  • Move a lighting shadow while holding the specimen fixed; classify the disagreement as capture-related until supported otherwise.
  • Inspect a contrast-panel style against a plain style reference; reject the identity mismatch before reporting shade defects.
  • Hide the back panel; preserve unknown coverage even if the front has no candidates.
  • Supply an untagged image encoding; shade remains unknown rather than defaulting to a convenient color space.
  • Place the seam interval across the example tolerance; request review without rounding into acceptance.
  • Repeat one garment across many frames; the lot sample count remains one specimen.

Baseline against blinded quality reviewers under the approved inspection setup, with instrument-backed adjudication for measurable properties. Report confirmed findings divided by all escalations, missed adjudicated defects divided by all adjudicated defects, and covered required regions divided by all required regions. Track unnecessary rejection recommendations as a business guardrail. Stratify by fabric texture, colorway, and capture session, not just overall accuracy.

Start with one flat garment style and one measurable seam defect. Three-dimensional garment collision validation examines digital simulation, which does not certify manufactured fabric. The first AI systems engineering milestone should be consistent evidence capture and a reviewer-owned disposition loop, with shade abstention working before more defect classes are added.

Sources