---
title: 'Bolt-SAM: Attribute Segmentation for Defect Editing'
url: https://www.emergentmind.com/topics/bolt-attribute-segmentation-model-bolt-sam
type: topic
---

# Bolt-SAM: Attribute Segmentation for Defect Editing

Bolt Attribute Segmentation Model (Bolt-SAM) is a bolt-specific attribute segmentation model introduced as the segmentation backbone of the segmentation-driven bolt defect editing framework SBDE, whose purpose is to generate precise masks for bolt components such as pins and nuts so that those attributes can later be removed and reconstructed during defect synthesis [2508.10509]. Rather than targeting generic object segmentation, Bolt-SAM is designed for high-quality mask generation under the imaging conditions of transmission-line inspection, where bolts are small, often low-resolution, weakly contrasted against the background, and frequently affected by lighting changes, shadows, clutter, and noise. Within SBDE, its role is foundational: it defines the regions to be edited, and the downstream mask optimization, LaMa-based inpainting, scene recovery, and data augmentation stages depend on its masks being boundary-consistent and semantically correct [2508.10509].

## 1. Problem setting and motivation

Bolt-SAM was proposed in the context of bolt defect detection for transmission lines, where defect images are scarce and data distributions are imbalanced [2508.10509]. The larger SBDE framework addresses this by converting normal bolts into defective ones through attribute editing, but that workflow requires a segmentation model capable of isolating bolt attributes with high precision. Bolt-SAM is therefore motivated by the need for accurate attribute masks rather than general-purpose instance masks.

The motivating difficulty is that existing segmentation tools, including SAM and RobustSAM, are reported to be hard to apply directly to bolt imagery because the relevant targets are visually challenging and structurally atypical [2508.10509]. Bolt attributes such as pins are not necessarily simple contiguous regions; a pin may appear as a thin, multipart, or disconnected structure. In this setting, even small segmentation errors have downstream consequences. If the segmented region is inaccurate, the inpainting stage may remove the wrong pixels, leave remnants of the original attribute, or include excess background, producing unnatural synthesized defects [2508.10509].

This suggests that Bolt-SAM is best understood not as an isolated segmentation model, but as a prerequisite mechanism for controllable defect synthesis. The central technical requirement is mask quality in service of editing fidelity, rather than segmentation accuracy in the abstract.

## 2. Position within the SBDE pipeline

SBDE consists of three linked stages: attribute segmentation, mask-guided editing, and edited-scene recovery [2508.10509]. Bolt-SAM occupies the first stage and supplies the mask $M_{seg}$ used by the later modules. A normal bolt image first enters Bolt-SAM, whose encoder-side enhancement and decoder-side multipart reasoning produce a fine-grained attribute mask. That mask is then passed to the mask optimization module (MOD), after which LaMa performs inpainting to remove the selected bolt attribute:

$$
I_{edit}=\mathrm{LaMa}(I_{ori},M_{MOD}).
$$

Bolt-SAM does not directly edit images; it produces the region definition that determines what is edited [2508.10509]. This separation is architecturally important. The segmentation stage identifies the target attribute, MOD enlarges and smooths the mask for more natural inpainting context, and LaMa reconstructs the edited image. The subsequent editing recovery augmentation (ERA) strategy then restores the edited defect bolt to the original inspection scene and expands the defect detection dataset [2508.10509].

A plausible implication is that Bolt-SAM enables the “segmentation-driven” character of SBDE by making the editable region explicit and structurally grounded. Without that explicit mask definition, the later editing stages would lack the precision required for bolt-specific defect synthesis.

## 3. Architecture: RobustSAM adaptation through CFA and MAMD

Bolt-SAM is constructed by improving RobustSAM with two components: the CLAHE-FFT Adapter (CFA) in the image encoder and the Multipart-Aware Mask Decoder (MAMD) in the mask-decoding stage [2508.10509]. The design retains SAM’s original image encoder and prompt encoder in frozen form, while training the adapter, mask decoder, and fusion network. This yields a lightweight bolt-specific adaptation rather than a full end-to-end retraining of the underlying segmentation backbone.

The CFA module addresses weak edge visibility in inspection images. It first enhances image details using Contrast Limited Adaptive Histogram Equalization, producing an enhanced image $I_{cla}$. The enhanced image is transformed to the frequency domain:

$$
z=\text{FFT}(I_{cla}).
$$

A high-pass filter based on the mask $M_{hpf}$ is then applied to isolate high-frequency information:

