|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""Exclusively Dark Image Dataset""" |
|
|
|
|
|
|
|
|
import os |
|
|
|
|
|
import datasets |
|
|
import pandas as pd |
|
|
|
|
|
|
|
|
_CITATION = """\ |
|
|
@article{Exdark, |
|
|
title = {Getting to Know Low-light Images with The Exclusively Dark Dataset}, |
|
|
author = {Loh, Yuen Peng and Chan, Chee Seng}, |
|
|
journal = {Computer Vision and Image Understanding}, |
|
|
volume = {178}, |
|
|
pages = {30-42}, |
|
|
year = {2019}, |
|
|
doi = {https://doi.org/10.1016/j.cviu.2018.10.010} |
|
|
} |
|
|
""" |
|
|
|
|
|
_DESCRIPTION = """\ |
|
|
The Exclusively Dark (ExDARK) dataset is a collection of low-light |
|
|
images from very low-light environments to twilight (i.e 10 different |
|
|
conditions) with 12 object classes (similar to PASCAL VOC) annotated on both |
|
|
image class level and local object bounding boxes. |
|
|
|
|
|
The object classes are as follows: |
|
|
|
|
|
- Dog |
|
|
- Motorbike |
|
|
- People |
|
|
- Cat |
|
|
- Chair |
|
|
- Table |
|
|
- Car |
|
|
- Bicycle |
|
|
- Bottle |
|
|
- Bus |
|
|
- Cup |
|
|
- Boat |
|
|
|
|
|
For more information about the original Exclusively Dark Image dataset, |
|
|
please visit the official dataset page: |
|
|
|
|
|
https://github.com/cs-chan/Exclusively-Dark-Image-Dataset |
|
|
|
|
|
Please refer to the original dataset source for any additional details, |
|
|
citations, or specific usage guidelines provided by the dataset creators. |
|
|
""" |
|
|
|
|
|
_HOMEPAGE = "https://github.com/cs-chan/Exclusively-Dark-Image-Dataset" |
|
|
|
|
|
_LICENSE = "bsd-3-clause" |
|
|
|
|
|
_LABEL_NAMES = [ |
|
|
"Dog", |
|
|
"Motorbike", |
|
|
"People", |
|
|
"Cat", |
|
|
"Chair", |
|
|
"Table", |
|
|
"Car", |
|
|
"Bicycle", |
|
|
"Bottle", |
|
|
"Bus", |
|
|
"Cup", |
|
|
"Boat", |
|
|
] |
|
|
|
|
|
|
|
|
class ExDark(datasets.GeneratorBasedBuilder): |
|
|
"""Exclusively Dark (ExDARK) dataset""" |
|
|
|
|
|
VERSION = datasets.Version("1.0.0") |
|
|
|
|
|
BUILDER_CONFIGS = [ |
|
|
datasets.BuilderConfig( |
|
|
name="exdark", |
|
|
version=VERSION, |
|
|
description="Exclusively Dark (ExDARK) dataset", |
|
|
), |
|
|
] |
|
|
|
|
|
DEFAULT_CONFIG_NAME = "exdark" |
|
|
|
|
|
def _info(self): |
|
|
return datasets.DatasetInfo( |
|
|
description=_DESCRIPTION, |
|
|
features=datasets.Features( |
|
|
{ |
|
|
"img": datasets.Image(), |
|
|
"target": datasets.Sequence( |
|
|
feature={ |
|
|
"labels": datasets.features.ClassLabel( |
|
|
names=_LABEL_NAMES |
|
|
), |
|
|
"bboxes": datasets.features.Sequence( |
|
|
feature=datasets.Value("float32") |
|
|
) |
|
|
} |
|
|
) |
|
|
} |
|
|
), |
|
|
homepage=_HOMEPAGE, |
|
|
license=_LICENSE, |
|
|
citation=_CITATION, |
|
|
) |
|
|
|
|
|
def _split_generators(self, dl_manager): |
|
|
data_dir = dl_manager.download_and_extract("ExDark.zip") |
|
|
|
|
|
metadata_path = os.path.join(data_dir, "ExDark", "metadata.csv") |
|
|
|
|
|
return [ |
|
|
datasets.SplitGenerator( |
|
|
name=datasets.Split.TRAIN, |
|
|
gen_kwargs={ |
|
|
"data_dir": data_dir, |
|
|
"metadata_path": metadata_path, |
|
|
"split": "train", |
|
|
}, |
|
|
), |
|
|
] |
|
|
|
|
|
def _generate_examples(self, data_dir, metadata_path, split): |
|
|
df = pd.read_csv(metadata_path) |
|
|
classes = df["class"].unique() |
|
|
|
|
|
df["class"] = df["class"].apply(lambda x: classes.tolist().index(x)) |
|
|
|
|
|
for idx, file_name in enumerate(df.file_name.unique()): |
|
|
img_path = os.path.join(data_dir, "ExDark", file_name) |
|
|
sample = df[df.file_name == file_name] |
|
|
bboxs = sample[["x", "y", "w", "h"]].to_numpy() |
|
|
labels = sample["class"].to_numpy() |
|
|
yield idx, { |
|
|
"img": img_path, |
|
|
"target": { |
|
|
"labels": labels, |
|
|
"bboxes": bboxs, |
|
|
}, |
|
|
} |
|
|
|