CN111915593A - Model building method, device, electronic device and storage medium - Google Patents

Model building method, device, electronic device and storage medium Download PDF

Info

Publication number
CN111915593A
CN111915593A CN202010775330.3A CN202010775330A CN111915593A CN 111915593 A CN111915593 A CN 111915593A CN 202010775330 A CN202010775330 A CN 202010775330A CN 111915593 A CN111915593 A CN 111915593A
Authority
CN
China
Prior art keywords
defect
feature map
image
model
detection
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202010775330.3A
Other languages
Chinese (zh)
Other versions
CN111915593B (en
Inventor
郝灿
彭沛然
王颖
高超
董登峰
王博
刘彤
周维虎
袁江
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Institute of Microelectronics of CAS
Original Assignee
Institute of Microelectronics of CAS
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Institute of Microelectronics of CAS filed Critical Institute of Microelectronics of CAS
Priority to CN202010775330.3A priority Critical patent/CN111915593B/en
Publication of CN111915593A publication Critical patent/CN111915593A/en
Application granted granted Critical
Publication of CN111915593B publication Critical patent/CN111915593B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/0002Inspection of images, e.g. flaw detection
    • G06T7/0004Industrial image inspection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10004Still image; Photographic image
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20081Training; Learning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20084Artificial neural networks [ANN]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/30Subject of image; Context of image processing
    • G06T2207/30108Industrial image inspection
    • G06T2207/30124Fabrics; Textile; Paper

Landscapes

  • Engineering & Computer Science (AREA)
  • Quality & Reliability (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Image Analysis (AREA)
  • Investigating Materials By The Use Of Optical Means Adapted For Particular Applications (AREA)

Abstract

A model establishing method, a device, electronic equipment and a storage medium for flaw detection are applied to the technical field of detection and comprise the following steps: establishing an image set, wherein the image set comprises defects of different types; constructing a flaw detection network model based on the image set and the Faster R-CNN; training the flaw detection network model to obtain a classification detection model; the classification detection model is used for detecting flaws of an image to be detected and outputting types, shapes and positions of the flaws in the image to be detected. The method can be used for detecting the flaw of the extreme size.

Description

模型建立方法、装置、电子设备及存储介质Model building method, device, electronic device and storage medium

技术领域technical field

本公开涉及图像检测技术领域,尤其涉及一种用于瑕疵检测的模型建立方法、装置、电子设备及存储介质。The present disclosure relates to the technical field of image detection, and in particular, to a model establishment method, device, electronic device and storage medium for defect detection.

背景技术Background technique

近年来,随着科技的发展,产品质量检测的自动化成为现代生产发展的主要趋势之一,自动化检验瑕疵对减轻劳动力、提高生产效率、推进行业智能化有重要意义。In recent years, with the development of science and technology, the automation of product quality inspection has become one of the main trends in the development of modern production. Automated inspection of defects is of great significance to reduce labor, improve production efficiency, and promote industry intelligence.

传统的人工目检的方法存在检测效率低、检测速度慢、检测精度低、检测标准不一致等问题。由于检测工作时间长,检验人员很容易产生视觉疲劳,不仅误检率和漏检率居高不下,对人眼的损伤也极大。所以,基于机器视觉和深度学习的瑕疵检测方法应运而生。The traditional manual visual inspection method has problems such as low detection efficiency, slow detection speed, low detection accuracy, and inconsistent detection standards. Due to the long inspection work time, inspectors are prone to visual fatigue, not only the false detection rate and missed inspection rate are high, but also the damage to the human eye is great. Therefore, defect detection methods based on machine vision and deep learning emerge as the times require.

针对瑕疵检测深度学习算法被广泛研究,主要应用在面料、毛毯、地砖等表面瑕疵检测上。现有技术中,有的利用基础网络、区域提议网络以及Fast R-CNN检测网络,建立基于深度学习的图像分类模型,在训练过程中每次迭代对输入数据进行特征提取,无需人工设计繁琐的图像特征提取器,但也仅仅是针对常规形状瑕疵完成初步的图像数据筛选,没有进行面料等瑕疵的特征加强,此外,卷积过程也将丢失较细小的瑕疵特征,因此检测精度不高。有的通过快速循环卷积神经网络方法搜索定位瑕疵区域,将特征和检测器结合到一个框架中,自动检测布匹瑕疵。其中运用RPN网络生成建议窗口,每张图片生成300个建议窗口,建议窗口的数量非常大,导致检测速度很慢。Deep learning algorithms for defect detection have been widely studied, and are mainly used in surface defect detection such as fabrics, blankets, and floor tiles. In the prior art, some use the basic network, the region proposal network and the Fast R-CNN detection network to establish an image classification model based on deep learning, and perform feature extraction on the input data in each iteration during the training process, without the need for manual design of cumbersome images. The image feature extractor only completes the preliminary image data screening for conventional shape defects, and does not enhance the characteristics of defects such as fabrics. In addition, the convolution process will also lose smaller defect features, so the detection accuracy is not high. Some search and locate defect areas through fast recurrent convolutional neural network methods, and combine features and detectors into a framework to automatically detect cloth defects. Among them, the RPN network is used to generate suggestion windows, and each image generates 300 suggested windows. The number of suggested windows is very large, resulting in very slow detection speed.

发明内容SUMMARY OF THE INVENTION

本公开的主要目的在于提供一种用于瑕疵检测的模型建立方法、装置、电子设备及存储介质,检测精度高,可用于极端尺寸的瑕疵检测。The main purpose of the present disclosure is to provide a model establishment method, device, electronic device and storage medium for flaw detection, which has high detection accuracy and can be used for flaw detection of extreme sizes.

为实现上述目的,本公开实施例第一方面提供一种用于瑕疵检测的模型建立方法,包括:In order to achieve the above object, a first aspect of the embodiments of the present disclosure provides a method for establishing a model for defect detection, including:

建立图像集,所述图像集中包括不同类型的瑕疵;creating a set of images that includes different types of imperfections;

基于所述图像集和Faster R-CNN搭建瑕疵检测网络模型;Build a defect detection network model based on the image set and Faster R-CNN;

训练所述瑕疵检测网络模型,得到分类检测模型;Train the defect detection network model to obtain a classification detection model;

其中,所述分类检测模型,用于对待检测图像进行瑕疵检测,输出所述待检测图像中瑕疵的类型、形状和位置。Wherein, the classification detection model is used to perform flaw detection on the image to be detected, and output the type, shape and position of the flaw in the image to be detected.

可选的,所述建立图像集包括:Optionally, the establishing an image set includes:

采集至少一个图像,并对所述图像中的瑕疵采用标签进行标注,得到所述图像集;collecting at least one image, and labeling the defects in the image with a label to obtain the image set;

其中,所述标签标注有瑕疵的类型、形状和位置信息中的至少一个。Wherein, the label is marked with at least one of the type, shape and position information of the defect.

可选的,所述基于所述图像集和Faster R-CNN搭建瑕疵检测网络模型包括:Optionally, the building a defect detection network model based on the image set and Faster R-CNN includes:

将所述图像集输入特征金字塔网络,得到第一瑕疵特征图,所述特征金字塔网络采用ResNet-50特征提取网络;Inputting the image set into a feature pyramid network to obtain a first defect feature map, and the feature pyramid network adopts a ResNet-50 feature extraction network;

将所述第一瑕疵特征图输入先验锚生成网络,构建基于Faster R-CNN的瑕疵检测网络模型。The first defect feature map is input into the prior anchor generation network, and a defect detection network model based on Faster R-CNN is constructed.

可选的,所述将所述图像集输入特征金字塔网络,得到第一瑕疵特征图包括:Optionally, the inputting the image set into the feature pyramid network to obtain the first defect feature map includes:

将所述图像集输入所述特征金字塔网络;inputting the image set into the feature pyramid network;

对所述图像集中的标注的瑕疵自下而上做卷积以获取尺寸依次减小的初步瑕疵特征图;Convolving the marked flaws in the image set from bottom to top to obtain a preliminary flaw feature map with decreasing sizes;

将所有初步瑕疵特征图均进行1*1卷积降维,得到中间瑕疵特征图;Perform 1*1 convolutional dimension reduction on all preliminary defect feature maps to obtain intermediate defect feature maps;

将所有中间瑕疵特征图均自上而下进行上采样,并均与相邻的下一尺寸的中间瑕疵特征图进行融合,得到尺寸依次减小第一瑕疵特征图。All the intermediate defect feature maps are up-sampled from top to bottom, and are fused with the adjacent intermediate defect feature maps of the next size to obtain the first defect feature map with decreasing size in turn.

可选的,所述将所述第一瑕疵特征图输入先验锚生成网络,构建基于Faster R-CNN的瑕疵检测网络模型包括:Optionally, inputting the first defect feature map into a priori anchor generation network, and constructing a defect detection network model based on Faster R-CNN includes:

在尺寸依次减小第一瑕疵特征图中生成候选子区域;generating candidate sub-regions in the first defect feature map with successively decreasing sizes;

根据每个图像中标签标注的瑕疵的位置,得到真值框;According to the position of the defect marked by the label in each image, the ground-truth box is obtained;

将每个图像的候选子区域与真值框进行比较,筛选出候选锚;Compare the candidate sub-regions of each image with the ground-truth box to filter out candidate anchors;

通过回归调整所述候选锚的形状,使每个图像的候选锚趋近于真值框,得到与所述尺寸依次减小第一瑕疵特征图对应的先验锚;Adjust the shape of the candidate anchor by regression, so that the candidate anchor of each image is close to the ground truth frame, and obtain the prior anchor corresponding to the first defect feature map with the size decreasing in turn;

将所述尺寸依次减小第一瑕疵特征图和所述第一瑕疵特征图对应的先验锚输入预设的分类网络,确定所述瑕疵检测网络模型的参数。The size is sequentially reduced to the first defect feature map and the prior anchors corresponding to the first defect feature map are input into a preset classification network to determine the parameters of the defect detection network model.

可选的,所述分类网络包括1个池化层和4个全连接层,所述将所述尺寸依次减小第一瑕疵特征图和所述第一瑕疵特征图对应的先验锚输入预设的分类网络,确定所述瑕疵检测网络模型的参数包括:Optionally, the classification network includes one pooling layer and four fully-connected layers, and the first defect feature map and the prior anchor input corresponding to the first defect feature map are sequentially reduced in size. The set classification network, the parameters to determine the defect detection network model include:

将所述尺寸依次减小第一瑕疵特征图和所述第一瑕疵特征图对应的先验锚输入至所述池化层,得到尺寸均相同的特征图和与所述特征图相对应的先验锚;The first defect feature map and the prior anchors corresponding to the first defect feature map are sequentially reduced in size and input to the pooling layer to obtain feature maps with the same size and prior anchors corresponding to the feature maps. Anchor test;

将所述尺寸均相同的特征图和与所述特征图相对应的先验锚作为第一个全连接层的输入,得到所述第一个全连接层的输出;Using the feature map with the same size and the prior anchor corresponding to the feature map as the input of the first fully connected layer to obtain the output of the first fully connected layer;

将所述第一个全连接层的输出作为第二个全连接层的输入,得到所述第二个全连接层的输出;Using the output of the first fully connected layer as the input of the second fully connected layer to obtain the output of the second fully connected layer;

将所述第二个全连接层的输出作为第三个全连接层的输入,使所述第三个全连接层通过回归输出每个图像中瑕疵的位置和形状信息;The output of the second fully connected layer is used as the input of the third fully connected layer, so that the third fully connected layer outputs the position and shape information of the flaws in each image through regression;

将所述第二个全连接层的输出作为第四个全连接层的输入,使所述第四个全连接层通过Softmax分类输出每个图像中瑕疵的类型信息。The output of the second fully-connected layer is used as the input of the fourth fully-connected layer, so that the fourth fully-connected layer outputs the type information of defects in each image through Softmax classification.

可选的,在训练所述瑕疵检测网络模型的过程中,采用交叉熵损失函数和先验锚的形状预测损失函数对所述瑕疵检测网络模型的训练过程进行约束。Optionally, in the process of training the defect detection network model, a cross-entropy loss function and a shape prediction loss function of a priori anchor are used to constrain the training process of the defect detection network model.

本公开实施例第二方面提供一种用于瑕疵检测的模型建立装置,包括:A second aspect of the embodiments of the present disclosure provides a model building apparatus for defect detection, including:

建立模块,用于建立图像集,所述图像集中包括不同类型的瑕疵;a building module for building an image set, the image set including different types of flaws;

搭建模块,用于基于所述图像集和Faster R-CNN搭建瑕疵检测网络模型;Building a module for building a defect detection network model based on the image set and Faster R-CNN;

训练模块,用于训练所述瑕疵检测网络模型,得到分类检测模型;a training module for training the defect detection network model to obtain a classification detection model;

其中,所述分类检测模型,用于对待检测图像进行瑕疵检测,输出所述待检测图像中瑕疵的类型、形状和位置。Wherein, the classification detection model is used to perform flaw detection on the image to be detected, and output the type, shape and position of the flaw in the image to be detected.

本公开实施例第三方面提供了一种电子设备,包括:A third aspect of the embodiments of the present disclosure provides an electronic device, including:

存储器,处理器及存储在存储器上并可在处理器上运行的计算机程序,其特征在于,所述处理器执行所述程序时实现本公开实施例第一方面提供的用于瑕疵检测的模型建立方法。A memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, when the processor executes the program, the model for defect detection provided by the first aspect of the embodiments of the present disclosure is implemented method.

本公开实施例第四方面提供了一种计算机可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现本公开实施例第一方面提供的用于瑕疵检测的模型建立方法。A fourth aspect of the embodiments of the present disclosure provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, implements the model establishment for defect detection provided in the first aspect of the embodiments of the present disclosure method.

从上述本公开实施例可知,本公开提供的用于瑕疵检测的模型建立方法、装置、电子设备及存储介质,通过特征金字塔网络的多尺寸特征融合算法,把本层特征与相邻的下一层特征融合,解决了传统神经网络中多层卷积提取特征时只选取最上层特征图造成的瑕疵特征信息丢失的问题,增强了小瑕疵的细节特征,使得瑕疵特征提取更准确,提高了对小瑕疵和细长瑕疵等极端形状瑕疵的敏感度和检测能力。通过对各尺寸第一瑕疵特征图上候选子区域的选择,得到较少数量的候选锚,再利用回归调整候选锚的尺寸,最终得到与瑕疵特征尺寸最接近的先验锚,该方法确定的先验锚不仅适用于极端尺寸的瑕疵检测,解决了Faster R-CNN网络中锚的形状固定的问题,有效地避免了锚的形状与瑕疵尺寸相差较大的情况,同时确定先验锚的过程也大大减少了候选锚的数量,有效地提高了检测速度。It can be seen from the above embodiments of the present disclosure that the model building method, device, electronic device and storage medium for defect detection provided by the present disclosure, through the multi-scale feature fusion algorithm of the feature pyramid network, the features of this layer and the adjacent next Layer feature fusion solves the problem of loss of defect feature information caused by only selecting the uppermost layer feature map when extracting features by multi-layer convolution in traditional neural networks, enhances the details of small defects, makes defect feature extraction more accurate, and improves accuracy. Sensitivity and detection capabilities for extreme shape flaws such as small and elongated flaws. By selecting the candidate sub-regions on the first defect feature map of each size, a smaller number of candidate anchors are obtained, and then the size of the candidate anchors is adjusted by regression, and finally the prior anchor closest to the size of the defect feature is obtained. The prior anchor is not only suitable for flaw detection of extreme sizes, but also solves the problem of the fixed shape of the anchor in the Faster R-CNN network. It also greatly reduces the number of candidate anchors, effectively improving the detection speed.

附图说明Description of drawings

为了更清楚地说明本公开实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本公开的一些实施例,对于本领域技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the following briefly introduces the accompanying drawings that need to be used in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only These are some embodiments of the present disclosure, and for those skilled in the art, other drawings can also be obtained from these drawings without creative effort.

图1为本公开一实施例提供的用于瑕疵检测的模型建立方法的流程示意图;FIG. 1 is a schematic flowchart of a model building method for defect detection according to an embodiment of the present disclosure;

图2为本公开一实施例提供的特征金字塔网络的示意图;2 is a schematic diagram of a feature pyramid network provided by an embodiment of the present disclosure;

图3为本公开一实施例提供的先验锚生成网络的示意图;3 is a schematic diagram of a prior anchor generation network provided by an embodiment of the present disclosure;

图4为本公开一实施例提供的分类检测模型的训练流程图;FIG. 4 is a training flowchart of a classification detection model provided by an embodiment of the present disclosure;

图5为本公开一实施例提供的用于瑕疵检测的模型建立装置的结构示意图;FIG. 5 is a schematic structural diagram of a model building apparatus for defect detection according to an embodiment of the present disclosure;

图6示出了一种电子设备的硬件结构示意图。FIG. 6 shows a schematic diagram of the hardware structure of an electronic device.

具体实施方式Detailed ways

为使得本公开的公开目的、特征、优点能够更加的明显和易懂,下面将结合本公开实施例中的附图,对本公开实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本公开一部分实施例,而非全部实施例。基于本公开中的实施例,本领域技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本公开保护的范围。In order to make the disclosed purposes, features and advantages of the present disclosure more obvious and understandable, the technical solutions in the embodiments of the present disclosure will be described clearly and completely below with reference to the accompanying drawings in the embodiments of the present disclosure. The embodiments described above are only a part of the embodiments of the present disclosure, but not all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by those skilled in the art without creative efforts shall fall within the protection scope of the present disclosure.

本公开分类检测模型包括特征提取网络、感兴趣区域生成网络、R-CNN分类和定位网络,其中特征提取网络为特征金字塔网络,不仅避免细小特征信息的丢失,还会将瑕疵特征进行补充增强,从而更准确地提取到瑕疵特征,所述的感兴趣区域生成网络采用先验锚生成网络,通过不同尺寸特征图上候选锚与真值框的比较确定先验锚的位置形状,为训练提供更准确的先验锚的位置形状,同时大大减少了候选锚的数量,有效地提高了定位精度和检测速度,对极端形状的瑕疵依然有显著效果。The classification and detection model disclosed in the present disclosure includes a feature extraction network, a region of interest generation network, and an R-CNN classification and positioning network. The feature extraction network is a feature pyramid network, which not only avoids the loss of small feature information, but also supplements and enhances flawed features. Thereby, the defect features can be extracted more accurately. The said region of interest generation network adopts a priori anchor generation network, and the position and shape of the prior anchor is determined by comparing the candidate anchor and the ground-truth frame on the feature maps of different sizes, which provides more information for training. Accurate the position and shape of the prior anchor, while greatly reducing the number of candidate anchors, effectively improving the positioning accuracy and detection speed, and still has a significant effect on the flaws of extreme shapes.

请参阅图1,图1为本公开一实施例提供的用于瑕疵检测的模型建立方法的流程示意图,该方法主要包括以下步骤:Please refer to FIG. 1. FIG. 1 is a schematic flowchart of a method for establishing a model for defect detection according to an embodiment of the present disclosure. The method mainly includes the following steps:

S101、建立图像集,该图像集中包括不同类型的瑕疵;S101, establish an image set, the image set includes different types of defects;

具体的,每种瑕疵类型的图像应为多张,例如,100张、200张等等,图像尺寸不要求。因面料瑕疵涵盖极端形状较多,所以本公开以面料瑕疵为例。面料的瑕疵的类型分为无疵点、破洞、污渍、抽丝、结、花板跳、百脚、粗经、粗纬、断经、断纬、稀密档、磨痕、轧痕、死皱、双纬、双经、筘路、纬纱不良等等。Specifically, there should be multiple images of each defect type, for example, 100 images, 200 images, etc., and the image size is not required. Because fabric flaws cover many extreme shapes, the present disclosure takes fabric flaws as an example. The types of fabric defects are divided into no defects, holes, stains, snagging, knots, pattern jumps, 100 feet, coarse warp, coarse weft, broken warp, broken weft, thin and dense files, wear marks, rolling marks, dead. Wrinkle, double weft, double warp, reed road, poor weft and so on.

S102、基于该图像集和Faster R-CNN搭建瑕疵检测网络模型;S102, build a defect detection network model based on the image set and Faster R-CNN;

S103、训练该瑕疵检测网络模型,得到分类检测模型;S103, train the defect detection network model to obtain a classification detection model;

其中,该分类检测模型,用于对待检测图像进行瑕疵检测,输出该待检测图像中瑕疵的类型、形状和位置。Wherein, the classification detection model is used to perform flaw detection on the image to be detected, and output the type, shape and position of the flaw in the image to be detected.

在本公开其中一个实施例中,步骤S101包括:In one of the embodiments of the present disclosure, step S101 includes:

采集至少一个图像,并对该图像中的瑕疵采用标签进行标注,得到该图像集;Collect at least one image, and label the defects in the image to obtain the image set;

其中,该标签标注有瑕疵的类型、形状和位置信息中的至少一个。Wherein, the label is marked with at least one of the type, shape and position information of the defect.

可选的,可以基于标签建立标签库,标签库中的标签文件按照COCO格式建立,以面料瑕疵为例,将采集到的所有带有瑕疵的面料图像数据构成图像集。Optionally, a label library may be established based on the labels, and the label files in the label library are established according to the COCO format. Taking fabric defects as an example, an image set is formed from all the collected fabric image data with defects.

在本实施例中,通过基于图像集和Faster R-CNN搭建瑕疵检测网络模型,再训练瑕疵检测网络模型,得到分类检测模型。可有效地提高定位精度和检测速度,对极端形状的瑕疵依然有显著效果。In this embodiment, a classification detection model is obtained by building a defect detection network model based on the image set and Faster R-CNN, and then training the defect detection network model. It can effectively improve positioning accuracy and detection speed, and still has a significant effect on flaws with extreme shapes.

在本公开其中一个实施例中,步骤S102包括:In one embodiment of the present disclosure, step S102 includes:

S1021、将该图像集输入特征金字塔网络,得到第一瑕疵特征图,该特征金字塔网络采用ResNet-50特征提取网络;S1021, input the image set into a feature pyramid network to obtain a first defect feature map, and the feature pyramid network adopts a ResNet-50 feature extraction network;

S1022、将该第一瑕疵特征图输入先验锚生成网络,构建基于Faster R-CNN的瑕疵检测网络模型。S1022 , input the first defect feature map into the prior anchor generation network, and construct a defect detection network model based on Faster R-CNN.

具体的,ResNet-50特征提取网络包含49个卷积层和一个全连接层,对采集到的面料图像自下而上做卷积进行尺寸依次减小的瑕疵特征提取,除了第一层是7*7卷积外,其余皆为1*1卷积和3*3卷积,得到一系列不同尺寸的特征图(尺寸依次减小),示例性的,如图2所示,可以从中选取第10层、第40层,第49层的初步瑕疵特征图C1、C2、C3进行1*1卷积降维和/或上采样。需要说明的是,本公开对选取的初步瑕疵特征图的层数和数量均不做限制,以上仅为示意性说明。Specifically, the ResNet-50 feature extraction network consists of 49 convolutional layers and a fully connected layer. The collected fabric images are convolved from bottom to top to extract defect features with decreasing sizes, except that the first layer is 7 Except for *7 convolution, the rest are 1*1 convolution and 3*3 convolution, and a series of feature maps of different sizes are obtained (the size decreases in turn). Preliminary defect feature maps C1, C2, C3 of layers 10, 40, and 49 are subjected to 1*1 convolution for dimensionality reduction and/or upsampling. It should be noted that the present disclosure does not limit the number and quantity of the selected preliminary defect feature maps, and the above is only a schematic illustration.

在本实施例中,将特征提取网络选取为特征金字塔网络,不仅避免细小特征信息的丢失,还会将瑕疵特征进行补充增强,从而更准确地提取到瑕疵特征,将感兴趣区域生成网络采用先验锚生成网络,可以为瑕疵检测网络的训练提供更准确的先验锚的位置形状,同时大大减少了候选锚的数量,有效地提高了定位精度和检测速度,对极端形状的瑕疵依然有显著效果。In this embodiment, the feature extraction network is selected as the feature pyramid network, which not only avoids the loss of small feature information, but also supplements and enhances the defect features, so as to extract the defect features more accurately. The anchor generation network can provide a more accurate position and shape of the prior anchor for the training of the defect detection network, and at the same time greatly reduce the number of candidate anchors, effectively improve the positioning accuracy and detection speed, and still have significant defects in extreme shapes. Effect.

在本公开其中一个实施例中,请参阅图2,步骤S1021包括:In one embodiment of the present disclosure, referring to FIG. 2 , step S1021 includes:

将该图像集输入该特征金字塔网络;Input the image set into the feature pyramid network;

对该图像集中的标注的瑕疵自下而上做卷积以获取尺寸依次减小的初步瑕疵特征图;Convolve the annotated defects in the image set from bottom to top to obtain preliminary defect feature maps with decreasing sizes;

将所有初步瑕疵特征图均进行1*1卷积降维,得到中间瑕疵特征图;Perform 1*1 convolutional dimension reduction on all preliminary defect feature maps to obtain intermediate defect feature maps;

将所有中间瑕疵特征图均自上而下进行上采样,并均与相邻的下一尺寸的中间瑕疵特征图进行融合,得到尺寸依次减小第一瑕疵特征图。All the intermediate defect feature maps are up-sampled from top to bottom, and are fused with the adjacent intermediate defect feature maps of the next size to obtain the first defect feature map with decreasing size in turn.

可理解的,参阅图2,图2中C1、C2和C3为尺寸依次减小的初步瑕疵特征图,F1、F2和F3为尺寸依次减小的第一瑕疵特征图,其中对应的初步瑕疵特征图、中间瑕疵特征图和第一瑕疵特征图的尺寸相同(图2中未示出中间瑕疵特征图),例如,C1的尺寸与F1相同,C2的尺寸与F2相同,C3的尺寸与F3相同。Understandably, referring to Fig. 2, C1, C2, and C3 in Fig. 2 are preliminary defect feature maps with decreasing sizes, F1, F2, and F3 are first defect feature maps with decreasing sizes, wherein the corresponding preliminary defect features The size of the image, the intermediate flaw feature map and the first flaw feature map are the same (the intermediate flaw feature map is not shown in Figure 2), for example, the size of C1 is the same as that of F1, the size of C2 is the same as that of F2, and the size of C3 is the same as that of F3 .

可理解的,第一瑕疵特征图包含初步瑕疵特征图和与该初步瑕疵特征图相邻的下一尺寸的初步瑕疵特征图中的所有瑕疵特征信息。具体的,请参阅图2,与C1相邻的下一尺寸的初步瑕疵特征图为C2,与C2相邻的下一尺寸的初步瑕疵特征图为C3。F1包括C1和C2的瑕疵特征信息,F2包括C2和C3的特征信息,其中,若C3为最后一个初步瑕疵特征图,由于最后一个尺寸的C3没有相邻的下一尺寸的初步瑕疵特征图,从而仅对C3进行1*1卷积降维,而不进行接下来的自上而下进行上采样,故F3仅包括C3的所有瑕疵特征信息。若C3具有相邻的下一尺寸的初步瑕疵特征图,则进行正常的1*1卷积降维,和自上而下的上采样。需要说明的是,图2仅为一种示意性说明,本公开不对做卷积得到的尺寸依次减小的初步瑕疵特征图的数量进行限定,其可以是1个、2个、3个、4个等等。It is understandable that the first defect feature map includes the preliminary defect feature map and all the defect feature information in the preliminary defect feature map of the next size adjacent to the preliminary defect feature map. Specifically, please refer to FIG. 2 , the preliminary defect feature map of the next size adjacent to C1 is C2, and the preliminary defect feature map of the next size adjacent to C2 is C3. F1 includes the defect feature information of C1 and C2, and F2 includes the feature information of C2 and C3. If C3 is the last preliminary defect feature map, since C3 of the last size has no adjacent preliminary defect feature map of the next size, Therefore, only 1*1 convolution dimension reduction is performed on C3, and the subsequent top-down upsampling is not performed, so F3 only includes all the defect feature information of C3. If C3 has an adjacent preliminary flaw feature map of the next size, normal 1*1 convolutional dimension reduction and top-down upsampling are performed. It should be noted that FIG. 2 is only a schematic illustration, and the present disclosure does not limit the number of preliminary defect feature maps whose sizes are successively reduced by convolution, which may be 1, 2, 3, 4 one and so on.

在本实施例中,把本层特征与相邻的下一层特征融合,解决了传统神经网络中多层卷积提取特征时只选取最上层特征图造成的瑕疵特征信息丢失的问题,增强了小瑕疵的细节特征,使得瑕疵特征提取更准确,提高了对小瑕疵和细长瑕疵等极端形状瑕疵的敏感度和检测能力。In this embodiment, the features of this layer are fused with the features of the adjacent next layer, which solves the problem of loss of defect feature information caused by only selecting the uppermost layer feature map when extracting features by multi-layer convolution in the traditional neural network, and enhances the The detailed features of small flaws make the extraction of flaw features more accurate, and improve the sensitivity and detection ability of extreme shape flaws such as small flaws and slender flaws.

在本公开其中一个实施例中,请参阅图3,步骤S1022包括:In one embodiment of the present disclosure, referring to FIG. 3 , step S1022 includes:

在尺寸依次减小第一瑕疵特征图中生成候选子区域;generating candidate sub-regions in the first defect feature map with successively decreasing sizes;

根据每个图像中标签标注的瑕疵的位置,得到真值框;According to the position of the defect marked by the label in each image, the ground-truth box is obtained;

将每个图像的候选子区域与真值框进行比较,筛选出候选锚;Compare the candidate sub-regions of each image with the ground-truth box to filter out candidate anchors;

通过回归调整该候选锚的形状,使每个图像的候选锚趋近于真值框,得到与该尺寸依次减小第一瑕疵特征图对应的先验锚;Adjust the shape of the candidate anchor by regression, so that the candidate anchor of each image is close to the ground truth frame, and obtain the prior anchor corresponding to the first defect feature map with the size decreasing in turn;

将该尺寸依次减小第一瑕疵特征图和该第一瑕疵特征图对应的先验锚输入预设的分类网络,确定该瑕疵检测网络模型的参数。The size is sequentially reduced to the first defect feature map and the prior anchors corresponding to the first defect feature map are input to a preset classification network to determine the parameters of the defect detection network model.

具体的,先验锚生成网络包含位置预测和形状预测两个步骤。位置预测也就是预测候选锚的中心点,将尺寸依次减小的第一瑕疵特征图中每个通道(通道数可自行设置)的图像均分别减去对应第一瑕疵特征图的所有通道的图像均值并通过1*1卷积和sigmoid函数得到与第一瑕疵特征图尺寸相同的概率图(概率图中包括第一瑕疵特征图中每个像素是瑕疵的概率)。将预定义的阈值ΔL与每个像素是瑕疵的概率进行比较,确定超过该阈值的像素,得到若干候选子区域,筛选包含真值框中心点的候选子区域即为候选锚,该候选子区域的中心点即为候选锚的中心点。形状预测是预测先验锚的形状尺寸,将原始图像中瑕疵真值框映射到尺寸依次减小的第一瑕疵特征图上,得到该第一瑕疵特征图上的真值框,通过回归调整尺寸依次减小的第一瑕疵特征图上候选锚的宽和高,最终使得调整后的候选锚与对应第一瑕疵特征图上真值框的交并比最大,即为该尺寸第一瑕疵特征图对应的先验锚。Specifically, the prior anchor generation network includes two steps: position prediction and shape prediction. The position prediction is to predict the center point of the candidate anchor, and the images of each channel (the number of channels can be set by yourself) in the first defect feature map with decreasing sizes are subtracted from the images of all channels corresponding to the first defect feature map respectively. Average and obtain a probability map with the same size as the first defect feature map through 1*1 convolution and sigmoid function (the probability map includes the probability that each pixel in the first defect feature map is a defect). Compare the predefined threshold ΔL with the probability that each pixel is a defect, determine the pixels that exceed the threshold, and obtain several candidate sub-regions, and filter the candidate sub-regions containing the center point of the ground truth box to be the candidate anchor, the candidate sub-region The center point of is the center point of the candidate anchor. Shape prediction is to predict the shape and size of the prior anchor, map the true value frame of the defect in the original image to the first defect feature map with decreasing size, and obtain the true value box on the first defect feature map, and adjust the size through regression. The width and height of the candidate anchors on the first defect feature map are successively reduced, and finally the intersection ratio of the adjusted candidate anchor and the ground truth box on the corresponding first defect feature map is the largest, which is the first defect feature map of this size. the corresponding prior anchors.

其中,阈值ΔL可以根据实际情况进行设定,例如0.5、0.6、.065等等。本公开对此不做限制。The threshold ΔL can be set according to the actual situation, such as 0.5, 0.6, .065 and so on. The present disclosure does not limit this.

在本实施例中,通过尺寸依次减小的第一瑕疵特征图上候选锚与真值框的比较确定先验锚的位置形状,为训练瑕疵检测网络模型提供更准确的先验锚的位置形状,同时大大减少了候选锚的数量,有效地提高了定位精度和检测速度,对极端形状的瑕疵依然有显著效果,还解决了Faster R-CNN网络中锚的形状固定的问题,有效地避免了锚的形状与瑕疵尺寸相差较大的情况。In this embodiment, the position and shape of the prior anchor is determined by comparing the candidate anchor on the first defect feature map with decreasing size and the ground truth frame, so as to provide a more accurate position and shape of the prior anchor for training the defect detection network model At the same time, the number of candidate anchors is greatly reduced, the positioning accuracy and detection speed are effectively improved, and it still has a significant effect on the defects of extreme shapes. It also solves the problem of the fixed shape of the anchors in the Faster R-CNN network, effectively avoiding the A situation where the shape of the anchor differs greatly from the size of the flaw.

在本公开其中一个实施例中,该分类网络包括1个池化层和4个全连接层,该将该尺寸依次减小第一瑕疵特征图和该第一瑕疵特征图对应的先验锚输入预设的分类网络,确定该瑕疵检测网络模型的参数包括:In one embodiment of the present disclosure, the classification network includes one pooling layer and four fully-connected layers, and the size is sequentially reduced by the first defect feature map and the prior anchor input corresponding to the first defect feature map. The preset classification network, the parameters for determining the defect detection network model include:

将该尺寸依次减小第一瑕疵特征图和该第一瑕疵特征图对应的先验锚输入至该池化层,得到尺寸均相同的特征图和与所述特征图相对应的先验锚;Decrease the size of the first flaw feature map and the prior anchors corresponding to the first flaw feature map in turn and input them to the pooling layer to obtain feature maps with the same size and a priori anchors corresponding to the feature maps;

将该尺寸均相同的特征图和与所述特征图相对应的先验锚作为第一个全连接层的输入,得到该第一个全连接层的输出;The feature map with the same size and the prior anchor corresponding to the feature map are used as the input of the first fully connected layer, and the output of the first fully connected layer is obtained;

将该第一个全连接层的输出作为第二个全连接层的输入,得到该第二个全连接层的输出;The output of the first fully connected layer is used as the input of the second fully connected layer, and the output of the second fully connected layer is obtained;

将该第二个全连接层的输出作为第三个全连接层的输入,使该第三个全连接层通过回归输出每个图像中瑕疵的位置和形状信息;The output of the second fully connected layer is used as the input of the third fully connected layer, so that the third fully connected layer outputs the position and shape information of the defects in each image through regression;

将该第二个全连接层的输出作为第四个全连接层的输入,使该第四个全连接层通过Softmax分类输出每个图像中瑕疵的类型信息。The output of the second fully-connected layer is used as the input of the fourth fully-connected layer, so that the fourth fully-connected layer outputs the type information of defects in each image through Softmax classification.

在本公开其中一个实施例中,在训练该瑕疵检测网络模型的过程中,采用交叉熵损失函数和先验锚的形状预测损失函数对该瑕疵检测网络模型的训练过程进行约束。In one of the embodiments of the present disclosure, in the process of training the defect detection network model, a cross-entropy loss function and a shape prediction loss function of a priori anchor are used to constrain the training process of the defect detection network model.

具体的,可以将S101中的图像集分为训练集和测试集,将训练集输入瑕疵检测网络模型中进行训练,在训练瑕疵检测网络模型的过程中,采用交叉熵损失函数和先验锚的形状预测损失函数对该瑕疵检测网络模型的训练过程进行约束。训练完成后,利用测试集对瑕疵检测网络模型进行测试。Specifically, the image set in S101 can be divided into a training set and a test set, and the training set can be input into the defect detection network model for training. In the process of training the defect detection network model, the cross entropy loss function and the prior anchor are used. The shape prediction loss function constrains the training process of the flaw detection network model. After the training is completed, use the test set to test the flaw detection network model.

其中,训练集与测试集按照9∶1,8∶2或者7∶3的比例进行划分,本公开对此不做限制。The training set and the test set are divided according to the ratio of 9:1, 8:2 or 7:3, which is not limited in the present disclosure.

更多的,在一个示例中,训练所用的初始化模型为在微软的COCO目标检测数据集上训练所得的模型,该模型的参数更新方式是Momentum,初始学习率为0.001,在迭代达到30000次后,学习率为0.0001,动量系数为0.9,批次大小为16,非极大值抑制的IoU阈值为0.7。More, in one example, the initialization model used for training is a model trained on Microsoft's COCO target detection dataset, the parameter update method of the model is Momentum, the initial learning rate is 0.001, and after 30,000 iterations , the learning rate is 0.0001, the momentum coefficient is 0.9, the batch size is 16, and the IoU threshold for non-maximum suppression is 0.7.

以上请参阅图4,图4为本公开一实施例提供的分类检测模型的训练流程图。本公开与现有技术相比的优点在于:通过特征金字塔网络的多尺寸特征融合算法,把本层特征与相邻的下一层特征融合,解决了传统神经网络中多层卷积提取特征时只选取最上层特征图造成的瑕疵特征信息丢失的问题,增强了小瑕疵的细节特征,使得瑕疵特征提取更准确,提高了对小瑕疵和细长瑕疵等极端形状瑕疵的敏感度和检测能力。通过对各尺寸第一瑕疵特征图上候选子区域的选择,得到较少数量的候选锚,再利用回归调整候选锚的尺寸,最终得到与瑕疵特征尺寸最接近的先验锚,该方法确定的先验锚不仅适用于极端尺寸的瑕疵检测,解决了Faster R-CNN网络中锚的形状固定的问题,有效地避免了锚的形状与瑕疵尺寸相差较大的情况,同时确定先验锚的过程也大大减少了候选锚的数量,有效地提高了检测速度。Please refer to FIG. 4 above. FIG. 4 is a training flowchart of a classification detection model provided by an embodiment of the present disclosure. Compared with the prior art, the advantage of the present disclosure is that: through the multi-dimensional feature fusion algorithm of the feature pyramid network, the features of this layer are fused with the features of the adjacent next layer, which solves the problem of multi-layer convolution in the traditional neural network when extracting features. Only the defect feature information loss caused by the top-level feature map is selected, which enhances the detail features of small defects, makes the extraction of defect features more accurate, and improves the sensitivity and detection ability of extreme shape defects such as small defects and slender defects. By selecting the candidate sub-regions on the first defect feature map of each size, a smaller number of candidate anchors are obtained, and then the size of the candidate anchors is adjusted by regression, and finally the prior anchor closest to the size of the defect feature is obtained. The prior anchor is not only suitable for flaw detection of extreme sizes, but also solves the problem of the fixed shape of the anchor in the Faster R-CNN network. It also greatly reduces the number of candidate anchors, effectively improving the detection speed.

请参阅图5,图5是本公开一实施例提供的用于瑕疵检测的模型建立装置的结构示意图,该装置可内置于电子设备中,该装置主要包括:Please refer to FIG. 5. FIG. 5 is a schematic structural diagram of a model building apparatus for defect detection provided by an embodiment of the present disclosure. The apparatus can be built in an electronic device, and the apparatus mainly includes:

建立模块501,用于建立图像集,该图像集中包括不同类型的瑕疵;establishing module 501, for establishing an image set, the image set includes different types of defects;

搭建模块502,用于基于该图像集和Faster R-CNN搭建瑕疵检测网络模型;A building module 502 is used to build a defect detection network model based on the image set and Faster R-CNN;

训练模块503,用于训练该瑕疵检测网络模型,得到分类检测模型;A training module 503 is used to train the defect detection network model to obtain a classification detection model;

其中,该分类检测模型,用于对待检测图像进行瑕疵检测,输出该待检测图像中瑕疵的类型、形状和位置。Wherein, the classification detection model is used to perform flaw detection on the image to be detected, and output the type, shape and position of the flaw in the image to be detected.

该建立模块501包括:The establishment module 501 includes:

采集子模块,由于采集至少一个图像;the acquisition sub-module, due to the acquisition of at least one image;

标注子模块,用于对该图像中的瑕疵采用标签进行标注,得到该图像集;The labeling sub-module is used to label the defects in the image to obtain the image set;

其中,该标签标注有瑕疵的类型、形状和位置信息中的至少一个。Wherein, the label is marked with at least one of the type, shape and position information of the defect.

在本公开其中一个实施例中,该搭建模块502包括:In one embodiment of the present disclosure, the building module 502 includes:

第一输入子模块,用于将该图像集输入特征金字塔网络,得到第一瑕疵特征图,该特征金字塔网络采用ResNet-50特征提取网络;The first input sub-module is used to input the image set into the feature pyramid network to obtain the first defect feature map, and the feature pyramid network adopts the ResNet-50 feature extraction network;

第二输入子模块,用于将该第一瑕疵特征图输入先验锚生成网络,构建基于Faster R-CNN的瑕疵检测网络模型。The second input sub-module is used to input the first defect feature map into the prior anchor generation network to construct a defect detection network model based on Faster R-CNN.

在本公开其中一个实施例中,该第一输入子模块具体用于:将该图像集输入该特征金字塔网络;对该图像集中的标注的瑕疵自下而上做卷积以获取尺寸依次减小的初步瑕疵特征图;将所有初步瑕疵特征图均进行1*1卷积降维,得到中间瑕疵特征图;将所有中间瑕疵特征图均自上而下进行上采样,并均与相邻的下一尺寸的中间瑕疵特征图进行融合,得到尺寸依次减小第一瑕疵特征图。In one of the embodiments of the present disclosure, the first input sub-module is specifically configured to: input the image set into the feature pyramid network; perform convolution of the labeled flaws in the image set from bottom to top to obtain the successive reduction in size The initial defect feature map of the The intermediate defect feature maps of one size are fused to obtain the first defect feature map with decreasing size in turn.

在本公开其中一个实施例中,该第二输入子模块具体用于:在尺寸依次减小第一瑕疵特征图中生成候选子区域;根据每个图像中标签标注的瑕疵的位置,得到真值框;将每个图像的候选子区域与真值框进行比较,筛选出候选锚;通过回归调整该候选锚的形状,使每个图像的候选锚趋近于真值框,得到与该尺寸依次减小第一瑕疵特征图对应的先验锚;将该尺寸依次减小第一瑕疵特征图和该第一瑕疵特征图对应的先验锚输入预设的分类网络,确定该瑕疵检测网络模型的参数。In one of the embodiments of the present disclosure, the second input sub-module is specifically configured to: generate candidate sub-regions in the first defect feature map with decreasing sizes in sequence; obtain the true value according to the position of the defect marked by the label in each image box; compare the candidate sub-region of each image with the ground-truth box, and filter out candidate anchors; adjust the shape of the candidate anchor by regression to make the candidate anchor of each image approach the ground-truth box, and obtain the same size in order Decrease the prior anchor corresponding to the first flaw feature map; reduce the size in turn to the first flaw feature map and the prior anchor corresponding to the first flaw feature map and input the preset classification network to determine the flaw detection network model. parameter.

在本公开其中一个实施例中,该分类网络包括1个池化层和4个全连接层,该将该尺寸依次减小第一瑕疵特征图和该第一瑕疵特征图对应的先验锚输入预设的分类网络,确定该瑕疵检测网络模型的参数包括:将该尺寸依次减小第一瑕疵特征图和该第一瑕疵特征图对应的先验锚输入至该池化层,得到尺寸均相同的特征图和与所述特征图相对应的先验锚;将该尺寸均相同的特征图和与所述特征图相对应的先验锚作为第一个全连接层的输入,得到该第一个全连接层的输出;将该第一个全连接层的输出作为第二个全连接层的输入,得到该第二个全连接层的输出;将该第二个全连接层的输出作为第三个全连接层的输入,使该第三个全连接层通过回归输出每个图像中瑕疵的位置和形状信息;将该第二个全连接层的输出作为第四个全连接层的输入,使该第四个全连接层通过Softmax分类输出每个图像中瑕疵的类型信息。In one embodiment of the present disclosure, the classification network includes one pooling layer and four fully-connected layers, and the size is sequentially reduced by the first defect feature map and the prior anchor input corresponding to the first defect feature map. For the preset classification network, determining the parameters of the defect detection network model includes: sequentially reducing the size of the first defect feature map and inputting the prior anchors corresponding to the first defect feature map to the pooling layer, and obtaining the same size The feature map and the prior anchor corresponding to the feature map; the feature map with the same size and the prior anchor corresponding to the feature map are used as the input of the first fully connected layer, and the first fully connected layer is obtained. The output of a fully connected layer; the output of the first fully connected layer is used as the input of the second fully connected layer, and the output of the second fully connected layer is obtained; the output of the second fully connected layer is used as the first fully connected layer. The input of the three fully connected layers makes the third fully connected layer output the location and shape information of defects in each image through regression; the output of the second fully connected layer is used as the input of the fourth fully connected layer, Make this fourth fully connected layer output the type information of the defects in each image through Softmax classification.

在本公开其中一个实施例中,在训练该瑕疵检测网络模型的过程中,采用交叉熵损失函数和先验锚的形状预测损失函数对该瑕疵检测网络模型的训练过程进行约束。In one of the embodiments of the present disclosure, in the process of training the defect detection network model, a cross-entropy loss function and a shape prediction loss function of a priori anchor are used to constrain the training process of the defect detection network model.

上述实施例未尽细节之处请参阅图1至图4所示实施例的相关描述,在此不再赘述。For details that are not described in the above embodiments, please refer to the related descriptions of the embodiments shown in FIGS. 1 to 4 , which will not be repeated here.

请参见图6,图6示出了一种电子设备的硬件结构图。Please refer to FIG. 6, which shows a hardware structure diagram of an electronic device.

本实施例中所描述的电子设备,包括:The electronic equipment described in this embodiment includes:

存储器61、处理器62及存储在存储器61上并可在处理器上运行的计算机程序,处理器执行该程序时实现前述图1所示实施例中描述的于瑕疵检测的模型建立方法。The memory 61 , the processor 62 and the computer program stored in the memory 61 and executable on the processor, when the processor executes the program, implements the model building method for defect detection described in the embodiment shown in FIG. 1 .

进一步地,该电子设备还包括:Further, the electronic device also includes:

至少一个输入设备63;至少一个输出设备64。At least one input device 63 ; at least one output device 64 .

上述存储器61、处理器62输入设备63和输出设备64通过总线65连接。The above-mentioned memory 61 , processor 62 input device 63 and output device 64 are connected through a bus 65 .

其中,输入设备63具体可为摄像头、触控面板、物理按键或者鼠标等等。输出设备64具体可为显示屏。The input device 63 may specifically be a camera, a touch panel, a physical button, a mouse, or the like. The output device 64 may specifically be a display screen.

存储器61可以是高速随机存取记忆体(RAM,Random Access Memory)存储器,也可为非不稳定的存储器(non-volatile memory),例如磁盘存储器。存储器61用于存储一组可执行程序代码,处理器62与存储器61耦合。The memory 61 may be a high-speed random access memory (RAM, Random Access Memory) memory, or may be a non-volatile memory (non-volatile memory), such as a disk memory. Memory 61 is used to store a set of executable program codes, and processor 62 is coupled to memory 61 .

进一步地,本公开实施例还提供了一种计算机可读存储介质,该计算机可读存储介质可以是设置于上述各实施例中的电子设备中,该计算机可读存储介质可以是前述图5所示实施例中的电子设备。该计算机可读存储介质上存储有计算机程序,该程序被处理器执行时实现前述图1所示实施例中描述的用于瑕疵检测的模型建立方法。进一步地,该计算机可存储介质还可以是U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。Further, an embodiment of the present disclosure further provides a computer-readable storage medium, and the computer-readable storage medium may be provided in the electronic device in the above-mentioned embodiments, and the computer-readable storage medium may be the one shown in FIG. 5 above. the electronic device in the example. The computer-readable storage medium stores a computer program, and when the program is executed by the processor, implements the model building method for defect detection described in the embodiment shown in FIG. 1 . Further, the computer-storable medium can also be a USB flash drive, a removable hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, etc. medium of program code.

需要说明的是,在本公开各个实施例中的各功能模块可以集成在一个处理模块中,也可以是各个模块单独物理存在,也可以两个或两个以上模块集成在一个模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。It should be noted that each functional module in each embodiment of the present disclosure may be integrated into one processing module, or each module may exist physically alone, or two or more modules may be integrated into one module. The above-mentioned integrated modules can be implemented in the form of hardware, and can also be implemented in the form of software function modules.

所述集成的模块如果以软件功能模块的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来。If the integrated modules are implemented in the form of software functional modules and sold or used as independent products, they may be stored in a computer-readable storage medium. Based on such understanding, the technical solutions of the present invention can be embodied in the form of software products in essence or in part that contributes to the prior art, or all or part of the technical solutions.

需要说明的是,对于前述的各方法实施例,为了简便描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本发明并不受所描述的动作顺序的限制,因为依据本发明,某些步骤可以采用其它顺序或者同时进行。其次,本领域技术人员也应该知悉,说明书中所描述的实施例均属于优选实施例,所涉及的动作和模块并不一定都是本发明所必须的。It should be noted that, for the convenience of description, the foregoing method embodiments are all expressed as a series of action combinations, but those skilled in the art should know that the present invention is not limited by the described action sequence. As in accordance with the present invention, certain steps may be performed in other orders or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily all necessary to the present invention.

在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述的部分,可以参见其它实施例的相关描述。In the above-mentioned embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference may be made to the relevant descriptions of other embodiments.

以上为对本发明所提供的一种用于瑕疵检测的模型建立方法、装置、电子设备及存储介质的描述,对于本领域的技术人员,依据本发明实施例的思想,在具体实施方式及应用范围上均会有改变之处,综上,本说明书内容不应理解为对本发明的限制。The above is a description of a model establishment method, device, electronic device and storage medium for defect detection provided by the present invention. There will be changes in the above, and in conclusion, the content of this specification should not be construed as a limitation to the present invention.

Claims (10)

1.一种用于瑕疵检测的模型建立方法,其特征在于,包括:1. a model building method for flaw detection, is characterized in that, comprises: 建立图像集,所述图像集中包括不同类型的瑕疵;creating a set of images that includes different types of imperfections; 基于所述图像集和Faster R-CNN搭建瑕疵检测网络模型;Build a defect detection network model based on the image set and Faster R-CNN; 训练所述瑕疵检测网络模型,得到分类检测模型;Train the defect detection network model to obtain a classification detection model; 其中,所述分类检测模型,用于对待检测图像进行瑕疵检测,输出所述待检测图像中瑕疵的类型、形状和位置。Wherein, the classification detection model is used to perform flaw detection on the image to be detected, and output the type, shape and position of the flaw in the image to be detected. 2.根据权利要求1所述的模型建立方法,其特征在于,所述建立图像集包括:2. The method for establishing a model according to claim 1, wherein the establishing an image set comprises: 采集至少一个图像,并对所述图像中的瑕疵采用标签进行标注,得到所述图像集;collecting at least one image, and labeling the defects in the image with a label to obtain the image set; 其中,所述标签标注有瑕疵的类型、形状和位置信息中的至少一个。Wherein, the label is marked with at least one of the type, shape and position information of the defect. 3.根据权利要求1所述的模型建立方法,其特征在于,所述基于所述图像集和FasterR-CNN搭建瑕疵检测网络模型包括:3. model building method according to claim 1, is characterized in that, described based on described image set and FasterR-CNN builds flaw detection network model and comprises: 将所述图像集输入特征金字塔网络,得到第一瑕疵特征图,所述特征金字塔网络采用ResNet-50特征提取网络;Inputting the image set into a feature pyramid network to obtain a first defect feature map, and the feature pyramid network adopts a ResNet-50 feature extraction network; 将所述第一瑕疵特征图输入先验锚生成网络,构建基于Faster R-CNN的瑕疵检测网络模型。The first defect feature map is input into the prior anchor generation network, and a defect detection network model based on Faster R-CNN is constructed. 4.根据权利要求3所述的模型建立方法,其特征在于,所述将所述图像集输入特征金字塔网络,得到第一瑕疵特征图包括:4. The method for establishing a model according to claim 3, wherein the inputting the image set into a feature pyramid network to obtain the first flaw feature map comprises: 将所述图像集输入所述特征金字塔网络;inputting the image set into the feature pyramid network; 对所述图像集中的标注的瑕疵自下而上做卷积以获取尺寸依次减小的初步瑕疵特征图;Convolving the marked flaws in the image set from bottom to top to obtain a preliminary flaw feature map with decreasing sizes; 将所有初步瑕疵特征图均进行1*1卷积降维,得到中间瑕疵特征图;Perform 1*1 convolutional dimension reduction on all preliminary defect feature maps to obtain intermediate defect feature maps; 将所有中间瑕疵特征图均自上而下进行上采样,并均与相邻的下一尺寸的中间瑕疵特征图进行融合,得到尺寸依次减小第一瑕疵特征图。All the intermediate defect feature maps are up-sampled from top to bottom, and are fused with the adjacent intermediate defect feature maps of the next size to obtain the first defect feature map with decreasing size in turn. 5.根据权利要求4所述的模型建立方法,其特征在于,所述将所述第一瑕疵特征图输入先验锚生成网络,构建基于Faster R-CNN的瑕疵检测网络模型包括:5. The method for establishing a model according to claim 4, wherein the described first flaw feature map is input into a priori anchor generation network, and the construction of the flaw detection network model based on Faster R-CNN comprises: 在尺寸依次减小第一瑕疵特征图中生成候选子区域;generating candidate sub-regions in the first defect feature map with successively decreasing sizes; 根据每个图像中标签标注的瑕疵的位置,得到真值框;According to the position of the defect marked by the label in each image, the ground-truth box is obtained; 将每个图像的候选子区域与真值框进行比较,筛选出候选锚;Compare the candidate sub-regions of each image with the ground-truth box to filter out candidate anchors; 通过回归调整所述候选锚的形状,使每个图像的候选锚趋近于真值框,得到与所述尺寸依次减小第一瑕疵特征图对应的先验锚;Adjust the shape of the candidate anchor by regression, so that the candidate anchor of each image is close to the ground truth frame, and obtain the prior anchor corresponding to the first defect feature map with the size decreasing in turn; 将所述尺寸依次减小第一瑕疵特征图和所述第一瑕疵特征图对应的先验锚输入预设的分类网络,确定所述瑕疵检测网络模型的参数。The size is sequentially reduced to the first defect feature map and the prior anchors corresponding to the first defect feature map are input into a preset classification network to determine the parameters of the defect detection network model. 6.根据权利要求5所述的模型建立方法,其特征在于,所述分类网络包括1个池化层和4个全连接层,所述将所述尺寸依次减小第一瑕疵特征图和所述第一瑕疵特征图对应的先验锚输入预设的分类网络,确定所述瑕疵检测网络模型的参数包括:6 . The model building method according to claim 5 , wherein the classification network comprises 1 pooling layer and 4 fully connected layers, and the size is sequentially reduced by the first defect feature map and all the The prior anchor corresponding to the first defect feature map is input to a preset classification network, and the parameters for determining the defect detection network model include: 将所述尺寸依次减小第一瑕疵特征图和所述第一瑕疵特征图对应的先验锚输入至所述池化层,得到尺寸均相同的特征图和与所述特征图对应的先验锚;Inputting the first defect feature map and the prior anchor corresponding to the first defect feature map in turn to the pooling layer to obtain a feature map with the same size and a prior corresponding to the feature map anchor; 将所述尺寸均相同的特征图和与所述特征图对应的先验锚作为第一个全连接层的输入,得到所述第一个全连接层的输出;Using the feature map with the same size and the prior anchor corresponding to the feature map as the input of the first fully connected layer to obtain the output of the first fully connected layer; 将所述第一个全连接层的输出作为第二个全连接层的输入,得到所述第二个全连接层的输出;Using the output of the first fully connected layer as the input of the second fully connected layer to obtain the output of the second fully connected layer; 将所述第二个全连接层的输出作为第三个全连接层的输入,使所述第三个全连接层通过回归输出每个图像中瑕疵的位置和形状信息;The output of the second fully connected layer is used as the input of the third fully connected layer, so that the third fully connected layer outputs the position and shape information of the flaws in each image through regression; 将所述第二个全连接层的输出作为第四个全连接层的输入,使所述第四个全连接层通过Softmax分类输出每个图像中瑕疵的类型信息。The output of the second fully-connected layer is used as the input of the fourth fully-connected layer, so that the fourth fully-connected layer outputs the type information of defects in each image through Softmax classification. 7.根据权利要求1至6任意一项所述的模型建立方法,其特征在于,在训练所述瑕疵检测网络模型的过程中,采用交叉熵损失函数和先验锚的形状预测损失函数对所述瑕疵检测网络模型的训练过程进行约束。7. The model building method according to any one of claims 1 to 6, wherein, in the process of training the defect detection network model, a cross-entropy loss function and a shape prediction loss function of a priori anchor are used to determine the accuracy of the defect detection network model. The training process of the flaw detection network model described above is constrained. 8.一种用于瑕疵检测的模型建立装置,其特征在于,包括:8. A model establishment device for defect detection, characterized in that, comprising: 建立模块,用于建立图像集,所述图像集中包括不同类型的瑕疵;a building module for building an image set, the image set including different types of flaws; 搭建模块,用于基于所述图像集和Faster R-CNN搭建瑕疵检测网络模型;Building a module for building a defect detection network model based on the image set and Faster R-CNN; 训练模块,用于训练所述瑕疵检测网络模型,得到分类检测模型;a training module for training the defect detection network model to obtain a classification detection model; 其中,所述分类检测模型,用于对待检测图像进行瑕疵检测,输出所述待检测图像中瑕疵的类型、形状和位置。Wherein, the classification detection model is used to perform flaw detection on the image to be detected, and output the type, shape and position of the flaw in the image to be detected. 9.一种电子设备,包括:存储器,处理器及存储在存储器上并可在处理器上运行的计算机程序,其特征在于,所述处理器执行所述计算机程序时,实现权利要求1至7中的任一项所述的用于瑕疵检测的模型建立方法中的各个步骤。9. An electronic device, comprising: a memory, a processor and a computer program stored on the memory and running on the processor, characterized in that, when the processor executes the computer program, claims 1 to 7 are realized Each step in the model building method for defect detection according to any one of the above. 10.一种计算机可读存储介质,其上存储有计算机程序,其特征在于,所述计算机程序被处理器执行时,实现权利要求1至7中的任一项所述的用于瑕疵检测的模型建立方法中的各个步骤。10. A computer-readable storage medium on which a computer program is stored, characterized in that, when the computer program is executed by a processor, the method for defect detection according to any one of claims 1 to 7 is implemented. The various steps in the model building method.
CN202010775330.3A 2020-08-04 2020-08-04 Model building method, device, electronic device and storage medium Active CN111915593B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010775330.3A CN111915593B (en) 2020-08-04 2020-08-04 Model building method, device, electronic device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010775330.3A CN111915593B (en) 2020-08-04 2020-08-04 Model building method, device, electronic device and storage medium

Publications (2)

Publication Number Publication Date
CN111915593A true CN111915593A (en) 2020-11-10
CN111915593B CN111915593B (en) 2025-04-25

Family

ID=73288034

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010775330.3A Active CN111915593B (en) 2020-08-04 2020-08-04 Model building method, device, electronic device and storage medium

Country Status (1)

Country Link
CN (1) CN111915593B (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112614101A (en) * 2020-12-17 2021-04-06 广东道氏技术股份有限公司 Polished tile flaw detection method based on multilayer feature extraction and related equipment
CN113610848A (en) * 2021-10-09 2021-11-05 阿里巴巴(中国)有限公司 Digital cloth processing system, cloth flaw detection method, device and medium
CN114219807A (en) * 2022-02-22 2022-03-22 成都爱迦飞诗特科技有限公司 Mammary gland ultrasonic examination image grading method, device, equipment and storage medium
CN114445351A (en) * 2021-12-31 2022-05-06 北京新氧科技有限公司 A kind of skin identification method, device, electronic device and storage medium
CN115082386A (en) * 2022-06-07 2022-09-20 华南理工大学 Injection molding part flaw detection method and device based on normal sample auxiliary feature extraction and medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109598290A (en) * 2018-11-22 2019-04-09 上海交通大学 A kind of image small target detecting method combined based on hierarchical detection
CN109598287A (en) * 2018-10-30 2019-04-09 中国科学院自动化研究所 The apparent flaws detection method that confrontation network sample generates is generated based on depth convolution
WO2019091464A1 (en) * 2017-11-12 2019-05-16 北京市商汤科技开发有限公司 Target detection method and apparatus, training method, electronic device and medium
CN110647906A (en) * 2019-08-02 2020-01-03 杭州电子科技大学 Clothing target detection method based on fast R-CNN method
CN110889838A (en) * 2019-11-26 2020-03-17 武汉纺织大学 Fabric defect detection method and device
CN111179239A (en) * 2019-12-24 2020-05-19 浙江大学 A tire X-ray defect detection method using background features for re-ranking

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2019091464A1 (en) * 2017-11-12 2019-05-16 北京市商汤科技开发有限公司 Target detection method and apparatus, training method, electronic device and medium
CN109598287A (en) * 2018-10-30 2019-04-09 中国科学院自动化研究所 The apparent flaws detection method that confrontation network sample generates is generated based on depth convolution
CN109598290A (en) * 2018-11-22 2019-04-09 上海交通大学 A kind of image small target detecting method combined based on hierarchical detection
CN110647906A (en) * 2019-08-02 2020-01-03 杭州电子科技大学 Clothing target detection method based on fast R-CNN method
CN110889838A (en) * 2019-11-26 2020-03-17 武汉纺织大学 Fabric defect detection method and device
CN111179239A (en) * 2019-12-24 2020-05-19 浙江大学 A tire X-ray defect detection method using background features for re-ranking

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
李宗洪等: "改进Faster R-CNN模型的汽车喷油器 阀座瑕疵检测算法", 广西科技大学学报, vol. 31, no. 1, 31 March 2020 (2020-03-31), pages 1 - 9 *

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112614101A (en) * 2020-12-17 2021-04-06 广东道氏技术股份有限公司 Polished tile flaw detection method based on multilayer feature extraction and related equipment
CN112614101B (en) * 2020-12-17 2024-02-20 广东道氏技术股份有限公司 Polished tile flaw detection method based on multilayer feature extraction and related equipment
CN113610848A (en) * 2021-10-09 2021-11-05 阿里巴巴(中国)有限公司 Digital cloth processing system, cloth flaw detection method, device and medium
CN113610848B (en) * 2021-10-09 2022-04-12 阿里巴巴(中国)有限公司 Digital cloth processing system, cloth flaw detection method, device and medium
CN114445351A (en) * 2021-12-31 2022-05-06 北京新氧科技有限公司 A kind of skin identification method, device, electronic device and storage medium
CN114219807A (en) * 2022-02-22 2022-03-22 成都爱迦飞诗特科技有限公司 Mammary gland ultrasonic examination image grading method, device, equipment and storage medium
CN115082386A (en) * 2022-06-07 2022-09-20 华南理工大学 Injection molding part flaw detection method and device based on normal sample auxiliary feature extraction and medium
CN115082386B (en) * 2022-06-07 2024-04-26 华南理工大学 Injection molded parts defect detection method, device and medium based on normal sample auxiliary feature extraction

Also Published As

Publication number Publication date
CN111915593B (en) 2025-04-25

Similar Documents

Publication Publication Date Title
CN111915593A (en) Model building method, device, electronic device and storage medium
JP7004145B2 (en) Defect inspection equipment, defect inspection methods, and their programs
CN111862064B (en) Silver wire surface flaw identification method based on deep learning
CN111402203B (en) Fabric surface defect detection method based on convolutional neural network
CN109509187B (en) An Efficient Inspection Algorithm for Small Defects in Large Resolution Cloth Images
CN108918536B (en) Tire mold surface character defect detection method, device, equipment and storage medium
JP2024509411A (en) Defect detection method, device and system
JP5546317B2 (en) Visual inspection device, visual inspection discriminator generation device, visual inspection discriminator generation method, and visual inspection discriminator generation computer program
CN110807422A (en) A deep learning-based text detection method in natural scenes
CN110264445A (en) The screen printing of battery quality determining method of piecemeal template matching combining form processing
CN104077577A (en) Trademark detection method based on convolutional neural network
CN114910480A (en) A machine vision-based wafer surface defect detection method
CN110889838A (en) Fabric defect detection method and device
CN116503388B (en) Defect detection method, device and storage medium
CN112991271A (en) Aluminum profile surface defect visual detection method based on improved yolov3
JP7496008B2 (en) Information processing device, method for controlling information processing device, and program
CN107274385A (en) Textile flaw detection method based on class grid pattern and its Gabor characteristic
CN115937143A (en) Fabric defect detection method
CN108647706A (en) Object recognition classification and defect detection method based on machine vision
CN116245882A (en) Circuit board electronic element detection method and device and computer equipment
CN118967672A (en) Industrial defect detection method, system, device and storage medium
CN114743102A (en) A kind of defect detection method, system and device for furniture board
CN114255212B (en) FPC surface defect detection method and system based on CNN
CN113807378A (en) Training data increment method, electronic device and computer-readable recording medium
WO2021166058A1 (en) Image recognition device, image recognition method, and recording medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant