Patent Description:
A number of engineering fields utilize functional drawings. In contrast to a physical models that represent the specific location, size and shape of elements, a functional drawing is independent of location, size and shape, focusing instead on process flow. In the field of plant and infrastructure design and maintenance, a common type of functional drawing is a P&ID. <FIG> is a view of a portion of an example P&ID <NUM>. The P&ID includes symbols <NUM> which represent elements (e.g., valves, pumps, vessels, instruments, etc.), text boxes <NUM> which provide descriptions of the elements (e.g., names, codes, properties, etc.), connections <NUM> that represent connections between elements (e.g., pipes, electrical wires, etc.), as well as other information (e.g., title blocks, legends, notes, etc.) (not shown).

A typical plant or infrastructure project may have hundreds of related P&IDs that have been created over the course of many years. These P&IDs often may be available in an image-only format (e.g., as a graphics file such as a JPG or PNG, or as an image-only PDF, etc.) that lacks machine-readable information (e.g., metadata) about the symbols, text boxes and connections represented therein. Sometimes the image-only P&ID originated from a scan of a printed document and is of poor quality, having low resolution, visual artifacts, obscured or blurry portions and the like.

In an image-only format, information in a P&ID is hard to validate and difficult to consume. There is an increasing desire to create digital twins of plants and infrastructure, and the information in P&IDs is often useful in creating such models. However, as the information in an image-only format is largely inaccessible to design and modeling applications, obtaining such information has often involved lengthy manual review and data entry. Even updating a P&ID itself is difficult with an image-only format.

One possible approach to address the problem of P&IDs in image-only formats is to manually recreate each P&ID in a design application. A human operator looks at an image-only P&ID and manually recreates every text box, symbol, connection, etc. he or she sees using the tools provided by the design application. The result is a new P&ID that includes machine-readable information describing the text boxes, symbols and connections, etc. Manual recreation can take hours, or tens of hours, depending on the complexity of the P&ID, rendering it impractical in many use cases. Further, manual recreation is inherently error prone due to its detailed yet repetitive nature. Significant additional time and effort may be needed to check and validate manually recreated P&IDs to ensure an acceptable level of accuracy.

Another possible approach to address the problem of P&IDs in image-only formats is to attempt to use a pattern recognition algorithm to determine information in each P&ID. The pattern recognition algorithm may search the P&ID for exact (pixel-by-pixel identical) copies of a set of cropped images from an image library. Upon finding an exact copy, information associated with the cropped image in the image library may be associated with the exact copy. While theoretically such an approach may build a set of machine-readable information for a P&ID in an image-only format, in practice the approach is largely unworkable. To operate successfully the pattern recognition algorithm requires a library of cropped images that are identical to everything in the P&ID. Since P&IDs often contain variations in how text boxes, symbols, connections, etc. are represented, in practice a new image library may need to be custom created for every, or nearly every, P&ID. Further, pattern recognition algorithms may be easily confused when a P&ID has low resolution, includes visual artifacts, has obscured or blurry portions or is otherwise of low quality. In such cases, images that ideally should identically match may not actually identically match, which may lead to missed identifications.

Accordingly, there is a need for improved techniques for extracting machine-readable information from P&IDs in image-only formats.

<NPL> describes symbol spotting on real-world digital architectural floor plans with a deep learning (DL)based framework. Traditional on-the-fly symbol spotting methods are unable to address the semantic challenge of graphical notation variability, i.e. low intra-class symbol similarity, an issue that is particularly important in architectural floor plan analysis. The presence of occlusion and clutter, characteristic of real-world plans, along with a varying graphical symbol complexity from almost trivial to highly complex, also pose challenges to existing spotting methods. They further describe leveraging recent advances in DL and adapting an object detection framework based on the You-Only-Look-Once (YOLO) architecture using a training strategy based on tiles, avoiding many issues particular to DL-based object detection networks related to the relative small size of symbols compared to entire floor plans, aspect ratios, and data augmentation. Experiments on real-world floor plans demonstrate that our method successfully detects architectural symbols with low intra-class similarity and of variable graphical complexity, even in the presence of heavy occlusion and clutter. Additional experiments on the public SESYD dataset confirm that our proposed approach can deal with various degradation and noise levels and outperforms other symbol spotting methods.

<NPL> describe evaluation the Faster R-CNN object detection algorithm as a general method for detection of symbols in handwritten graphics.

