Disclosure of Invention
The present invention is directed to a method for identifying a device number, so as to solve one of the above drawbacks or defects caused in the prior art.
In order to achieve the purpose, the invention is realized by adopting the following technical scheme:
acquiring a picture of the device to be tested containing the number area;
inputting the picture of the device to be tested into the trained numbering area positioning network model, and positioning the numbering area of the device; extracting a numbering region for positioning, and acquiring a numbering region picture of the device; the numbering region positioning network model comprises a YOLO v3 network added with a numbering region category and a number category;
inputting the picture of the numbering region into the trained number recognition network model to obtain the device number; the number recognition network model includes a YOLO v3 network joining a number area category and a number category.
The method for training the numbering area positioning network model comprises the following steps:
acquiring a device picture containing a numbering region;
marking the number area of the picture containing the number area;
and inputting the picture subjected to numbering region labeling into a numbering region positioning network model, and training the numbering region positioning network model.
Further, the method comprises the step of carrying out boundary frame marking on the numbering area of the picture through a labelImg marking tool, and obtaining the picture with the marked numbering area.
The method for identifying the network model by the training number comprises the following steps:
extracting a numbering region part in the picture subjected to numbering region labeling, and acquiring a numbering region picture;
marking each number in the picture of the numbering area;
and inputting the picture of the numbering area subjected to digital labeling into a numbering recognition network model, and training the numbering recognition network model.
Further, the method comprises the step of carrying out boundary box labeling on each number in the picture of the numbered area through a labelImg labeling tool, wherein the category of each boundary box is the number in the boundary box.
Further, the method includes labeling the bounding boxes of the numbers in the picture in the numbering area on the premise that the bounding boxes are not overlapped.
The method for identifying the device number comprises the steps of positioning a number area in a device picture through a number area positioning network model, extracting a number area picture for positioning, inputting the number area picture into a trained number identification network model, and obtaining the device number; the invention solves the problem that the serial number can not be identified in different regions, provides the serial number identification method with high accuracy and high identification efficiency, and solves the problem that the device serial number can not be identified in a network-free environment without being carried out in a network-free environment.
Detailed Description
The invention is further described below with reference to the accompanying drawings. The following examples are only for illustrating the technical solutions of the present invention more clearly, and the protection scope of the present invention is not limited thereby.
When positioning is carried out, the Yolov3 neural network obtains a prior frame through a clustering method, and 4 coordinate values are predicted for each boundary frame by using the prior frame: t is tx、ty、twAnd th. A picture is divided into S × S units, and for the predicted unit, if the target cell is at the margin of the upper left corner of the imagex,cy) And it corresponds to a bounding box with width and height pw、phThen the predicted value of the network is:
bx=σ(tx)+cx(1)
by=σ(ty)+cy(2)
bw=pwetw(3)
bh=pheth(4)
wherein, bxAnd byIs the coordinate of the center point of the predicted bounding box, bwIs to predict the width of the bounding box, bhIs the width of the prediction bounding box, σ (t)x)、σ(ty) Is the loss of square error of the coordinates, txAnd tyCoordinate value of center point, t, representing normalized bounding boxwAnd thRespectively representing the width and height of the normalized bounding box.
The Darknet-53 network is a network used for extracting features in the YOLOv3 network, a first feature map is obtained through 7 convolutions on the basis of a feature map obtained by the Darknet-53 network, and first prediction is carried out on the feature map. And then obtaining the output of the 3 rd to last convolutional layer from back to front, carrying out convolution once multiplied by 2 upsampling for one time, connecting the upsampling feature with the 43 th convolution feature, obtaining a second feature map through 7 convolutions, and carrying out second prediction on the feature map. And then obtaining the output of the 3 rd to last convolutional layer from back to front, carrying out convolution once multiplied by 2 upsampling once, connecting the upsampling feature with the 26 th convolution feature, obtaining a third feature map through 7 convolutions, and carrying out third prediction on the feature map.
The YOLOv3 network uses a new Darknet-53 network to extract features, which merges YOLOv2, Darknet-19 and other new residual networks, consisting of successive 3 x 3 and 1 x 1 convolutional layers, each followed by a BN layer and a LeakyReLU layer. Finally it has 53 convolutional layers and is therefore named Darknet-53 network. Experiments on ImageNet show that the Darknet-53 network indeed works well, and compared with ResNet-152 and ResNet-101, Darknet-53 not only has equivalent classification accuracy, but also has much faster calculation speed and fewer network layers. Darknet-53 adopts a layer-hopping connection mode of ResNet, uses a large number of residual error layer-hopping structures, and has three advantages. The first advantage is that an important point of the current deep learning model is whether the network can be converged finally, and the structure can enable the network to be converged even under the condition of deep depth. The second advantage is that the deeper the network built by the deep learning is, the better the expressed object characteristics are, and the better the target detection and classification effects are. The third advantage is that 1 × 1 convolution in the residual structure reduces the number of channels of each convolution to a great extent, which not only reduces parameters and the stored model, but also reduces the calculation amount.
The embodiment provides a method for identifying a device number, which is implemented on a Python platform, and for example, referring to fig. 1, the method for identifying a device number includes the following steps:
step 1: training a numbering area positioning network model;
using a mobile phone to shoot a plurality of device pictures containing numbering areas, wherein each picture contains clear numbering information of the steel device, and one picture contains one number;
and marking the number area in each picture by using a labelImg marking tool through the bounding box, positioning the number position in each picture, marking the bounding box, referring to fig. 3, wherein the types of the bounding boxes for marking the number areas in each picture are the same, and the type names can be customized. After the successful annotation, an XML file is generated, and then the XML file is converted into a TXT file suitable for YOLOv3 training.
Adding a numbering area type and a number type into a YOLO v3 network, wherein the numbering area type refers to the name of a numbering area for positioning, and the name of the numbering area can be customized; the number category refers to each number specifically contained in the numbered region. The YOLOv3 network is shown in fig. 2;
extracting the picture of the numbering area marked by using the boundary frame, and acquiring the picture of the numbering area;
and taking the numbering region as a feature, training a YOLOv3 network added with the numbering region type and the number type by using the picture labeled with the numbering region, and positioning the picture numbering region by using a YOLOv3 network added with the numbering region type and the number type to form a numbering region positioning network model of the picture.
In the picture numbering region positioning network model, the numbering region in the picture is positioned through a Darknet-53 network, and the positioning characteristics of the whole numbering region are extracted.
Step 2: training the number to identify the network model;
extracting a numbering region part in the picture subjected to numbering region labeling and obtained according to the step 1, and obtaining a numbering region picture;
using a labelImg labeling tool to label each number in the number area picture, and acquiring the number area picture subjected to number labeling, wherein the type of each boundary frame in the number area picture subjected to number labeling is the number in the boundary frame, namely the label name of each boundary frame is the print number contained in the boundary frame: for example, if the number is "321024", the positions of six numbers, that is, "3", "2", "1", "0", "2", and "4", are labeled with bounding boxes respectively, and the names thereof are "3", "2", "1", "0", "2", and "4";
the labeling is performed with as little overlap as possible so as to better enable the network to learn the characteristics of the words to achieve the desired recognition effect, and the effect diagram for performing the digital labeling is shown in fig. 4.
And taking the number label as a characteristic, inputting the picture of the number area subjected to the number label into a YOLOv3 network added with the number area type and the number type for training, wherein the YOLOv3 network added with the number area type and the number type is used for identifying each number in the number area, and the network forms a number identification network model of the picture.
And step 3: positioning a numbering area of a picture sample to be detected;
when testing is carried out, a mobile phone is used for shooting a picture of a device containing a numbering region, the picture contains clear numbering information of the steel device, one picture contains one number, and the picture of the device to be tested containing the numbering region is obtained;
inputting a picture of the device to be tested into the trained numbering area positioning network model obtained in the step 1, and positioning the numbering area of the device;
and extracting the number area for positioning, and acquiring the number area picture of the device.
And 4, step 4: identifying the serial number of the picture sample to be detected;
and (4) inputting the picture of the numbering region acquired according to the step (3) into the trained number identification network model acquired according to the step (2), identifying each number in the numbering region, and outputting the device number.
According to the method for identifying the device number, the improved YOLOv3 algorithm is used for positioning the number area of the device and identifying the number in the positioned number area, the problems that the existing OCR character identification system cannot identify the area, the identification speed is low and the existing OCR character identification system needs to rely on a network are solved, the method provided by the embodiment of the invention has the advantages of high accuracy and good robustness, and the problem of waste of manpower and material resources in the traditional manual counting device number is solved.
The above description is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, several modifications and variations can be made without departing from the technical principle of the present invention, and these modifications and variations should also be regarded as the protection scope of the present invention.