albertvillanova HF staff commited on
Commit
77f3279
1 Parent(s): b06aab3

Convert dataset to Parquet (#7)

Browse files

- Convert dataset to Parquet (07b99472b005ad10a278dae540165d83134d7cbb)
- Delete loading script (1ba2c58cf0232c242af5c917516befc748b3df41)

README.md CHANGED
@@ -20,6 +20,7 @@ task_ids:
20
  paperswithcode_id: mnist
21
  pretty_name: MNIST
22
  dataset_info:
 
23
  features:
24
  - name: image
25
  dtype: image
@@ -37,16 +38,23 @@ dataset_info:
37
  '7': '7'
38
  '8': '8'
39
  '9': '9'
40
- config_name: mnist
41
  splits:
42
  - name: train
43
- num_bytes: 17470848
44
  num_examples: 60000
45
  - name: test
46
- num_bytes: 2916440
47
  num_examples: 10000
48
- download_size: 11594722
49
- dataset_size: 20387288
 
 
 
 
 
 
 
 
50
  ---
51
 
52
  # Dataset Card for MNIST
 
20
  paperswithcode_id: mnist
21
  pretty_name: MNIST
22
  dataset_info:
23
+ config_name: mnist
24
  features:
25
  - name: image
26
  dtype: image
 
38
  '7': '7'
39
  '8': '8'
40
  '9': '9'
 
41
  splits:
42
  - name: train
43
+ num_bytes: 17223300.0
44
  num_examples: 60000
45
  - name: test
46
+ num_bytes: 2875182.0
47
  num_examples: 10000
48
+ download_size: 18157506
49
+ dataset_size: 20098482.0
50
+ configs:
51
+ - config_name: mnist
52
+ data_files:
53
+ - split: train
54
+ path: mnist/train-*
55
+ - split: test
56
+ path: mnist/test-*
57
+ default: true
58
  ---
59
 
60
  # Dataset Card for MNIST
mnist.py DELETED
@@ -1,120 +0,0 @@
1
- # coding=utf-8
2
- # Copyright 2020 The TensorFlow Datasets Authors and the HuggingFace Datasets Authors.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
-
16
- # Lint as: python3
17
- """MNIST Data Set"""
18
-
19
-
20
- import struct
21
-
22
- import numpy as np
23
-
24
- import datasets
25
- from datasets.tasks import ImageClassification
26
-
27
-
28
- _CITATION = """\
29
- @article{lecun2010mnist,
30
- title={MNIST handwritten digit database},
31
- author={LeCun, Yann and Cortes, Corinna and Burges, CJ},
32
- journal={ATT Labs [Online]. Available: http://yann.lecun.com/exdb/mnist},
33
- volume={2},
34
- year={2010}
35
- }
36
- """
37
-
38
- _DESCRIPTION = """\
39
- The MNIST dataset consists of 70,000 28x28 black-and-white images in 10 classes (one for each digits), with 7,000
40
- images per class. There are 60,000 training images and 10,000 test images.
41
- """
42
-
43
- _URL = "https://storage.googleapis.com/cvdf-datasets/mnist/"
44
- _URLS = {
45
- "train_images": "train-images-idx3-ubyte.gz",
46
- "train_labels": "train-labels-idx1-ubyte.gz",
47
- "test_images": "t10k-images-idx3-ubyte.gz",
48
- "test_labels": "t10k-labels-idx1-ubyte.gz",
49
- }
50
-
51
-
52
- class MNIST(datasets.GeneratorBasedBuilder):
53
- """MNIST Data Set"""
54
-
55
- BUILDER_CONFIGS = [
56
- datasets.BuilderConfig(
57
- name="mnist",
58
- version=datasets.Version("1.0.0"),
59
- description=_DESCRIPTION,
60
- )
61
- ]
62
-
63
- def _info(self):
64
- return datasets.DatasetInfo(
65
- description=_DESCRIPTION,
66
- features=datasets.Features(
67
- {
68
- "image": datasets.Image(),
69
- "label": datasets.features.ClassLabel(names=["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]),
70
- }
71
- ),
72
- supervised_keys=("image", "label"),
73
- homepage="http://yann.lecun.com/exdb/mnist/",
74
- citation=_CITATION,
75
- task_templates=[
76
- ImageClassification(
77
- image_column="image",
78
- label_column="label",
79
- )
80
- ],
81
- )
82
-
83
- def _split_generators(self, dl_manager):
84
- urls_to_download = {key: _URL + fname for key, fname in _URLS.items()}
85
- downloaded_files = dl_manager.download_and_extract(urls_to_download)
86
- return [
87
- datasets.SplitGenerator(
88
- name=datasets.Split.TRAIN,
89
- gen_kwargs={
90
- "filepath": (downloaded_files["train_images"], downloaded_files["train_labels"]),
91
- "split": "train",
92
- },
93
- ),
94
- datasets.SplitGenerator(
95
- name=datasets.Split.TEST,
96
- gen_kwargs={
97
- "filepath": (downloaded_files["test_images"], downloaded_files["test_labels"]),
98
- "split": "test",
99
- },
100
- ),
101
- ]
102
-
103
- def _generate_examples(self, filepath, split):
104
- """This function returns the examples in the raw form."""
105
- # Images
106
- with open(filepath[0], "rb") as f:
107
- # First 16 bytes contain some metadata
108
- _ = f.read(4)
109
- size = struct.unpack(">I", f.read(4))[0]
110
- _ = f.read(8)
111
- images = np.frombuffer(f.read(), dtype=np.uint8).reshape(size, 28, 28)
112
-
113
- # Labels
114
- with open(filepath[1], "rb") as f:
115
- # First 8 bytes contain some metadata
116
- _ = f.read(8)
117
- labels = np.frombuffer(f.read(), dtype=np.uint8)
118
-
119
- for idx in range(size):
120
- yield idx, {"image": images[idx], "label": str(labels[idx])}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
mnist/test-00000-of-00001.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d49fcf556ce25b002b302e318ce4a11098bbfe5d4499c3f35d7c72297c52374b
3
+ size 2595890
mnist/train-00000-of-00001.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f2c01285a9f89399335b00ee4e8d499dc4e46db5e39c74903ce5618d895eb3bf
3
+ size 15561616