<NPL> describe a pipeline for automatically digitizing P&IDs. The pipeline combines a series of computer vision techniques to detect symbols in a diagram, match symbols with associated text, and detect connections between symbols through lines. For the symbol detection task, Convolutional Neural Network is trained to classify certain common symbols with over <NUM>% precision and recall. To detect connections between symbols, a graph search approach is used to traverse a diagram through its lines and discover interconnected symbols.

In various embodiments, techniques are provided for using machine learning to extract machine-readable labels for text boxes and symbols in P&IDs in image-only formats (e.g. JPG, PNG, image-only PDF, etc.). The information in each label is predicted with a respective confidence level. Machine learning algorithms are adapted and extended to address challenges presented by P&IDs.

According to a first aspect of the invention, there is provided a method for extracting machine-readable labels for text boxes and symbols in piping and instrumentation drawings, (P&IDs,) in image-only formats. The method comprises predicting, by an optical character recognition, (OCR,) algorithm of a P&ID data extraction application executing on a computing device, bounding boxes and text within text boxes in a P&ID in an image-only format, wherein the predicted text within text boxes are labels for the text boxes. The method comprises detecting, by a first machine learning algorithm of the P&ID data extraction application that is based on a Faster Region-based Convolutional Neural Network, R-CNN, architecture, symbols in the P&ID, the detecting to return a predicted bounding box and predicted class of equipment for each symbol. The method comprises decimating one or more of the predicted bounding boxes to avoid overlapping detections using a non-maximum suppression algorithm. The method comprises inferring, by a second machine learning algorithm of the P&ID data extraction application that is based on a different deep neural network architecture adapted for properties classification, a number of properties for each detected symbol having a remaining predicted bounding box, wherein the number of properties depends on the predicted class of equipment and each property has a number of property values. The method comprises storing, in a machine-readable format in a memory of the computing device device for each text box, the bounding box and label for the text box, and, for each detected symbol having a remaining predicted bounding box, the predicted bounding box and label including the predicted class of equipment and inferred properties, and displaying the predicted bounding boxes and labels for the text boxes and the symbols in a user interface. It should be understood that a variety of additional features and alternative embodiments may be implemented other than those discussed in this Summary. This Summary is intended simply as a brief introduction to the reader for the further description that follows and does not indicate or imply that the examples mentioned herein cover all aspects of the disclosure or are necessary or essential aspects of the disclosure.

The description refers to the accompanying drawings of example embodiments, of which:.

<FIG> is a high-level block diagram of an example P&ID data extraction application. The P&ID data extraction application <NUM> may be a stand-alone software application or a component of a larger software application, for example, a design and modeling software application. The software may be divided into local software <NUM> that executes on one or more computing devices local to an end-user (collectively "local devices") and, in some cases, cloud-based software <NUM> that is executed on one or more computing devices remote from the end-user (collectively "cloud computing devices") accessible via a network (e.g., the Internet). Each computing device may include processors, memory/storage, a display screen, and other hardware (not shown) for executing software, storing data and/or displaying information. The local software <NUM> may include a frontend client <NUM> and one or more backend clients <NUM> operating on a local device. The cloud-based software <NUM> may include, in some cases, one or more backend clients <NUM> operating on cloud computing devices. The frontend client <NUM> may provide user interface functionality as well as perform certain non-processing intensive operations. The backend client(s) <NUM> may perform certain more processing intensive operations (e.g., OCR operations, machine learning operations, etc.). The front-end client <NUM> and backend client(s) <NUM> may operate concurrently on different tasks, such that a user may utilize the user interface of the P&ID data extraction application <NUM> to perform tasks while one or more backend clients <NUM> are performing different tasks, and without waiting for their completion.

<FIG> is a high level sequence of steps <NUM> for extracting machine-readable labels for text boxes and symbols in P&IDs in image-only formats. At step <NUM>, the P&ID data extraction application <NUM> loads a P&ID in image-only format (e.g. JPG, PNG, image-only PDF, etc.) that lacks machine-readable information about the text boxes, symbols and connections. In some cases the P&ID originated from a scan of a printed document.

At step <NUM>, the P&ID data extraction application <NUM> preprocess the P&ID to rasterize, resize and/or binarize the P&ID. Rasterization may involve decompression, conversion, and/or extraction operations to produce a rasterized P&ID. Resizing may involve changing resolution (e.g., dots-per-inch (DPI)) to a resolution more easily processed (e.g., by an OCR algorithm, machine learning algorithm, etc.). Binarization may involve using an adaptive threshold to reduce color or grayscale information in the P&ID to black and white (i.e. binary information). As a further part of step <NUM>, the P&ID data extraction application <NUM> may also apply noise reduction and image geometry correction. Noise reduction may involve applying filters to remove noise from the P&ID (e.g., which may have been introduced by scanning a paper document) without sacrificing an undue amount or real detail. Image geometry correction may involve correcting shear, rotation, or other types of deformations (e.g., which may have been introduced by scanning a paper document).

