Update more details in Readme.md.
Browse files
README.md
CHANGED
|
@@ -1,20 +1,65 @@
|
|
| 1 |
---
|
| 2 |
license: mit
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
| 4 |
The ImageNet-A dataset contains 7,500 natural adversarial examples.
|
| 5 |
|
| 6 |
-
Source: https://github.com/hendrycks/natural-adv-examples.
|
| 7 |
-
Also see the ImageNet-C and ImageNet-P datasets at https://github.com/hendrycks/robustness
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
@article{hendrycks2019nae,
|
| 10 |
title={Natural Adversarial Examples},
|
| 11 |
author={Dan Hendrycks and Kevin Zhao and Steven Basart and Jacob Steinhardt and Dawn Song},
|
| 12 |
journal={arXiv preprint arXiv:1907.07174},
|
| 13 |
year={2019}
|
| 14 |
}
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
There are 200 classes we consider. The WordNet ID and a description of each class is as follows.
|
| 17 |
|
|
|
|
| 18 |
n01498041 stingray
|
| 19 |
n01531178 goldfinch
|
| 20 |
n01534433 junco
|
|
@@ -214,4 +259,5 @@ n09835506 baseball player
|
|
| 214 |
n11879895 rapeseed
|
| 215 |
n12057211 yellow lady's slipper
|
| 216 |
n12144580 corn
|
| 217 |
-
n12267677 acorn
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: mit
|
| 3 |
+
task_categories:
|
| 4 |
+
- image-classification
|
| 5 |
---
|
| 6 |
+
|
| 7 |
The ImageNet-A dataset contains 7,500 natural adversarial examples.
|
| 8 |
|
| 9 |
+
- Source: https://github.com/hendrycks/natural-adv-examples.
|
| 10 |
+
- Also see the ImageNet-C and ImageNet-P datasets at https://github.com/hendrycks/robustness
|
| 11 |
+
|
| 12 |
+
## Usage
|
| 13 |
+
|
| 14 |
+
```python
|
| 15 |
+
import os
|
| 16 |
+
import json
|
| 17 |
+
import io
|
| 18 |
+
|
| 19 |
+
from datasets import load_dataset
|
| 20 |
+
from huggingface_hub import snapshot_download
|
| 21 |
+
from PIL import Image
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
snapshot_download(repo_id="barkermrl/imagenet-a", repo_type="dataset", local_dir="./imagenet-a/")
|
| 25 |
+
imagenet_a = load_dataset("parquet", data_files="./imagenet-a/data/train-*.parquet")['train']
|
| 26 |
|
| 27 |
+
with open("./imagenet-a/dataset_infos.json", "r") as f:
|
| 28 |
+
infos = json.load(f)
|
| 29 |
+
class_names = infos["barkermrl--imagenet-a"]["features"]["label"]["names"]
|
| 30 |
+
|
| 31 |
+
imagenet_a = imagenet_a.map(lambda e: {"label_name": class_names[e["label"]]})
|
| 32 |
+
for sample in imagenet_a:
|
| 33 |
+
image = sample["image"]
|
| 34 |
+
image_bytes = image["bytes"]
|
| 35 |
+
image_path = image['path']
|
| 36 |
+
img = Image.open(io.BytesIO(image_bytes)).convert("RGB")
|
| 37 |
+
print(img.size, image_path)
|
| 38 |
+
|
| 39 |
+
label = sample['label']
|
| 40 |
+
print(type(label))
|
| 41 |
+
|
| 42 |
+
label_name = sample['label_name']
|
| 43 |
+
print(type(label_name), label_name)
|
| 44 |
+
break
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
## Reference
|
| 48 |
+
|
| 49 |
+
```bibtex
|
| 50 |
@article{hendrycks2019nae,
|
| 51 |
title={Natural Adversarial Examples},
|
| 52 |
author={Dan Hendrycks and Kevin Zhao and Steven Basart and Jacob Steinhardt and Dawn Song},
|
| 53 |
journal={arXiv preprint arXiv:1907.07174},
|
| 54 |
year={2019}
|
| 55 |
}
|
| 56 |
+
```
|
| 57 |
+
|
| 58 |
+
## Classes
|
| 59 |
|
| 60 |
There are 200 classes we consider. The WordNet ID and a description of each class is as follows.
|
| 61 |
|
| 62 |
+
```
|
| 63 |
n01498041 stingray
|
| 64 |
n01531178 goldfinch
|
| 65 |
n01534433 junco
|
|
|
|
| 259 |
n11879895 rapeseed
|
| 260 |
n12057211 yellow lady's slipper
|
| 261 |
n12144580 corn
|
| 262 |
+
n12267677 acorn
|
| 263 |
+
```
|