Team Ai
Datasetpublic

prasatee/lines-dataset

P&ID Line Detection Dataset This dataset contains cropped images from P&ID (Piping and Instrumentation Diagrams) with line segment annotations for line detection and segmentation tasks. Dataset Splits The dataset is split by source image to prevent data leakage: Split Source Images Samples Line Segments Train 400 (80%) 8,000 69,483 Validation 50 (10%) 1,000 9,485 Test 50 (10%) 1,000 8,940 Dataset Structure lines_dataset/ ├──… See the full description on the dataset page: https://huggingface.co/datasets/prasatee/lines-dataset.

sourceHugging Facemitupdated 10mo agoView on Hugging Face
0likes877downloads
Dataset Card

P&ID Line Detection Dataset

This dataset contains cropped images from P&ID (Piping and Instrumentation Diagrams) with line segment annotations for line detection and segmentation tasks.

Dataset Description

  • —Total source images: 500
  • —Total cropped samples: 10,000
  • —Total line segments: 87,908
  • —Crops per image: 20
  • —Image sizes: Various sizes under 1000px (e.g., 300x500, 512x768, 900x900)

Dataset Splits

The dataset is split by source image to prevent data leakage:

SplitSource ImagesSamplesLine Segments
Train400 (80%)8,00069,483
Validation50 (10%)1,0009,485
Test50 (10%)1,0008,940

Dataset Structure

lines_dataset/
├── train/
│   ├── metadata.jsonl
│   └── *.jpg (8,000 images)
├── validation/
│   ├── metadata.jsonl
│   └── *.jpg (1,000 images)
├── test/
│   ├── metadata.jsonl
│   └── *.jpg (1,000 images)
└── visualizer/
    └── (visualization app)

Each sample contains:

  • —file_name: Image filename
  • —source_image_idx: Index of the original P&ID image
  • —crop_idx: Index of this crop from the source image
  • —width: Crop width in pixels
  • —height: Crop height in pixels
  • —lines: Dictionary with:
  • —segments: List of line segments as [x1, y1, x2, y2] (start and end points)
  • —line_types: List of line types ("solid" or "dashed")
  • —pipelines: List of pipeline names for each line

Usage

python
from datasets import load_dataset

# Load the dataset
dataset = load_dataset("imagefolder", data_dir="path/to/lines_dataset")

# Access splits
train_data = dataset["train"]
val_data = dataset["validation"]
test_data = dataset["test"]

# Access a sample
sample = train_data[0]
image = sample["image"]
lines = sample["lines"]
segments = lines["segments"]      # [[x1, y1, x2, y2], ...]
line_types = lines["line_types"]  # ["solid", "dashed", ...]
pipelines = lines["pipelines"]    # ["5\"-EK-2648", ...]

# Draw lines on image
from PIL import ImageDraw
draw = ImageDraw.Draw(image)
for seg in segments:
    x1, y1, x2, y2 = seg
    draw.line([(x1, y1), (x2, y2)], fill="blue", width=3)
image.show()

Visualizer

A built-in visualizer is included to explore the dataset:

bash
cd lines_dataset/visualizer
pip install flask
python app.py

Then open http://localhost:5051 in your browser.

Line Segment Format

Each line segment is represented as [x1, y1, x2, y2] where:

  • —(x1, y1) is the start point
  • —(x2, y2) is the end point
  • —Coordinates are in pixels, relative to the cropped image
  • —Lines are clipped to crop boundaries - partial lines that extend beyond the crop are included with endpoints adjusted to the crop edges

Line Types

  • —solid: Continuous pipeline lines
  • —dashed: Dashed lines (often representing signal/instrument lines)

License

MIT License