Datasets:
Tasks:
Image Classification
Modalities:
Image
Formats:
imagefolder
Languages:
English
Size:
10K - 100K
License:
import os | |
from datasets import DatasetInfo, GeneratorBasedBuilder, Split, SplitGenerator, Value, Image, ClassLabel | |
_CATEGORIES = ["buildings", "forest", "glacier", "mountain", "sea", "street"] | |
class IntelImageClassification(GeneratorBasedBuilder): | |
def _info(self): | |
return DatasetInfo( | |
description="Intel Image Classification dataset with 6 natural scene categories.", | |
features={ | |
"image": Image(), | |
"label": ClassLabel(names=_CATEGORIES), | |
}, | |
supervised_keys=("image", "label"), | |
homepage="https://www.kaggle.com/datasets/puneet6060/intel-image-classification", | |
# citation="Puneet Jindal, Intel Image Classification (Kaggle Dataset)", | |
) | |
def _split_generators(self, dl_manager): | |
data_dir = os.path.join(dl_manager.manual_dir, "data") | |
return [ | |
SplitGenerator(name=Split.TRAIN, gen_kwargs={"filepath": os.path.join(data_dir, "seg_train")}), | |
SplitGenerator(name=Split.TEST, gen_kwargs={"filepath": os.path.join(data_dir, "seg_test")}), | |
SplitGenerator(name=Split.VALIDATION, gen_kwargs={"filepath": os.path.join(data_dir, "seg_pred")}), | |
] | |
def _generate_examples(self, filepath): | |
idx = 0 | |
for label in sorted(os.listdir(filepath)): | |
label_path = os.path.join(filepath, label) | |
if not os.path.isdir(label_path): | |
continue | |
for img_file in sorted(os.listdir(label_path)): | |
if img_file.lower().endswith((".jpg", ".jpeg", ".png")): | |
yield idx, { | |
"image": os.path.join(label_path, img_file), | |
"label": label, | |
} | |
idx += 1 | |