Update README.md
Browse files
README.md
CHANGED
@@ -21,13 +21,13 @@ dataset_info:
|
|
21 |
dtype: string
|
22 |
splits:
|
23 |
- name: validation
|
24 |
-
num_bytes: 64018244
|
25 |
num_examples: 101
|
26 |
- name: test
|
27 |
-
num_bytes: 125460818
|
28 |
num_examples: 199
|
29 |
download_size: 189448472
|
30 |
-
dataset_size: 189479062
|
31 |
configs:
|
32 |
- config_name: default
|
33 |
data_files:
|
@@ -35,4 +35,48 @@ configs:
|
|
35 |
path: data/validation-*
|
36 |
- split: test
|
37 |
path: data/test-*
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
dtype: string
|
22 |
splits:
|
23 |
- name: validation
|
24 |
+
num_bytes: 64018244
|
25 |
num_examples: 101
|
26 |
- name: test
|
27 |
+
num_bytes: 125460818
|
28 |
num_examples: 199
|
29 |
download_size: 189448472
|
30 |
+
dataset_size: 189479062
|
31 |
configs:
|
32 |
- config_name: default
|
33 |
data_files:
|
|
|
35 |
path: data/validation-*
|
36 |
- split: test
|
37 |
path: data/test-*
|
38 |
+
license: mit
|
39 |
+
task_categories:
|
40 |
+
- image-to-text
|
41 |
+
- object-detection
|
42 |
+
size_categories:
|
43 |
+
- n<1K
|
44 |
---
|
45 |
+
|
46 |
+
# DM codes dataset
|
47 |
+
|
48 |
+
The dataset contains photos of Data Matrix (DM) codes and their annotations. The photos were taken on an iPhone and annotated manually by a human.
|
49 |
+
The annotations contain **text**, which is encoded in the DM code and the pixel coordinates of the DM code vertices.
|
50 |
+
The vertices are: **tl** = top left, **tr** = top right, **br** = bottom right, **bl** = bottom left.
|
51 |
+
Attribute **is_clean** specifies whether the DM code on the image is expected to be easily readable. For every DM code, there is exactly one image
|
52 |
+
with `is_clean=true` and several images with `is_clean=false`.
|
53 |
+
|
54 |
+
If you want to crop the DM codes from the images, use the following code:
|
55 |
+
|
56 |
+
```python
|
57 |
+
import numpy as np
|
58 |
+
import datasets
|
59 |
+
from PIL import Image
|
60 |
+
from skimage import transform
|
61 |
+
|
62 |
+
def crop_dm_code(example: dict, square_side: int = 200, square_padding: int = 25) -> dict:
|
63 |
+
vertices = np.asarray((example["tl"], example["tr"], example["br"], example["bl"]))
|
64 |
+
unit_square = np.asarray([
|
65 |
+
[square_padding, square_padding],
|
66 |
+
[square_side + square_padding, square_padding],
|
67 |
+
[square_side + square_padding, square_side + square_padding],
|
68 |
+
[square_padding, square_side + square_padding]
|
69 |
+
])
|
70 |
+
transf = transform.ProjectiveTransform()
|
71 |
+
if not transf.estimate(unit_square, vertices): raise Exception("estimate failed")
|
72 |
+
cropped_np_image = transform.warp(
|
73 |
+
np.array(example["image"]),
|
74 |
+
transf,
|
75 |
+
output_shape=(square_side + square_padding * 2, square_side + square_padding * 2)
|
76 |
+
)
|
77 |
+
cropped_image = Image.fromarray((cropped_np_image * 255).astype(np.uint8))
|
78 |
+
return {"cropped_image": cropped_image}
|
79 |
+
|
80 |
+
dataset = datasets.load_dataset("shortery/dm-codes")
|
81 |
+
dataset = dataset.map(crop_dm_code)
|
82 |
+
```
|