|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""TODO: Add a description here.""" |
|
|
|
|
|
import csv |
|
import os |
|
|
|
import datasets |
|
|
|
|
|
|
|
|
|
_CITATION = """\ |
|
@InProceedings{yu2019lytnet, |
|
title = {LYTNet: A Convolutional Neural Network for Real-Time Pedestrian Traffic Lights and Zebra Crossing Recognition for the Visually Impaired}, |
|
author = {Yu, Samuel and Lee, Heon and Kim, John}, |
|
booktitle = {Computer Analysis of Images and Patterns (CAIP)}, |
|
month = {Aug}, |
|
year = {2019} |
|
} |
|
""" |
|
|
|
|
|
|
|
_DESCRIPTION = """\ |
|
This new dataset is designed to solve this great NLP task and is crafted with a lot of care. |
|
""" |
|
|
|
|
|
_HOMEPAGE = "https://github.com/samuelyu2002/ImVisible" |
|
|
|
|
|
_LICENSE = "" |
|
|
|
|
|
|
|
|
|
_URLS = { |
|
"imgs": "ptl_dataset.tar.gz", |
|
"train": "training_file.csv", |
|
"validation": "validation_file.csv", |
|
"test": "testing_file.csv", |
|
} |
|
|
|
|
|
|
|
class ImVision(datasets.GeneratorBasedBuilder): |
|
"""TODO: Short description of my dataset.""" |
|
|
|
VERSION = datasets.Version("1.1.0") |
|
|
|
def _info(self): |
|
features = datasets.Features( |
|
{ |
|
"img": datasets.Image(), |
|
"boxes": datasets.features.Sequence({ |
|
"label": datasets.Value("int8"), |
|
"occluded": datasets.Value("bool"), |
|
"x_max": datasets.Value("float"), |
|
"x_min": datasets.Value("float"), |
|
"y_max": datasets.Value("float"), |
|
"y_min": datasets.Value("float"), |
|
}), |
|
} |
|
) |
|
|
|
return datasets.DatasetInfo( |
|
|
|
description=_DESCRIPTION, |
|
|
|
features=features, |
|
|
|
|
|
|
|
|
|
homepage=_HOMEPAGE, |
|
|
|
license=_LICENSE, |
|
|
|
citation=_CITATION, |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
urls = _URLS |
|
data_dir = dl_manager.download_and_extract(urls) |
|
return [ |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TRAIN, |
|
gen_kwargs={ |
|
"img_folder": os.path.join(data_dir["imgs"], "PTL_Dataset_876x657/"), |
|
"labels": data_dir["train"], |
|
}, |
|
), |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TEST, |
|
|
|
gen_kwargs={ |
|
"img_folder": os.path.join(data_dir["imgs"], "PTL_Dataset_876x657/"), |
|
"labels": data_dir["test"], |
|
}, |
|
), |
|
datasets.SplitGenerator( |
|
name=datasets.Split.VALIDATION, |
|
|
|
gen_kwargs={ |
|
"img_folder": os.path.join(data_dir["imgs"], "PTL_Dataset_876x657/"), |
|
"labels": data_dir["validation"], |
|
}, |
|
), |
|
] |
|
|
|
|
|
def _generate_examples(self, img_folder, labels): |
|
|
|
|
|
with open(labels, encoding="utf-8") as f: |
|
reader = csv.reader(f) |
|
for key, row in enumerate(reader): |
|
if key == 0: |
|
continue |
|
|
|
fname, label, x_min, y_min, x_max, y_max, occluded = row |
|
yield key - 1, { |
|
"img": os.path.join(img_folder, fname), |
|
"boxes": [ |
|
{ |
|
"label": int(label), |
|
"occluded": occluded != "not_blocked", |
|
"x_max": float(x_max), |
|
"x_min": float(x_min), |
|
"y_max": float(y_max), |
|
"y_min": float(y_min), |
|
} |
|
] |
|
} |