---
title: DFNet for Industrial Defect Classification
url: https://www.emergentmind.com/topics/d3fnet
type: topic
---

# DFNet for Industrial Defect Classification

D3FNet, in the context of industrial inspection, corresponds to the model formally named **DFNet** in the paper “Decision Fusion Network with Perception Fine-tuning for Defect Classification” [2309.12630]. DFNet is a two-stage network for surface defect classification in which a segmentation stage produces defect-focused semantic and feature representations, and a classification stage fuses them to make the final decision. Its design addresses three difficulties emphasized in the paper: background interference, low-contrast defects, and label edge uncertainty. The method combines a **Decision Fusion Module (DFM)**, a **Perception Fine-tuning Module (PFM)**, and an **inner-outer separation weight matrix** for segmentation supervision, and it is reported on publicly available datasets including KolektorSDD2 and Magnetic-tile-defect-datasets [2309.12630].

## 1. Task setting and motivating failure modes

DFNet is proposed for **industrial surface defect classification**, namely deciding whether an image of a surface is defective or defect-free and, in the magnetic tile setting, which defect category it belongs to [2309.12630]. The motivating examples include electrical commutator imagery in KolektorSDD2 and magnetic tile imagery in Magnetic-tile-defect-datasets.

The paper isolates three recurrent causes of misjudgment. The first is **background interference / background-like defects**: some background patterns are visually similar to defects, especially when defects are small, and complex, uneven backgrounds with random lighting and texture can look defect-like. The stated consequence is false positives, in which a normal image is falsely labeled as defective. The second is **low-contrast defects**: fine scratches and other subtle anomalies are visually submerged in the background, their edges are blurred, and the classifier may miss them, producing false negatives. The third is **label edge uncertainty in segmentation**: when dilation-based augmentation expands defect regions to obtain more positive pixels, boundaries become ambiguous, and incorrect treatment of those dilated edges can degrade segmentation precision and, consequently, classification [2309.12630].

Against this background, the paper contrasts DFNet with two conventional families. **Single-stage classification networks** such as GoogLeNet, EfficientNetV2, ConvNeXt, and Swin-v2 rely only on image-level labels, learn global features, and have no explicit mechanism to identify where the defect is. **Segmentation-based or two-stage methods** such as SBDA and MDD use pixel-level labels, but the paper argues that they do not explicitly handle low contrast and strong background similarity, treat segmentation output rather naively in classification, and remain vulnerable to edge uncertainty introduced by label dilation. DFNet is positioned as a response to these specific deficiencies [2309.12630].

## 2. Two-stage network organization

DFNet is a **two-stage** architecture composed of a segmentation stage and a classification stage [2309.12630]. The segmentation stage uses a backbone feature extractor based on the first stage of **MDD** and outputs a high-dimensional feature map with **1152 channels**. This stage is augmented by the **Perception Fine-tuning Module**, which produces initial and refined segmentation maps together with refined foreground and background features. The classification stage is built around the **Decision Fusion Module**, which receives both the refined feature representation and a segmentation-derived semantic representation.

The data flow is described explicitly. A raw surface image is mapped by the backbone to a feature tensor
$$
F \in \mathbb{R}^{H\times W\times 1152}.
$$
A \(1\times1\) single-channel convolution then generates an initial segmentation map \(S_{\text{init}}\) and a foreground/background weight map \(W_{\text{fg/bg}}\). The weight map is used to separate the backbone feature map into foreground and background components. After refinement, the resulting feature maps are merged as
$$
F_{\text{merge}} = F + F_{\text{fg}}^{\text{ref}} + F_{\text{bg}}^{\text{ref}}.
$$
In parallel, complementary segmentation maps derived from refined foreground and background features are combined with \(S_{\text{init}}\) to produce the final segmentation result \(S_{\text{final}}\). The classification stage consumes \(F_{\text{merge}}\) in a feature decision branch and \(S_{\text{final}}\) in a semantic decision branch, and then outputs either a binary defect/non-defect decision or a multi-class defect category prediction [2309.12630].

This organization encodes the paper’s central premise: classification should depend jointly on **where** the defect is, via semantic segmentation, and **what** it looks like, via feature maps. A plausible implication is that the architecture uses segmentation not merely as an auxiliary task, but as a structured decision input.

## 3. Decision Fusion Module