$$
M_{hpf}^{i, j}(\tau)=\left\{\begin{array}{ll} 0, & \frac{4\left|\left(i-\frac{H}{2}\right)\left(j-\frac{W}{2}\right)\right|}{H W} \leq \tau \\
1, & \text { otherwise } \end{array}\right.
$$

where $H$ and $W$ are the image height and width, and $\tau$ controls the low-frequency cutoff. The filtered signal is transformed back:

$$
I_{hfc}=\text{IFFT}(z\cdot M_{hpf}).
$$

This high-frequency component is combined with the patch embedding output to form the input feature $F_i$ for the adapter. The adapter is an MLP-based projection defined as

$$
P^i=\mathrm{FC}_{up}(\mathrm{GELU}(\mathrm{FC}^i_{tune}(F_i))).
$$

Here, $\mathrm{FC}_{tune}$ is trainable for each adapter block, and $\mathrm{FC}_{up}$ is a shared up-projection layer mapping the prompt vector to the transformer embedding dimension [2508.10509]. The resulting prompt $P^i$ is appended to each transformer layer, steering the encoder toward edge-aware bolt-relevant features. In practical terms, the paper states that this is especially helpful for nuts and small pin parts.

MAMD addresses the structural complexity of bolt attributes, especially pins. Because bolt pins often appear in dispersed multipart form, a single-shot mask prediction is described as less reliable [2508.10509]. MAMD therefore adopts a multipart-aware, multi-task fine-tuning scheme. For pins, the attribute is split into three parts—pin0, pin1, and pin2—which are trained separately with point prompts and then fused into a complete pin mask. For nuts, a single branch is sufficient because nuts are structurally simpler than multipart pins [2508.10509].

## 4. Multipart supervision, prompting strategy, and optimization objective

A central design choice in Bolt-SAM is the use of point prompts rather than box prompts for fine-grained bolt attribute localization [2508.10509]. The paper states that point prompts provide more precise localization in low-resolution bolt images, whereas box prompts tend to include too much irrelevant background. This is particularly consequential for disconnected or thin structures such as pins.

For each local region in MAMD, the optimization uses a composite loss:

$$
L_{local,i}=\alpha \cdot L_{focal}(M_{i},GT_{i})+\beta \cdot L_{Dice}(M_{i},GT_{i}),
$$

where $M_i$ is the predicted mask and $GT_i$ is the ground-truth mask for sub-region $i$, and $\alpha,\beta$ are weighting coefficients [2508.10509]. The Focal Loss is used to address class imbalance and hard-to-segment boundary pixels, while Dice Loss promotes overlap quality and shape consistency. The complete attribute mask is obtained by merging local masks through a lightweight fusion network implemented with two convolution layers and batch normalization. The global mask is stated to be optimized with the same local loss formulation [2508.10509].

Training uses point prompts in a specific way: three points are randomly sampled from the ground-truth mask during training [2508.10509]. Bolt-SAM fine-tunes only CFA and MAMD; the remaining components inherited from the RobustSAM baseline remain frozen. The reported implementation uses a learning rate of $10^{-4}$, batch size 2, and 50 epochs on two NVIDIA 4090 GPUs with PyTorch 2.4, CUDA 12.1, and Python 3.10 [2508.10509].

This training configuration reinforces the model’s intended scope. Bolt-SAM is not presented as a universal segmentation system, but as a narrowly adapted segmentation engine optimized for bolt imagery, bolt attributes, and the needs of subsequent editing.

## 5. Datasets, evaluation protocol, and quantitative performance

The study constructs three datasets: BDD for scene-level defect detection, BDG for bolt image editing and generation comparison, and BAS for bolt attribute segmentation [2508.10509]. Bolt-SAM is trained and evaluated on BAS, which contains only normal bolts and manually annotated masks for nut and pin attributes; the pin is additionally split into pin0, pin1, and pin2 [2508.10509].

The segmentation metrics are mean Intersection over Union (mIoU), Dice, and Pixel Accuracy (PA). Bolt-SAM is compared against SAM, SAM-Adapter, HQ-SAM, and RobustSAM, with both 1-point and 3-point prompt settings tested [2508.10509].

With 3-point prompts, the main reported results are as follows:

| Attribute | mIoU | Dice | PA |
|---|---:|---:|---:|
| Pin | 75.66% | 86.01% | 98.02% |
| Nut | 76.78% | 86.47% | 94.71% |

These results are reported to outperform RobustSAM with 3 points, described as the strongest baseline, by about 4.50 points mIoU, 3.21 points Dice, and 0.54 points PA for pin segmentation, and by 6.34, 4.57, and 1.95 points for nut segmentation [2508.10509]. The paper also reports that Bolt-SAM produces clearer boundaries and fewer missed regions than competing methods, including under complex background interference.

The ablation study isolates the contributions of the two added modules:

| Setting | Pin mIoU | Nut mIoU |
|---|---:|---:|
| B1 baseline | 71.16 | 70.44 |
| B2 + CFA | 74.83 | 76.78 |
| B3 + MAMD | 73.75 | — |
| B4 + CFA + MAMD | 75.66 | — |

The reported pattern is functionally specific: CFA alone improves nut segmentation noticeably, MAMD alone improves pin segmentation, and using both together gives the best overall performance [2508.10509]. This division of effect matches the intended roles of the modules: CFA enhances difficult edge information, while MAMD targets multipart structure.

## 6. Interaction with MOD-LaMa and contribution to defect augmentation

Once Bolt-SAM generates a mask, SBDE applies the MOD-LaMa pipeline [2508.10509]. MOD is not part of Bolt-SAM itself, but its necessity clarifies why Bolt-SAM’s masks matter. Because bolt images are low-resolution and segmentation masks can remain tight around the target, LaMa may lack sufficient surrounding context for natural inpainting. MOD therefore enlarges and smooths the segmentation region using morphological operations. The opening operation is defined as

$$
M_{open}=(M_{seg}\ominus s) \oplus s,
$$

where $s$ is the structuring element. Erosion and dilation are given as

$$
(M_{seg}\ominus s)(x,y) = \{o \mid (s)_o \subseteq M_{seg}\} =\min_{(x,j)\in s} {M_{seg}(x+i,y+j)},
$$

$$
(M_{open}\oplus s)(x,y) = \{o \mid (s)_o \cap M_{open} \ne \emptyset \} =\min_{(x,j)\in s} {M_{open}(x+i,y+j)}.
$$

The final optimized mask is

$$
M_{MOD}=M_{open} \oplus s.
$$

The structural dependence is explicit: better segmentation yields better masks; better masks yield better morphological optimization; and better optimized masks yield more realistic LaMa inpainting [2508.10509]. This relation is reflected in the reported editing ablations. When Bolt-SAM and MOD-LaMa are combined, attribute editing accuracy and human preference are highest; the paper gives pin AEA of $85.89\%$ and nut AEA of $77.17\%$, together with the highest HPS scores [2508.10509].

At the downstream detection level, the SBDE-augmented dataset improves YOLOv11 performance over both the original and copy-augmented baselines, increasing overall precision, recall, and mAP [2508.10509]. Although those detection gains belong to the full SBDE system rather than to Bolt-SAM in isolation, the paper positions Bolt-SAM as the enabling mechanism that makes defect synthesis controllable and structurally faithful.

## 7. Significance, scope, and interpretive context

Bolt-SAM is significant within SBDE because it adapts SAM-style segmentation to the specific geometry and imaging conditions of bolt inspection [2508.10509]. Its two defining interventions are complementary. CFA improves feature extraction through CLAHE and FFT-based high-frequency enhancement, while MAMD improves robustness to multipart and non-contiguous structures through point-prompted, part-wise supervision and mask fusion. The resulting masks are then refined by MOD and used by LaMa to synthesize defective bolts.

A common misconception would be to treat Bolt-SAM as a generic bolt detector or as an image editing model. The paper describes neither. Bolt-SAM is a segmentation engine specialized for bolt attributes, and its output is an attribute mask rather than a defect label or an edited image [2508.10509]. Its practical importance derives from its role in the larger editing pipeline.

Another potential misconception is that segmentation quality can be judged independently of the downstream task. The formulation in SBDE argues the opposite. In this setting, boundary precision, semantic correctness, and completeness of thin or disconnected parts directly condition the realism of defect synthesis [2508.10509]. This suggests that Bolt-SAM exemplifies task-coupled segmentation design: the segmentation objective is shaped by the requirements of subsequent inpainting and augmentation, not merely by generic region overlap metrics.

The code for the overall project is reported as publicly available at the repository linked by the authors [2508.10509]. Within the research trajectory defined by SBDE, Bolt-SAM serves as the segmentation component that makes segmentation-driven bolt defect editing technically viable.

Source: https://www.emergentmind.com/topics/bolt-attribute-segmentation-model-bolt-sam