Datasets:
Tasks:
Image Classification
Modalities:
Image
Formats:
imagefolder
Sub-tasks:
multi-class-image-classification
Languages:
English
Size:
< 1K
Tags:
image-classification
spark-plugs
edge-impulse
automotive
predictive-maintenance
computer-vision
License:
File size: 1,357 Bytes
b1ba503 |
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 |
import os
from datasets import DatasetInfo, GeneratorBasedBuilder, SplitGenerator, Split, Features, ClassLabel, Image
class SparkPlugClassification(GeneratorBasedBuilder):
def _info(self):
classes = ["carbon_fouled", "mechanical_damage", "normal", "oil_fouled"]
return DatasetInfo(
description="Spark Plug Condition Classification Dataset",
features=Features({
"image": Image(),
"label": ClassLabel(names=classes)
}),
supervised_keys=("image", "label"),
)
def _split_generators(self, dl_manager):
data_dir = os.path.join(dl_manager.manual_dir, "data")
return [
SplitGenerator(name=Split.TRAIN, gen_kwargs={"data_dir": data_dir}),
]
def _generate_examples(self, data_dir):
idx = 0
for label in sorted(os.listdir(data_dir)):
class_dir = os.path.join(data_dir, label)
if not os.path.isdir(class_dir):
continue
for fname in os.listdir(class_dir):
if fname.lower().endswith((".jpg", ".jpeg", ".png")):
path = os.path.join(class_dir, fname)
yield idx, {
"image": path,
"label": label
}
idx += 1
|