Document file detection method, device, electronic device and readable storage medium
By combining feature detection model and deep learning model, the color features and image features of document files of specified types are detected, and the problems of low detection efficiency and large errors in the prior art are solved, and efficient and accurate document file detection is achieved.
Patent Information
- Application Number
- CN202010998537.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-21
- Publication Date
- 2025-02-28
- Estimated Expiration
- 2040-09-21
AI Technical Summary
The prior art is inefficient and errors when detecting whether document files of a specified type are leaked, with high manual detection costs, slow watermark detection speed and easy to miss inspection.
By combining the feature detection model and the deep learning model, the image to be identified is obtained and color feature detection is performed, and the color feature detection is initially determined whether the color features of the document file of the specified type are met. If satisfied, it will be further identified through the deep learning model to determine whether the image is a document file of the specified type.
Improves the efficiency and accuracy of document file detection of specified types, reduces detection errors, and realizes rapid identification and alarm prompts.
Smart Images

Figure CN112132008B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer data processing, and in particular to a document file detection method, device, electronic device and readable storage medium. Background Art
[0002] With the use and promotion of mobile office, some paper materials are transferred to electronic documents through photography, scanning and other means for easy reading and storage. This method brings certain security risks to materials that are not suitable for wide dissemination and contain private information or files of specified types. At present, when detecting whether a specified type of document file has leaked, it is usually detected manually, or a watermark is set on the file in advance, and the watermark is used to detect whether a leak has occurred. Among them, for manual detection, due to the existence of manual intervention, the detection efficiency and cost are high, and it is easy to cause secondary leakage of the specified type of document file. For automatic detection through watermarks, the added watermark information is extracted and matched during the detection process. This method is slow when detecting massive images. In addition, the electronic watermark has distortion, deformation and other factors after the second shooting, so there is a situation of missed detection. That is, the current efficiency of detecting the specified type of document file is low, and there are certain errors. Summary of the invention
[0003] The present application provides a document file detection method, device, electronic device and readable storage medium, which can improve the efficiency of document file detection of specified types and reduce errors.
[0004] In order to achieve the above purpose, the technical solutions provided in the embodiments of the present application are as follows:
[0005] In a first aspect, an embodiment of the present application provides a document file detection method, the method comprising:
[0006] Obtain an image to be recognized;
[0007] Inputting the image to be recognized into a feature detection model of a document file of a specified type to obtain a first detection result;
[0008] When the first detection result indicates that the image to be identified meets the color characteristics of the specified type of document file, the image to be identified is input into a trained deep learning model to obtain a second detection result of the deep learning model identifying the image to be identified, and the second detection result includes a result indicating that the image to be identified is a document file of the specified type, or a result indicating that the image to be identified is not a document file of the specified type.
[0009] In the above-mentioned embodiment, the feature detection model can detect the color features of the image to be identified to determine whether the color features of the image to be identified meet the color features of the specified type of document file, so that the image to be identified can be initially detected and judged. Then, after the color features of the image to be identified meet the color features of the specified type of document file, the trained deep learning model detects the image to be identified to determine the detection result of the image to be identified. Based on this, by combining the feature detection model with the deep learning model, the efficiency and accuracy of the detection can be improved and the detection error can be reduced.
[0010] In combination with the first aspect, in some optional implementations, before acquiring the image to be recognized, the method includes:
[0011] Get multiple image materials;
[0012] Determining a first-category image set and a second-category image set from the plurality of image materials, wherein the first-category image set includes a plurality of first-category images and is provided with a first tag indicating that the first-category images are document files of the specified type, and the second-category image set includes a plurality of second-category images and is provided with a second tag indicating that the second-category images are document files of non-specified types;
[0013] The deep learning model is trained using the first category image set and the second category image set to obtain a trained deep learning model for identifying whether an image is a document file of the specified type.
[0014] In conjunction with the first aspect, in some optional implementations, determining the first type of image set and the second type of image set from the acquired multiple image materials includes:
[0015] Deduplication processing is performed on the multiple image materials by using an image deduplication algorithm to obtain deduplicated image materials;
[0016] The first category image set and the second category image set are determined from the deduplicated image materials.
[0017] In combination with the first aspect, in some optional implementations, deduplication processing is performed on the multiple image materials by using an image deduplication algorithm to obtain deduplicated image materials, including:
[0018] Calculate the information summary of each image in the multiple image materials by using an image deduplication algorithm;
[0019] When there are two or more images with the same information summary, the two or more images are deduplicated to obtain the deduplicated image material.
[0020] In combination with the first aspect, in some optional implementations, inputting the image to be identified into a feature detection model of a document file of a specified type to obtain a first detection result includes:
[0021] Inputting the image to be recognized into a feature detection model of the specified type of document file, and converting the image to be recognized into an image of a specified size through the feature detection model of the specified type of document file;
[0022] Determine, by using the feature detection model of the document file of the specified type, the ratio of the number of pixels representing a specified color to the number of pixels representing a white class in the image of the specified size, wherein the specified color is the color of the header title of the document in the image to be identified;
[0023] When the ratio is within a set range, determining that the image to be identified meets the color characteristics of the document file of the specified type;
[0024] When the ratio is not within the set range, it is determined that the image to be identified does not meet the color feature of the document file of the specified type.
[0025] In combination with the first aspect, in some optional implementations, the method further includes:
[0026] When the second detection result indicates that the image to be identified is a document file of a specified type, an alarm prompt is issued.
[0027] In combination with the first aspect, in some optional implementations, the deep learning model includes a NASNET model provided with a fully connected layer and a Dropout layer.
[0028] In a second aspect, an embodiment of the present application further provides a document file detection device, the device comprising:
[0029] An acquisition unit, used for acquiring an image to be recognized;
[0030] A first detection unit, configured to input the image to be identified into a feature detection model of a document file of a specified type to obtain a first detection result;
[0031] A second detection unit is used to input the image to be identified into a trained deep learning model when the first detection result indicates that the image to be identified meets the color characteristics of the specified type of document file, so as to obtain a second detection result of the deep learning model identifying the image to be identified, wherein the second detection result includes a result indicating that the image to be identified is a document file of the specified type, or a result indicating that the image to be identified is not a document file of the specified type.
[0032] In a third aspect, an embodiment of the present application further provides an electronic device, comprising a memory and a processor coupled to each other, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the electronic device executes the above-mentioned document file detection method.
[0033] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, wherein a computer program is stored in the computer-readable storage medium. When the computer program is executed on a computer, the computer executes the above-mentioned document file detection method. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0035] Figure 1 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
[0036] Figure 2 A flowchart of a document file detection method provided in an embodiment of the present application.
[0037] Figure 3 for Figure 2 Schematic diagram of the flow chart of the sub-steps included in step S220.
[0038] Figure 4 A block diagram of a document file detection device provided in an embodiment of the present application.
[0039] Icons: 10 - electronic device; 11 - processing module; 12 - storage module; 100 - document file detection device; 110 - acquisition unit; 120 - first detection unit; 130 - second detection unit. DETAILED DESCRIPTION
[0040] The technical solutions in the embodiments of the present application will be described below in conjunction with the accompanying drawings in the embodiments of the present application. It should be noted that the terms "first", "second" and the like are only used to distinguish descriptions and cannot be understood as indicating or implying relative importance.
[0041] The embodiments of the present application are described in detail below in conjunction with the accompanying drawings. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.
[0042] Please refer to Figure 1, an embodiment of the present application provides an electronic device 10, which can be used to detect whether a document file is a document file of a specified type. Among them, the document file of the specified type can be determined according to actual conditions. The document file of the specified type is usually a file that is not suitable for wide dissemination and contains private information, and usually has a specified format. For example, the document file of the specified type can be, but is not limited to, a red-headed file, a green-headed file, etc.
[0043] In this embodiment, the red-headed file can be understood as another name for confidential documents, appointment documents, and urgent documents of the company. The red-headed file is a document file with a red font at the head. Similarly, the green-headed file is a document file with a green font at the head.
[0044] In this embodiment, the electronic device 10 may include a processing module 11 and a storage module 12. The storage module 12 stores a computer program, and when the computer program is executed by the processing module 11, the electronic device 10 may execute each step of the document file detection method described below.
[0045] Of course, the electronic device 10 may also include other modules, for example, the electronic device 10 may also include a communication module and a document file detection device 100. The processing module 11, the storage module 12, the communication module and the document file detection device 100 are directly or indirectly electrically connected to each other to achieve data transmission or interaction. For example, these components may be electrically connected to each other through one or more communication buses or signal lines.
[0046] The electronic device 10 can establish a communication connection with other devices (such as user terminals) through the communication module. The electronic device 10 can be, but is not limited to, a personal computer, a server, and other devices. The user terminal can be, but is not limited to, a smart phone, a tablet computer, a personal digital assistant (PDA), a mobile Internet device (MID), and the like.
[0047] Please refer to Figure 2 The embodiment of the present application also provides a document file detection method, which can be applied to the above-mentioned electronic device 10, and each step in the method is executed or implemented by the electronic device 10. The method may include the following steps:
[0048] Step S210, obtaining an image to be recognized;
[0049] Step S220, inputting the image to be recognized into a feature detection model of a document file of a specified type to obtain a first detection result;
[0050] Step S230, when the first detection result indicates that the image to be identified meets the color characteristics of the specified type of document file, the image to be identified is input into a trained deep learning model to obtain a second detection result of the deep learning model identifying the image to be identified, and the second detection result includes a result indicating that the image to be identified is a document file of the specified type, or a result indicating that the image to be identified is not a document file of the specified type.
[0051] In the above-mentioned embodiment, the feature detection model can detect the color features of the image to be identified to determine whether the color features of the image to be identified meet the color features of the specified type of document file, so that the image to be identified can be initially detected and judged. Then, after the color features of the image to be identified meet the color features of the specified type of document file, the trained deep learning model detects the image to be identified to determine the detection result of the image to be identified. Based on this, by combining the feature detection model with the deep learning model, the efficiency and accuracy of the detection can be improved and the detection error can be reduced.
[0052] The following will take the example of specifying the type of document file as a red-headed file to explain the steps of the method in detail, as follows:
[0053] In step S210, when the image to be identified needs to be detected, the electronic device 10 can obtain the image to be identified. For example, the user terminal can send the collected image to be detected to the electronic device 10, so that the electronic device 10 obtains the image to be identified. Alternatively, the server pre-stores the image to be identified that needs to be detected, and the electronic device 10 can obtain the image to be identified from the server.
[0054] It is understandable that as long as the electronic device 10 can obtain the image to be recognized, there is no specific limitation on the way in which the electronic device 10 obtains the image to be recognized. The image to be recognized is usually an image obtained by photographing a document file or by scanning a paper document.
[0055] In step S220, the feature detection model may be used to perform color feature detection processing on the image to be identified, and to determine whether the color features of the image to be identified meet the color features of a document file of a specified type.
[0056] For example, for a red-headed document, a red-headed document usually has a specific format, and the header of the document file is in large red font. In an image obtained by photographing a red-headed document, the ratio of the number of red pixels to the number of white pixels in the image is usually within a set range.
[0057] If the feature detection model determines that the ratio of the number of red pixels to white pixels in the image to be identified is within the set range, it is determined that the image to be identified meets the color characteristics of the red-headed document; if the ratio is not within the set range, it is determined that the image to be identified does not meet the color characteristics of the red-headed document. Among them, the set range can be determined according to actual conditions. Based on this, it is possible to preliminarily determine whether the document in the image to be identified is a document file of a specified type, and filter out the images to be identified that do not meet the color characteristics of the red-headed document, which is conducive to reducing the number of images that the deep learning model needs to identify and detect, and improving the accuracy of detection.
[0058] In step S230, the trained deep learning model can be used to detect whether the image to be identified is a document file of a specified type. The image to be identified input to the deep learning model is an image that meets the color characteristics of a document file of a specified type. After the deep learning model performs convolution and other operations on the image to be identified, it can obtain a second detection result of whether the image to be identified is a document file of a specified type.
[0059] In this embodiment, the training model in the deep learning model can be selected according to the actual situation. For example, the training model of the deep learning model can be, but is not limited to, ResNeXt-101, PolyNet, SENet and other models. Among them, ResNeXt-101, PolyNet, SENet are well known to those skilled in the art and will not be described here.
[0060] Of course, deep learning can also be other models, for example, the deep learning model includes a NASNet (Neural Architecture Search Net) model with a fully connected layer and a Dropout layer. Understandably, the fully connected layer can act as a classifier in the deep learning model to improve the learning ability of the model. Adding a Dropout layer to the fully connected layer can prevent the model from overfitting and improve the accuracy of model detection.
[0061] As an optional implementation, before step S210, the method may further include a step of training the classification model. For example, the method may further include:
[0062] Get multiple image materials;
[0063] Determining a first-category image set and a second-category image set from the plurality of image materials, wherein the first-category image set includes a plurality of first-category images and is provided with a first tag indicating that the first-category images are document files of the specified type, and the second-category image set includes a plurality of second-category images and is provided with a second tag indicating that the second-category images are document files of non-specified types;
[0064] The deep learning model is trained using the first category image set and the second category image set to obtain a trained deep learning model for identifying whether an image is a document file of the specified type.
[0065] In this embodiment, the electronic device 10 can obtain the corresponding image material through a web crawler. The image material needs to include images that have a specified type of document file and images that are not a specified type of document file. The number of image materials is usually large, and the number of images included in the image material can be 10,000, 100,000, etc. The number of image materials is not specifically limited here.
[0066] After obtaining a large amount of image materials, each image in the image materials may be pre-set with a corresponding label.
[0067] The label is used to indicate that the image is a document file of a specified type, or is used to indicate that the image is not a document file of a specified type, and can be set manually. The electronic device 10 can determine the first type image set and the second type image set according to the label in the image material. The first label is used to indicate that the document in the image is a document file of a specified type, and the second label is used to indicate that the document in the image is a document file of a non-specified type. The first label and the second label can be determined according to actual conditions, and are not specifically limited here.
[0068] After obtaining the first image set and the second image set, the deep learning model can be trained using the first image set, the second image set and the corresponding labels, and then the trained model is tested and verified to obtain a trained deep learning model. The process of training and testing the deep learning model using the first image set and the second image set is well known to those skilled in the art and is not specifically limited here.
[0069] After the deep learning model completes training and testing, the resulting deep learning model is a trained deep learning model, which can be used to identify whether there is a document in the detection image, and when a document exists, determine whether the document in the image is a document file of a specified type.
[0070] As an optional implementation manner, the step of determining the first type of image set and the second type of image set from the acquired multiple image materials may include:
[0071] Deduplication processing is performed on the multiple image materials by using an image deduplication algorithm to obtain deduplicated image materials;
[0072] The first category image set and the second category image set are determined from the deduplicated image materials.
[0073] In this embodiment, there may be duplicate images in a large amount of image materials acquired by the electronic device 10. At this time, the electronic device 10 can perform deduplication processing on the duplicate images in the image materials to improve the effectiveness of the image materials and prevent the duplicate images from affecting the effect of model training. The deduplication algorithm can be selected according to the actual situation and is not specifically limited here.
[0074] After deduplication of multiple image materials, a first category image set and a second category image set are determined from the deduplication image materials.
[0075] As an optional implementation manner, the multiple image materials are deduplicated by using an image deduplication algorithm to obtain deduplicated image materials, including:
[0076] Calculate the information summary of each image in the multiple image materials by using an image deduplication algorithm;
[0077] When there are two or more images with the same information summary, the two or more images are deduplicated to obtain the deduplicated image material.
[0078] In this embodiment, the image deduplication algorithm may be MD5 (Message-Digest Algorithm 5). Understandably, it can be used to calculate the message digest of each image, which may be a hash value of the image. For completely identical image files, although the names are different, when the message digest is calculated using MD5, the character string of the calculated message digest will be exactly the same. In this way, the message digest of each image can be used to determine whether the same image exists in the image material. If the same image exists, deduplication is performed on the two or more identical images. That is, in each group of identical multiple images, one of the images is retained and the other images are deleted, thereby obtaining the deduplicated image material.
[0079] Please refer to Figure 3 As an optional implementation, step S220 may include the following sub-steps:
[0080] Sub-step S221, inputting the image to be recognized into the feature detection model of the specified type of document file, and converting the image to be recognized into an image of a specified size through the feature detection model of the specified type of document file;
[0081] Sub-step S222, determining the ratio of the number of pixels representing a specified color to the number of pixels representing a white class in the image of the specified size through the feature detection model of the document file of the specified type, wherein the specified color is the color of the header title of the document in the image to be identified;
[0082] Sub-step S223, when the ratio is within a set range, determining that the image to be identified meets the color characteristics of the specified type of document file;
[0083] Sub-step S224, when the ratio is not within the set range, determining that the image to be identified does not meet the color characteristics of the specified type of document file.
[0084] In this embodiment, the feature detection model can convert the size of the image to be identified into a specified size to facilitate the extraction of color features. The specified size can be determined according to actual conditions, for example, the specified size can be 32*32 pixels.
[0085] When the specified type of document is a red header file, the specified color is red. In an image, due to image brightness or other reasons, red is not necessarily pure red. That is, the color whose color difference between the specified color and pure red is within the specified range is red. Color features can be represented by RGB values. The specified range can be determined according to actual conditions. Among them, the RGB value of pure red is (255,0,0).
[0086] Exemplarily, when the electronic device 10 identifies whether the color of a pixel is red, it can decompose the brightness from the color according to the HSV (Hue Saturation Value) color space. The purity of red, green, and blue can be represented by S. S is a proportional value ranging from 0 to 1, which is used to represent the ratio between the purity of the color of the selected pixel and the maximum purity of the color. When S=0, there is only grayscale. In this way, the purity of red can be calculated to determine whether the color of the selected pixel is red. If the red purity of the selected pixel is greater than or equal to the set threshold, the color of the pixel is considered to be red. Based on this, the color of the pixel is judged to avoid missed detection due to color difference. Among them, the threshold setting can be determined according to the actual situation, and no specific limitation is made here.
[0087] Similarly, white is not limited to pure white. The RGB value of pure white is (255, 255, 255). If the color difference between the color of a pixel and pure white is within the set threshold range, the color of the pixel is determined to be white. The method of determining whether the color of a pixel is white is similar to the method of determining whether the color of a pixel is red, which will not be repeated here.
[0088] For red-headed documents, the ratio of red pixels to white pixels is usually within a set range, which can be determined according to actual conditions. For example, the set range can be 0.1% to 0.5%. The electronic device 10 can calculate the ratio of the number of red pixels to the number of white pixels in the image to be processed of a specified size through a feature detection model, and then determine whether the ratio is within the set range. If the ratio is within the set range, it is considered that the image to be identified meets the color characteristics of the red-headed document; if the ratio is not within the specified range, it is determined that the image to be identified does not meet the color characteristics of the red-headed document. At this time, it usually means that the document in the image to be identified is not a red-headed document, and there is no need to detect it through a deep learning model.
[0089] Based on the above design, by performing preliminary detection on the images to be identified, some images to be identified that are not document files of the specified type can be filtered out. For images to be identified that are initially judged to be document files of the specified type, they need to be input into the deep learning model for further detection, which is conducive to improving the accuracy, reliability and efficiency of document file detection. For example, through the above method, the accuracy rate of red-headed document detection can reach more than 95%, and for images with a pixel size of 4000*3000 of the image to be identified, a detection speed of 20 images per second can be achieved.
[0090] As an optional implementation, after step S230, the method may further include: when the second detection result indicates that the image to be identified is a document file of a specified type, issuing an alarm prompt.
[0091] In this embodiment, when the detection result of the electronic device 10 indicates that the image to be identified is a document file of a specified type, an alarm prompt is issued, which is conducive to the operator to promptly discover suspicious images. That is, the image to be identified corresponding to the alarm prompt may be a leaked document image. For example, when the electronic device 10 identifies that the image to be identified is a red-headed document, it issues an alarm prompt information. Based on this, it is conducive to quickly detecting suspicious images, so that when a secret document is leaked, remedial measures can be taken in time to reduce losses.
[0092] Please refer to Figure 4 The embodiment of the present application also provides a document file detection device 100, which can be applied to the above-mentioned electronic device 10 to execute or implement each step of the method. The document file detection device 100 includes at least one software function module that can be stored in the storage module 12 in the form of software or firmware or fixed in the operating system (OS) of the electronic device 10. The processing module 11 is used to execute the executable module stored in the storage module 12, such as the software function module and computer program included in the document file detection device 100.
[0093] In this embodiment, the document file detection device 100 may include an acquisition unit 110, a first detection unit and a second detection unit 130, and the operations performed may be as follows:
[0094] An acquisition unit 110 is used to acquire an image to be recognized;
[0095] A first detection unit, configured to input the image to be identified into a feature detection model of a document file of a specified type to obtain a first detection result;
[0096] The second detection unit 130 is used to input the image to be identified into a trained deep learning model when the first detection result indicates that the image to be identified meets the color characteristics of the specified type of document file, so as to obtain a second detection result of the deep learning model identifying the image to be identified, wherein the second detection result includes a result indicating that the image to be identified is a document file of the specified type, or a result indicating that the image to be identified is not a document file of the specified type.
[0097] Optionally, the document file detection device 100 may further include a training image determination unit and a training unit. Before the acquisition unit 110 executes step S210, the acquisition unit 110 may also be used to acquire multiple image materials; the training image determination unit is used to determine a first-category image set and a second-category image set from the multiple image materials, wherein the first-category image set includes multiple first-category images and is provided with a first label indicating that the first-category image is a document file of the specified type, and the second-category image set includes multiple second-category images and is provided with a second label indicating that the second-category image is not a document file of the specified type; the training unit is used to train a deep learning model through the first-category image set and the second-category image set to obtain a trained deep learning model for identifying whether an image is a document file of the specified type.
[0098] Optionally, the training image determination unit may also be used to:
[0099] Deduplication processing is performed on the multiple image materials by using an image deduplication algorithm to obtain deduplicated image materials;
[0100] The first category image set and the second category image set are determined from the deduplicated image materials.
[0101] Optionally, the training image determination unit may also be used to:
[0102] Calculate the information summary of each image in the multiple image materials by using an image deduplication algorithm;
[0103] When there are two or more images with the same information summary, the two or more images are deduplicated to obtain the deduplicated image material.
[0104] Optionally, the first detection unit may also be used for:
[0105] Inputting the image to be recognized into a feature detection model of the specified type of document file, and converting the image to be recognized into an image of a specified size through the feature detection model of the specified type of document file;
[0106] Determine, by using the feature detection model of the document file of the specified type, the ratio of the number of pixels representing a specified color to the number of pixels representing a white class in the image of the specified size, wherein the specified color is the color of the header title of the document in the image to be identified;
[0107] When the ratio is within a set range, determining that the image to be identified meets the color characteristics of the document file of the specified type;
[0108] When the ratio is not within the set range, it is determined that the image to be identified does not meet the color feature of the document file of the specified type.
[0109] Optionally, the document file detection device 100 may further include a prompting unit, configured to issue an alarm prompt when the second detection result indicates that the image to be identified is a document file of a specified type.
[0110] In this embodiment, the processing module 11 can be an integrated circuit chip with signal processing capabilities. The above-mentioned processing module 11 can be a general-purpose processor. For example, the processor can be a central processing unit (CPU), a graphics processing unit (GPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, which can implement or execute the disclosed methods, steps and logic block diagrams in the embodiments of this application.
[0111] The storage module 12 may be, but is not limited to, a random access memory, a read-only memory, a programmable read-only memory, an erasable programmable read-only memory, an electrically erasable programmable read-only memory, etc. In this embodiment, the storage module 12 may be used to store images to be recognized, deep learning models, feature detection models, etc. Of course, the storage module 12 may also be used to store programs, and the processing module 11 executes the program after receiving the execution instruction.
[0112] The communication module is used to establish a communication connection between the electronic device 10 and other devices (such as user terminals) through a network, and to send and receive data through the network.
[0113] Understandably, Figure 1 The structure shown is only a schematic diagram of a structure of the electronic device 10. The electronic device 10 may also include Figure 1 More components are shown. Figure 1 Each component shown in the figure can be implemented by hardware, software or a combination thereof.
[0114] It should be noted that those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process of the electronic device 10 and the document file detection device 100 described above can refer to the corresponding process of each step in the aforementioned method, and will not be elaborated here.
[0115] The embodiment of the present application further provides a computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is run on a computer, the computer executes the document file detection method described in the above embodiment.
[0116] Through the description of the above implementation methods, technical personnel in this field can clearly understand that the present application can be implemented by hardware, and can also be implemented by means of software plus a necessary general hardware platform. Based on such an understanding, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.), including a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each implementation scenario of the present application.
[0117] In summary, the present application provides a document file detection method, device, electronic device and readable storage medium. The method includes: obtaining an image to be identified; inputting the image to be identified into a feature detection model of a specified type of document file to obtain a first detection result; when the first detection result indicates that the image to be identified meets the color feature of the specified type of document file, inputting the image to be identified into a trained deep learning model to obtain a second detection result of the deep learning model identifying the image to be identified, and the second detection result includes a result indicating that the image to be identified is a document file of the specified type, or a result indicating that the image to be identified is not a document file of the specified type. In this solution, the feature detection model can detect the color feature of the image to be identified to determine whether the color feature of the image to be identified meets the color feature of the specified type of document file, so that the image to be identified can be preliminarily detected and judged. Then, after the color feature of the image to be identified meets the color feature of the specified type of document file, the trained deep learning model detects the image to be identified to determine the detection result of the image to be identified. Based on this, by combining the feature detection model with the deep learning model, the efficiency and accuracy of the detection can be improved and the detection error can be reduced.
[0118] In the embodiments provided in the present application, it should be understood that the disclosed device, system and method can also be implemented in other ways. The above-described device, system and method embodiments are merely schematic, for example, the flowchart and block diagram in the accompanying drawings show the possible architecture, function and operation of the system, method and computer program product according to the multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a part of a module, a program segment or a code, and a part of the module, program segment or code contains one or more executable instructions for implementing the specified logical function. It should also be noted that each box in the block diagram and / or the flowchart, and the combination of the boxes in the block diagram and / or the flowchart can be implemented by a dedicated hardware-based system that performs the specified function or action, or can be implemented by a combination of dedicated hardware and computer instructions. In addition, each functional module in each embodiment of the present application can be integrated together to form an independent part, or each module can exist separately, or two or more modules can be integrated to form an independent part.
[0119] The above description is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A document file detection method, characterized in that: The method comprises: Obtain an image to be recognized; Inputting the image to be recognized into a feature detection model of a document file of a specified type to obtain a first detection result; When the first detection result indicates that the image to be identified meets the color feature of the specified type of document file, the image to be identified is input into a trained deep learning model to obtain a second detection result of the deep learning model identifying the image to be identified, the second detection result including a result indicating that the image to be identified is a document file of the specified type, or a result indicating that the image to be identified is not a document file of the specified type; Among them, the step of inputting the image to be identified into the feature detection model of the specified type of document file to obtain the first detection result includes: inputting the image to be identified into the feature detection model of the specified type of document file, and converting the image to be identified into an image of a specified size through the feature detection model of the specified type of document file; determining the ratio of the number of pixels representing a specified color to the number of pixels representing a white class in the image of the specified size through the feature detection model of the specified type of document file, wherein the specified color is the color of the header title of the document in the image to be identified; when the ratio is within a set range, determining that the image to be identified meets the color characteristics of the specified type of document file; when the ratio is not within the set range, determining that the image to be identified does not meet the color characteristics of the specified type of document file.
2. The method according to claim 1, characterized in that: Before acquiring the image to be recognized, the method includes: Get multiple image materials; Determining a first-category image set and a second-category image set from the plurality of image materials, wherein the first-category image set includes a plurality of first-category images and is provided with a first tag indicating that the first-category images are document files of the specified type, and the second-category image set includes a plurality of second-category images and is provided with a second tag indicating that the second-category images are document files of non-specified types; The deep learning model is trained using the first category image set and the second category image set to obtain a trained deep learning model for identifying whether an image is a document file of the specified type.
3. The method according to claim 2, characterized in that Determining a first type of image set and a second type of image set from the acquired multiple image materials includes: Deduplication processing is performed on the multiple image materials by using an image deduplication algorithm to obtain deduplicated image materials; The first category image set and the second category image set are determined from the deduplicated image materials.
4. The method according to claim 3, characterized in that The multiple image materials are deduplicated by using an image deduplication algorithm to obtain deduplicated image materials, including: Calculate the information summary of each image in the multiple image materials by using an image deduplication algorithm; When there are two or more images with the same information summary, the two or more images are deduplicated to obtain the deduplicated image material.
5. The method according to claim 1, characterized in that: The method further comprises: When the second detection result indicates that the image to be identified is a document file of a specified type, an alarm prompt is issued.
6. The method according to claim 1, characterized in that The deep learning model includes a NASNET model provided with a fully connected layer and a Dropout layer.
7. A document file detection device, characterized in that: The device comprises: An acquisition unit, used for acquiring an image to be recognized; A first detection unit, configured to input the image to be identified into a feature detection model of a document file of a specified type to obtain a first detection result; A second detection unit is used for inputting the image to be identified into a trained deep learning model to obtain a second detection result of the deep learning model identifying the image to be identified when the first detection result indicates that the image to be identified meets the color characteristics of the specified type of document file, wherein the second detection result includes a result indicating that the image to be identified is a document file of the specified type, or a result indicating that the image to be identified is not a document file of the specified type; The first detection unit is specifically used to: input the image to be identified into the feature detection model of the specified type of document file, and convert the image to be identified into an image of a specified size through the feature detection model of the specified type of document file; determine the ratio of the number of pixels representing a specified color to the number of pixels representing a white class in the image of the specified size through the feature detection model of the specified type of document file, wherein the specified color is the color of the header title of the document in the image to be identified; when the ratio is within a set range, determine that the image to be identified meets the color characteristics of the specified type of document file; when the ratio is not within the set range, determine that the image to be identified does not meet the color characteristics of the specified type of document file.
8. An electronic device, characterized in that: The electronic device comprises a memory and a processor coupled to each other, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the electronic device executes the document file detection method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed on a computer, the computer is enabled to execute the document file detection method according to any one of claims 1 to 6.