Clear Sky Science · en

Contrastive learning enhanced MobileMamba for real time industrial defect detection on edge devices

· Back to index

Smarter eyes for factory metal

From cars and airplanes to bridges and household appliances, modern life depends on metal parts that must not crack, peel or pit. Today, many factories still rely on bulky computers or even human inspectors to find tiny defects on fast‑moving production lines. This paper introduces a new kind of compact artificial intelligence (AI) system that can spot very small flaws on metal surfaces quickly and accurately, even when running on low‑power devices mounted directly next to the machines that make those parts.

Why tiny cracks are a big problem

Metal sheets and profiles pass through welding, casting and cutting stages before they become finished products. Along the way they can pick up cracks, holes, scratches and other surface defects. Missed flaws can shorten the lifetime of a part or even lead to dangerous failures. Computer‑vision systems based on deep learning have begun to automate this inspection work, but many of the most accurate methods are too slow or heavy to run on small, inexpensive “edge” devices that factories prefer to install on the line. Existing fast models, in turn, often struggle with very small or low‑contrast defects and can be fooled by noisy or patterned backgrounds.

Figure 1
Figure 1.

A lighter, sharper digital inspector

The authors present MobileMamba, a new lightweight detection network designed specifically for industrial metal inspection. It builds on the popular YOLO family of object‑detection models but replaces key parts of the architecture with components that are both more efficient and better at seeing the whole picture. A central idea is to use a recent sequence‑modeling technique called Mamba, which can capture long‑range patterns in an image with far less computation than attention‑based networks. Wrapped in a slim building block using depthwise convolutions, MobileMamba learns to combine fine local details, like a hairline crack, with broader context across the metal sheet, all while keeping the model’s size and power needs low.

Teaching the model what really matters

Real inspection images are dominated by normal, defect‑free regions, so a model can easily become biased toward calling everything “OK.” To counter this, the researchers add an auxiliary training objective based on contrastive learning. During training, the system continually compares feature patterns from defect regions (foreground) with those from clean background areas, and also contrasts correct defect boxes with incorrect predictions. Crucially, it does not treat all background examples equally: it automatically finds the “hard” negative samples—background patches that look most similar to defects—and forces the model to pay extra attention to telling them apart. This extra loss term is used only while the system is learning and disappears during operation, so it does not slow down real‑time use.

Figure 2
Figure 2.

Proving performance on real factory data

The team tested their approach on three widely used industrial datasets of steel and aluminum surfaces, containing various defect types such as cracks, inclusions and rolled pits. Compared with several modern lightweight detectors, the new method consistently reached higher detection scores while using fewer parameters and less computation. On all three datasets, it boosted accuracy by around three percentage points over similarly compact YOLO‑based models. The authors then built an even smaller “nano” version of MobileMamba and deployed it on an inexpensive NVIDIA Jetson Nano edge board. Even under reduced image sizes, this version still achieved real‑time inspection speeds of at least 25 frames per second while outperforming other edge‑oriented detectors in accuracy.

What this means for real factories

For non‑specialists, the main outcome is straightforward: this work delivers an AI inspector that is both fast and frugal enough for small industrial computers, yet sharp enough to catch fine, hard‑to‑see defects on metal surfaces. By redesigning how the network gathers information across an image and by training it to focus on the trickiest background look‑alikes, the authors show that factories do not have to choose between speed and reliability. With further refinements, such as smarter compression and combining ordinary images with thermal or X‑ray views, approaches like MobileMamba could help bring safer, more consistent quality control to a wide range of manufacturing lines.

Citation: Huang, J., Ariffin, S.A., Yang, Q. et al. Contrastive learning enhanced MobileMamba for real time industrial defect detection on edge devices. Sci Rep 16, 5096 (2026). https://doi.org/10.1038/s41598-026-35515-4

Keywords: metal defect detection, edge AI, industrial inspection, lightweight neural networks, contrastive learning