File size: 2,146 Bytes
6e6a3a7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
---
license: mit
task_categories:
  - image-segmentation
  - object-detection
tags:
  - P&ID
  - lines
  - pipelines
  - engineering
  - diagrams
  - line-detection
size_categories:
  - 1K<n<10K
---

# 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:** 10000
- **Total line segments:** 44754
- **Crops per image:** 20
- **Image sizes:** Various sizes under 1000px (e.g., 300x500, 512x768, 900x900)

## Dataset Structure

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 a sample
sample = dataset["train"][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()
```

## 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
- Only lines where **both endpoints** are fully inside the crop are included

## Line Types

- `solid`: Continuous pipeline lines
- `dashed`: Dashed lines (often representing signal/instrument lines)

## License

MIT License