Papers
Topics
Authors
Recent
Search
2000 character limit reached

MOD-LaMa: Bolt Defect Editing

Updated 5 July 2026
  • The paper introduces MOD-LaMa as a mask optimization and inpainting module that edits normal bolts into defect-like images without using defect examples.
  • MOD-LaMa combines a deterministic mask refinement process with the pre-trained LaMa model to precisely remove bolt attributes and ensure scene consistency.
  • Its design addresses the scarcity and imbalance of defect samples in transmission-line inspections, improving defect augmentation and detection performance.

Searching arXiv for the specified paper and related context. I’ll look up the cited arXiv entry to ground the article in the current record. MOD-LaMa denotes the bolt defect attribute editing model introduced as the key editing component of the broader SBDE pipeline, ā€œA Segmentation-driven Editing Method for Bolt Defect Augmentation and Detectionā€ (Xiao et al., 14 Aug 2025). Its function is to convert normal bolt instances into realistic defective bolts by removing bolt attributes such as the pin or nut from carefully segmented bolt crops, while preserving surrounding structure and scene consistency. In the paper’s formulation, MOD-LaMa is not a standalone generative system; it is a composition of a deterministic mask optimization module (MOD) and the pre-trained image inpainting model LaMa, designed for a setting in which ordinary bolts are abundant but defect samples are scarce and imbalanced.

1. Definition and problem setting

The paper situates MOD-LaMa within transmission-line inspection, where bolt defect detection is constrained by the scarcity of defect images and by class imbalance between normal and defective instances (Xiao et al., 14 Aug 2025). The proposed response is not defect generation from scratch, but attribute editing of normal bolts. The rationale given is that bolts are small, geometrically regular objects that require precise local editing without distorting the image.

Within SBDE, the pipeline is explicitly divided into two stages. First, the target bolt attribute is segmented precisely using Bolt-SAM. Second, the segmented region is edited to synthesize a defect using MOD-LaMa. The target operation is local removal of specific bolt attributes, particularly the pin or nut, so that a normal bolt is transformed into a defect-like bolt image suitable for augmentation.

The paper’s conceptual goal is described as zero-defect-shot attribute editing. In this usage, the term means that editing a normal bolt into a defective one does not require defect examples during the editing step itself. A plausible implication is that the method is tailored to industrial domains in which defect acquisition is expensive or operationally rare, but normal-state imagery is relatively easy to collect.

2. Architectural composition of MOD-LaMa

MOD-LaMa consists of a simple morphological optimization module integrated with LaMa (Xiao et al., 14 Aug 2025). MOD is explicitly described as a deterministic mask-processing step rather than a learned network. Its purpose is to convert the segmentation mask MsegM_{seg} into a more suitable inpainting mask MMODM_{MOD} through opening, followed by an additional dilation.

The paper gives the mask optimization equations as:

Mopen=(MsegāŠ–s)āŠ•sM_{open}=(M_{seg}\ominus s) \oplus s

where ss is the structural element.

The erosion and dilation are defined in the paper as:

(MsegāŠ–s)(x,y)={o∣(s)oāŠ†Mseg}Ā =min⁔(x,j)∈sMseg(x+i,y+j)\begin{aligned} (M_{seg}\ominus s)(x,y) & =\{o \mid (s)_o \subseteq M_{seg}\} \ &=\min_{(x,j)\in s} {M_{seg}(x+i,y+j)} \end{aligned}

(MopenāŠ•s)(x,y)={o∣(s)o∩Mopenā‰ āˆ…}Ā =min⁔(x,j)∈sMopen(x+i,y+j)\begin{aligned} (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)} \end{aligned}

The final optimized mask is then:

MMOD=MopenāŠ•s\begin{aligned} M_{MOD}=M_{open} \oplus s \end{aligned}

LaMa is subsequently applied by direct inference:

Iedit=LaMa(Iori,MMOD)\begin{aligned} I_{edit}=\mathrm{LaMa}(I_{ori},M_{MOD}) \end{aligned}

The integration is therefore straightforward: Bolt-SAM produces MsegM_{seg}, MOD refines it into MMODM_{MOD}, and LaMa inpaints the optimized masked region to generate the edited defective bolt MMODM_{MOD}0. The paper emphasizes that MOD-LaMa uses the pre-trained LaMa directly, with no additional fine-tuning. This is significant because the reported gain is attributed to mask optimization before inpainting, not to modifying LaMa’s architecture or retraining it on bolt-specific imagery.

3. Editing workflow and the role of mask optimization

The full editing workflow begins with a normal bolt image MMODM_{MOD}1 cropped from an inspection image (Xiao et al., 14 Aug 2025). Bolt-SAM is then used to segment the target attribute. For pin editing, the pin is split into three parts—pin0, pin1, and pin2—whereas nut editing uses a single branch. Local masks are generated for each part using point prompts, fused into a complete attribute mask, optimized by MOD, and finally inpainted by LaMa to remove the target region. The edited bolt can later be returned to the inspection scene through ERA.

