Datasets:
Add description feature
Browse files
CC6204-Hackaton-Cub-Dataset.py
CHANGED
@@ -81,9 +81,10 @@ class CubDataset(datasets.GeneratorBasedBuilder):
|
|
81 |
def _info(self):
|
82 |
features = datasets.Features({
|
83 |
"image": datasets.Image(),
|
84 |
-
"
|
|
|
85 |
})
|
86 |
-
keys = ("image", "
|
87 |
|
88 |
return datasets.DatasetInfo(
|
89 |
description=_DESCRIPTION,
|
@@ -102,7 +103,6 @@ class CubDataset(datasets.GeneratorBasedBuilder):
|
|
102 |
|
103 |
# Download images
|
104 |
data_files = dl_manager.download_and_extract(_URLS["image_urls"])
|
105 |
-
#data_files = dl_manager.download_and_extract(_URLS["mini_images_urls"])
|
106 |
path_files = dl_manager.iter_files(data_files)
|
107 |
for img in path_files:
|
108 |
img_idx = _IMGNAME2ID[os.path.basename(img)]
|
@@ -112,16 +112,6 @@ class CubDataset(datasets.GeneratorBasedBuilder):
|
|
112 |
else:
|
113 |
test_files.append(img)
|
114 |
test_idx.append(img_idx)
|
115 |
-
|
116 |
-
#for batch in data_files:
|
117 |
-
#path_files = dl_manager.iter_files(batch)
|
118 |
-
#for img in path_files:
|
119 |
-
#if img.endswith("\d+.jpg"):
|
120 |
-
#img_idx = _IMGNAME2ID[img]
|
121 |
-
#if img_idx in _TRAIN_IDX_SET:
|
122 |
-
#train_files.append(img)
|
123 |
-
#else:
|
124 |
-
#test_files.append(img)
|
125 |
|
126 |
return [
|
127 |
datasets.SplitGenerator(
|
@@ -148,6 +138,7 @@ class CubDataset(datasets.GeneratorBasedBuilder):
|
|
148 |
if file_name.endswith(".jpg"):
|
149 |
yield i, {
|
150 |
"image": path,
|
151 |
-
"
|
|
|
152 |
}
|
153 |
|
|
|
81 |
def _info(self):
|
82 |
features = datasets.Features({
|
83 |
"image": datasets.Image(),
|
84 |
+
"description": datasets.Value("string"),
|
85 |
+
"label": datasets.features.ClassLabel(names=_NAMES),
|
86 |
})
|
87 |
+
keys = ("image", "description", "label")
|
88 |
|
89 |
return datasets.DatasetInfo(
|
90 |
description=_DESCRIPTION,
|
|
|
103 |
|
104 |
# Download images
|
105 |
data_files = dl_manager.download_and_extract(_URLS["image_urls"])
|
|
|
106 |
path_files = dl_manager.iter_files(data_files)
|
107 |
for img in path_files:
|
108 |
img_idx = _IMGNAME2ID[os.path.basename(img)]
|
|
|
112 |
else:
|
113 |
test_files.append(img)
|
114 |
test_idx.append(img_idx)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
|
116 |
return [
|
117 |
datasets.SplitGenerator(
|
|
|
138 |
if file_name.endswith(".jpg"):
|
139 |
yield i, {
|
140 |
"image": path,
|
141 |
+
"description": "lala"
|
142 |
+
"label": _ID2LABEL[_IMGID2CLASSID[image_idx[i]]],
|
143 |
}
|
144 |
|