TMCNet: A few-shot defect segmentation method based on triplet-based feature enhancement and multi-scale cascaded decoding

Zilin Xia, Yufan Zhao, Hongyu Xiang, Jinan Gu, Libin Zheng, Wenbo WangJ. King Saud Univ. Comput. Inf. sci 2025

In high-stakes industrial manufacturing, identifying surface defects like cracks or stains is critical for quality control. However, deep learning models typically require vast amounts of annotated data, which is often unavailable for rare defects. To address this "data drought," a new framework called TMCNet has been introduced in the Journal of King Saud University - Computer and Information Sciences. TMCNet is a few-shot segmentation (FSS) method capable of identifying and delineating defects using as little as a single training example.

Challenges in Industrial Defect Segmentation

Traditional deep learning models are notoriously data-hungry. In factory environments, rare defects may only have a handful of documented examples, making standard training impossible. Few-shot segmentation aims to bridge this gap by using a "support" image to identify similar defects in a "query" image. However, industrial defects present unique hurdles that standard FSS models often fail to clear.

Figure 1: Key challenges in industrial few-shot defect segmentation, including subtle inter-class distinctions and high intra-class diversity.

As illustrated in Figure 1, these challenges include:

  1. Subtle Inter-class Distinctions: The visual difference between a harmless surface texture and a structural defect can be extremely fine.
  2. Large Scale Variations: Defects range from microscopic pinholes to extensive scratches.
  3. High Intra-class Diversity: Defects of the same category (e.g., "scratches") can look vastly different depending on lighting and material properties.

The TMCNet Framework

TMCNet employs a dual-branch architecture (Support and Query) integrated with three innovative components designed to capture both fine-grained details and global context.

1. Triplet-Based Feature Enhancement (TBFE)

The TBFE module utilizes a "HiLo" attention mechanism to process features from three distinct perspectives: salient characteristics (obvious features), local fine-grained details (textures), and global contextual dependencies. This ensures the model understands how a defect relates to its surrounding surface.

2. Multi-Receptive Field Enhancement (MRFE)

To handle extreme variations in defect scale, the MRFE module uses dilated convolutions with varying rates (1, 3, and 5). This allows the network to maintain a broad receptive field without sacrificing spatial resolution, effectively "seeing" defects at multiple scales simultaneously.

3. Multi-Scale Cascaded Decoder (MSCD)

Rather than generating a segmentation mask in a single step, TMCNet uses a top-down refinement strategy. The MSCD fuses preliminary predictions from multiple network layers, allowing high-level semantic information to guide the precise detection of low-level edges.

Experimental Results and Insights

The model was evaluated on two challenging benchmarks: FSSD-12 (12 types of industrial surface defects) and Surface Defects-4i (covering leather, rail tracks, and aluminum). Using a three-fold cross-validation strategy, TMCNet demonstrated superior generalization to unseen defect categories.

  • State-of-the-Art Performance: On the FSSD-12 benchmark (1-shot), TMCNet achieved a 67.8% mIoU, outperforming previous leaders like MAPTNet and SCCAN by 2.0%. On Surface Defects-4i, it reached 42.3% mIoU, a 3.1% improvement over the runner-up.
  • Precision and Focus: Qualitative analysis using Grad-CAM visualizations showed that TMCNet maintains a tighter focus on actual defect regions, avoiding the blurred boundaries or missed small-scale defects common in baseline models.

Future Directions

While TMCNet sets a new standard for few-shot defect segmentation, the authors identified areas for further improvement. Future work will focus on model compression to facilitate real-time deployment on edge devices and the development of edge-aware loss functions to further sharpen defect boundaries. Additionally, addressing "adjacency issues"—where distinct small defects are merged into a single blob—remains a priority for refining industrial inspection systems.

Summary updated

BibTeX
@article{xia2025tmcnet,
  author = {Zilin Xia and Yufan Zhao and Hongyu Xiang and Jinan Gu and Libin Zheng and Wenbo Wang},
  title = {{TMCNet: A few-shot defect segmentation method based on triplet-based feature enhancement and multi-scale cascaded decoding}},
  journal = {J. King Saud Univ. Comput. Inf. sci},
  year = {2025},
  doi = {10.1007/s44443-025-00360-4},
}
Figure