Stanislav Kalinin commited on
Commit
e55e244
1 Parent(s): 089a7c6

feat: Add base loading script anad dataset_infos

Browse files
Files changed (2) hide show
  1. Peter.py +36 -0
  2. dataset_infos.json +14 -0
Peter.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import datasets
3
+
4
+
5
+ class FixturesOCR(datasets.GeneratorBasedBuilder):
6
+ def _info(self):
7
+ return datasets.DatasetInfo(
8
+ features=datasets.Features(
9
+ {
10
+ "image": datasets.Image(),
11
+ }
12
+ )
13
+ )
14
+
15
+ def _split_generators(self, dl_manager):
16
+ DL_URLS = [
17
+ "https://huggingface.co/datasets/sberbank-ai/Peter/resolve/main/images.zip"
18
+ ]
19
+ data_files = dl_manager.download_and_extract(DL_URLS)
20
+
21
+ return [
22
+ datasets.SplitGenerator(
23
+ name=datasets.Split.TEST,
24
+ gen_kwargs={
25
+ "image_paths": dl_manager.iter_files(data_files),
26
+ },
27
+ ),
28
+ ]
29
+
30
+ def _generate_examples(self, image_paths):
31
+ """Generate examples."""
32
+ for idx, image_path in enumerate(image_paths):
33
+ example = {
34
+ "image": image_path,
35
+ }
36
+ yield idx, example
dataset_infos.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "default": {
3
+ "description": "Digital Peter: recognition of Peter the Great's manuscripts",
4
+ "features": {
5
+ "image": {"decode": true, "id": null, "_type": "Image"}
6
+ },
7
+ "splits": {"test": {
8
+ "name": "train",
9
+ "num_bytes": 100259,
10
+ "num_examples": 662,
11
+ "dataset_name": "images"
12
+ }}
13
+ }
14
+ }