We discuss the implementation of a YOLOv5-based object detection model, the data set and augmentation techniques used, and the integration of optical character recognition (OCR) for accurate identification and processing of instrument tags, making use of regular expression-based instrument number extraction, highlighting the importance of adaptability and flexibility in handling diverse numbering conventions.
Finally, we explain how this can be the first step in the digitalisation roadmap of the asset through the creation of a knowledge graph digital twin.
The Ultimate Goal: Building Knowledge Graphs with P&ID Data
Our first goal is to create a P&ID scanning capability that facilitates the extraction of instrument tags from existing P&ID documents, paving the way for the construction of comprehensive and accurate knowledge graph of the asset.
The process follows three steps:
• Computer vision-based instrument object extraction, using the YOLOv5 model.
• Optical Character Recognition (OCR) with a RegEx filter to extract textual data.
• Integration with Knowledge Graph building tools.
Step 1 - YOLOv5: A Powerful Object Detection Algorithm
The first step is to identify instrument “objects” within a P&ID drawing.
As a computer vision model for object detection, YOLOv5 stands out as a revolutionary object detection algorithm due to its exceptional speed and efficiency. Its ability to identify multiple objects within an image with excellent performance makes it an ideal choice for real-time applications.
At its core, YOLO operates by dividing images into a grid and predicting bounding boxes and class probabilities for each cell. This approach allows for rapid and accurate detection of various objects within an image, making YOLO a popular choice in real-time computer vision applications.
The success of any object detection model hinges on the quality and diversity of the training dataset. For our P&ID Scanner, we meticulously crafted and annotated a comprehensive dataset of P&ID images, labelling each instrument tag for training the YOLOv5 model.
To address the inherent class imbalance in the dataset, we employed augmentation techniques to increase the diversity of training data for underrepresented classes. Augmentation involves applying transformations like rotations, flips, and scaling to original images, generating a wider variety of training data while preserving the original characteristics of the objects. This approach helps prevent the model from becoming biased towards the dominant class, ensuring accurate recognition of all instrument tags.
The effectiveness of our data set and augmentation techniques is evident in the model’s ability to reliably detect instrument tags with high accuracy, even in challenging P&ID drawings containing complex layouts and variations in tag appearance.
The training process involves feeding the model with annotated P&ID images and adjusting its parameters to improve its ability to accurately detect and classify instrument tags. Fine-tuning the model’s hyperparameters is crucial to achieving optimal performance.
Once all the instruments in a P&ID have been identified, the task remains to transform an image into textual data.
Step 2 - Bridging the Gap Between Visual and Textual Data: Optical Character Recognition (OCR) with RegEx
Optical Character Recognition (OCR) plays a crucial role in our P&ID Scanner, bridging the gap between visual data in diagrams and the textual information required to populate a tag database and building knowledge graphs. OCR converts the visual symbols and annotations found in P&ID diagrams into machine-readable text, enabling more efficient processing of the extracted data.
In the context of P&ID diagrams, OCR is essential for accurately identifying and extracting instrument numbers, which are often displayed as text labels within the drawings. This allows the scanner to convert the detected tags into a structured format, ready for integration with knowledge graph building tools.
P&ID diagrams often adhere to specific numbering conventions, which can vary across different companies and industries. To handle this diversity, we employ a flexible approach based on regular expressions (RegEx), enabling the P&ID Scanner to adapt to different numbering formats.
We use a combination of three separate regular expressions to identify distinct parts of the instrument numbers, such as prefix, numeric portion, and suffix. This allows for greater adaptability and ensures that the scanner can accurately extract instrument numbers even when faced with unique numbering conventions.
By combining OCR with this flexible regular expression approach, the P&ID Scanner achieves high accuracy in extracting instrument numbers from P&IDs, even those with complex and non-standard numbering schemes.
Step 3 - Integration with Knowledge Graph Building Tools
The extracted instrument tags are then seamlessly integrated with knowledge graph building tools, transforming the raw instrument textual data into a structured and interconnected representation of information. This integration empowers users to explore complex relationships within the P&ID data and unlock valuable insights.
By connecting instrument tags to other relevant information, such as equipment, process parameters, and operational data, users can create a comprehensive knowledge graph that serves as a powerful tool to drive enhanced visualisation and workflow automation, empowered by the context derived from the knowledge graph.
The ability to navigate and analyse this interconnected data leads to more informed decision-making, improved efficiency, and a deeper understanding of the process system.
P&ID Scanner: A Game Changer for Digitalisation in the Process Industry
The P&ID Scanner is a game-changer for digitalisation in the process industry, particularly for mature assets, offering a robust and efficient solution for extracting instrument tags from non-digital P&ID drawings. By leveraging advanced technologies such as YOLOv5 object detection, OCR, and regular expressions, the P&ID Scanner provides accurate, adaptable, and scalable data extraction capabilities.
The integration with knowledge graph building tools empowers users to unlock valuable insights from their P&ID data, enabling them to make informed decisions, optimise processes, and drive innovation in the process industry.
The P&ID Scanner is a testament to the power of data-driven technologies in revolutionising the way we work, enabling a more efficient and insightful approach to managing and leveraging information in the process industry.