Peter / Peter.py
Stanislav Kalinin
fix: Train dataset
ddc318b
raw
history blame
993 Bytes
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