At step <NUM>, which may be optional, the P&ID data extraction application <NUM> may display the preprocessed P&ID within a window of its user interface while machine-readable labels are being extracted in subsequent steps. <FIG> is a view of a portion of an example preprocessed P&ID <NUM> that may be displayed in the user interface of the P&ID data extraction application <NUM>. At this stage text boxes and symbols are not readily extracted from the underlying image.

At step <NUM>, the P&ID data extraction application <NUM> employs an OCR algorithm to predict bounding boxes that surround, and text within, each text box in the P&ID. The OCR algorithm may be implemented by an OCR architecture (e.g., FormRecognizer of Microsoft Azure Cognitive Services) adapted to P&ID characteristics. In general, the operation of OCR algorithms may be divided into three primary stages: a physical layout analysis stage, a text recognition stage, and a language modeling stage. In the physical layout stage the OCR algorithm divides the image into non-text regions and text lines and places bounding boxes around the text lines. In the text recognition stage the OCR algorithm recognizes text contained within each text line, and represents possible recognition alternatives as a hypothesis graph. Recognition may involve segmenting each text line into individual characters, extracting features from individual character images and classifying the individual character images based on the extracted features. In the language modeling stage the OCR algorithm may select among the recognition alternatives based on knowledge about language, vocabulary and grammar.

The language modeling stage may use statistical language models, such as dictionaries, n-gram patterns, stochastic grammars and the like. The language modeling stage may be adapted to P&ID characteristics. First, rather than use a general dictionary, a domain-specific dictionary may be used to bias predictions towards words and codes expected in P&IDs. The domain-specific dictionary may be an industry-wide dictionary based on general knowledge of words and codes used in P&IDs of a given industry, or may be a user-specific dictionary based on a particular list of words and codes used by the user in their P&IDs. Second, domain-specific patterns of n-grams may be used to prevent bias against words and codes expected in P&IDs, but uncommon in general text (e.g., the numeral "<NUM>" together with letters, which may commonly be misinterpreted as the letter "O" given patterns of general text, the numeral "<NUM>" together with letters, which may commonly be misinterpreted as the letter "<NUM>" given patterns in general text, etc.). Domain-specific patterns of n-grams may be custom coded or extracted from P&IDs that have been successfully processed and validated.

At step <NUM>, the P&ID data extraction application <NUM> employs a machine learning algorithm to detect symbols in the P&ID and produce a set of a predicted bounding boxes and predicted classes of equipment. The machine learning algorithm may involve a region-based convolutional neural network object detection architecture (e.g., the Faster Region-based Convolutional Neural Network (R-CNN) architecture) that is adapted to handle P&ID characteristics. An object detection framework (e.g., the Dectectron2 framework) may implement the architecture.

<FIG> is a diagram <NUM> of an example region-based convolutional neural network object detection architecture (e.g., a Faster R-CNN architecture) <NUM> that may be adapted to handle P&ID characteristics. In general, the architecture takes the preprocessed P&ID as an input image <NUM> and produces a set of predicted bounding box, predicted classes and confidences as an output <NUM>. The architecture <NUM> includes three primary portions: a feature pyramid network <NUM>, a region proposal network (RPN) <NUM> and a box head <NUM>. The feature pyramid network <NUM> extracts feature maps from the input image at different scales. The RPN <NUM> detects object regions from the multi-scaled feature maps. The box head <NUM> crops regions of feature maps using proposal boxes into multiple fixed-size features, obtains bounding box locations and classification results and filters these to produce a final output of bounding boxes and classes.

More specifically, the input image <NUM> is set to a predetermined image dimensions. In general applications the smallest image dimension may be set to <NUM> to <NUM> pixels. In order to have adequate resolution to "see" all symbols in a P&ID, the smallest image dimension may be increased to a larger value (e.g., <NUM> pixels).

The feature pyramid network <NUM> includes a residual neural network (Resnet) having a stem block and stages that each contain multiple bottleneck blocks. Each bottleneck block includes multiple convolution layers. The layers may also include an input layer and an output layer. Every layer may include a predetermined number of filters. To better handle P&ID characteristics, the number of filters in the input layer may be increased and the number of filters in each output layer may be decreased from that used in general applications. The bottleneck blocks and their layers generally operate to connect high-to-low resolution convolutions in series. To better detect both very large objects (e.g., that may occupy <NUM>-<NUM>% of the total P&ID) and very small ones (e.g., that occupy only a few pixels), the number of resolutions may be expanded (e.g., adding at least one resolution above and at least one resolution below) beyond the range of resolutions used in general applications.