The motivation for MOD is stated explicitly in the paper: ā€œDue to the low resolution of bolt images, the masks generated by Bolt-SAM often lack sufficient contextual coverage, limiting the effectiveness of LaMa's inpainting.ā€ MOD therefore exists to enlarge and smooth the segmentation mask so that LaMa receives a better editing region. The importance of this step is not merely cosmetic. The target outcome is a realistic defective bolt, rather than a trivial masked deletion, because the result is intended for downstream data augmentation.

This design also clarifies how MOD-LaMa differs from standard LaMa usage. Standard LaMa would receive the raw segmentation mask. MOD-LaMa instead applies opening to smooth boundary noise, then performs extra dilation to enlarge the region and provide more context, so that the inpainted result is more natural and consistent. The paper therefore frames MOD-LaMa as a mask-refinement + inpainting editing module rather than a fully generative defect synthesizer.

4. Dependence on Bolt-SAM, CFA, and MAMD

MOD-LaMa depends directly on the quality of the masks supplied by Bolt-SAM, so the upstream segmentation components are integral to its operation (Xiao et al., 14 Aug 2025). Bolt-SAM is the segmentation model that extracts the target bolt attribute masks used for editing. Two subcomponents are highlighted: the CLAHE-FFT Adapter (CFA) and the Multipart-Aware Mask Decoder (MAMD).

CFA is introduced to improve feature extraction for difficult bolt images. It combines CLAHE for contrast enhancement, FFT to isolate high-frequency edge information, and an adapter module with linear layers to inject those features into the transformer encoder. The paper gives the high-pass filter mask as:

MMODM_{MOD}2

and the adapter output as:

MMODM_{MOD}3

MAMD improves segmentation of complex bolt attributes by splitting the pin into pin0, pin1, and pin2, fine-tuning each part with point prompts, and fusing local masks into a complete mask. This is especially relevant because the pin is small and often non-contiguous. The local loss is defined as:

MMODM_{MOD}4

and the global mask uses the same optimization form as the local loss.

The practical implication is direct: MOD-LaMa is only as effective as the mask it receives. The paper’s interpretation is that Bolt-SAM improves segmentation quality, MOD-LaMa improves editing region quality, and together they enable robust bolt defect attribute editing.

5. Recovery augmentation and scene-level synthesis

The edited crop generated by MOD-LaMa is not the end product of SBDE. The paper introduces ERA, or editing recovery augmentation, to place the edited defect bolt back into the original inspection scene (Xiao et al., 14 Aug 2025). The workflow is: use LabelImg to annotate normal bolts in the inspection image MMODM_{MOD}5; crop the bolt instance to obtain MMODM_{MOD}6; edit it with SBDE to get MMODM_{MOD}7; paste MMODM_{MOD}8 back into its original location; update the label to the defect class; and obtain the augmented scene image MMODM_{MOD}9.

The manuscript provides an ERA recovery equation, although the text is described as somewhat garbled. The intended meaning is that pixels inside the bolt bounding box are replaced by the edited bolt, while all other pixels remain from the original inspection image. That design preserves the original transmission-line scene and changes only the local bolt region, which the paper identifies as suitable for object detection training.

The paper also contrasts ERA with a copy-based augmentation control. Copy augmentation duplicates original bolts, whereas SBDE-aug replaces normal bolts with realistic defect bolts. This distinction is important because the purpose of MOD-LaMa is not only to produce plausible crop-level edits, but to produce augmented scene-level training examples that retain the statistics of real inspection backgrounds.

6. Datasets, implementation, and quantitative results

The experimental study uses three constructed datasets: BDD for bolt defect detection at inspection-image level, BDG for bolt defect generation at crop level, and BAS for bolt attribute segmentation (Xiao et al., 14 Aug 2025).

Dataset Role Size or composition
BDD Detection dataset 1770 inspection images; 1433 training, 337 test; 4979 normal, 549 pin losing, 307 nut losing
BDG Generation dataset 2253 bolt images; 1393 normal, 517 pin losing, 300 nut losing
BAS Segmentation dataset Normal bolts only; masks for nut, pin, pin0, pin1, pin2; 886 train / 220 test for each mask type

The implementation details given in the paper are specific. Bolt-SAM fine-tunes only CFA and MAMD while other parameters are frozen. Point prompts are used, with three points randomly sampled from the ground truth mask during training. The learning rate is 0.0001, batch size is 2, training runs for 50 epochs, and the environment is PyTorch 2.4, CUDA 12.1, Python 3.10 on two NVIDIA 4090 GPUs. For MOD-LaMa, the structuring element for opening is asymmetric Mopen=(MsegāŠ–s)āŠ•sM_{open}=(M_{seg}\ominus s) \oplus s0, and the structuring element for dilation is centrally symmetric Mopen=(MsegāŠ–s)āŠ•sM_{open}=(M_{seg}\ominus s) \oplus s1. No LaMa fine-tuning is performed.

