Skip to main content
Back

SAM FTI-FDet Teaches Meta's SAM to Inspect Freight Trains Without Human Prompts

A self-prompting SAM variant with a TinyViT backbone hits 74.6 APbox on freight train fault segmentation while staying edge deployable.

Pro

  • SAM FTI-FDet adapts Segment Anything with an auto-prompt generator for freight train fault segmentation, code on GitHub.
  • Achieves 74.6 APbox and 74.2 APmask on a 4,410-image real-world inspection dataset with 15 classes.
  • Uses a TinyViT-SAM backbone from MobileSAM, dropping model size to 148 MB with 36M parameters.
  • Enables quantitative brake shoe wear measurement, hitting 96 to 97 percent accuracy across wear severity levels.
  • Outperforms FastSAM, RSPrompter, and Mask R-CNN under noise and occlusion, dropping to 60.8 APbox instead of collapsing.
  • Struggles with small, low-contrast defects since fixed prompt budgets prioritize visually salient regions.

Automated freight train inspection is one of those problems that sounds solved until you look at real data. Cameras at inspection stations have to detect worn brake shoes, missing pins, and damaged bearing saddles across cluttered undercarriages caked in dust and grease. A team from Hubei University of Technology and Huazhong University of Science and Technology has released SAM FTI-FDet, a lightweight adaptation of Meta's Segment Anything Model that learns to prompt itself for this task, with code available on GitHub.

Why regular detectors fall over on trains

Freight train inspection has a specific flavor of hard. Key components such as brake shoes and bearing saddles are particularly prone to excessive wear, yet traditional object detection methods lack the capability to quantitatively analyze these wear conditions. Bounding boxes tell you a part exists, but they cannot measure how much material is left on a worn brake shoe.

Instance segmentation solves that, but CNN-based systems tuned for one inspection station tend to break at the next one. Zhang et al. introduced a lightweight anchor-free detection framework tailored to key braking components. While the method delivers high accuracy with minimal computational cost, the authors also reported substantial performance degradation when the model was applied to previously unseen inspection stations. Foundation models like SAM offer better generalization, but its dependence on external prompts (e.g., clicks or bounding boxes) and sensitivity to prompt placement make it unsuitable for fully automated industrial applications.

Teaching SAM to prompt itself

The core trick is replacing the human clicking on a SAM interface with a learned module that generates prompts directly from image features. Central to our method is the Prompt generator, which eliminates the need for manual intervention by learning to generate high-quality prompts directly from global image representations.

Under the hood, the pipeline has three main pieces:

  • TinyViT-SAM backbone borrowed from MobileSAM, a distilled SAM encoder that shrinks compute enough to run on edge devices.
  • Adaptive Feature Dispatcher that aggregates multi-scale features from backbone layers, then splits them back out to different resolutions for downstream tasks.
  • Prompt generator built from a Transformer decoder. It starts with a small set of learnable query vectors and refines them layer by layer through self-attention and cross-attention over image features, producing prompt embeddings that get fed to SAM's mask decoder.
Architecture diagram of the TinyViT-SAM framework with prompt generator

The authors also found that fine-tuning the encoder while freezing the decoder gave the best results, a common pattern when adapting foundation models to narrow domains without destroying their general priors.

The numbers

The team built a dataset from real inspection stations. The dataset consists of 4,410 images covering 6 scenarios and 15 classes. Images were captured with industrial cameras from side and bottom views, under daylight and LED illumination, complete with dust and grease.

On this dataset, SAM FTI-FDet hits 74.6 APbox and 74.2 APmask, edging past Mask2Former with a Swin-T backbone (74.3 / 73.8) and beating other SAM adaptations like RSPrompter-query (72.7 / 71.9). The efficiency story is where it gets interesting:

MethodAPmaskParamsModel Size (MB)
Mask2Former (Swin-T)73.849M739.5
RSPrompter-query (SAM-B)71.9131M303.3
SAM FTI-FDet (TinyViT)74.236.3M148.2

That is roughly a fifth the model size of a comparable Mask2Former setup with slightly better mask accuracy. On MS-COCO with independent fine-tuning, it also outperforms FastSAM and RSPrompter on both APbox and APmask, suggesting the design is not purely overfit to trains.

What it is actually good for

The concrete payoff is quantitative wear measurement. The authors show pixel-level segmentation of brake shoes lets them classify wear into slight (70 to 100 percent material remaining), moderate (30 to 70 percent), and severe (below 30 percent), hitting 96.7, 94.8, and 97.5 accuracy respectively, well above bounding-box projection or edge-detection baselines. That is the difference between "this brake shoe exists" and "this brake shoe needs replacement now."

Feature map comparison showing prompt-guided localization on train components

Where it breaks

Robustness testing under motion blur, Gaussian noise, cutout occlusions, and color shifts drops performance to 60.8 APbox and 59.6 APmask. That is still better than FastSAM, RSPrompter, and Mask R-CNN under the same conditions, but a substantial fall from clean-data numbers. The authors also flag a structural weakness: with a fixed prompt budget, small or low-contrast objects tend to get skipped because prompts naturally gravitate to salient regions. If your target defects are subtle, you may need to rethink the prompt allocation.

The broader point

Beyond the freight domain, the paper is a clean case study in adapting a general foundation model to a narrow industrial task without full fine-tuning of the base weights. The recipe of a distilled backbone plus a learned prompt generator plus frozen decoder is transferable to any inspection setting where you have limited labeled data but structured, repetitive components, from manufacturing lines to power infrastructure. It is also a reminder that MobileSAM-style distilled backbones are quietly becoming the default way to get SAM onto edge hardware.