Update README.md
Browse files
README.md
CHANGED
@@ -19,4 +19,26 @@ configs:
|
|
19 |
---
|
20 |
# Dataset Card for "imagenet-1k-train-sampled2048"
|
21 |
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
---
|
20 |
# Dataset Card for "imagenet-1k-train-sampled2048"
|
21 |
|
22 |
+
```python
|
23 |
+
import numpy as np
|
24 |
+
from datasets import Dataset
|
25 |
+
import timm.data
|
26 |
+
|
27 |
+
|
28 |
+
def get_dataset():
|
29 |
+
dataset = timm.data.create_dataset(
|
30 |
+
root='[LOCAL IMAGENET FOLDER]',
|
31 |
+
name='',
|
32 |
+
split='train',
|
33 |
+
is_training=False,
|
34 |
+
)
|
35 |
+
sampled_indices = np.random.default_rng(42).choice(len(dataset), size=2048, replace=False)
|
36 |
+
images = [dataset[i][0] for i in sampled_indices]
|
37 |
+
labels = [dataset[i][1] for i in sampled_indices]
|
38 |
+
return images, labels
|
39 |
+
|
40 |
+
|
41 |
+
images, labels = get_dataset()
|
42 |
+
dataset = Dataset.from_dict({"image": images, "label": labels})
|
43 |
+
dataset.push_to_hub('yujiepan/imagenet-1k-train-sampled2048')
|
44 |
+
```
|