Please wait a minute...
Journal of ZheJiang University (Engineering Science)  2026, Vol. 60 Issue (11): 2442-2452    DOI: 10.3785/j.issn.1008-973X.2026.11.013
    
Anomaly detection algorithm based on multi-task contrastive constraints and controllable anomaly synthesis
Yuxuan LIU1(),Enqi SU1,Peiguang JING1,Hongbo SUN2,*(),Yuting SU1
1. School of Electrical and Information Engineering, Tianjin University, Tianjin 300072, China
2. China Telecom Artificial Intelligence Technology (Beijing) Co., Ltd., Beijing 100027, China
Download: HTML     PDF(3832KB) HTML
Export: BibTeX | EndNote (RIS)      

Abstract  

A multi-task, contrastive-constraint-based algorithm was proposed to address the challenge of ambiguous boundaries between normal and anomalous features in unsupervised visual anomaly detection. First, highly realistic anomalous images were generated by a controllable anomaly synthesis module and used as multi-task supervisory signals to train the projection layer. Second, in the feature compactness aggregation task, the distances between normal sample feature embeddings were minimized to guide the projection layer toward a compact representation of normal features. In the anomaly sensitivity task, contrastive loss was minimized to increase the projection layer’s focus on anomaly-sensitive regions. In the anomaly feature suppression task, feature similarity loss was minimized to suppress anomalous features during feature propagation. Finally, multi-scale features extracted by the projection layer were fused by an adaptive fusion reconstruction module to enable accurate anomaly detection and localization. Effectiveness validation experiments were performed on multiple public datasets for the proposed algorithm. Results showed that the proposed algorithm achieved an image-level area under the receiver operating characteristic curve (AUROC) of 99.3% on the MVTec dataset.



Key words: anomaly detection      dynamic diffusion      multi-task contrastive constraint      multi-scale feature fusion      unsupervised learning     
Received: 08 October 2025      Published: 16 October 2026
CLC:  TP 181  
Fund:  国家自然科学基金资助项目(62361002).
Corresponding Authors: Hongbo SUN     E-mail: liuyx2@tju.edu.cn;sunhb3@chinatelecom.cn
Cite this article:

Yuxuan LIU,Enqi SU,Peiguang JING,Hongbo SUN,Yuting SU. Anomaly detection algorithm based on multi-task contrastive constraints and controllable anomaly synthesis. Journal of ZheJiang University (Engineering Science), 2026, 60(11): 2442-2452.

URL:

https://www.zjujournals.com/eng/10.3785/j.issn.1008-973X.2026.11.013     OR     https://www.zjujournals.com/eng/Y2026/V60/I11/2442


基于多任务对比约束与可控缺陷生成的异常检测算法

针对无监督视觉异常检测中正常与异常特征边界区分模糊的问题,提出基于多任务对比约束的算法. 通过可控异常生成模块生成高拟真的异常图像,作为训练投影层的多任务监督信号;在特征紧凑聚合任务中,通过最小化正常样本特征嵌入之间的距离,指导投影层将正常特征紧密聚集;在异常敏感任务中,通过最小化对比度损失,提高投影层对异常敏感区域的关注. 在异常特征抑制任务中,通过最小化特征相似度损失,抑制特征传递过程中的异常特征;通过自适应融合重建模块融合投影层提取的多尺度特征,实现精确的异常检测和定位. 在多个公开数据集上开展算法的有效性验证实验. 结果表明,所提算法在MVTec数据集上的图像级接受者特性曲线下面积(AUROC)为99.3%.


