Upload folder using huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
dataset_info:
|
| 3 |
+
config_name: emnist-digits
|
| 4 |
+
features:
|
| 5 |
+
- name: image
|
| 6 |
+
dtype: image
|
| 7 |
+
- name: label
|
| 8 |
+
dtype:
|
| 9 |
+
class_label:
|
| 10 |
+
names:
|
| 11 |
+
'0': '0'
|
| 12 |
+
'1': '1'
|
| 13 |
+
'2': '2'
|
| 14 |
+
'3': '3'
|
| 15 |
+
'4': '4'
|
| 16 |
+
'5': '5'
|
| 17 |
+
'6': '6'
|
| 18 |
+
'7': '7'
|
| 19 |
+
'8': '8'
|
| 20 |
+
'9': '9'
|
| 21 |
+
splits:
|
| 22 |
+
- name: train
|
| 23 |
+
num_bytes: 102313112
|
| 24 |
+
num_examples: 240000
|
| 25 |
+
- name: test
|
| 26 |
+
num_bytes: 17047892
|
| 27 |
+
num_examples: 40000
|
| 28 |
+
download_size: 70361159
|
| 29 |
+
dataset_size: 119361004
|
| 30 |
+
---
|
| 31 |
+
|
| 32 |
+
# Dataset Card for "emnist-digits"
|
| 33 |
+
|
| 34 |
+
## Dataset Information
|
| 35 |
+
|
| 36 |
+
The `emnist-digits` dataset is a set of images of handwritten digits. The dataset is split into a training set and a test set.
|
| 37 |
+
|
| 38 |
+
## Data Fields
|
| 39 |
+
|
| 40 |
+
- `image`: The image of the handwritten digit. The data type of this field is `image`.
|
| 41 |
+
- `label`: The label of the handwritten digit. The data type of this field is `class_label`, and it can take on the values '0' to '9'.
|
| 42 |
+
|
| 43 |
+
## Data Splits
|
| 44 |
+
|
| 45 |
+
- `train`: The training set consists of 240000 examples, with a total size of 102313112 bytes.
|
| 46 |
+
- `test`: The test set consists of 40000 examples, with a total size of 17047892 bytes.
|
emnist_digits.py
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import struct
|
| 2 |
+
|
| 3 |
+
import numpy as np
|
| 4 |
+
|
| 5 |
+
import datasets
|
| 6 |
+
from datasets.tasks import ImageClassification
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
_URL = "./raw/"
|
| 10 |
+
_URLS = {
|
| 11 |
+
"train_images": "emnist-digits-train-images-idx3-ubyte.gz",
|
| 12 |
+
"train_labels": "emnist-digits-train-labels-idx1-ubyte.gz",
|
| 13 |
+
"test_images": "emnist-digits-test-images-idx3-ubyte.gz",
|
| 14 |
+
"test_labels": "emnist-digits-test-labels-idx1-ubyte.gz",
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class EMNIST(datasets.GeneratorBasedBuilder):
|
| 19 |
+
|
| 20 |
+
BUILDER_CONFIGS = [
|
| 21 |
+
datasets.BuilderConfig(
|
| 22 |
+
name="emnist-digits",
|
| 23 |
+
version=datasets.Version("1.0.0"),
|
| 24 |
+
)
|
| 25 |
+
]
|
| 26 |
+
|
| 27 |
+
def _info(self):
|
| 28 |
+
return datasets.DatasetInfo(
|
| 29 |
+
features=datasets.Features(
|
| 30 |
+
{
|
| 31 |
+
"image": datasets.Image(),
|
| 32 |
+
"label": datasets.features.ClassLabel(
|
| 33 |
+
names=["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
|
| 34 |
+
),
|
| 35 |
+
}
|
| 36 |
+
),
|
| 37 |
+
supervised_keys=("image", "label"),
|
| 38 |
+
task_templates=[
|
| 39 |
+
ImageClassification(
|
| 40 |
+
image_column="image",
|
| 41 |
+
label_column="label",
|
| 42 |
+
)
|
| 43 |
+
],
|
| 44 |
+
)
|
| 45 |
+
|
| 46 |
+
def _split_generators(self, dl_manager):
|
| 47 |
+
urls_to_download = {key: _URL + fname for key, fname in _URLS.items()}
|
| 48 |
+
downloaded_files = dl_manager.download_and_extract(urls_to_download)
|
| 49 |
+
return [
|
| 50 |
+
datasets.SplitGenerator(
|
| 51 |
+
name=datasets.Split.TRAIN,
|
| 52 |
+
gen_kwargs={
|
| 53 |
+
"filepath": (
|
| 54 |
+
downloaded_files["train_images"],
|
| 55 |
+
downloaded_files["train_labels"],
|
| 56 |
+
),
|
| 57 |
+
"split": "train",
|
| 58 |
+
},
|
| 59 |
+
),
|
| 60 |
+
datasets.SplitGenerator(
|
| 61 |
+
name=datasets.Split.TEST,
|
| 62 |
+
gen_kwargs={
|
| 63 |
+
"filepath": (
|
| 64 |
+
downloaded_files["test_images"],
|
| 65 |
+
downloaded_files["test_labels"],
|
| 66 |
+
),
|
| 67 |
+
"split": "test",
|
| 68 |
+
},
|
| 69 |
+
),
|
| 70 |
+
]
|
| 71 |
+
|
| 72 |
+
def _generate_examples(self, filepath, split):
|
| 73 |
+
"""This function returns the examples in the raw form."""
|
| 74 |
+
# Images
|
| 75 |
+
with open(filepath[0], "rb") as f:
|
| 76 |
+
# First 16 bytes contain some metadata
|
| 77 |
+
_ = f.read(4)
|
| 78 |
+
size = struct.unpack(">I", f.read(4))[0]
|
| 79 |
+
_ = f.read(8)
|
| 80 |
+
images = np.frombuffer(f.read(), dtype=np.uint8).reshape(size, 28, 28)
|
| 81 |
+
|
| 82 |
+
# Labels
|
| 83 |
+
with open(filepath[1], "rb") as f:
|
| 84 |
+
# First 8 bytes contain some metadata
|
| 85 |
+
_ = f.read(8)
|
| 86 |
+
labels = np.frombuffer(f.read(), dtype=np.uint8)
|
| 87 |
+
|
| 88 |
+
for idx in range(size):
|
| 89 |
+
yield idx, {"image": images[idx], "label": str(labels[idx])}
|
raw/emnist-digits-test-images-idx3-ubyte.gz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b8af2fa21489446ae2db650940730a8bb7f3a036f9af5fc812285780b7057749
|
| 3 |
+
size 10022836
|
raw/emnist-digits-test-labels-idx1-ubyte.gz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a41b8198a446725163f3cb3d8240184428646e89f9433433938d1bed4b42870a
|
| 3 |
+
size 19960
|
raw/emnist-digits-train-images-idx3-ubyte.gz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6eb259949d5f82adeac6ce30efa2fc43b3d3828102a812d5152ee395e66a2df2
|
| 3 |
+
size 60204504
|
raw/emnist-digits-train-labels-idx1-ubyte.gz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:53a1c3beae162946cd2f696a9a6ce20c17a28cf43fe35eb1b3c4dfa1d07d4c54
|
| 3 |
+
size 113859
|