Disclosure of Invention
The invention aims to provide a method and a device for identifying the damage condition of paper money based on deep learning, which are used for overcoming the defects of single detectable defect type and weak generalization capability in the prior art, monitoring the damage state of the paper money in real time and effectively monitoring the damage defect of the paper money in a small area.
To achieve the above object, the present invention provides a method for recognizing banknote breakage based on deep learning, comprising: acquiring image information of paper money, and respectively intercepting a defect image block and a standard image block in the image information to generate defect data and non-defect data; filtering and/or amplifying the defect data and the non-defect data to generate a training image, calibrating the damaged position of the paper currency in the defect data to generate defect type data, and generating training set data according to the training image and the defect type data; training a preset YOLOv3 network through the training set data to obtain a banknote detection model, and inputting a banknote image to be detected into the banknote detection model to obtain characteristic parameters; and calculating according to the characteristic parameters to obtain a paper currency defect ratio, and comparing the paper currency defect ratio with a preset threshold value to obtain the damage condition of the paper currency.
In the method for recognizing banknote damage based on deep learning, it is preferable that the acquiring of the image information of the banknote includes: and collecting a paper money image through CDD visual detection equipment, and converting the paper money image into a gray image to obtain image information.
In the banknote breakage recognition method based on the deep learning, it is preferable that the generating of the training image by performing the filtering and/or amplification processing on the defect data and the non-defect data includes: replacing the particle noise of the defect data and the defect-free data by utilizing a low-pass or high-pass filter according to the weighted average value of each pixel in the pixel point field of the particle noise in the defect data and the defect-free data; and performing amplification on the defect data and the non-defect data by one or more combinations of rotating according to a preset angle, adjusting brightness and contrast and adding Gaussian white noise.
In the banknote breakage recognition method based on the deep learning, the defect type data preferably includes a picture path, a breakage type, and coordinate position information.
In the banknote breakage recognition method based on the deep learning, the preset YOLOv3 network preferably includes: darknet-53 in the YOLOv3 network structure was replaced by a dense connection network DenseNet.
In the method for recognizing banknote damage based on deep learning, preferably, the calculating and obtaining the banknote defect ratio from the feature parameters includes: acquiring position parameters in the characteristic parameters, and calculating to obtain length and width data of the paper money according to the position parameters; and substituting the length and width data and the confidence level and the defect classification probability in the characteristic parameters into a preset sigmoid function to calculate and obtain the defect ratio of the paper money.
The present invention also provides a banknote breakage recognition apparatus based on deep learning, the apparatus including: the device comprises an image acquisition module, a preprocessing module, a training module and an identification module; the image acquisition module is used for acquiring image information of paper money, and respectively intercepting a defect image block and a standard image block in the image information to generate defect data and non-defect data; the preprocessing module is used for carrying out filtering and/or amplification processing on the defect data and the non-defect data to generate a training image, calibrating the damaged position of the paper currency in the defect data to generate defect type data, and generating training set data according to the training image and the defect type data; the training module is used for training a preset Yolov3 network through the training set data to obtain a banknote detection model, and inputting a banknote image to be detected into the banknote detection model to obtain characteristic parameters; the recognition module is used for calculating according to the characteristic parameters to obtain a paper currency defect ratio, and comparing the paper currency defect ratio with a preset threshold value to obtain a paper currency damage condition.
In the banknote breakage recognition apparatus based on the deep learning, preferably, the image capture module includes: and collecting a paper money image through CDD visual detection equipment, and converting the paper money image into a gray image to obtain image information.
In the banknote breakage recognition apparatus based on the deep learning, preferably, the preprocessing module includes a filtering unit and an amplifying unit; the filtering unit is used for replacing the particle noise points of the defect data and the defect-free data by utilizing a low-pass or high-pass filter through the weighted average value of each pixel in the pixel point field of the particle noise points in the defect data and the defect-free data; the amplification unit is used for amplifying one or more combinations of rotating the defect data and the non-defect data according to a preset angle, adjusting brightness and contrast and adding Gaussian white noise.
In the banknote damage condition recognition device based on deep learning, preferably, the recognition module includes a calculation unit, and the calculation unit is configured to acquire a position parameter in the feature parameters, and calculate length and width data of the banknote according to the position parameter; and substituting the length and width data and the confidence level and the defect classification probability in the characteristic parameters into a preset sigmoid function to calculate and obtain the defect ratio of the paper money.
The invention also provides a computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the method when executing the computer program.
The present invention also provides a computer-readable storage medium storing a computer program for executing the above method.
The invention has the beneficial technical effects that: aiming at the small-size damage condition of the paper money, the original three original prediction scales of Yolov3 cannot meet the requirements, so the 4 th prediction scale is added. The feature map of [52, 255] is up-sampled and connected to the feature map of [104,104,255] size in the convolution process, which is a 4-fold down-sampled size of the input image and whose receptive field is suitable for detecting the smaller-sized defect location among the banknote defects. The dense connection network DenseNet is used for replacing an original network structure Darknet-53, each layer of the DenseNet can receive all the previous layers as additional input of the DenseNet, multi-layer characteristic reuse can be better realized, the problem of gradient disappearance in the original structure is relieved, and the network computing efficiency is improved.
Detailed Description
The following detailed description of the embodiments of the present invention will be provided with reference to the drawings and examples, so that how to apply the technical means to solve the technical problems and achieve the technical effects can be fully understood and implemented. It should be noted that, unless otherwise specified, the embodiments and features of the embodiments of the present invention may be combined with each other, and the technical solutions formed are within the scope of the present invention.
Additionally, the steps illustrated in the flow charts of the figures may be performed in a computer system such as a set of computer-executable instructions and, although a logical order is illustrated in the flow charts, in some cases, the steps illustrated or described may be performed in an order different than here.
Referring to fig. 1, the method for recognizing banknote damage based on deep learning provided by the present invention specifically includes:
s101, acquiring image information of paper money, and respectively intercepting a defect image block and a standard image block in the image information to generate defect data and non-defect data;
s102, filtering and/or amplifying the defect data and the non-defect data to generate a training image, calibrating the damaged position of the paper currency in the defect data to generate defect type data, and generating training set data according to the training image and the defect type data;
s103, training a preset YOLOv3 network through the training set data to obtain a banknote detection model, and inputting a banknote image to be detected into the banknote detection model to obtain characteristic parameters;
s104, calculating according to the characteristic parameters to obtain a paper currency defect ratio, and comparing the paper currency defect ratio with a preset threshold value to obtain a paper currency damage condition.
The defect type data comprises a picture path, a damage type and coordinate position information.
In the above embodiment, acquiring the image information of the bill includes: and collecting a paper money image through CDD visual detection equipment, and converting the paper money image into a gray image to obtain image information. Specifically, in actual work, a CCD visual inspection device can be used for collecting a paper money image and converting the paper money image into a gray image, a defect image block is respectively intercepted on the paper money gray image to serve as defect data, and a normal image is intercepted to serve as non-defect data. The truncated image requires resize to a size of 416x 416.
Referring to fig. 2, in an embodiment of the invention, the filtering and/or amplifying the defect data and the non-defect data to generate a training image includes:
s201, replacing the particle noise points of the defect data and the defect-free data by utilizing a low-pass or high-pass filter through the weighted average value of each pixel in the pixel point field of the particle noise points in the defect data and the defect-free data;
s202, amplifying the defect data and the non-defect data by one or more combinations of rotating according to a preset angle, adjusting brightness and contrast and adding Gaussian white noise.
Specifically, in actual work, aiming at the characteristic that the collection of a paper money image domain is easily influenced by internal noise such as particle noise on an image collecting instrument and an optical negative film, a low-pass or high-pass filter is used, and the weighted average value of each pixel in a certain pixel point domain is used for replacing the original pixel value.
The image set is expanded by rotating the original image by 90 degrees, 180 degrees and 270 degrees and adjusting the contrast and the brightness; the number of image samples is further extended by adding white gaussian noise. The number of the extended defect data and defect-free data samples is about 2500, the ratio of the number of the images in the training set to the number of the images in the testing set is 8:2, and the types of the defects comprise spots, scratches and defects.
In an embodiment of the present invention, in the step S102, the banknote damage location in the defect data is calibrated to generate defect type data, the location of the banknote damage in the training picture can be calibrated by using labelImg software, and an XML file corresponding to a passacal format is generated, where the generated XML file includes the picture path, the type of the damage and the coordinate location information. The training set is composed of images and XML files corresponding to the images.
In an embodiment of the present invention, the predetermined YOLOv3 network includes: darknet-53 in the YOLOv3 network structure was replaced by a dense connection network DenseNet. Specifically, in actual work, the YOLOv3 network firstly divides an input picture into a plurality of cells, and if the center of an object to be detected falls in a certain cell, the cell is responsible for predicting the object and outputting various attributes (including the position, width and height of a central point, confidence and category information) of the object. The YOLOv3 feature extraction network is shown in fig. 3. In order to improve the feature extraction capability, a dense connection network DenseNet is used for replacing an original network structure Darknet-53, and the structure diagram of the DenseNet is shown in figure 4.
The formula is used to show that the output of the DenseNet network at the l layer is:
xl=Hl([x0,x1,...,xl-1]);
wherein xlRepresents the output of the l-th neural network, HlRepresenting a non-linear function. It can be seen that each layer of the DenseNet can accept all the previous layers as additional input, so that the reuse of characteristics among multiple layers can be better realized, the problem of gradient disappearance in the original structure is relieved, and the network calculation efficiency is improved.
An input picture with the size of 416X416 enters a DenseNet network to obtain 3 original branches, and the branches are subjected to a series of operations such as convolution, upsampling and combination to finally obtain three characteristic pictures of y1, y2 and y3 with different sizes in a characteristic diagram 4, wherein the three characteristic pictures correspond to 32-time downsampling, 16-time downsampling and 8-time downsampling respectively. The shapes are [13, 255], [26, 255] and [52, 255] respectively, which correspond to detection targets of large size, medium size and small size respectively. However, for the small-size damage of the paper money, the original three original prediction scales of Yolov3 cannot meet the requirements, so the 4 th prediction scale is added. The feature map of [52, 255] is up-sampled and connected to the feature map of [104,104,255] size in the convolution process, which is a 4-fold down-sampled size of the input image and whose receptive field is suitable for detecting the smaller-sized defect location among the banknote defects.
Referring to fig. 5, in an embodiment of the present invention, the calculating the banknote defect ratio according to the characteristic parameters includes:
s501, acquiring position parameters in the characteristic parameters, and calculating to obtain length and width data of the paper money according to the position parameters;
and S502, according to the length and width data, the confidence level and the defect classification probability in the characteristic parameters, the preset sigmoid function is substituted to calculate and obtain the defect ratio of the paper money.
Specifically, in actual operation, the output bounding box of a neural network is typically represented by a set of 6-element vectors. Respectively, 4 location parameters center _ x, center _ y, w, h, and 1 confidence (1 or 0) and 1 defect classification probability p (i) ([1,0,0,0,0 … ], [0,1,0,0,0 … ]). Wherein center _ x and center _ y are the abscissa and ordinate of the central position of the output bounding box; w and h are length and width information of the output bounding box. The confidence level represents whether the current bounding box has an object. If the confidence of the frame is less than a given threshold, the frame is considered to contain no object, a sigmoid function is mainly used, the function can restrict the result output by the feature layer to the interval of [0, 1], if the decimal obtained by the result continuously passing through the sigmoid function is greater than the set threshold, the result belongs to the category, otherwise, the boundary frame is deleted and the follow-up processing is not considered. The boxes whose confidence levels are equal to or greater than the confidence level threshold are then subjected to non-maximum suppression (NMS) processing. Therefore, whether the paper money is damaged to a certain degree and needs to be recovered can be judged according to the following formula:
where n is the number of output bounding boxes, P (object) is the corresponding confidence, w, h are the length and width of the output bounding boxes, W, H is the length and width of the banknote, and X is the quotient of the detected defect area and the total banknote area. And comparing the X with a set threshold value, and if the ratio of the sum of the detected defect areas to the total area of the paper money is larger than or equal to the set threshold value, determining that the damage of the paper money reaches a certain degree and needing to be recycled.
Referring to fig. 6, the present invention further provides a banknote breakage recognition apparatus based on deep learning, the apparatus including: the device comprises an image acquisition module, a preprocessing module, a training module and an identification module; the image acquisition module is used for acquiring image information of paper money, and respectively intercepting a defect image block and a standard image block in the image information to generate defect data and non-defect data; the preprocessing module is used for carrying out filtering and/or amplification processing on the defect data and the non-defect data to generate a training image, calibrating the damaged position of the paper currency in the defect data to generate defect type data, and generating training set data according to the training image and the defect type data; the training module is used for training a preset Yolov3 network through the training set data to obtain a banknote detection model, and inputting a banknote image to be detected into the banknote detection model to obtain characteristic parameters; the recognition module is used for calculating according to the characteristic parameters to obtain a paper currency defect ratio, and comparing the paper currency defect ratio with a preset threshold value to obtain a paper currency damage condition.
In the above embodiment, the image capturing module includes: and collecting a paper money image through CDD visual detection equipment, and converting the paper money image into a gray image to obtain image information. In another embodiment, the pretreatment module comprises a filtration unit and an amplification unit; the filtering unit is used for replacing the particle noise points of the defect data and the defect-free data by utilizing a low-pass or high-pass filter through the weighted average value of each pixel in the pixel point field of the particle noise points in the defect data and the defect-free data; the amplification unit is used for amplifying one or more combinations of rotating the defect data and the non-defect data according to a preset angle, adjusting brightness and contrast and adding Gaussian white noise.
In an embodiment of the present invention, the identification module includes a calculation unit, and the calculation unit is configured to obtain a position parameter in the characteristic parameters, and calculate length and width data of the banknote according to the position parameter; and substituting the length and width data and the confidence level and the defect classification probability in the characteristic parameters into a preset sigmoid function to calculate and obtain the defect ratio of the paper money.
The invention has the beneficial technical effects that: aiming at the small-size damage condition of the paper money, the original three original prediction scales of Yolov3 cannot meet the requirements, so the 4 th prediction scale is added. The feature map of [52, 255] is up-sampled and connected to the feature map of [104,104,255] size in the convolution process, which is a 4-fold down-sampled size of the input image and whose receptive field is suitable for detecting the smaller-sized defect location among the banknote defects. The dense connection network DenseNet is used for replacing an original network structure Darknet-53, each layer of the DenseNet can receive all the previous layers as additional input of the DenseNet, multi-layer characteristic reuse can be better realized, the problem of gradient disappearance in the original structure is relieved, and the network computing efficiency is improved.
The invention also provides a computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the method when executing the computer program.
The present invention also provides a computer-readable storage medium storing a computer program for executing the above method.
As shown in fig. 7, theelectronic device 600 may further include:communication module 110,input unit 120,audio processing unit 130,display 160,power supply 170. It is noted that theelectronic device 600 does not necessarily include all of the components shown in fig. 7; furthermore, theelectronic device 600 may also comprise components not shown in fig. 7, which may be referred to in the prior art.
As shown in fig. 7, thecentral processor 100, sometimes referred to as a controller or operational control, may include a microprocessor or other processor device and/or logic device, thecentral processor 100 receiving input and controlling the operation of the various components of theelectronic device 600.
Thememory 140 may be, for example, one or more of a buffer, a flash memory, a hard drive, a removable media, a volatile memory, a non-volatile memory, or other suitable device. The information relating to the failure may be stored, and a program for executing the information may be stored. And thecentral processing unit 100 may execute the program stored in thememory 140 to realize information storage or processing, etc.
Theinput unit 120 provides input to thecpu 100. Theinput unit 120 is, for example, a key or a touch input device. Thepower supply 170 is used to provide power to theelectronic device 600. Thedisplay 160 is used to display an object to be displayed, such as an image or a character. The display may be, for example, an LCD display, but is not limited thereto.
Thememory 140 may be a solid state memory such as Read Only Memory (ROM), Random Access Memory (RAM), a SIM card, or the like. There may also be a memory that holds information even when power is off, can be selectively erased, and is provided with more data, an example of which is sometimes called an EPROM or the like. Thememory 140 may also be some other type of device.Memory 140 includes buffer memory 141 (sometimes referred to as a buffer). Thememory 140 may include an application/function storage section 142, and the application/function storage section 142 is used to store application programs and function programs or a flow for executing the operation of theelectronic device 600 by thecentral processing unit 100.
Thememory 140 may also include adata store 143, thedata store 143 for storing data, such as contacts, digital data, pictures, sounds, and/or any other data used by the electronic device. Thedriver storage portion 144 of thememory 140 may include various drivers of the electronic device for communication functions and/or for performing other functions of the electronic device (e.g., messaging application, address book application, etc.).
Thecommunication module 110 is a transmitter/receiver 110 that transmits and receives signals via anantenna 111. The communication module (transmitter/receiver) 110 is coupled to thecentral processor 100 to provide an input signal and receive an output signal, which may be the same as in the case of a conventional mobile communication terminal.
Based on different communication technologies, a plurality ofcommunication modules 110, such as a cellular network module, a bluetooth module, and/or a wireless local area network module, may be provided in the same electronic device. The communication module (transmitter/receiver) 110 is also coupled to aspeaker 131 and amicrophone 132 via anaudio processor 130 to provide audio output via thespeaker 131 and receive audio input from themicrophone 132 to implement general telecommunications functions.Audio processor 130 may include any suitable buffers, decoders, amplifiers and so forth. In addition, anaudio processor 130 is also coupled to thecentral processor 100, so that recording on the local can be enabled through amicrophone 132, and so that sound stored on the local can be played through aspeaker 131.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The above-mentioned embodiments are intended to illustrate the objects, technical solutions and advantages of the present invention in further detail, and it should be understood that the above-mentioned embodiments are only exemplary embodiments of the present invention, and are not intended to limit the scope of the present invention, and any modifications, equivalent substitutions, improvements and the like made within the spirit and principle of the present invention should be included in the scope of the present invention.