Datasets:

Languages:
English
Multilinguality:
monolingual
Size Categories:
10K<n<100K
Language Creators:
machine-generated
Source Datasets:
extended|fashion_mnist
ArXiv:
Tags:
License:

Support streaming

#3
by albertvillanova HF staff - opened
Files changed (2) hide show
  1. data.zip +3 -0
  2. fashion_mnist_corrupted.py +11 -11
data.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:008da37ffe6fd498247a6d4d4a29d0aba4fa694018087bd9816dcad4ef525265
3
+ size 27512552
fashion_mnist_corrupted.py CHANGED
@@ -3,7 +3,7 @@
3
  This module contains the huggingface dataset adaptation of
4
  the Corrupted Fashion-Mnist Data Set.
5
  Find the full code at `https://github.com/testingautomated-usi/fashion-mnist-c`."""
6
- import struct
7
 
8
  import datasets
9
  import numpy as np
@@ -38,11 +38,9 @@ if CONFIG.version == datasets.Version("1.0.0"):
38
  else:
39
  raise ValueError("Unsupported version.")
40
 
41
- _URL = (
42
- f"https://raw.githubusercontent.com/testingautomated-usi/fashion-mnist-c/{tag}/generated/npy/"
43
- )
44
-
45
- _URLS = {
46
  "train_images": "fmnist-c-train.npy",
47
  "train_labels": "fmnist-c-train-labels.npy",
48
  "test_images": "fmnist-c-test.npy",
@@ -86,10 +84,10 @@ class FashionMnistCorrupted(datasets.GeneratorBasedBuilder):
86
  )
87
 
88
  def _split_generators(self, dl_manager):
89
- urls_to_download = {
90
- key: _URL + fname for key, fname in _URLS.items()
 
91
  }
92
- downloaded_files = dl_manager.download_and_extract(urls_to_download)
93
 
94
  return [
95
  datasets.SplitGenerator(
@@ -117,8 +115,10 @@ class FashionMnistCorrupted(datasets.GeneratorBasedBuilder):
117
  def _generate_examples(self, filepath, split):
118
  """This function returns the examples in the raw form."""
119
  # Images
120
- images = np.load(filepath[0])
121
- labels = np.load(filepath[1])
 
 
122
 
123
  if images.shape[0] != labels.shape[0]:
124
  raise ValueError(
 
3
  This module contains the huggingface dataset adaptation of
4
  the Corrupted Fashion-Mnist Data Set.
5
  Find the full code at `https://github.com/testingautomated-usi/fashion-mnist-c`."""
6
+ import os.path
7
 
8
  import datasets
9
  import numpy as np
 
38
  else:
39
  raise ValueError("Unsupported version.")
40
 
41
+ # Downloaded from: f"https://raw.githubusercontent.com/testingautomated-usi/fashion-mnist-c/{tag}/generated/npy/
42
+ _URL = "data.zip"
43
+ _FILENAMES = {
 
 
44
  "train_images": "fmnist-c-train.npy",
45
  "train_labels": "fmnist-c-train-labels.npy",
46
  "test_images": "fmnist-c-test.npy",
 
84
  )
85
 
86
  def _split_generators(self, dl_manager):
87
+ data_dir = dl_manager.download_and_extract(_URL)
88
+ downloaded_files = {
89
+ key: os.path.join(data_dir, fname) for key, fname in _FILENAMES.items()
90
  }
 
91
 
92
  return [
93
  datasets.SplitGenerator(
 
115
  def _generate_examples(self, filepath, split):
116
  """This function returns the examples in the raw form."""
117
  # Images
118
+ with open(filepath[0], "rb") as f:
119
+ images = np.load(f)
120
+ with open(filepath[1], "rb") as f:
121
+ labels = np.load(f)
122
 
123
  if images.shape[0] != labels.shape[0]:
124
  raise ValueError(