The **Decision Fusion Module (DFM)** is the classification-stage component that fuses a semantic decision vector with a feature decision vector [2309.12630]. Its feature decision branch takes \(F_{\text{merge}}\) as input and applies a sequence of convolution and max-pooling operations: \(5\times5\times8\), then \(5\times5\times16\), then \(5\times5\times32\), each followed by max-pooling. Global max pooling and global average pooling are then applied to obtain vectors
$$
A \in \mathbb{R}^{32}, \qquad B \in \mathbb{R}^{32}.
$$

The semantic decision branch takes a one-channel segmentation map, such as \(S_{\text{final}}\), and applies an analogous conv+pool sequence to produce a 32-channel semantic feature map. Global max pooling and global average pooling yield
$$
C \in \mathbb{R}^{32}, \qquad D \in \mathbb{R}^{32}.
$$
The fusion mechanism is **simple concatenation**:
$$
\mathbf{z} = [A; B; C; D] \in \mathbb{R}^{128}.
$$
The concatenated vector is passed through a fully connected layer,
$$
p = W_{\text{fc}}\mathbf{z} + b_{\text{fc}},
$$
followed by **Sigmoid** for binary classification or **Softmax** for multi-class classification [2309.12630].

The classification loss is cross-entropy:
$$
\mathcal{L}_{\text{cla}} = \mathcal{L}_{\text{CE}}(\hat{y}, y),
$$
and in the paper’s notation,
$$
\mathcal{L}_2 = \mathcal{L}_{\text{cla}}(\delta(p)).
$$
The paper does not describe an explicit weighted-sum or attention-based fusion inside DFM; instead, the fully connected layer learns how to weigh the concatenated semantic and feature components. This is a notable design choice because the fusion mechanism is intentionally simple, with the architectural novelty concentrated in the dual-branch decision decomposition and the segmentation-side perception refinement.

## 4. Perception Fine-tuning Module

The **Perception Fine-tuning Module (PFM)** operates in the segmentation stage and is intended to fine-tune the network’s perception of **foreground defects** versus **background** [2309.12630]. Starting from the backbone feature map \(F\), PFM first generates an initial segmentation map and a weight map, then separates features into foreground and background streams:
$$
F_{\text{fg}} = W_{\text{fg/bg}} \odot F,
$$
with the background stream described conceptually as
$$
F_{\text{bg}} = (1 - W_{\text{fg/bg}})\odot F.
$$

The foreground and background streams are refined by separate modules, each consisting of **4 stacked \(3\times3\) convolution layers**, with the **last two using dilation rates 2 and 5**. These modules produce \(F_{\text{fg}}^{\text{ref}}\) and \(F_{\text{bg}}^{\text{ref}}\). The refined features are merged with the original backbone feature map to form \(F_{\text{merge}}\), which is sent to DFM’s feature decision branch. In parallel, complementary segmentation maps are produced from the refined foreground and background features and combined with the initial segmentation to yield the final segmentation map \(S_{\text{final}}\). Both \(S_{\text{init}}\) and \(S_{\text{final}}\) are supervised with segmentation ground truth [2309.12630].

Conceptually, PFM serves two purposes. First, it enhances defect-related patterns and suppresses background interference by explicitly separating foreground and background features. Second, the use of dilated convolutions with rates 2 and 5 enlarges the effective contextual field around each pixel, which the paper links to better perception of low-contrast defects. The reported heat-map visualizations indicate that, without PFM, the network tends to highlight larger areas and often mixes background, whereas with PFM, attention is more concentrated on actual defect regions and background activation is suppressed [2309.12630].

## 5. Inner-outer separation weighting for segmentation supervision

To address ambiguity introduced by **dilation-based data augmentation**, the paper introduces an **inner-outer Separation Weight Matrix (SWM)** for segmentation loss weighting [2309.12630]. The problem is that expanding defect masks with kernels such as \(25\times25\) or \(7\times7\) increases positive pixels and can improve class balance, but larger dilation reduces segmentation accuracy because the outer expanded pixels are uncertain. The paper also argues that prior distance-based attenuation methods reduce weights of true inner defect areas, which is undesirable.

The separation weight matrix is defined pixel-wise as
$$
M(\text{pix}) =
\begin{cases}
\displaystyle \frac{D(\text{pix})}{D_{\max}(\text{pix})}, & D(\text{pix}) \le d, \\
1, & D(\text{pix}) > d,
\end{cases}
$$
where \(D(\text{pix})\) is the Euclidean distance transform value of the pixel, \(D_{\max}(\text{pix})\) is the maximum distance in the dilated defect region, and \(d\) is the threshold separating inner and outer regions. Under this scheme, the **inner region** keeps weight \(1\), while the **outer dilated border** is attenuated proportionally to distance [2309.12630].

