Download unearthedartifacts.py from Unearthed/unearthed_artifacts: direct link, hf CLI and curl.
- Browser
- Download file 1.41 kB
-
https://huggingface.co/datasets/Unearthed/unearthed_artifacts/resolve/main/unearthedartifacts.py
- Command line
-
hf download hf://datasets/Unearthed/unearthed_artifacts/unearthedartifacts.py
-
curl -L -o unearthedartifacts.py https://huggingface.co/datasets/Unearthed/unearthed_artifacts/resolve/main/unearthedartifacts.py
1.41 kB
| import tensorflow_datasets as tfds | |
| class UnearthedArtifacts(tfds.core.GeneratorBasedBuilder): | |
| VERSION = tfds.core.Version("1.0.0") | |
| def _info(self): | |
| return tfds.core.DatasetInfo( | |
| builder=self, | |
| description="Artifact image dataset.", | |
| features=tfds.features.FeaturesDict({ | |
| "image": tfds.features.Image(), | |
| "label": tfds.features.ClassLabel( | |
| names=["scrapers", "arrowheads", "axehammerstones"] | |
| ), | |
| }), | |
| supervised_keys=("image", "label"), | |
| ) | |
| def _split_generators(self, dl_manager): | |
| img_dir = r"C:\Users\chava\unearthed_artifacts_dataset" | |
| return { | |
| "train": self._generate_examples(img_dir), | |
| } | |
| def _generate_examples(self, img_dir): | |
| import os | |
| classes = ["scrapers", "arrowheads", "axehammerstones"] | |
| for label in classes: | |
| class_path = os.path.join(img_dir, label) | |
| if not os.path.exists(class_path): | |
| continue | |
| for img_name in os.listdir(class_path): | |
| if img_name.lower().endswith((".jpg", ".jpeg", ".png")): | |
| yield f"{label}_{img_name}", { | |
| "image": os.path.join(class_path, img_name), | |
| "label": label, | |
| } | |