Image-oriented ocean bill of lading parsing method, device and equipment
By preprocessing and sample annotation of image-form sea bill of lading, the object detection model is trained, and the problem of extracting effective content under complex table structure is solved, achieving high accuracy and reliability extraction effect.
Patent Information
- Application Number
- CN202210164827.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-22
- Publication Date
- 2025-02-14
- Estimated Expiration
- 2042-02-22
AI Technical Summary
It is difficult for the prior art to effectively extract the effective content in the shipping bill of lading in the image form, especially when the table format is complex, the table line is missing, the curve table line, background watermark, and the text content is offset, the extraction is difficult and has low accuracy.
By obtaining the sea bill of lading to be parsed, image preprocessing is performed, cropping and sample labeling table information areas, forming a target detection sea bill of lading data set, and training the target detection model through this data set to perform tests to improve extraction accuracy.
It realizes efficient extraction of effective content in shipping bills of lading under complex table structure, improves the accuracy and reliability of extraction, and meets practical application needs.
Smart Images

Figure CN114724152B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of logistics information processing technology, and in particular to an image-oriented ocean bill of lading parsing method, device and terminal equipment. Background Art
[0002] In the field of international logistics, the shipping service platform provides intermediary services for import and export companies, cross-border e-commerce companies, etc., including inquiries from shipping companies, booking, customs declaration, trailers, etc. The ocean bill of lading is the final contract formed by the shipping company accepting logistics business, which records detailed logistics information, including: sender, recipient, ship number, route number, departure port, arrival port, etc. After the shipping service platform receives the bill of lading from the shipping company, it needs to check the bill of lading with the internal information of the platform.
[0003] As we all know, ocean bills of lading exist in two forms: one is an electronically generated PDF document format, from which elements such as line segments and characters can be extracted for content analysis; the other is an image file generated by screenshots or scans, and various information is only displayed visually on the image.
[0004] Various elements in the PDF format ocean bill of lading can assist the information extraction process, but the image format ocean bill of lading only contains visual information. And because ocean bills of lading generally have a table structure, the format is diverse and complex. Different shipping companies have their own bill of lading formats, and the format is very complex, including a large number of cell merges, cell dislocations, etc. Therefore, the accuracy of extracting valid content from image-based ocean bills of lading is greatly reduced, and the difficulty of extracting valid content from ocean bills of lading is greatly increased. Summary of the invention
[0005] Based on this, it is necessary to provide an image-based ocean bill of lading parsing method, device, storage medium and terminal device that can solve the problem of difficulty in extracting valid content of ocean bills of lading and low accuracy when the table format is complex, part of the table lines are missing, curved table lines, background watermarks, and text content are offset during the existing image-based ocean bill of lading parsing process.
[0006] An embodiment of the present invention provides an image-oriented ocean bill of lading parsing method, the method comprising the following steps:
[0007] Obtaining an ocean bill of lading to be parsed, and performing image preprocessing on the ocean bill of lading to obtain a preprocessed ocean bill of lading;
[0008] Cropping and labeling the table information area of the pre-processed ocean bill of lading to obtain an object detection ocean bill of lading data set;
[0009] The target detection model is trained using the ocean bill of lading dataset, and the trained target detection model is tested.
[0010] Furthermore, the method of performing image preprocessing on the ocean bill of lading to obtain the preprocessed ocean bill of lading includes:
[0011] Convert the ocean bill of lading to be parsed into an image file;
[0012] Obtaining a bill of lading in an image file, and performing direction correction on the bill of lading;
[0013] The ocean bill of lading after direction correction is subjected to grayscale processing, and the portion with a grayscale value less than a threshold is removed to obtain a preprocessed ocean bill of lading.
[0014] Furthermore, the method of cropping and labeling the table information area of the pre-processed ocean bill of lading to obtain the target detection ocean bill of lading data set includes:
[0015] Obtaining all logistics information except cargo details in the pre-processed ocean bill of lading, and cropping the table information area corresponding to the logistics information;
[0016] Determine whether the "key value-content" pair in the table information area is in the same cell;
[0017] If the "key-value-content" pair is in the same cell, it is marked with a rectangular box;
[0018] If the "key-value-content" pairs are in different cells, they are marked with rectangular boxes respectively;
[0019] The target detection ocean bill of lading data set is obtained according to the marked rectangular frame.
[0020] Furthermore, the method for training the target detection model using the ocean bill of lading dataset includes:
[0021] Dividing the target detection ocean bill of lading dataset into a training set and a test set;
[0022] The training set is input into the target detection model for training, and the hyperparameters batch_size and epochs are continuously adjusted during the training process until the model accuracy obtained by the test set test is greater than the preset value, and the model training is terminated.
[0023] Furthermore, the method further comprises:
[0024] Input the table information area image into the target detection model to obtain the bounding box prediction given by the model;
[0025] All rectangular frames are cropped according to the border prediction to form a text area picture set;
[0026] Perform OCR recognition on each text area image to obtain the text content corresponding to the text area image;
[0027] Retrieve the predefined key value in the text content corresponding to each text area image, and after finding the text area corresponding to the predefined key value, if the text area only contains the key value text and the text area is immediately below the table line, then the content text is in the adjacent text area below the text area, otherwise the content text and the key value text are in the same text area, or the content text does not exist;
[0028] Based on all the retrieved predefined key values, a data dictionary of all the predefined key values is obtained.
[0029] Another embodiment of the present invention provides an image-oriented ocean bill of lading parsing device, the device comprising:
[0030] An image processing module is used to obtain the ocean bill of lading to be parsed and perform image preprocessing on the ocean bill of lading to obtain a preprocessed ocean bill of lading;
[0031] A sample processing module, used for cropping and labeling the table information area of the pre-processed ocean bill of lading to obtain an object detection ocean bill of lading data set;
[0032] The model training module is used to train the target detection model through the ocean bill of lading data set and test the trained target detection model.
[0033] Further, the ocean bill of lading is subjected to image preprocessing to obtain a preprocessed ocean bill of lading, wherein the image processing module is specifically used to:
[0034] Convert the ocean bill of lading to be parsed into an image file;
[0035] Obtaining a bill of lading in an image file, and performing direction correction on the bill of lading;
[0036] grayscale processing is performed on the ocean bill of lading after direction correction, and a portion whose grayscale value is less than a threshold is removed to obtain a preprocessed ocean bill of lading;
[0037] Furthermore, the table information area of the pre-processed ocean bill of lading is cropped and sampled to obtain a target detection ocean bill of lading data set. The sample processing module is specifically used to:
[0038] Obtaining all logistics information except cargo details in the pre-processed ocean bill of lading, and cropping the table information area corresponding to the logistics information;
[0039] Determine whether the "key value-content" pair in the table information area is in the same cell;
[0040] If the "key-value-content" pair is in the same cell, it is marked with a rectangular box;
[0041] If the "key-value-content" pairs are in different cells, they are marked with rectangular boxes respectively;
[0042] The target detection ocean bill of lading data set is obtained according to the marked rectangular frame.
[0043] Furthermore, in training the target detection model using the ocean bill of lading dataset, the model training module is specifically used to:
[0044] Dividing the target detection ocean bill of lading dataset into a training set and a test set;
[0045] The training set is input into the target detection model for training, and the hyperparameters batch_size and epochs are continuously adjusted during the training process until the model accuracy obtained by the test set test is greater than the preset value, and the model training is terminated.
[0046] Another embodiment of the present invention further provides a computer-readable storage medium, which includes a stored computer program; wherein, when the computer program is running, it controls the device where the computer-readable storage medium is located to execute the image-oriented ocean bill of lading parsing method as described above.
[0047] Another embodiment of the present invention further proposes a terminal device, comprising a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor implements the image-oriented ocean bill of lading parsing method as described above when executing the computer program.
[0048] The above-mentioned image-based ocean bill of lading parsing method obtains the ocean bill of lading to be parsed, and performs image preprocessing on the ocean bill of lading to obtain a preprocessed ocean bill of lading; the table information area of the preprocessed ocean bill of lading is cropped and sample labeled to obtain a target detection ocean bill of lading data set; the target detection model is trained through the ocean bill of lading data set, and the trained target detection model is tested. Compared with the prior art, the present invention can solve the problems of difficulty and low accuracy in extracting valid content of ocean bills of lading when the table format is complex, part of the table line is missing, curved table lines, background watermarks, and text content are offset in the existing image-based ocean bill of lading parsing process, and meets the actual application needs. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] Figure 1A schematic diagram of a flow chart of an image-oriented ocean bill of lading parsing method provided by an embodiment of the present invention;
[0050] Figure 2 A diagram showing the effect of sample annotation in the image-oriented ocean bill of lading parsing method provided by an embodiment of the present invention;
[0051] Figure 3 A structural block diagram of an image-oriented ocean bill of lading parsing device provided by an embodiment of the present invention;
[0052] Figure 4 A structural diagram of a device terminal provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0053] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this technical field without creative work are within the scope of protection of the present invention.
[0054] It should be noted that the step numbers in the text are only for the convenience of explaining the specific embodiment and do not limit the order of execution of the steps. The method provided in this embodiment can be executed by a related server, and the following description will be given by taking the server as the execution subject as an example.
[0055] like Figure 1 to Figure 2 As shown, the image-oriented ocean bill of lading parsing method provided by the embodiment of the present invention is applied to an ocean bill of lading parsing system, and the method includes steps S11 to S13:
[0056] Step S11, obtaining the ocean bill of lading to be analyzed, and performing image preprocessing on the ocean bill of lading to obtain a preprocessed ocean bill of lading.
[0057] Specifically, the ocean bill of lading to be parsed is converted into an image file; the ocean bill of lading in the image file is obtained, and the direction of the ocean bill of lading is corrected; the ocean bill of lading after the direction correction is gray-scaled, and the part with a gray-scale value less than a threshold is removed to obtain a pre-processed ocean bill of lading.
[0058] Furthermore, ocean bills of lading are converted from electronic PDF files to image files in various ways. During the conversion process (such as scanning), the content of a single page may be rotated, causing the text line to be tilted, which makes subsequent OCR recognition difficult. Therefore, the image is first oriented. The correction method is to identify the horizontal line in the image, calculate the angle between this line and the horizontal line, and rotate the entire image inversely by this angle to achieve horizontal correction of the text content. Then the image is converted into a grayscale image, and the watermark part with a grayscale value below a certain threshold is removed to complete the image preprocessing.
[0059] Step S12, cropping and labeling the table information area of the pre-processed ocean bill of lading to obtain an object detection ocean bill of lading data set.
[0060] Specifically, all logistics information except cargo details in the pre-processed ocean bill of lading is obtained, and the table information area corresponding to the logistics information is cropped; it is determined whether the "key-value-content" pairs in the table information area are in the same cell; if the "key-value-content" pairs are in the same cell, they are marked with a rectangular box; if the "key-value-content" pairs are in different cells, they are marked with rectangular boxes respectively; and the target detection ocean bill of lading data set is obtained according to the marked rectangular boxes.
[0061] Furthermore, the table information area includes all logistics service information except the product details, such as consignee and consignor, departure port, arrival port, freight method, etc. The table information area is located in the upper half of the first page of the bill of lading. By cropping out the table information area, the interference of redundant information on the target detection model can be reduced.
[0062] Furthermore, the sample annotations are visualized and annotated using the open source software labelme; the specific annotation method is as follows:
[0063] If the key-value-content pair is in the same cell (the key-value-content pair is key, value or key-value pair, for example, the sender SHIPPER is the key value and the specific address is the content), it is marked with a rectangular box, such as Figure 2 As shown in the upper left, upper right and lower left sub-figures;
[0064] If the key-value-content pairs are in different cells (usually adjacent cells), they are marked with rectangular boxes respectively, such as Figure 2 As shown in the lower right sub-figure;
[0065] During the marking process, the rectangular frame cannot touch any table lines.
[0066] In this embodiment, the present invention annotates one thousand image samples, covering 45 ocean bill of lading formats of 32 shipping companies, to form an ocean bill of lading dataset for target detection. Each rectangular box is a "key value" or "content" or "key value-content" pair, that is, an object to be detected.
[0067] Step S13, training the target detection model using the ocean bill of lading dataset, and testing the trained target detection model.
[0068] Specifically, the target detection ocean bill of lading dataset is divided into a training set and a test set; the training set is input into the target detection model for training, and the hyperparameters such as batch_size and epochs are continuously adjusted during the training process until the model accuracy obtained by the test set test is greater than the preset value, and the model training is terminated.
[0069] Furthermore, all samples are randomly divided into a training set and a test set, and the ratio of the number of samples in the two sets is 8:2; the present invention adopts the open source target detection model yolov5 (other target detection models such as RetinaNet, Faster R-CNN, etc. can also be applied here), and is trained on NVIDIA GPU; by adjusting hyperparameters such as batch_size and epochs until the model accuracy obtained by the test set test is greater than 95%, the model training is terminated.
[0070] It should also be noted that the method further comprises:
[0071] Input the table information area picture into the target detection model to obtain the border prediction given by the model; cut out all the rectangular frames according to the border prediction to form a text area picture set; perform OCR recognition on each text area picture respectively to obtain the text content corresponding to the text area picture; retrieve the predefined key value (such as SHIPPER) in the text content corresponding to each text area picture, and after finding the text area corresponding to the predefined key value (such as SHIPPER), if the text area only contains the key value text and the text area is adjacent to the table line, then the content text is in the adjacent text area below the text area, otherwise the content text and the key value text are in the same text area, or the content text does not exist; according to all the retrieved predefined key values, obtain a data dictionary of all predefined key values.
[0072] The present invention directly detects the "key value-content" pair without touching the table line through the target detection model. If the "key value" and "content" are separated by the table line, they are detected separately. This method is closer to human vision and reading habits. It first looks for the "key value" and then looks for the content around the "key value". It does not care about the overall table structure, but pays more attention to the micro-layout format of the "key value-content" pair. It solves the problem that the table form is complex and the table structure is difficult to reproduce. The target detection method of the "key value-content" pair also weakens the dependence of the processing flow on the table line, and solves the problems of missing, half-missing, curved table lines, etc.
[0073] The above-mentioned image-based ocean bill of lading parsing method obtains the ocean bill of lading to be parsed, and performs image preprocessing on the ocean bill of lading to obtain a preprocessed ocean bill of lading; the table information area of the preprocessed ocean bill of lading is cropped and sample labeled to obtain a target detection ocean bill of lading data set; the target detection model is trained through the ocean bill of lading data set, and the trained target detection model is tested. Compared with the prior art, the present invention can solve the problems of difficulty and low accuracy in extracting valid content of ocean bills of lading when the table format is complex, part of the table line is missing, curved table lines, background watermarks, and text content are offset in the existing image-based ocean bill of lading parsing process, and meets the actual application needs.
[0074] It should be understood that, although the various steps in the above-mentioned flow chart are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the above-mentioned flow chart may include a plurality of sub-steps or a plurality of stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these sub-steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.
[0075] See also Figure 3 The present invention also provides an image-oriented ocean bill of lading parsing device, the device comprising:
[0076] The image processing module 21 is used to obtain the ocean bill of lading to be analyzed, and perform image preprocessing on the ocean bill of lading to obtain a preprocessed ocean bill of lading.
[0077] Specifically, the ocean bill of lading to be parsed is converted into an image file; the ocean bill of lading in the image file is obtained, and the direction of the ocean bill of lading is corrected; the ocean bill of lading after the direction correction is gray-scaled, and the part with a gray-scale value less than a threshold is removed to obtain a pre-processed ocean bill of lading.
[0078] Furthermore, ocean bills of lading are converted from electronic PDF files to image files in various ways. During the conversion process (such as scanning), the content of a single page may be rotated, causing the text line to be tilted, which makes subsequent OCR recognition difficult. Therefore, the image is first oriented. The correction method is to identify the horizontal line in the image, calculate the angle between this line and the horizontal line, and rotate the entire image inversely by this angle to achieve horizontal correction of the text content. Then the image is converted into a grayscale image, and the watermark part with a grayscale value below a certain threshold is removed to complete the image preprocessing.
[0079] The sample processing module 22 is used to crop and mark samples of the table information area of the pre-processed ocean bill of lading to obtain a target detection ocean bill of lading data set.
[0080] Specifically, all logistics information except cargo details in the pre-processed ocean bill of lading is obtained, and the table information area corresponding to the logistics information is cropped; it is determined whether the "key value-content" pair in the table information area is in the same cell; if the "key value-content" pair is in the same cell, it is marked with a rectangular frame; if the "key value" and "content" are in different cells, they are marked with rectangular frames respectively; the target detection ocean bill of lading data set is obtained according to the marked rectangular frames.
[0081] Furthermore, the table information area includes all logistics service information except the product details, such as consignee and consignor, departure port, arrival port, freight method, etc. The table information area is located in the upper half of the first page of the bill of lading. By cutting out the table information area, the interference of redundant information on the target detection model can be reduced.
[0082] Furthermore, the sample annotations are visualized and annotated using the open source software labelme; the specific annotation method is as follows:
[0083] If the key-value-content pair is in the same cell (the key-value-content pair is key, value or key-valuepair, the sender SHIPPER is the "key value" and the specific address is the "content"), it is marked with a rectangular box, such as Figure 2 As shown in the upper left, upper right and lower left sub-figures;
[0084] If the key-value-content pairs are in different cells (usually adjacent cells), they are marked with rectangular boxes respectively, such as Figure 2 As shown in the lower right sub-figure;
[0085] During the sample annotation process, the rectangular frame cannot touch any table lines.
[0086] In this embodiment, the present invention annotates one thousand image samples, covering 45 ocean bill of lading formats of 32 shipping companies, to form an ocean bill of lading dataset for target detection. Each rectangular box is a "key value" or "content" or "key value-content" pair, that is, an object to be detected.
[0087] The model training module 23 is used to train the target detection model using the ocean bill of lading data set and test the trained target detection model.
[0088] Specifically, the target detection ocean bill of lading dataset is divided into a training set and a test set; the training set is input into the target detection model for training, and the hyperparameters such as batch_size and epochs are continuously adjusted during the training process until the model accuracy obtained by the test set test is greater than the preset value, and the model training is terminated.
[0089] Furthermore, all samples are randomly divided into a training set and a test set, and the ratio of the number of samples in the two sets is 8:2; the present invention adopts the open source target detection model yolov5 (other target detection models such as RetinaNet, Faster R-CNN, etc. can also be applied here), and is trained on NVIDIA GPU; by adjusting hyperparameters such as batch_size and epochs until the model accuracy obtained by the test set test is greater than 95%, the model training is terminated.
[0090] It should also be noted that the ocean bill of lading parsing device is also used for:
[0091] Input the table information area picture into the target detection model to obtain the border prediction given by the model; cut out all the rectangular frames according to the border prediction to form a text area picture set; perform OCR recognition on each text area picture respectively to obtain the text content corresponding to the text area picture; retrieve the predefined key value (such as SHIPPER) in the text content corresponding to each text area picture, and after finding the text area corresponding to the predefined key value (such as SHIPPER), if the text area only contains the key value text and the text area is adjacent to the table line, then the content text is in the adjacent text area below the text area, otherwise the content text and the key value text are in the same text area, or the content text does not exist; according to all the retrieved predefined key values, obtain a data dictionary of all predefined key values.
[0092] The present invention directly detects the "key value-content" pair without touching the table line through the target detection model. If the "key value-content" is separated by the table line, it is detected separately. This method is closer to human vision and reading habits. It first looks for the "key value" and then looks for the content around the "key value". It does not care about the overall table structure, but pays more attention to the micro-layout format of the "key value-content" pair. It solves the problem that the table form is complex and the table structure is difficult to reproduce. The target detection method of the "key value-content" pair also weakens the dependence of the processing flow on the table line, and solves the problems of missing, half-missing, curved table lines, etc.
[0093] The image-based ocean bill of lading parsing device provided in the embodiment of the present invention obtains an ocean bill of lading to be parsed, and performs image preprocessing on the ocean bill of lading to obtain a preprocessed ocean bill of lading; crops and samples the table information area of the preprocessed ocean bill of lading to obtain a target detection ocean bill of lading data set; trains a target detection model through the ocean bill of lading data set, and tests the trained target detection model. Compared with the prior art, the present invention can solve the problems of difficulty and low accuracy in extracting valid content of ocean bills of lading in the existing image-based ocean bill of lading parsing process when faced with complex table formats, missing table lines, curved table lines, background watermarks, and text content offset, and meets actual application needs.
[0094] An embodiment of the present invention further provides a computer-readable storage medium, which includes a stored computer program; wherein, when the computer program is running, it controls the device where the computer-readable storage medium is located to execute the image-oriented ocean bill of lading parsing method as described above.
[0095] The embodiment of the present invention also provides a terminal device, see Figure 4 As shown, it is a structural block diagram of a preferred embodiment of a terminal device provided by the present invention, wherein the terminal device comprises a processor 10, a memory 20, and a computer program stored in the memory 20 and configured to be executed by the processor 10, and the processor 10 implements the image-oriented ocean bill of lading parsing method as described above when executing the computer program.
[0096] Preferably, the computer program can be divided into one or more modules / units (such as computer program 1, computer program 2, ...), and the one or more modules / units are stored in the memory 20 and executed by the processor 10 to complete the present invention. The one or more modules / units can be a series of computer program instruction segments that can complete specific functions, and the instruction segments are used to describe the execution process of the computer program in the terminal device.
[0097] The processor 10 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor, or the processor 10 may be any conventional processor. The processor 10 is the control center of the terminal device, and various parts of the terminal device are connected using various interfaces and lines.
[0098] The memory 20 mainly includes a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function, etc., and the data storage area can store related data, etc. In addition, the memory 20 can be a high-speed random access memory, or a non-volatile memory, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, and a flash card (Flash Card), etc., or the memory 20 can also be other volatile solid-state storage devices.
[0099] It should be noted that the above terminal device may include, but is not limited to, a processor and a memory. Those skilled in the art will understand that Figure 4 The structural block diagram is merely an example of a terminal device and does not constitute a limitation on the terminal device. The terminal device may include more or fewer components than shown in the figure, or a combination of certain components, or different components.
[0100] In summary, the image-based ocean bill of lading parsing method, device, storage medium and terminal device provided by the present invention first obtain the ocean bill of lading to be parsed, and perform image preprocessing on the ocean bill of lading to obtain a preprocessed ocean bill of lading; crop and sample annotate the table information area of the preprocessed ocean bill of lading to obtain a target detection ocean bill of lading data set; train the target detection model through the ocean bill of lading data set, and test the trained target detection model. Compared with the prior art, the present invention can solve the problems of difficulty and low accuracy in extracting valid content of ocean bills of lading in the existing image-based ocean bill of lading parsing process when faced with complex table formats, missing table lines, curved table lines, background watermarks, and text content offset, and meets the actual application needs.
[0101] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the technical principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A method for parsing ocean bills of lading in image form, characterized in that: The method comprises the following steps: Obtaining an ocean bill of lading to be parsed, and performing image preprocessing on the ocean bill of lading to obtain a preprocessed ocean bill of lading; Cropping and labeling the table information area of the pre-processed ocean bill of lading to obtain an object detection ocean bill of lading data set; The target detection model is trained by using the target detection ocean bill of lading dataset, and the trained target detection model is tested; The process of cropping and labeling the table information area of the pre-processed ocean bill of lading to obtain the target detection ocean bill of lading dataset includes the following steps: Obtaining all logistics information except cargo details in the pre-processed ocean bill of lading, and cropping the table information area corresponding to the logistics information; Determine whether the key-value-content pairs in the table information area are in the same cell; If the key-value-content pair is in the same cell, it is marked with a rectangular box; If the key-value-content pairs are in different cells, they are marked with rectangular boxes respectively; The target detection ocean bill of lading data set is obtained according to the marked rectangular frame; the rectangular frame does not touch any table line; The method further comprises: Input the table information area image into the target detection model to obtain the bounding box prediction given by the model; All rectangular frames are cropped according to the border prediction to form a text area picture set; Perform OCR recognition on each text area image to obtain the text content corresponding to the text area image; Retrieve the predefined key value in the text content corresponding to each text area image, and after finding the text area corresponding to the predefined key value, if the text area only contains the key value text and the text area is immediately below the table line, then the content text is in the adjacent text area below the text area, otherwise the content text and the key value text are in the same text area, or the content text does not exist; Based on all the retrieved predefined key values, a data dictionary of all the predefined key values is obtained.
2. The image-oriented ocean bill of lading analysis method according to claim 1, characterized in that: Performing image preprocessing on the ocean bill of lading to obtain a preprocessed ocean bill of lading includes the following steps: Convert the ocean bill of lading to be parsed into an image file; Obtaining a bill of lading in an image file, and performing direction correction on the bill of lading; The ocean bill of lading after direction correction is subjected to grayscale processing, and the portion with a grayscale value less than a threshold is removed to obtain a preprocessed ocean bill of lading.
3. The image-oriented ocean bill of lading analysis method according to claim 1, characterized in that: Training the target detection model using the target detection ocean bill of lading dataset and testing the trained target detection model includes the following steps: Dividing the target detection ocean bill of lading dataset into a training set and a test set; The training set is input into the target detection model for training, and the hyperparameters batch_size and epochs are continuously adjusted during the training process until the model accuracy obtained by the test set test is greater than the preset value, and the model training is terminated.
4. A device for analyzing ocean bills of lading in image form, characterized in that: The device comprises: An image processing module is used to obtain the ocean bill of lading to be parsed and perform image preprocessing on the ocean bill of lading to obtain a preprocessed ocean bill of lading; A sample processing module, used for cropping and labeling the table information area of the pre-processed ocean bill of lading to obtain an object detection ocean bill of lading data set; A model training module, used to train a target detection model using the target detection ocean bill of lading dataset, and to test the trained target detection model; Among them, the sample processing module is specifically used to: Obtaining all logistics information except cargo details in the pre-processed ocean bill of lading, and cropping the table information area corresponding to the logistics information; Determine whether the key-value-content pairs in the table information area are in the same cell; If the key-value-content pair is in the same cell, it is marked with a rectangular box; If the key-value-content pairs are in different cells, they are marked with rectangular boxes respectively; The target detection ocean bill of lading data set is obtained according to the marked rectangular frame; the rectangular frame does not touch any table line; The device is also used for: Input the table information area image into the target detection model to obtain the bounding box prediction given by the model; All rectangular frames are cropped according to the border prediction to form a text area picture set; Perform OCR recognition on each text area image to obtain the text content corresponding to the text area image; Retrieve the predefined key value in the text content corresponding to each text area image, and after finding the text area corresponding to the predefined key value, if the text area only contains the key value text and the text area is immediately below the table line, then the content text is in the adjacent text area below the text area, otherwise the content text and the key value text are in the same text area, or the content text does not exist; Based on all the retrieved predefined key values, a data dictionary of all the predefined key values is obtained.
5. The image-oriented ocean bill of lading parsing device according to claim 4, characterized in that: The image processing module is specifically used for: Convert the ocean bill of lading to be parsed into an image file; Obtaining a bill of lading in an image file, and performing direction correction on the bill of lading; The ocean bill of lading after direction correction is subjected to grayscale processing, and the portion with a grayscale value less than a threshold is removed to obtain a preprocessed ocean bill of lading.
6. The image-oriented ocean bill of lading parsing device according to claim 4, characterized in that: The model training module is specifically used to: Dividing the target detection ocean bill of lading dataset into a training set and a test set; The training set is input into the target detection model for training, and the hyperparameters batch_size and epochs are continuously adjusted during the training process until the model accuracy obtained by the test set test is greater than the preset value, and the model training is terminated.
7. A terminal device, characterized in that: The invention comprises a processor, a memory and a computer program stored in the memory and configured to be executed by the processor, wherein the processor implements the image-oriented ocean bill of lading parsing method according to any one of claims 1 to 3 when executing the computer program.
Citation Information
Patent Citations
Multi-stage data generation self-circulation financial invoice text intelligent identification system and method
CN111079562A
Data labeling method and device, electronic equipment and computer readable storage medium
CN113407745A
Method and equipment for realizing full-text retrieval of character picture and image type scanning copy
CN113806472A