For segmentation, the reported metrics are mIoU, Dice, and PA. Bolt-SAM with 3-point prompts achieves the best reported segmentation, with Pin: mIoU 75.66, Dice 86.01, PA 98.02, and Nut: mIoU 76.78, Dice 86.47, PA 94.71. The paper states that these outperform RobustSAM and other SAM variants.

For editing comparison, the paper reports PSNR, SSIM, and LPIPS. In pin editing, SBDE achieves SSIM 88.94, PSNR 23.54, LPIPS 19.05, compared with representative prior baselines such as Null-text Inversion at SSIM 81.46, PSNR 17.72, LPIPS 46.03; Negative Inversion at SSIM 80.31, PSNR 17.39, LPIPS 48.24; and Direct Inversion at SSIM 79.13, PSNR 17.19, LPIPS 50.55. In nut editing, SBDE achieves SSIM 83.39, PSNR 21.95, LPIPS 14.97, while Null-text Inversion reports SSIM 79.01, PSNR 19.07, LPIPS 36.64; Negative Inversion reports SSIM 78.85, PSNR 18.19, LPIPS 39.23; and Direct Inversion reports SSIM 78.23, PSNR 18.12, LPIPS 40.07.

For downstream detection, the reported metrics are P, R, Mopen=(MsegāŠ–s)āŠ•sM_{open}=(M_{seg}\ominus s) \oplus s2, and Mopen=(MsegāŠ–s)āŠ•sM_{open}=(M_{seg}\ominus s) \oplus s3. Compared with the original dataset and copy augmentation, SBDE-aug yields the strongest overall result: Original has P 86.0, R 76.0, mAP50 83.1, mAP50:95 46.8; Copy-aug has P 84.2, R 77.8, mAP50 84.5, mAP50:95 46.2; and SBDE-aug has P 88.2, R 78.3, mAP50 87.5, mAP50:95 47.8. The paper also notes improvements over the original of +2.2 P, +2.3 R, +4.4 mAP50, and +1.0 mAP50:95. This suggests that the edited defects are not only visually plausible under image-similarity metrics, but also operationally useful for detector training.

7. Ablations, interpretation, and limitations

The paper includes a dedicated editing ablation that isolates the contribution of the mask optimization stage (Xiao et al., 14 Aug 2025). Four settings are evaluated: S1 = RobustSAM + LaMa, S2 = Bolt-SAM + LaMa, S3 = RobustSAM + MOD-LaMa, and S4 = Bolt-SAM + MOD-LaMa. The ablation metrics are AEA and HPS.

Setting Pin: AEA, HPS Nut: AEA, HPS
S1 11.83, 1.17 9.92, 1.08
S2 13.17, 1.83 11.78, 2.14
S3 78.63, 3.2 69.82, 2.87
S4 85.89, 3.8 77.17, 3.91

These results are used in the paper to argue that Bolt-SAM alone does not solve editing, that adding MOD-LaMa yields a large improvement in editing correctness, and that the combination of Bolt-SAM and MOD-LaMa gives the best results. The formal definition of AEA is:

Mopen=(MsegāŠ–s)āŠ•sM_{open}=(M_{seg}\ominus s) \oplus s4

The paper also states that HPS is a human ranking-based score averaged over experts and edited images, but its equation is typographically corrupted in the provided text and is not reproducible verbatim here.

Several misconceptions are precluded by the paper’s own framing. MOD-LaMa is not a retrained LaMa variant; it uses pre-trained LaMa directly. It is not a latent-space translation or diffusion inversion method; those categories are used as comparison baselines, including StarGAN-v2, ReStyle + e4e, Null-text Inversion, Negative-prompt Inversion, and Direct Inversion. It is also not a global scene editor; its design is localized and scene-preserving, editing only the bolt attribute region and leaving the rest intact.

The main stated limitation is that performance remains affected by the pixel quality of the original images. The paper states: ā€œAlthough the proposed SBDE method has achieved good results in bolt editing, its performance is still affected by the pixel quality of the original images.ā€ Given the low resolution typical of bolt imagery, this limitation is consistent with the method’s heavy dependence on mask quality and local inpainting context. A plausible implication is that the effectiveness of MOD-LaMa scales with the quality of both the crop extraction and the upstream attribute segmentation, rather than with broader increases in generative model capacity.

Definition Search Book Streamline Icon: https://streamlinehq.com
References (1)

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Bolt Defect Attribute Editing Model (MOD-LaMa).