关键词: 异常检测,  动态扩散,  多任务对比约束,  多尺度特征融合,  无监督学习 
Fig.1 Framework of anomaly detection algorithm based on multi-task contrastive constraints and controllable anomaly synthesis
Fig.2 Schematic diagram of anomaly inference process
类别AUROCI/%
PSVDDRIADPaDiMRD4ADATSNNIGSF本研究
地毯92.984.299.898.999.896.5100
铁丝网94.699.696.710099.9100100
皮革90.9100100100100100100
砖瓦97.898.798.199.398.810099.9
木头96.593.099.299.299.699.799.5
瓶子98.699.999.910010096.0100
电缆90.381.992.795.010085.699.2
胶囊76.788.491.396.396.893.997.5
榛子92.083.392.099.910099.8100
金属94.088.598.710098.799.7100
药丸86.183.893.396.696.797.298.2
螺丝钉81.384.585.897.096.886.698.6
牙刷10010096.199.593.1100100
晶体管91.590.997.496.798.395.398.8
拉链97.998.190.398.598.299.698.4
平均值92.191.795.598.598.496.799.3
Tab.1 Image-level anomaly detection results of different algorithms on MVTec dataset
类别AUROCP/%
PSVDDRIADPaDiMRD4ADATSNNIGSF本研究
地毯92.696.399.198.999.197.499.2
铁丝网96.298.897.399.399.099.299.3
皮革97.499.499.299.499.498.999.5
砖瓦91.489.194.195.695.099.796.6
木头90.885.894.995.394.897.396.1
瓶子98.198.498.398.798.896.398.8
电缆96.884.296.797.498.093.398.5
胶囊95.892.898.598.798.697.498.7
榛子97.596.198.298.998.999.599.2
金属98.092.597.297.396.099.598.1
药丸95.195.795.798.298.099.598.4
螺丝钉95.798.898.599.699.197.299.6
牙刷98.198.998.899.198.999.699.1
晶体管97.087.797.592.594.584.794.8
拉链95.197.898.598.298.398.298.5
平均值95.794.297.597.897.897.298.3
Tab.2 Pixel-level anomaly detection results of different algorithms on MVTec dataset
类别AUPRO/%
PSVDDRIADPaDiMRD4ADATSNNIGSF本研究
地毯86.561.496.297.097.370.597.7
铁丝网84.036.494.697.697.266.997.7
皮革75.749.197.899.199.173.299.2
砖瓦92.552.686.090.688.897.292.5
木头81.638.291.190.992.484.493.5
瓶子80.576.494.896.696.481.596.9
电缆84.024.488.891.092.762.094.3
胶囊86.238.293.595.895.751.695.7
榛子84.733.892.695.595.183.796.3
金属84.064.385.692.388.496.892.3
药丸82.551.692.796.496.193.297.0
螺丝钉85.943.994.498.296.643.898.5
牙刷83.950.693.194.593.294.294.5
晶体管50.339.284.578.083.940.183.2
拉链16.963.495.995.495.083.295.8
平均值77.348.292.193.993.974.895.0
Tab.3 Region-level anomaly detection results of different algorithms on MVTec dataset
算法AUROCI/%AUROCP/%
Class 01Class 02Class 03平均值Class 01Class 02Class 03平均值
VT-ADL99.094.077.090.097.671.082.683.7
P-SVDD91.693.691.092.195.772.182.183.3
FastFlow99.482.491.190.997.193.698.396.3
PatchCore95.594.799.396.590.979.399.890.0
CFA98.185.599.094.295.996.098.696.8
AWSSA-UNet93.391.999.094.710082.099.893.9
本研究96.593.999.796.796.296.499.797.4
Tab.4 Image-level and pixel-level anomaly detection results of different algorithms on BTAD dataset
Fig.3 Convergence curves of performance metric
Fig.4 Image comparison of different anomaly synthesis methods
Fig.5 Anomaly localization visualization results of proposed algorithm on MVTec dataset
目标训练组合AUROCI/%AUROCP/%AUPRO/%
可控异常生成策略99.398.395.0
CutPaste 异常合成策略98.998.094.6
基线98.497.793.8
基线$ +{L}_{\text{S}} $99.098.194.5
基线$ +{L}_{\text{S}}+{L}_{\text{C}} $99.198.194.6
基线$ +{L}_{\text{S}}+{L}_{\text{C}}+{L}_{\text{R}} $99.398.294.8
基线$ +{L}_{\text{S}}+{L}_{\text{C}}+{L}_{\text{R}}+\text{AFRM} $99.398.395.0
Tab.5 Performance of different training objective combinations on MVTec dataset
算法ti/sM/MBAUROCI/%AUROCP/%AUPRO/%
P-SVDD0.48—92.195.777.3
PaDiM0.95380095.597.592.1
SPADE1.40140085.596.591.7
本研究0.2245699.398.395.0
Tab.6 Comparison of complexity among different algorithm on MVTec dataset
[1]   张鹏, 田子都, 王浩 基于改进生成对抗网络的飞参数据异常检测方法[J]. 浙江大学学报: 工学版, 2022, 56 (10): 1967- 1976
ZHANG Peng, TIAN Zidu, WANG Hao Flight parameter data anomaly detection method based on improved generative adversarial network[J]. Journal of Zhejiang University: Engineering Science, 2022, 56 (10): 1967- 1976
doi: 10.3785/j.issn.1008-973X.2022.10.008
[2]   YE F, HUANG C, CAO J, et al Attribute restoration framework for anomaly detection[J]. IEEE Transactions on Multimedia, 2022, 24: 116- 127
doi: 10.1109/TMM.2020.3046884
[3]   SALEHI M, EFTEKHAR A, SADJADI N, et al. Puzzle-AE: novelty detection in images through solving puzzles [EB/OL]. (2022–02–10)[2025–10–08]. https://arxiv.org/pdf/2008.12959.
[4]   LI C L, SOHN K, YOON J, et al. CutPaste: self-supervised learning for anomaly detection and localization [C]// Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. Nashville: IEEE, 2021: 9659–9669.
[5]   SCHLÜTER H M, TAN J, HOU B, et al. Self-supervised out-of-distribution detection and localization with natural synthetic anomalies (NSA) [EB/OL]. (2021–09–30)[2025–10–08]. https://arxiv.org/pdf/2109.15222v1.
[6]   ZAVRTANIK V, KRISTAN M, SKOČAJ D. DRÆM: a discriminatively trained reconstruction embedding for surface anomaly detection [C]// Proceedings of the IEEE/CVF International Conference on Computer Vision. Montreal: IEEE, 2022: 8310–8319.
[7]   ZHANG F, ZHU H, CEN Y, et al Low-shot unsupervised visual anomaly detection via sparse feature representation[J]. IEEE Transactions on Neural Networks and Learning Systems, 2025, 36 (5): 7903- 7917
doi: 10.1109/TNNLS.2024.3420818
[8]   CAI Y, LIANG D, LUO D, et al A discrepancy aware framework for robust anomaly detection[J]. IEEE Transactions on Industrial Informatics, 2024, 20 (3): 3986- 3995
doi: 10.1109/TII.2023.3318302
[9]   ZHANG F, KAN S, ZHANG D, et al A graph model-based multiscale feature fitting method for unsupervised anomaly detection[J]. Pattern Recognition, 2023, 138: 109373
doi: 10.1016/j.patcog.2023.109373
[10]   IULIANO A, LIÒ P, MANFREDI G, et al. Denoising probabilistic diffusion models for synthetic healthcare image generation [C]// Proceedings of the IEEE International Workshop on Metrology for Living Environment. Chania: IEEE, 2024: 415–420.
[11]   HO J, JAIN A, ABBEEL P. Denoising diffusion probabilistic models [EB/OL]. (2020–12–16)[2025–10–08]. https://arxiv.org/pdf/2006.11239.
[12]   ZAGORUYKO S, KOMODAKIS N. Wide residual networks [EB/OL]. (2017–06–14)[2025–10–08]. https://arxiv.org/pdf/1605.07146.
[13]   DEFARD T, SETKOV A, LOESCH A, et al. PaDiM: a patch distribution modeling framework for anomaly detection and localization [C]// Pattern Recognition. ICPR International Workshops and Challenges. Cham: Springer, 2021: 475–489.
[14]   JOYCE J M. Kullback-Leibler divergence [M]// LOVRIC M. International encyclopedia of statistical science. [S.l.]: Springer, 2011: 720–722.
[15]   BERGMANN P, FAUSER M, SATTLEGGER D, et al. MVTec AD: a comprehensive real-world dataset for unsupervised anomaly detection [C]// Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. Long Beach: IEEE, 2020: 9584–9592.
[16]   MISHRA P, VERK R, FORNASIER D, et al. VT-ADL: a vision transformer network for image anomaly detection and localization [C]// Proceedings of the IEEE 30th International Symposium on Industrial Electronics. Kyoto: IEEE, 2021: 1–6.
[17]   YI J, YOON S. Patch SVDD: patch-level SVDD for anomaly detection and segmentation [C]// Computer Vision – ACCV 2020. Cham: Springer, 2021: 375–390.
[18]   ZAVRTANIK V, KRISTAN M, SKOČAJ D Reconstruction by inpainting for visual anomaly detection[J]. Pattern Recognition, 2021, 112: 107706
doi: 10.1016/j.patcog.2020.107706
[19]   COHEN N, HOSHEN Y. Sub-image anomaly detection with deep pyramid correspondences [EB/OL]. (2021–02–03)[2025–10–08]. https://arxiv.org/pdf/2005.02357.
[20]   DENG H, LI X. Anomaly detection via reverse distillation from one-class embedding [C]// Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. New Orleans: IEEE, 2022: 9727–9736.
[21]   XING P, SUN Y, ZENG D, et al Normal image guided segmentation framework for unsupervised anomaly detection[J]. IEEE Transactions on Circuits and Systems for Video Technology, 2024, 34 (6): 4639- 4652
doi: 10.1109/TCSVT.2023.3327448
[22]   ROTH K, PEMULA L, ZEPEDA J, et al. Towards total recall in industrial anomaly detection [C]// Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. New Orleans: IEEE, 2022: 14298–14308.
[23]   DE PAULA MONTEIRO R, LOZADA M C, MENDIETA D R C, et al A hybrid prototype selection-based deep learning approach for anomaly detection in industrial machines[J]. Expert Systems with Applications, 2022, 204: 117528
doi: 10.1016/j.eswa.2022.117528
[1] Rui CAI,Qinhan GUO,Zihao ZHANG,Jianfeng DONG,Rong ZHANG,Baolong LIU,Xun WANG. Large model-assisted noise-robust unsupervised skeleton representation learning[J]. Journal of ZheJiang University (Engineering Science), 2026, 60(9): 1972-1979.
[2] Minghua ZHAO,Yuxuan LYU,Jiahao LYU,Yifei CHEN,Cheng SHI,Jing HU. Video anomaly detection based on multi-scale appearance and motion fusion[J]. Journal of ZheJiang University (Engineering Science), 2026, 60(8): 1730-1738.
[3] Guoyan LI,Wei YU,Yupeng MEI,Minghui ZHANG,Xinqiang WANG. Building extraction from remote sensing images with global-local feature fusion[J]. Journal of ZheJiang University (Engineering Science), 2026, 60(5): 1100-1108.
[4] Xuemei ZHANG,Ying SUN,Xueying ZHANG. Speech emotion recognition with unsupervised graph contrastive learning[J]. Journal of ZheJiang University (Engineering Science), 2026, 60(4): 782-790.
[5] Guoyan LI,Penghui LI,Rong LIU,Yupeng MEI,Minghui ZHANG. Remote sensing road extraction by fusing multi-scale resolution and strip feature[J]. Journal of ZheJiang University (Engineering Science), 2026, 60(3): 585-593.
[6] Chunjuan LIU,Yihang BAO,Xiaosuo WU,Haowen YAN,Tieshuan ZHU,Haoran ZHAO. PCB defect detection algorithm based on detail enhancement and cross-scale attention fusion[J]. Journal of ZheJiang University (Engineering Science), 2026, 60(11): 2431-2441.
[7] Jiangang ZHANG,Xiao LI,Dandan FENG. Dynamic kernel perception for pavement distress detection in UAV inspection[J]. Journal of ZheJiang University (Engineering Science), 2026, 60(10): 2141-2152.
[8] Yuzhen BU,Jiabin YU,Daobin MA,Liangyu CHEN,Long SUN,Li YANG,Dongping ZHANG. Industrial image anomaly detection via diffusion synthesis and feature mining[J]. Journal of ZheJiang University (Engineering Science), 2026, 60(10): 2186-2195.
[9] Jian XIAO,Liangliang WU,Xinze HE,Xin HU. Image feature matching algorithm based on anomaly detection[J]. Journal of ZheJiang University (Engineering Science), 2025, 59(6): 1140-1147.
[10] Qincheng JIANG,Jianfeng TAO,Yangyang WANG,Yulei ZHANG,Chengliang LIU. EWT-LSTM based industrial robot joint anomaly detection[J]. Journal of ZheJiang University (Engineering Science), 2025, 59(5): 982-994.
[11] Dengfeng LIU,Wenjing GUO,Shihai CHEN. Content-guided attention-based lane detection network[J]. Journal of ZheJiang University (Engineering Science), 2025, 59(3): 451-459.
[12] Bote WANG,Qing WANG,Qiang LIU,Bo JIN. Self-supervised anomaly recognition method for wind turbine blade based on multi-channel vibration principal features[J]. Journal of ZheJiang University (Engineering Science), 2025, 59(3): 653-660.
[13] Tianfei WANG,Wenjun ZHOU,Sheng XIANG,Yuhang HE,Bo PENG. Industrial image anomaly detection method based on adversarial learning of abnormal features[J]. Journal of ZheJiang University (Engineering Science), 2025, 59(12): 2566-2575.
[14] Gang XIAO,Dapeng LU,Wenbo ZHENG,Zhenbo CHENG,Yuanming ZHANG. Multivariable time series data anomaly detection method based on spatiotemporal graph attention network[J]. Journal of ZheJiang University (Engineering Science), 2025, 59(10): 2134-2143.
[15] Yi LIU,Yidan CHEN,Lin GAO,Jiao HONG. Lightweight road extraction model based on multi-scale feature fusion[J]. Journal of ZheJiang University (Engineering Science), 2024, 58(5): 951-959.