Update README.md
Browse files
README.md
CHANGED
@@ -29,3 +29,74 @@ configs:
|
|
29 |
- split: train
|
30 |
path: data/train-*
|
31 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
- split: train
|
30 |
path: data/train-*
|
31 |
---
|
32 |
+
# Dataset Summary
|
33 |
+
BCE-Arabic Layout Detection dataset contains layout annotations for Arabic documents from the BCE-Arabic corpus. It includes bounding box annotations for various region types including text regions, images, tables, charts, and graphics.
|
34 |
+
|
35 |
+
## Dataset Details
|
36 |
+
- **Size**: {size} pages
|
37 |
+
- **Source**: BCE-Arabic Corpus
|
38 |
+
- **Languages**: Arabic
|
39 |
+
- **Task**: Document Layout Analysis
|
40 |
+
|
41 |
+
### Supported Tasks
|
42 |
+
- Document Layout Analysis
|
43 |
+
- OCR Region Detection
|
44 |
+
- Document Understanding
|
45 |
+
|
46 |
+
### Contents
|
47 |
+
Each sample contains:
|
48 |
+
- Image: Page scan (RGB)
|
49 |
+
- Width: Original image width
|
50 |
+
- Height: Original image height
|
51 |
+
- Normalized Bounding Boxes: List of normalized bounding boxes for each region
|
52 |
+
- Region Types: List of region types for each bounding box
|
53 |
+
- text_types: List of text types for each bounding box
|
54 |
+
- category: Document category
|
55 |
+
|
56 |
+
### Example Usage
|
57 |
+
```python
|
58 |
+
from datasets import load_dataset
|
59 |
+
import json
|
60 |
+
import cv2
|
61 |
+
import numpy as np
|
62 |
+
|
63 |
+
# Load dataset
|
64 |
+
dataset = load_dataset("ahmedheakl/arocrbench_bce_arabic_layout")
|
65 |
+
|
66 |
+
# Get a sample
|
67 |
+
sample = dataset['train'][0]
|
68 |
+
|
69 |
+
# Access image and annotations
|
70 |
+
image = sample['image']
|
71 |
+
width = row['width']
|
72 |
+
height = row['height']
|
73 |
+
bboxes = row['normalized_bounding_boxes']
|
74 |
+
region_types = row['region_types']
|
75 |
+
|
76 |
+
# Draw each bounding box
|
77 |
+
for bbox, region_type in zip(bboxes, region_types):
|
78 |
+
# Convert normalized coordinates to pixel values
|
79 |
+
x1 = int(bbox[0] * width)
|
80 |
+
y1 = int(bbox[1] * height)
|
81 |
+
x2 = int(bbox[2] * width)
|
82 |
+
y2 = int(bbox[3] * height)
|
83 |
+
|
84 |
+
color = color_map.get(region_type, (0, 0, 0)) # Default to black if unknown
|
85 |
+
|
86 |
+
# Draw rectangle and label
|
87 |
+
cv2.rectangle(image, (x1, y1), (x2, y2), color, 3)
|
88 |
+
cv2.putText(image, region_type, (x1, y1 - 10),
|
89 |
+
cv2.FONT_HERSHEY_SIMPLEX, 1, color, 2)
|
90 |
+
cv2.imshow('image', image)
|
91 |
+
cv2.waitKey(0)
|
92 |
+
cv2.destroyAllWindows()
|
93 |
+
|
94 |
+
```
|
95 |
+
|
96 |
+
## Data Fields
|
97 |
+
- `image`: Page image (PIL Image)
|
98 |
+
- `width`: Image width (int)
|
99 |
+
- `height`: Image height (int)
|
100 |
+
- `category`: Document category (string)
|
101 |
+
- `total_regions`: Number of regions (int)
|
102 |
+
- `region_types`: List of region types
|