Please wait a minute...
浙江大学学报(工学版)  2026, Vol. 60 Issue (11): 2442-2452    DOI: 10.3785/j.issn.1008-973X.2026.11.013
计算机技术     
基于多任务对比约束与可控缺陷生成的异常检测算法
刘宇轩1(),苏恩祈1,井佩光1,孙宏博2,*(),苏育挺1
1. 天津大学 电气自动化与信息工程学院,天津 300072
2. 中电信人工智能科技(北京)有限公司,北京 100027
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
 全文: PDF(3832 KB)   HTML
摘要:

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

关键词: 异常检测;  动态扩散;  多任务对比约束;  多尺度特征融合;  无监督学习    
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
收稿日期: 2025-10-08 出版日期: 2026-10-16
CLC:  TP 181  
基金资助: 国家自然科学基金资助项目(62361002).
通讯作者: 孙宏博     E-mail: liuyx2@tju.edu.cn;sunhb3@chinatelecom.cn
作者简介: 刘宇轩(2001—),男,硕士生,从事图像、视频语义分析研究. orcid.org/0009-0005-8351-3454. E-mail:liuyx2@tju.edu.cn
服务  
把本文推荐给朋友
加入引用管理器
E-mail Alert
作者相关文章  
刘宇轩
苏恩祈
井佩光
孙宏博
苏育挺

引用本文:

刘宇轩,苏恩祈,井佩光,孙宏博,苏育挺. 基于多任务对比约束与可控缺陷生成的异常检测算法[J]. 浙江大学学报(工学版), 2026, 60(11): 2442-2452.

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.

链接本文:

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

图 1  基于多任务对比约束与可控缺陷生成的异常检测算法框架
图 2  异常推理过程示意图
类别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
表 1  不同算法在MVTec数据集中的图像级异常检测结果
类别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
表 2  不同算法在MVTec数据集中的像素级异常检测结果
类别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
表 3  不同算法在MVTec数据集中的区域级异常检测结果
算法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
表 4  不同算法在BTAD数据集中的图像级和像素级异常检测结果
图 3  性能指标的收敛曲线
图 4  不同异常合成方法的图像对比
图 5  所提算法在MVTec数据集上的异常定位可视化结果
目标训练组合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
表 5  在MVTec数据集上不同训练目标组合的性能表现
算法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
表 6  不同算法在MVTec数据集上的复杂度对比
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] 蔡蕊,郭钦涵,张子豪,董建锋,张荣,刘宝龙,王勋. 大模型辅助的噪声鲁棒无监督骨架表示学习[J]. 浙江大学学报(工学版), 2026, 60(9): 1972-1979.
[2] 赵明华,吕雨萱,吕佳豪,陈逸飞,石程,胡静. 基于多尺度外观运动融合的视频异常检测[J]. 浙江大学学报(工学版), 2026, 60(8): 1730-1738.
[3] 李国燕,于威,梅玉鹏,张明辉,王新强. 全局局部特征融合的遥感图像建筑物提取[J]. 浙江大学学报(工学版), 2026, 60(5): 1100-1108.
[4] 张雪梅,孙颖,张雪英. 基于无监督图对比学习的语音情感识别[J]. 浙江大学学报(工学版), 2026, 60(4): 782-790.
[5] 李国燕,李鹏辉,刘榕,梅玉鹏,张明辉. 融合多尺度分辨率和带状特征的遥感道路提取[J]. 浙江大学学报(工学版), 2026, 60(3): 585-593.
[6] 刘春娟,包易航,吴小所,闫浩文,朱铁栓,赵浩然. 基于细节增强和跨尺度注意力融合的PCB缺陷检测算法[J]. 浙江大学学报(工学版), 2026, 60(11): 2431-2441.
[7] 张建刚,李肖,冯丹丹. 基于动态核感知的无人机视角路面病害检测方法[J]. 浙江大学学报(工学版), 2026, 60(10): 2141-2152.
[8] 卜玉真,余家斌,马道滨,陈梁宇,孙龙,杨力,章东平. 基于扩散合成与特征挖掘的工业图像异常检测[J]. 浙江大学学报(工学版), 2026, 60(10): 2186-2195.
[9] 肖剑,武亮亮,何昕泽,胡欣. 基于异常检测的图像特征匹配算法[J]. 浙江大学学报(工学版), 2025, 59(6): 1140-1147.
[10] 蒋沁诚,陶建峰,王洋洋,张宇磊,刘成良. 基于EWT-LSTM的工业机器人关节异常检测[J]. 浙江大学学报(工学版), 2025, 59(5): 982-994.
[11] 刘登峰,郭文静,陈世海. 基于内容引导注意力的车道线检测网络[J]. 浙江大学学报(工学版), 2025, 59(3): 451-459.
[12] 王天飞,周文俊,项圣,贺宇航,彭博. 基于异常特征对抗学习的工业图像异常检测方法[J]. 浙江大学学报(工学版), 2025, 59(12): 2566-2575.
[13] 朵琳,殷瑜,段威,张芸,任勇. 基于改进YOLOv8的船舶目标检测算法[J]. 浙江大学学报(工学版), 2025, 59(11): 2379-2388.
[14] 肖刚,卢大鹏,郑文博,程振波,张元鸣. 基于时空图注意力网络的多变量时序数据异常检测方法[J]. 浙江大学学报(工学版), 2025, 59(10): 2134-2143.
[15] 刘欢,李云红,张蕾涛,郭越,苏雪平,朱耀麟,侯乐乐. 基于MA-ConvNext网络和分步关系知识蒸馏的苹果叶片病害识别[J]. 浙江大学学报(工学版), 2024, 58(9): 1757-1767.