|
from PIL import Image |
|
import numpy as np |
|
|
|
import json |
|
import os |
|
|
|
import datasets |
|
|
|
|
|
_DESCRIPTION = """ |
|
""" |
|
|
|
_HOMEPAGE = "" |
|
|
|
_LICENSE = "" |
|
|
|
_URL = "https://huggingface.co/datasets/alexrods/mini_car_bikes_detection/resolve/main" |
|
|
|
_URLS = { |
|
"train_images": f"{_URL}/data/train.zip", |
|
"test_images": f"{_URL}/data/test.zip", |
|
} |
|
|
|
_CATEGORIES = ['Car', 'bike'] |
|
|
|
|
|
class MiniCarBikesDetection(datasets.GeneratorBasedBuilder): |
|
|
|
VERSION = datasets.Version("1.0.0") |
|
|
|
def _info(self): |
|
features = datasets.Features( |
|
{ |
|
"image": datasets.Image(), |
|
"image_name": datasets.Value("string"), |
|
} |
|
) |
|
|
|
return datasets.DatasetInfo( |
|
description=_DESCRIPTION, |
|
features=features, |
|
homepage=_HOMEPAGE, |
|
license=_LICENSE, |
|
) |
|
|
|
|
|
def _split_generators(self, dl_manager): |
|
data_files = dl_manager.download(_URLS) |
|
return [ |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TRAIN, |
|
gen_kwargs={ |
|
"image_files": dl_manager.iter_archive(data_files["train_images"]), |
|
}, |
|
), |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TEST, |
|
gen_kwargs={ |
|
"image_files": dl_manager.iter_archive(data_files["test_images"]), |
|
}, |
|
), |
|
] |
|
|
|
def _generate_examples(self, image_files): |
|
for image_file in image_files: |
|
yield image_file, { |
|
"image": {"path": image_file[0], "bytes": image_file[1].read()}, |
|
"image_name": image_file[0], |
|
} |
|
|
|
|
|
|
|
|