File size: 993 Bytes
e55e244
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ddc318b
e55e244
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
import datasets


class FixturesOCR(datasets.GeneratorBasedBuilder):
    def _info(self):
        return datasets.DatasetInfo(
            features=datasets.Features(
                {
                    "image": datasets.Image(),
                }
            )
        )

    def _split_generators(self, dl_manager):
        DL_URLS = [
            "https://huggingface.co/datasets/sberbank-ai/Peter/resolve/main/images.zip"
        ]
        data_files = dl_manager.download_and_extract(DL_URLS)

        return [
            datasets.SplitGenerator(
                name=datasets.Split.TRAIN,
                gen_kwargs={
                    "image_paths": dl_manager.iter_files(data_files),
                },
            ),
        ]

    def _generate_examples(self, image_paths):
        """Generate examples."""
        for idx, image_path in enumerate(image_paths):
            example = {
                "image": image_path,
            }
            yield idx, example