Unsupervised Anomaly Detection for BFS Bottles With Vision Mamba and Dynamic Masking
Abstract
Blow-Fill-Seal (BFS) technology is widely used in sterile pharmaceutical manufacturing. Due to the complex structure of BFS bottles, the defects usually exhibit highly diverse appearances and inconsistent feature distributions, which brings critical challenges for supervised defect detection methods. To address this issue, we propose an unsupervised Anomaly Detection model based on Vision Mamba and Dynamic Masking (named ViMDMAD). ViMDMAD first employs a pretrained Vision Transformer as the encoder to extract multi-level semantic features. Subsequently, we design a lightweight Loss Prediction-Driven Dynamic Masking module to generate dynamic soft masks, guiding the decoder to focus on critical regions while alleviating identity mapping and suppressing over-reconstruction of anomalous areas. Then, we propose an enhanced Global–Local Vision Mamba decoder to reconstruct mask-perturbed feature sequences through state-space modeling. Finally, multi-level reconstruction errors between the encoder and decoder are aggregated to produce anomaly score maps for defect detection. Based on the BFS AD dataset and the MVTec AD benchmark dataset, extensive experiments have been conducted. Experimental results demonstrate that ViMDMAD achieves image-level areas under the receiver operating characteristic curve of 97.4% and 99.0%, outperforming existing methods and highlighting its effectiveness for automated visual inspection and quality assessment in complex industrial environments.