Upload 3 files
Browse files- Realistic-Occlusion-Dataset.py +70 -0
- classes_rod.py +23 -0
- dataset_info.json +1 -0
Realistic-Occlusion-Dataset.py
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
|
| 3 |
+
import datasets
|
| 4 |
+
from datasets.tasks import ImageClassification
|
| 5 |
+
|
| 6 |
+
from .classes_rod import ROD_CLASSES
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
_CITATION = """\
|
| 10 |
+
@article{BibTeX
|
| 11 |
+
}
|
| 12 |
+
"""
|
| 13 |
+
|
| 14 |
+
_HOMEPAGE = "https://arielnlee.github.io/PatchMixing/"
|
| 15 |
+
|
| 16 |
+
_DESCRIPTION = """\
|
| 17 |
+
ROD is meant to serve as a metric for evaluating models' robustness to occlusion. It is the product of a meticulous object collection protocol aimed at collecting and capturing 40+ distinct, real-world objects from 16 classes.
|
| 18 |
+
"""
|
| 19 |
+
|
| 20 |
+
_DATA_URL = {
|
| 21 |
+
"rod": [
|
| 22 |
+
f"https://huggingface.co/datasets/ariellee/Realistic-Occlusion-Dataset/resolve/main/rod_{i}.tar.gz"
|
| 23 |
+
for i in range(2)
|
| 24 |
+
]
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
class ROD(datasets.GeneratorBasedBuilder):
|
| 29 |
+
VERSION = datasets.Version("1.0.0")
|
| 30 |
+
|
| 31 |
+
DEFAULT_WRITER_BATCH_SIZE = 16
|
| 32 |
+
|
| 33 |
+
def _info(self):
|
| 34 |
+
assert len(ROD_CLASSES) == 16
|
| 35 |
+
return datasets.DatasetInfo(
|
| 36 |
+
description=_DESCRIPTION,
|
| 37 |
+
features=datasets.Features(
|
| 38 |
+
{
|
| 39 |
+
"image": datasets.Image(),
|
| 40 |
+
"label": datasets.ClassLabel(names=list(ROD_CLASSES.values())),
|
| 41 |
+
}
|
| 42 |
+
),
|
| 43 |
+
homepage=_HOMEPAGE,
|
| 44 |
+
citation=_CITATION,
|
| 45 |
+
task_templates=[ImageClassification(image_column="image", label_column="label")],
|
| 46 |
+
)
|
| 47 |
+
|
| 48 |
+
def _split_generators(self, dl_manager):
|
| 49 |
+
"""Returns SplitGenerators."""
|
| 50 |
+
archives = dl_manager.download(_DATA_URL)
|
| 51 |
+
|
| 52 |
+
return [
|
| 53 |
+
datasets.SplitGenerator(
|
| 54 |
+
name="ROD",
|
| 55 |
+
gen_kwargs={
|
| 56 |
+
"archives": [dl_manager.iter_archive(archive) for archive in archives["rod"]],
|
| 57 |
+
},
|
| 58 |
+
),
|
| 59 |
+
]
|
| 60 |
+
|
| 61 |
+
def _generate_examples(self, archives):
|
| 62 |
+
"""Yields examples."""
|
| 63 |
+
idx = 0
|
| 64 |
+
for archive in archives:
|
| 65 |
+
for path, file in archive:
|
| 66 |
+
if path.endswith(".jpg"):
|
| 67 |
+
synset_id = os.path.basename(os.path.dirname(path))
|
| 68 |
+
ex = {"image": {"path": path, "bytes": file.read()}, "label": synset_id}
|
| 69 |
+
yield idx, ex
|
| 70 |
+
idx += 1
|
classes_rod.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from collections import OrderedDict
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
ROD_CLASSES = OrderedDict(
|
| 5 |
+
{
|
| 6 |
+
1: "banana",
|
| 7 |
+
2: "baseball",
|
| 8 |
+
3: "cowboy hat",
|
| 9 |
+
4: "cup",
|
| 10 |
+
5: "dumbbell",
|
| 11 |
+
6: "hammer",
|
| 12 |
+
7: "laptop",
|
| 13 |
+
8: "microwave",
|
| 14 |
+
9: "mouse",
|
| 15 |
+
10: "orange",
|
| 16 |
+
11: "pillow",
|
| 17 |
+
12: "plate",
|
| 18 |
+
13: "screwdriver",
|
| 19 |
+
14: "skillet",
|
| 20 |
+
15: "spatula",
|
| 21 |
+
16: "vase",
|
| 22 |
+
}
|
| 23 |
+
)
|
dataset_info.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"description": "ROD is meant to serve as a metric for evaluating models' robustness to occlusion. It is the product of a meticulous object collection protocol aimed at collecting and capturing 40+ distinct, real-world objects from 16 classes.\n", "citation": "@article{BibTeX\n}\n", "homepage": "https://arielnlee.github.io/PatchMixing/", "license": "", "features": {"image": {"_type": "Image"}, "label": {"names": ["banana", "baseball", "cowboy hat", "cup", "dumbbell", "hammer", "laptop", "microwave", "mouse", "orange", "pillow", "plate", "screwdriver", "skillet", "spatula", "vase"], "_type": "ClassLabel"}}, "task_templates": [{"task": "image-classification", "label_column": "label"}], "builder_name": "realistic-occlusion-dataset", "config_name": "default", "version": {"version_str": "1.0.0", "major": 1, "minor": 0, "patch": 0}, "splits": {"ROD": {"name": "ROD", "num_bytes": 3306212413, "num_examples": 1231, "shard_lengths": [272, 192, 144, 192, 224, 144, 63], "dataset_name": "realistic-occlusion-dataset"}}, "download_checksums": {"https://huggingface.co/datasets/ariellee/Realistic-Occlusion-Dataset/resolve/main/rod_0.tar.gz": {"num_bytes": 1350865094, "checksum": null}, "https://huggingface.co/datasets/ariellee/Realistic-Occlusion-Dataset/resolve/main/rod_1.tar.gz": {"num_bytes": 1934272362, "checksum": null}}, "download_size": 3285137456, "dataset_size": 3306212413, "size_in_bytes": 6591349869}
|