The output of the feature pyramid network <NUM> is a set of multi-scale feature maps with different receptive fields which are received by the RPN <NUM>. The RPN <NUM> includes a RPN head that processes the feature maps to produce an objectness map and anchor deltas map. Eventually, up to a predetermined number of proposal bounding boxes are chosen. Typically this is done by applying proposed anchor deltas to the corresponding anchors, sorting proposed bounding boxes by objectness scores, and selecting the top scored boxes from each feature level. In general applications, the predetermined number for proposal bounding boxes is generally <NUM>. To better handle P&IDs that may have hundreds of symbols, the number may be increased (e.g., to <NUM>).

The set of multi-scale feature maps from the feature pyramid network <NUM> and the proposal bounding boxes from the RPN <NUM> are received by the box head <NUM>. A region of interest (ROI) pooling process crops (pools) regions of feature maps that are specified by the proposal bounding boxes into multiple fixed-size features. Then the cropped regions are fed to a head network having layers which classify objects in the regions and fine tune bounding box positions and shapes. Up to a predetermined number of predicted bounding boxes and predicted classes are inferred, and confidences determined. In general applications the predetermined number for predicted bounding boxes is generally <NUM>. To better handle P&IDs that may have hundreds of symbols, the number may be increased (e.g., to <NUM>).

Returning to <FIG>, at step <NUM>, the P&ID data extraction application <NUM> employs a modified non maximum suppression algorithm to decimate any predicted bounding boxes that are determined to improperly overlap. The non-maximum suppression algorithm may be optimized to better handle P&IDs. <FIG> is a flow diagram of an example sequence of steps for a modified non-maximum suppression algorithm. The modified non-maximum suppression algorithm takes as input a set of predicted bounding boxes, associated classes and confidences. At step <NUM>, the algorithm weights the confidences of each bound box based on a measure of importance of the associated class and their location. The measure of importance may be predefined based on typical patterns in P&IDs in an industry or P&IDs of a specific user. At step <NUM>, the modified non maximum suppression algorithm finds the bounding box with the highest weighted confidence in the set of predicted bounding boxes, removes it from that set, and places it in an output set. At step <NUM>, the modified non maximum suppression algorithm computes a dynamic overlap of other bounding boxes of the set of predicted bounding boxes and the bounding box with the highest weighted confidence. In contrast to a traditional overlap calculation, dynamic overlap considers the shape of the symbol enclosed within each bounding box (e.g., a round symbol within a rectangular bounding box) and adjusts calculated overlap based on the shapes. Such adjustment may be based on a calculation of the actual overlap given the shape of each bounding box or on various rules of thumb or approximations of overlap given the shapes. At step <NUM>, the modified non maximum suppression algorithm deletes all bounding boxes from the set of predicted bounding boxes with a calculated overlap greater than a predetermined threshold, provided that such predicted bounding boxes are not associated with a symbol having a class that is designated as a container (i.e. a symbol whose class indicates it is intended to include other symbols). At step <NUM>, the modified non maximum suppression algorithm determines whether there are any remaining bounding boxes in the set of predicted bounding boxes (i.e. that have not been placed in the output set or deleted). If so, execution loops to step <NUM>. If not, at step <NUM>, the output set is returned and decimation of improperly overlapping bounding boxes is complete.

At step <NUM>, the P&ID data extraction application <NUM> employs a machine learning algorithm to infer properties for each symbol having a predicted bounding box that remains after improperly overlapping bounding boxes have been decimated. The machine learning algorithm may be based on a deep neural network architecture adapted for properties classification implemented by a framework (e.g., the PyTorch framework). The framework may enable features such as n-dimensional tensor computation with acceleration and automatic differentiation. <FIG> is a diagram <NUM> illustrating use of a deep neural network architecture adapted for properties classification. The deep neural network architecture receives a portion of the P&ID detected as a symbol by step <NUM> as an input image <NUM>. The input image is applied to a dense convolutional neural network (e.g., a DenseNet Backbone) <NUM>. Whereas convolutional networks typically have one connection between each layer and its subsequent layer, each layer of the dense convolutional neural network may receive feature maps of all preceding layers as inputs, and provide its own feature maps as inputs of all subsequent layers. The outputs of the dense convolutional neural network <NUM> are provided to a common decoding layer <NUM>, which may be a fully-connected layer. The common decoding layer <NUM> produces output modules <NUM> that include a variable number of properties depending on the class, and for each property a variable number of possible values and a confidence in each possible value. For example, for the class "valve" there may be <NUM> distinct properties (e.g., type, openness, operation mode, number of inlets, regulation mode, angle, fail type, and connection type). Each of these <NUM> distinct properties may have a number of possible values ranging from <NUM> to <NUM>. Each value has an associated confidence to be the correct value. Given that the number of possible choices is finite, the confidences always sum to <NUM>%. For example, assuming a property has <NUM> possible values, the confidences may be <NUM>%, <NUM>% and <NUM>%. While the deep neural network architecture may return all possible values, only those having a confidence that exceeds a predetermined threshold may be utilized.

