SatwikKambham commited on
Commit
a001ee7
·
1 Parent(s): 93c26ff

Added loading script

Browse files
Files changed (1) hide show
  1. ex-dark.py +154 -0
ex-dark.py ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ """Exclusively Dark Image Dataset"""
15
+
16
+
17
+ import os
18
+
19
+ import datasets
20
+ import pandas as pd
21
+
22
+
23
+ _CITATION = """\
24
+ @article{Exdark,
25
+ title = {Getting to Know Low-light Images with The Exclusively Dark Dataset},
26
+ author = {Loh, Yuen Peng and Chan, Chee Seng},
27
+ journal = {Computer Vision and Image Understanding},
28
+ volume = {178},
29
+ pages = {30-42},
30
+ year = {2019},
31
+ doi = {https://doi.org/10.1016/j.cviu.2018.10.010}
32
+ }
33
+ """
34
+
35
+ _DESCRIPTION = """\
36
+ The Exclusively Dark (ExDARK) dataset is a collection of low-light
37
+ images from very low-light environments to twilight (i.e 10 different
38
+ conditions) with 12 object classes (similar to PASCAL VOC) annotated on both
39
+ image class level and local object bounding boxes.
40
+
41
+ The object classes are as follows:
42
+
43
+ - Dog
44
+ - Motorbike
45
+ - People
46
+ - Cat
47
+ - Chair
48
+ - Table
49
+ - Car
50
+ - Bicycle
51
+ - Bottle
52
+ - Bus
53
+ - Cup
54
+ - Boat
55
+
56
+ For more information about the original Exclusively Dark Image dataset,
57
+ please visit the official dataset page:
58
+
59
+ https://github.com/cs-chan/Exclusively-Dark-Image-Dataset
60
+
61
+ Please refer to the original dataset source for any additional details,
62
+ citations, or specific usage guidelines provided by the dataset creators.
63
+ """
64
+
65
+ _HOMEPAGE = "https://github.com/cs-chan/Exclusively-Dark-Image-Dataset"
66
+
67
+ _LICENSE = "bsd-3-clause"
68
+
69
+ _LABEL_NAMES = [
70
+ "Dog",
71
+ "Motorbike",
72
+ "People",
73
+ "Cat",
74
+ "Chair",
75
+ "Table",
76
+ "Car",
77
+ "Bicycle",
78
+ "Bottle",
79
+ "Bus",
80
+ "Cup",
81
+ "Boat",
82
+ ]
83
+
84
+
85
+ class ExDark(datasets.GeneratorBasedBuilder):
86
+ """Exclusively Dark (ExDARK) dataset"""
87
+
88
+ VERSION = datasets.Version("1.0.0")
89
+
90
+ BUILDER_CONFIGS = [
91
+ datasets.BuilderConfig(
92
+ name="exdark",
93
+ version=VERSION,
94
+ description="Exclusively Dark (ExDARK) dataset",
95
+ ),
96
+ ]
97
+
98
+ DEFAULT_CONFIG_NAME = "exdark"
99
+
100
+ def _info(self):
101
+ return datasets.DatasetInfo(
102
+ description=_DESCRIPTION,
103
+ features=datasets.Features(
104
+ {
105
+ "img": datasets.Image(),
106
+ "label": datasets.Sequence(
107
+ feature={
108
+ "class": datasets.ClassLabel(names=_LABEL_NAMES),
109
+ "x": datasets.Value("int32"),
110
+ "y": datasets.Value("int32"),
111
+ "w": datasets.Value("int32"),
112
+ "h": datasets.Value("int32"),
113
+ }
114
+ ),
115
+ }
116
+ ),
117
+ homepage=_HOMEPAGE,
118
+ license=_LICENSE,
119
+ citation=_CITATION,
120
+ )
121
+
122
+ def _split_generators(self, dl_manager):
123
+ data_dir = dl_manager.download_and_extract("ExDark.zip")
124
+
125
+ metadata_path = os.path.join(data_dir, "ExDark", "metadata.csv")
126
+
127
+ return [
128
+ datasets.SplitGenerator(
129
+ name=datasets.Split.TRAIN,
130
+ gen_kwargs={
131
+ "data_dir": data_dir,
132
+ "metadata_path": metadata_path,
133
+ "split": "train",
134
+ },
135
+ ),
136
+ ]
137
+
138
+ def _generate_examples(self, data_dir, metadata_path, split):
139
+ df = pd.read_csv(metadata_path)
140
+ classes = df["class"].unique()
141
+
142
+ df["class"] = df["class"].apply(lambda x: classes.tolist().index(x))
143
+
144
+ for idx, file_name in enumerate(df.file_name.unique()):
145
+ sample = df[df.file_name == file_name]
146
+ bboxs = sample[["x", "y", "w", "h"]].to_numpy()
147
+ labels = sample["class"].to_numpy()
148
+ yield idx, {
149
+ "img": file_name,
150
+ "label": {
151
+ "labels": labels,
152
+ "bboxes": bboxs,
153
+ },
154
+ }