Datasets:
Tasks:
Image Classification
Sub-tasks:
multi-class-image-classification
Languages:
English
Size:
1K<n<10K
License:
| """Rock Glacier dataset with images of the chilean andes""" | |
| import os | |
| import datasets | |
| from datasets.tasks import ImageClassification | |
| _HOMEPAGE = "https://github.com/alcazar90/rock-glacier-detection" | |
| _CITATION = """\ | |
| @ONLINE {rock-glacier-dataset, | |
| author="CMM-Glaciares", | |
| title="Rock Glacier Dataset", | |
| month="October", | |
| year="2022", | |
| url="https://github.com/alcazar90/rock-glacier-detection" | |
| } | |
| """ | |
| _DESCRIPTION = """\ | |
| TODO: Add a description... | |
| """ | |
| _URLS = { | |
| "train": "https://huggingface.co/datasets/alkzar90/rock-glacier-dataset/resolve/main/data/train.tar.gz", | |
| "validation": "https://huggingface.co/datasets/alkzar90/rock-glacier-dataset/resolve/main/data/validation.tar.gz" | |
| } | |
| _NAMES = ["glaciar", "cordillera"] | |
| class RockGlacierDataset(datasets.GeneratorBasedBuilder): | |
| """Rock Glacier images dataset.""" | |
| def _info(self): | |
| return datasets.DatasetInfo( | |
| description=_DESCRIPTION, | |
| features=datasets.Features( | |
| { | |
| "image": datasets.Image(), | |
| "labels": datasets.features.ClassLabel(names=_NAMES), | |
| } | |
| ), | |
| supervised_keys=("image", "labels"), | |
| homepage=_HOMEPAGE, | |
| citation=_CITATION, | |
| task_templates=[ImageClassification(image_column="image", label_column="labels")], | |
| ) | |
| def _split_generators(self, dl_manager): | |
| data_files = dl_manager.download_and_extract(_URLS) | |
| return [ | |
| datasets.SplitGenerator( | |
| name=datasets.Split.TRAIN, | |
| gen_kwargs={ | |
| "files": dl_manager.iter_files([data_files["train"]]), | |
| }, | |
| ), | |
| datasets.SplitGenerator( | |
| name=datasets.Split.VALIDATION, | |
| gen_kwargs={ | |
| "files": dl_manager.iter_files([data_files["validation"]]), | |
| }, | |
| ), | |
| ] | |
| def _generate_examples(self, files): | |
| for i, path in enumerate(files): | |
| file_name = os.path.basename(path) | |
| if file_name.endswith(".png"): | |
| yield i, { | |
| "image": path, | |
| "labels": os.path.basename(os.path.dirname(path)).lower(), | |
| } | |