File size: 4,372 Bytes
5fc39ef a001ee7 5fc39ef a001ee7 892a33d a001ee7 892a33d 5fc39ef a001ee7 | 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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | # Copyright 2020 The HuggingFace Datasets Authors and the current dataset
# script contributor.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""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(),
"labels": datasets.Sequence(
feature=datasets.features.ClassLabel(
names=_LABEL_NAMES,
),
),
"bboxes": datasets.Sequence(
feature=datasets.Sequence(
feature=datasets.Value("float32"),
length=4,
),
),
}
),
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,
"labels": labels,
"bboxes": bboxs,
}
|