Datasets:
Tasks:
Image Classification
Formats:
parquet
Sub-tasks:
multi-class-image-classification
Languages:
English
Size:
1K - 10K
License:
Update files from the datasets library (from 1.18.0)
Browse filesRelease notes: https://github.com/huggingface/datasets/releases/tag/1.18.0
beans.py
CHANGED
@@ -14,7 +14,7 @@
|
|
14 |
# limitations under the License.
|
15 |
"""Beans leaf dataset with images of diseased and health leaves."""
|
16 |
|
17 |
-
|
18 |
|
19 |
import datasets
|
20 |
from datasets.tasks import ImageClassification
|
@@ -65,7 +65,7 @@ class Beans(datasets.GeneratorBasedBuilder):
|
|
65 |
supervised_keys=("image", "labels"),
|
66 |
homepage=_HOMEPAGE,
|
67 |
citation=_CITATION,
|
68 |
-
task_templates=[ImageClassification(image_column="image", label_column="labels"
|
69 |
)
|
70 |
|
71 |
def _split_generators(self, dl_manager):
|
@@ -74,24 +74,29 @@ class Beans(datasets.GeneratorBasedBuilder):
|
|
74 |
datasets.SplitGenerator(
|
75 |
name=datasets.Split.TRAIN,
|
76 |
gen_kwargs={
|
77 |
-
"
|
78 |
},
|
79 |
),
|
80 |
datasets.SplitGenerator(
|
81 |
name=datasets.Split.VALIDATION,
|
82 |
gen_kwargs={
|
83 |
-
"
|
84 |
},
|
85 |
),
|
86 |
datasets.SplitGenerator(
|
87 |
name=datasets.Split.TEST,
|
88 |
gen_kwargs={
|
89 |
-
"
|
90 |
},
|
91 |
),
|
92 |
]
|
93 |
|
94 |
-
def _generate_examples(self,
|
95 |
-
for i, path in enumerate(
|
96 |
-
|
97 |
-
|
|
|
|
|
|
|
|
|
|
|
|
14 |
# limitations under the License.
|
15 |
"""Beans leaf dataset with images of diseased and health leaves."""
|
16 |
|
17 |
+
import os
|
18 |
|
19 |
import datasets
|
20 |
from datasets.tasks import ImageClassification
|
|
|
65 |
supervised_keys=("image", "labels"),
|
66 |
homepage=_HOMEPAGE,
|
67 |
citation=_CITATION,
|
68 |
+
task_templates=[ImageClassification(image_column="image", label_column="labels")],
|
69 |
)
|
70 |
|
71 |
def _split_generators(self, dl_manager):
|
|
|
74 |
datasets.SplitGenerator(
|
75 |
name=datasets.Split.TRAIN,
|
76 |
gen_kwargs={
|
77 |
+
"files": dl_manager.iter_files([data_files["train"]]),
|
78 |
},
|
79 |
),
|
80 |
datasets.SplitGenerator(
|
81 |
name=datasets.Split.VALIDATION,
|
82 |
gen_kwargs={
|
83 |
+
"files": dl_manager.iter_files([data_files["validation"]]),
|
84 |
},
|
85 |
),
|
86 |
datasets.SplitGenerator(
|
87 |
name=datasets.Split.TEST,
|
88 |
gen_kwargs={
|
89 |
+
"files": dl_manager.iter_files([data_files["test"]]),
|
90 |
},
|
91 |
),
|
92 |
]
|
93 |
|
94 |
+
def _generate_examples(self, files):
|
95 |
+
for i, path in enumerate(files):
|
96 |
+
file_name = os.path.basename(path)
|
97 |
+
if file_name.endswith(".jpg"):
|
98 |
+
yield i, {
|
99 |
+
"image_file_path": path,
|
100 |
+
"image": path,
|
101 |
+
"labels": os.path.basename(os.path.dirname(path)).lower(),
|
102 |
+
}
|