金文倩 朱媛媛 王笑梅
摘? 要: 提出一種以U-Net為基礎(chǔ),依據(jù)零件缺陷的特點(diǎn)對(duì)網(wǎng)絡(luò)進(jìn)行一系列改進(jìn)的模型,以提升網(wǎng)絡(luò)對(duì)零件缺陷的分割精度.首先在U-Net結(jié)構(gòu)中的編碼階段,使用改進(jìn)的殘差網(wǎng)絡(luò)Res2Net提高該階段的特征提取能力;然后在網(wǎng)絡(luò)編碼器與解碼器的中間部位增加空洞卷積,在不改變特征圖尺寸的情況下增加感受野,降低誤檢率與漏檢率;最后在U-Net的輸出階段與Mini U-Net進(jìn)行結(jié)合,對(duì)原本的輸出結(jié)果進(jìn)行二次補(bǔ)丁,提高對(duì)微小缺陷的檢測(cè)精度.實(shí)驗(yàn)結(jié)果表明,對(duì)MVTec數(shù)據(jù)集進(jìn)行分割的F1-Score分?jǐn)?shù)達(dá)到87.21%,時(shí)間為0.017 s,達(dá)到了良好的檢測(cè)效果.
關(guān)鍵詞: 圖像分割; 缺陷檢測(cè); U-Net; Res2Net; 空洞卷積
中圖分類號(hào): TP 391??? 文獻(xiàn)標(biāo)志碼: A??? 文章編號(hào): 1000-5137(2022)02-0129-06
Part defect segmentation and annotation based on improved U-Net
JIN Wenqian, ZHU Yuanyuan*, WANG Xiaomei
(College of Information, Mechanical and Electrical Engineering, Shanghai Normal University, Shanghai 201418, China)
Abstract:A model based on U-Net network and a series of improvements to it according to the characteristics of part defects were proposed to improve the segmentation accuracy of part defects. Firstly, the improved residual network Res2Net was used in the coding stage of U-Net network structure to improve the feature extraction ability during this stage. Secondly, the hole convolution was added in the middle of the network encoder and decoder, and the receptive field was increased without changing the size of the characteristic image, so as to reduce the false detection rate and omission detection rate. Finally, in the output stage of U-Net, Mini U-Net was combined with to patch the original output results, so as to improve the detection accuracy of small defects. The experimental results showed that the F1-Score of MVtec dataset segmentation reached 87.21% and the time was 0.017 s, with which outstanding detection effect could be achieved.
Key words:image segmentation; defect detection; U-Net; Res2Net; void convolution
0? 引言
將深度學(xué)習(xí)和缺陷檢測(cè)問題相結(jié)合是當(dāng)下十分熱門的研究領(lǐng)域.CHEN等[1]結(jié)合single shot multibox detector(SSD)網(wǎng)絡(luò)及you only look once(YOLO)算法構(gòu)建了一個(gè)由粗到細(xì)的級(jí)聯(lián)檢測(cè)網(wǎng)絡(luò),對(duì)高鐵線路緊固件進(jìn)行缺陷檢測(cè);CHA等[2]通過faster region convolutional neural networks(FasterRCNN)檢測(cè)混凝土裂縫,中、高兩級(jí)鋼腐蝕,螺栓腐蝕和鋼筋分層5種損傷類型;YU等[3]提出一種基于YOLOv4的空心杯電樞表面空洞缺陷檢測(cè)的方法,解決空心杯電樞表面微小缺陷檢測(cè)過程中檢測(cè)精度低、速度慢以及不能實(shí)時(shí)檢測(cè)等問題.上述檢測(cè)算法對(duì)于缺陷僅能進(jìn)行籠統(tǒng)的方框標(biāo)注,無法精確到圖像的具體像素.本文作者將圖像分割應(yīng)用到目標(biāo)缺陷檢測(cè)領(lǐng)域,將圖像中的像素分割出來,對(duì)應(yīng)到不同類別中.首先在U-Net結(jié)構(gòu)的[4]編碼階段使用改進(jìn)的殘差網(wǎng)絡(luò)Res2Net[5]提高特征提取能力,使用更細(xì)粒度進(jìn)行特征提取.在網(wǎng)絡(luò)編碼器與解碼器的中間部位增加空洞卷積[6],通過改變擴(kuò)張率來擴(kuò)大感受野,在不改變特征圖尺寸的情況下獲取不同尺度的特征信息,可以避免下采樣所造成的細(xì)節(jié)信息丟失等問題,降低誤檢率與漏檢率.最后在U-Net的輸出階段,將之與Mini U-Net[7]進(jìn)行結(jié)合,對(duì)原本的輸出結(jié)果進(jìn)行二次補(bǔ)丁,提高對(duì)微小缺陷的檢測(cè)精度.98883410-D20E-490F-9F06-C3584C2EAFBE
1? 改進(jìn)的U-Net模型
1.1模型結(jié)構(gòu)
對(duì)U-Net模型編碼器-解碼器的基本結(jié)構(gòu)進(jìn)行改進(jìn)(圖1).
在模型的編碼器階段,將原先的普通卷積結(jié)構(gòu)替換為Res2Net模型[8],使用更細(xì)的粒度獲取多尺度特征,擴(kuò)大圖像感受野,增加圖像分割的精度.
編碼器與解碼器之間連接空洞卷積結(jié)構(gòu),進(jìn)一步擴(kuò)大感受野,獲得不同尺度的特征圖像.如圖1所示,先串聯(lián)空洞率分別為1,2,4的3個(gè)空洞卷積,每層的感受野分別為3,7,15[9].U-Net的編碼器部分有4個(gè)下采樣層,在最后一個(gè)特征圖上融合了第一個(gè)特征圖上的特征信息,并以此覆蓋第一個(gè)特征圖上的特征信息.
Mini U-Net是由U-Net的中間部分組成的.最后將U-Net的輸出部分連接一個(gè)Mini U-Net對(duì)U-Net的輸出結(jié)果作二次補(bǔ)丁,避免零件因存在微小缺陷而導(dǎo)致的模糊和細(xì)節(jié)丟失等情況.
1.2Res2Net
Res2Net結(jié)構(gòu)圖如圖2所示.
由此可以得到不同數(shù)量以及不同感受野大小的輸出,再經(jīng)過一個(gè)1×1的卷積,將輸出進(jìn)行融合.這種先拆分再融合的策略能夠提高特征處理的效率.
1.3空洞卷積
增加網(wǎng)絡(luò)特征點(diǎn)的感受野就意味著要增加接觸到的圖像范圍,這樣能獲得更多語義層次及更好的特征,感受野越大,包含的特征更加趨于全局;反之,包含的特征會(huì)趨于局部.由Visual Geometry Group(VGG)網(wǎng)絡(luò)可知,1個(gè)7×7卷積層的正則化等效于3個(gè)3×3卷積層的疊加,通過多個(gè)小的卷積層的疊加不僅可以大幅度地減少運(yùn)算參數(shù),還能具備同樣的正則化效果,減少了過擬合的可能性,更好地緩解了U-Net在縮小放大過程所產(chǎn)生的特征圖細(xì)節(jié)丟失和精度下降的問題.
2? 實(shí)驗(yàn)與分析
2.1消融實(shí)驗(yàn)
為了驗(yàn)證本研究方法的有效性,設(shè)計(jì)了消融實(shí)驗(yàn)檢驗(yàn)Res2Net、空洞卷積和MiniU-Net分別對(duì)零件圖像分割標(biāo)注的影響效果,如表1所示.
由表1可知:原始的U-Net模型在零件數(shù)據(jù)集上進(jìn)行分割標(biāo)注實(shí)驗(yàn)的分割效果尚佳,但準(zhǔn)確率較低;將原先的卷積結(jié)構(gòu)改進(jìn)為Res2Net之后,各項(xiàng)性能都有了一定程度的提升,但是召回率的提升幅度較小;在此基礎(chǔ)上繼續(xù)增加空洞卷積提高感受野,模型的性能得到進(jìn)一步的提高;再加入MiniU-Net進(jìn)行第二次補(bǔ)丁訓(xùn)練,3個(gè)指標(biāo)都有明顯的提升.從原始U-Net模型到最終的模型,每增加一個(gè)改進(jìn)模塊,模型的性能都有不同程度的提升,體現(xiàn)了模型改進(jìn)的有效性.
2.2基于MVTec螺絲數(shù)據(jù)集異常區(qū)域分割
圖4為使用改進(jìn)的U-Net模型對(duì)MVTec螺絲數(shù)據(jù)集[10]進(jìn)行異常區(qū)域分割的結(jié)果.數(shù)據(jù)集共有mainpulated_front螺絲前端、scratch_head頂部劃痕、scratch_neck頸部劃痕、thread_side螺紋側(cè)面4個(gè)部位的缺陷.圖4展示了數(shù)據(jù)集中的ground_truth標(biāo)簽圖,可以看出改進(jìn)的U-Net模型可以將數(shù)據(jù)集中的異常區(qū)域分割出來,準(zhǔn)確率較高,對(duì)于thread_side螺紋側(cè)面缺陷存在一定的漏檢現(xiàn)象.
表2為對(duì)螺絲數(shù)據(jù)集的檢測(cè)結(jié)果.從表2中可以看出,本研究的模型對(duì)于各缺陷檢測(cè)的平均精度均值(mAP)均在80%以上,有良好的分割效果.其中,對(duì)于scratch_head頂部劃痕的分割效果最好,達(dá)到91.19%,對(duì)于thread_side螺紋側(cè)面的分割效果最差.
3? 結(jié)論
通過在U-Net的編碼器階段添加改進(jìn)的ResNet結(jié)構(gòu),增加檢測(cè)粒度;在編碼器與解碼器中間部位連接空洞卷積,在不改變特征圖尺寸大小的情況下,增加模型感受野;在U-Net解碼器的輸出部分連接MiniU-Net,對(duì)網(wǎng)絡(luò)進(jìn)行二次補(bǔ)丁,提高微小缺陷的檢測(cè)精度.實(shí)驗(yàn)結(jié)果表明,改進(jìn)后的U-Net具有良好的檢測(cè)效果,檢測(cè)速度較快,檢測(cè)精度較高.
參考文獻(xiàn):
[1]? CHEN J W, LIU Z G, WANG H R, et al. Automatic defect detection of fasteners on the catenary support device using deep convolutional neural network [J]. IEEE Transactions on Instrumentation and Measurement,2018,67(2):257-269.
[2]? CHA Y, CHOI W, SUH G, et al. Autonomous structural visual inspection using region:based deep learning for detecting multiple damage types [J]. Computer‐Aided Civil and Infrastructure Engineering,2018,33(9):731-747.
[3]? YU C H, HUANG H S, ZENG F, et al. Real-time detection of surface defects of hollow cup armature base on YOLO_v4 [J]. Modular Machine Tool & Manufacturing Technique,2021(6):59-62,66.98883410-D20E-490F-9F06-C3584C2EAFBE
[4]? RONNEBERGER O, FISCHER P, BROX T. U-Net: convolutional networks for biomedical image segmentation [C]// International Conference on Medical Image Computing and Computer-Assisted Intervention. Strasbourg: Springer,2015:234-241.
[5]? GAO S H,CHENG M M,ZHAO K, et al. Res2Net: a new multi?scale backbone architecture[J]. IEEE Transactions on Pattern Analysis and Machine Intelligence,2019, 43(2):652-662.
[6]? YU F, KOLTUN V. Multi?scale context aggregation by dilated convolutions [C]// International Conference on Learning Representations. ICLR: San Juan,2016:arXiv:1511.07122.
[7]? CAI Q H, LIU Y H, ZHANG R F.Two-stage retinal vessel segmentation based on improved U-Net [J]. Laser & Optoelectronics Progress,2021,58(16):480-490.
[8]? HE K M, ZHANG X Y, REN S Q, et al. Deep residual learning for image recognition [C]// 2016 IEEE Conference on Computer Vision and Pattern Recognition. Las Vegas: IEEE,2016:770-778.
[9]? QU Z, CHEN W.Concrete pavement crack detection based on dilated convolution and multi-features fusion [J/OL].Computer Science[2021-12-23]. http:// kns.cnki.net/kcms/detail/50.1075.TP.20211011.1608.004.html.
[10] BERGMANN P, BATZNER K, FAUSER M, et al. The MVTec anomaly detection dataset: a comprehensive real?world dataset for unsupervised anomaly detection [J]. International Journal of Computer Vision,2021,129(1):1038-1059.
(責(zé)任編輯:包震宇,顧浩然)98883410-D20E-490F-9F06-C3584C2EAFBE
上海師范大學(xué)學(xué)報(bào)·自然科學(xué)版2022年2期