File size: 3,455 Bytes
219591d
 
b0623a8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
219591d
b0623a8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9308295
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
---
license: mit
task_categories:
  - object-detection
language:
  - en
tags:
  - legal-metrology
  - ocr
  - obb
  - yolo
  - imagefolder
  - computer-vision
size_categories:
  - n<1K
configs:
  - config_name: default
    data_files:
      - split: train
        path: "images/train/**"
      - split: validation
        path: "images/val/**"
---

# Legal Metrology Dataset

Annotated product packaging image dataset for detecting mandatory **Legal Metrology** declarations using Oriented Bounding Boxes (OBB) and axis-aligned bounding boxes.

## Dataset Summary

- **Total images:** 794 (`.jpg`)
- **Total annotations:** 4,760 labeled regions across 9 classes
- **Splits:** 80/20 deterministic split (`seed=42`)
  - `train`: 635 images, 3,799 annotations
  - `validation` (`images/val` / `labels/val`): 159 images, 961 annotations

## Classes

| ID | Class Name | Train | Validation | Total |
|---:|---|---:|---:|---:|
| 0 | `CONSUMER_CARE` | 515 | 123 | 638 |
| 1 | `COUNTRY_OF_ORIGIN` | 119 | 40 | 159 |
| 2 | `EXPIRY_DATE` | 481 | 120 | 601 |
| 3 | `GENERIC_NAME` | 413 | 114 | 527 |
| 4 | `MANUFACTURER_DETAILS` | 494 | 118 | 612 |
| 5 | `MANUFACTURING_DATE` | 527 | 134 | 661 |
| 6 | `MRP_BLOCK` | 586 | 142 | 728 |
| 7 | `NET_QUANTITY` | 574 | 140 | 714 |
| 8 | `UNIT_SALE_PRICE` | 90 | 30 | 120 |

## Repository Layout

```text
.
├── .gitattributes
├── README.md
├── data.yaml                  # Ultralytics YOLO-OBB config
├── images/
│   ├── train/
│   │   ├── metadata.jsonl     # Hugging Face ImageFolder annotations
│   │   └── *.jpg              # 635 training images
│   └── val/
│       ├── metadata.jsonl     # Hugging Face ImageFolder annotations
│       └── *.jpg              # 159 validation images
└── labels/
    ├── train/
    │   └── *.txt              # 635 YOLO-OBB label files
    └── val/
        └── *.txt              # 159 YOLO-OBB label files
```

### Annotation Formats

- **Hugging Face `ImageFolder` (`images/*/metadata.jsonl`)**:
  - `file_name`: image filename relative to the split directory
  - `width`, `height`: image dimensions in pixels
  - `objects.bbox`: axis-aligned COCO-style `[x_min, y_min, width, height]` in pixels
  - `objects.categories`: integer class IDs (`0`–`8`)
  - `objects.category_names`: string class names
  - `objects.obb_polygons`: normalized 4-point oriented bounding box polygons `[x1, y1, x2, y2, x3, y3, x4, y4]`
- **YOLO-OBB (`labels/*/*.txt` + `data.yaml`)**:
  - One annotation per line: `<class_id> <x1> <y1> <x2> <y2> <x3> <y3> <x4> <y4>` (normalized `[0, 1]` coordinates).

## Usage

### Hugging Face `datasets`

```python
from datasets import load_dataset

ds = load_dataset("arnavgrao/LegalMetrologyDataset")
```

### Ultralytics YOLO-OBB

```bash
yolo obb train data=data.yaml model=yolo11n-obb.pt imgsz=1024
```

## Dataset Curators

- **Arnav G Rao** — [@arnavgrao](https://huggingface.co/arnavgrao)
- **Kaninika Sardar** — [@kaninika20](https://huggingface.co/kaninika20)
- **Nidhi C A** — [@nidhica](https://huggingface.co/nidhica)

## Citation

```bibtex
@dataset{rao2026legalmetrology,
  author       = {Rao, Arnav G and Sardar, Kaninika and C A, Nidhi},
  title        = {Legal Metrology Dataset},
  year         = {2026},
  publisher    = {Hugging Face},
  howpublished = {\url{https://huggingface.co/datasets/arnavgrao/LegalMetrologyDataset}}
}
```