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:
| 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 | |