At step <NUM>, P&ID data extraction application <NUM> constructs labels from the predicted classes of equipment and inferred properties, and stores bounding boxes and labels in a machine-readable format in memory. The machine-readable format may be separate from the image-only format, for example, a JSON file related to, but separate from, the JPG file, PNG file, or image-only PDF file that includes the P&ID image. Alternative, the machine-readable format may be integrated into a file that stores the P&ID image.

Depending on the use case, the machine-readable format may be used in various ways. At step <NUM>, which may be optional, the P&ID data extraction application <NUM> may display the label-extracted P&ID within a window of its user interface. <FIG> is a view of a portion of an example label-extracted P&ID 800that may be displayed in the user interface of the P&ID data extraction application <NUM>. Bounding boxes for text boxes and symbols are visually represented by overlays (e.g., colored highlighting). Labels may be displayed in ancillary windows of the user interface (not shown) for user confirmation or correction. The machine-readable format may additionally, or alternatively, be provided to a design and modeling application (e.g., for use in building a model/digital twin or for other purposes).

Prior to using the neural networks described above in connection with steps <NUM> and <NUM>, the neural networks need to be trained on a number of labeled samples. Labeled samples may be produced in various manners. In some cases, labeled samples may be generated by a special labeling application that includes automation and support for increasing efficiency of repetitive tasks common to labeling P&IDs. In other cases, labeled samples may be produced using traditional techniques. <FIG> is a flow diagram of an example sequence of steps <NUM> for training a neural network of the P&ID data extraction application <NUM> to detect symbols. At step <NUM>, a batch of labeled samples (e.g., <NUM>) are received and applied to the current model which attempts to detect symbols. In some cases, a labeled sample may be subject to a randomized cropping to avoid showing the same thing to the neural network when iterative operations are performed. At step <NUM>, the output (prediction) is compared to the labels of the sample which represent ground truth. A set of loss values is computed to indicate how close or far the model is from the desired output. In general applications uncommon classes are given lesser importance. To better handle P&IDs where some symbols are much more prevalent than others, the loss values may be altered to give higher weights to samples that are part of uncommon classes. At step <NUM>, errors made by the model are analyzed and back propagated. The model parameters are adjusted to avoid the observed errors. At step <NUM>, the performance of the model is computed using another labeled sample (which has not yet been seen during training) and the performance compared to predetermined level of performance. Additionally, a run time is compared to predetermined time limit. If neither condition is met, execution loops to step <NUM> and training continues with a new batch of labeled samples. If either condition is met, it is treated as a stopping criterion, and training is concluded and the model output at step <NUM>.

Claim 1:
A method for extracting machine-readable labels for text boxes and symbols in piping and instrumentation drawings, P&IDs, in image-only formats, comprising:
predicting, by an optical character recognition, OCR, algorithm of a P&ID data extraction application executing on a computing device, bounding boxes and text within text boxes in a P&ID in an image-only format, wherein the predicted text within text boxes are labels for the text boxes;
detecting, by a first machine learning algorithm of the P&ID data extraction application that is based on a Faster Region-based Convolutional Neural Network, R-CNN, architecture, symbols in the P&ID, the detecting to return a predicted bounding box and predicted class of equipment for each symbol;
decimating one or more of the predicted bounding boxes to avoid overlapping detections using a non-maximum suppression algorithm;
inferring, by a second machine learning algorithm of the P&ID data extraction application that is based on a different deep neural network architecture adapted for properties classification, a number of properties for each detected symbol having a remaining predicted bounding box, wherein the number of properties depends on the predicted class of equipment and each property has a number of property values;
storing, in a machine-readable format in a memory of the computing device for each text box, the bounding box and label for the text box, and, for each detected symbol having a remaining predicted bounding box, the predicted bounding box and label including the predicted class of equipment and inferred properties; and
displaying the predicted bounding boxes and labels for the text boxes and the symbols in a user interface.