Datasets:
VinayHajare
commited on
Commit
•
135cb72
1
Parent(s):
d148b96
Update fruits30.py
Browse files- fruits30.py +23 -9
fruits30.py
CHANGED
@@ -5,22 +5,37 @@ from .classes import FRUITS30_CLASSES
|
|
5 |
|
6 |
class fruits30(datasets.GeneratorBasedBuilder):
|
7 |
|
8 |
-
|
9 |
assert len(FRUITS30_CLASSES) == 30
|
10 |
return datasets.DatasetInfo(
|
11 |
-
description
|
12 |
-
|
13 |
-
features
|
14 |
{
|
15 |
"image": datasets.Image(),
|
16 |
-
"label": datasets.ClassLabel(names
|
17 |
}
|
18 |
),
|
19 |
-
homepage
|
20 |
-
task_templates
|
21 |
)
|
22 |
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
"""Yields examples."""
|
25 |
idx = 0
|
26 |
for archive in archives:
|
@@ -33,4 +48,3 @@ class fruits30(datasets.GeneratorBasedBuilder):
|
|
33 |
ex = {"image": {"path": path, "bytes": file.read()}, "label": label}
|
34 |
yield idx, ex
|
35 |
idx += 1
|
36 |
-
|
|
|
5 |
|
6 |
class fruits30(datasets.GeneratorBasedBuilder):
|
7 |
|
8 |
+
def _info(self):
|
9 |
assert len(FRUITS30_CLASSES) == 30
|
10 |
return datasets.DatasetInfo(
|
11 |
+
description="The fruits-30 is an image dataset for fruit image classification task."
|
12 |
+
" It contains high-quality images of 30 types of fruit with annotation using segmentation.",
|
13 |
+
features=datasets.Features(
|
14 |
{
|
15 |
"image": datasets.Image(),
|
16 |
+
"label": datasets.ClassLabel(names=list(FRUITS30_CLASSES.values())),
|
17 |
}
|
18 |
),
|
19 |
+
homepage="https://github.com/VinayHajare/Fruit-Image-Dataset",
|
20 |
+
task_templates=[ImageClassification(image_column="image", label_column="label")],
|
21 |
)
|
22 |
|
23 |
+
def _split_generators(self, dl_manager):
|
24 |
+
"""Returns SplitGenerators."""
|
25 |
+
data_dir = "./FruitImageDataset"
|
26 |
+
|
27 |
+
# Only return the "train" split
|
28 |
+
return [
|
29 |
+
datasets.SplitGenerator(
|
30 |
+
name=datasets.Split.TRAIN,
|
31 |
+
gen_kwargs={
|
32 |
+
"data_dir": data_dir,
|
33 |
+
"split": "train",
|
34 |
+
},
|
35 |
+
)
|
36 |
+
]
|
37 |
+
|
38 |
+
def _generate_examples(self, archives, split):
|
39 |
"""Yields examples."""
|
40 |
idx = 0
|
41 |
for archive in archives:
|
|
|
48 |
ex = {"image": {"path": path, "bytes": file.read()}, "label": label}
|
49 |
yield idx, ex
|
50 |
idx += 1
|
|