The weighted segmentation loss is
$$
\mathcal{L}_{\text{seg}}(\text{pix}) = M(\text{pix}) \cdot \hat{\mathcal{L}}(\text{pix}),
$$
with overall loss
$$
\mathcal{L}_{\text{seg}} = \sum_{\text{pix}} M(\text{pix}) \cdot \hat{\mathcal{L}}(\text{pix}).
$$
This weighting is applied to both the initial segmentation loss \(\mathcal{L}_{\text{pre\_seg}}\) and the refined segmentation loss \(\mathcal{L}_{\text{seg}}\). The stated intent is to preserve the benefits of dilation-based augmentation while reducing misjudgment at ambiguous defect edges [2309.12630].

## 6. Training strategy, losses, and reported results

The implementation is reported in **PyTorch** on a **single GPU (RTX 3060Ti)** with the **Adam** optimizer [2309.12630]. Training is end-to-end with mixed supervision from pixel-level segmentation labels and image-level classification labels. An important strategy is **gradient truncation initially**: gradients from the classification network are not propagated back to the segmentation network in early epochs, so that segmentation can converge first without destabilization from noisy classification gradients. To handle class imbalance, positive and negative samples are alternated during training, and one epoch is defined as all positive samples having been used once [2309.12630].

The paper defines three losses: \(\mathcal{L}_{\text{pre\_seg}}\), \(\mathcal{L}_{\text{seg}}\), and \(\mathcal{L}_{\text{cla}}\). With pixel-wise weighting,
$$
\mathcal{L}_1 = M(\text{pix}) \cdot \big(\mathcal{L}_{\text{pre\_seg}} + \mathcal{L}_{\text{seg}}\big),
$$
and the total loss is given by an epoch-dependent combination:
$$
\mathcal{L}_{\text{total}} = \frac{n}{n_{\text{ep}}}\cdot \mathcal{L}_1 + \left(1 - \frac{n}{n_{\text{ep}}}\right)\cdot \mathcal{L}_2,
$$
where \(n\) is the current epoch and \(n_{\text{ep}}\) is the total number of epochs [2309.12630].

Dataset-specific hyperparameters are also reported. For **KolektorSDD2**, training uses **100 epochs**, **learning rate 0.01**, **batch size 1**, and a **\(25\times25\)** dilation kernel because many defects are minute and larger dilation improves classification. For **Magnetic-Tile**, the classification network uses **200 epochs**, **learning rate 0.001**, **batch size 1**, and a **\(7\times7\)** dilation kernel because defects are often larger and smaller dilation is sufficient [2309.12630].

The abstract reports **96.1% AP** on **KolektorSDD2** and **94.6% mAP** on **Magnetic-tile-defect-datasets**. Within the paper’s framing, these results are presented as evidence that joint use of DFM, PFM, and SWM improves robustness under complex backgrounds and low-contrast defect conditions [2309.12630].

## 7. Terminological ambiguity and distinction from similarly named models

A recurrent point of confusion is nomenclature. The paper itself names the method **DFNet**, not explicitly **D3FNet** [2309.12630]. The available description states that, if “D3FNet” is used in this context, it likely refers to this **Decision Fusion Network with Perception Fine-tuning**. This suggests that the label “D3FNet” is, here, an informal alias rather than the formal model name.

That distinction matters because orthographically similar names refer to different systems in other parts of the literature. **D3** denotes a **dynamic DNN decomposition system for lossless synergistic inference** across device, edge, and cloud tiers [2101.05952]. **D3Net** denotes a **densely connected multidilated DenseNet** for dense prediction tasks such as semantic segmentation and audio source separation [2011.11844]. A later and unrelated model explicitly named **D3FNet** is a **Differential Attention Fusion Network for Fine-Grained Road Structure Extraction in Remote Perception Systems**, built on D-LinkNet for road segmentation in high-resolution remote sensing imagery [2508.15537]. These models address different tasks, use different architectures, and should not be conflated with DFNet for defect classification.

Within the defect-inspection literature, therefore, the technically precise designation is **DFNet**, with “D3FNet” functioning only as an external or secondary label for the system introduced in [2309.12630].

Source: https://www.emergentmind.com/topics/d3fnet