Instance Segmentation Based Graph Extraction for Handwritten Circuit Diagram Images

Johannes Bayer, Amit Kumar Roy, Andreas Dengel · DOI

Abstract

Digitizing handwritten circuit diagrams remains a significant challenge due to the inherent noise of hand-drawn sketches and the complexity of topological extraction. This paper presents a streamlined pipeline that utilizes Mask R-CNN for simultaneous instance segmentation and keypoint detection. By treating connectivity as a primary feature of the machine learning model, the approach replaces traditional, brittle computer vision heuristics with a robust two-step process of inference and geometric matching. Experimental results on an extended version of the Circuit Graph Handwritten Dataset (CGHD) demonstrate the viability of this end-to-end graph extraction method.

Introduction

The digitization of handwritten circuit diagrams—found in student notebooks, engineering journals, and historical archives—is a notoriously difficult task. Unlike CAD-generated schematics, handwritten sketches are characterized by overlapping components, inconsistent symbol representations, and distracting backgrounds such as lined or squared paper.

Traditional digitization methods typically rely on rigid, multi-step computer vision pipelines: first detecting symbols, then tracing lines, and finally attempting to infer connectivity. These pipelines are often computationally expensive and prone to failure when faced with the "noisy" nature of human sketching. While deep learning has significantly improved symbol detection, extracting the underlying circuit topology (the "who is connected to whom" graph) remains a major hurdle. This research aims to simplify the process by leveraging instance segmentation to treat connectivity as a first-class citizen in the machine learning process.

Methodology

The core of this approach is a shift toward Instance Segmentation using the Mask R-CNN architecture (implemented via Detectron 2). Instead of merely placing bounding boxes around components, the model is trained to perform two simultaneous tasks:

  1. Instance Segmentation: Identifying the exact pixels belonging to electrical components and wires.
  2. Keypoint Extraction: Identifying specific "ports" or terminals where electrical connections occur.

By training the model to recognize ports and wire masks simultaneously, the post-processing stage is simplified. Rather than using complex pathfinding algorithms to determine if a line touches a symbol, the system uses a simple geometric matching algorithm to link the predicted wire masks to the identified component ports.

Data Preparation and Dataset Extension

To train the model without an prohibitive amount of manual labeling, the researchers developed a semi-automated data preparation workflow. The study utilizes and extends the Circuit Graph Handwritten Dataset (CGHD), which originally contained 2,208 raw images with over 185,000 bounding box annotations.

The authors added an extension consisting of 245 binary segmentation maps featuring 18,276 individual polygon annotations. The workflow involved:

  • Binary Segmentation: Using filters and manual correction to separate pencil strokes from the paper background.
  • Mask Refinement: Refining existing bounding boxes into precise polygons by intersecting them with the binary stroke maps.
  • Addition Mask Generation: A "leftover" logic where any stroke area not covered by a component polygon was automatically labeled as a "wire." This avoided the tedious task of manually tracing every connection line.
  • Keypoint Assignment: Using a library of symbol prototypes to automatically map where terminals should be located based on the symbol's orientation.

Results and Discussion

The experiment served as a proof-of-concept for the viability of this end-to-end approach. The Mask R-CNN model achieved a minimum training loss of 0.44 and a maximum training mask accuracy of 0.94. On the validation set, the model showed a loss of 1.39.

Qualitative analysis confirmed that the model could successfully extract graph structures from complex sketches. The results were described as "reasonable, yet incomplete," particularly in very dense or messy areas. One of the primary strengths of the method is moving the complexity into the inference stage; by predicting ports and wires directly, the final graph extraction becomes a trivial geometric exercise.

Limitations and Future Work

Despite the promising results, several areas for improvement were identified:

  • Connector Differentiation: The current model identifies the location of a port but cannot yet distinguish between specific terminal types (e.g., the Base, Collector, and Emitter of a transistor).
  • Rotation Sensitivity: The authors suggest a dedicated rotation prediction head is needed to better handle symbols drawn at non-standard angles.
  • OCR Integration: Future iterations must incorporate Optical Character Recognition (OCR) to read component values (e.g., "10kΩ") and labels.
  • Discontinuous Wires: The pipeline currently struggles with "broken" wires. The researchers propose that Graph Neural Networks (GNNs) could be utilized in post-processing to "heal" these gaps and improve overall topological accuracy.

Summary updated

BibTeX
@inproceedings{bayer2023instance,
  author = {Johannes Bayer and Amit Kumar Roy and Andreas Dengel},
  title = {{Instance Segmentation Based Graph Extraction for Handwritten Circuit Diagram Images}},
  booktitle = {ICPRAM},
  year = {2023},
  doi = {10.5220/0011752600003411},
}
Figure