I have trained a YOLO model for detecting components in P&ID diagrams, and it works reasonably well for discrete symbols. However, I am facing challenges with pipes and lines:
The model is not giving accurate results for continuous edges (pipes/lines).
Bounding boxes are not aligning correctly with the linear structures.
Since pipes are thin and extend across diagrams, YOLO seems to struggle compared to symbol detection.
Could you please advise on the best approach for this? Should I:
Continue refining YOLO training with more annotated data for pipes/lines, or
Combine YOLO with traditional methods (like edge detection / Hough transform) to handle the line structures?
Any suggestions, examples, or references would be very helpful.
There’s a lot of nuance to your question, it will likely warrant a significant amount of research to arrive at the “best” answer (for your usage). First and most importantly, you should define for yourself what the goal is for identifying each line/connection. As an example, do you care about what type of line (dashed vs solid), it’s directionality, and/or branching? Listing out what you information you need/want, will help better guide your research for an answer.
A lot of how YOLO performs for line detection will come down to the line structure and the way they’re annotated. If the aim was to detect a line with no other features (no arrows, endpoints, breaks, joints, jogs, etc.) it might be a bit challenging, as YOLO and other CNNs are optimized to search for 2D features to detect and classify objects. Since a featureless line is 1D in nature, it could prove quite challenging. However, since most P&ID diagrams usually contain lines with features, it’s likely possible to use YOLO to detect them. The trick will come down to how they’re annotated.
Data labeling is always the crux of a well trained model. Without quality annotations, and a sufficient number of them, the model will likely perform poorly. You should survey the types of features that are in your diagrams and list all of them out. Then you’ll need to ensure that your training and validation dataset have a sufficient number of all of these features, fully annotated. It’s critical you don’t leave any lines un-annotated, as this will have an adverse impact on the model’s performance. Additionally, you may want to explore ways to pre-process images to make it easier to detect the lines and their features. A good resource would be this paper: https://www.mdpi.com/2076-3417/11/21/10054 which is specifically about preprocessing and annotating lines from P&ID diagrams to train an older CNN architecture with. The principles should also apply to your YOLO model as well.
Of course you could use Hough transform to aid with your annotations too. It’s tricky though, b/c the arguments for the Hough transform may not be universally applicable to all your diagrams or lines. The OpenCV documentation has some decent tutorials and information on Hough transforms for line detection.