Skip to content

Commit

Permalink
[fbsync] Fix (Fashion|K)MNIST download and MNIST download test (#3557)
Browse files Browse the repository at this point in the history
Summary:
* add mirrors to (Fashion|K)MNIST

* fix download tests for MNIST

Reviewed By: fmassa

Differential Revision: D27128007

fbshipit-source-id: 2ca4bba7d8e823cdca3174f408f14e9e6e2e8346
  • Loading branch information
vincentqb authored and facebook-github-bot committed Mar 18, 2021
1 parent dc62ac3 commit 9acebc5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
3 changes: 2 additions & 1 deletion test/test_datasets_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ def voc():


def mnist():
return collect_download_configs(lambda: datasets.MNIST(ROOT, download=True), name="MNIST")
with unittest.mock.patch.object(datasets.MNIST, "mirrors", datasets.MNIST.mirrors[-1:]):
return collect_download_configs(lambda: datasets.MNIST(ROOT, download=True), name="MNIST")


def fashion_mnist():
Expand Down
28 changes: 16 additions & 12 deletions torchvision/datasets/mnist.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,15 @@ class FashionMNIST(MNIST):
target_transform (callable, optional): A function/transform that takes in the
target and transforms it.
"""
mirrors = [
"http://fashion-mnist.s3-website.eu-central-1.amazonaws.com/"
]

resources = [
("http://fashion-mnist.s3-website.eu-central-1.amazonaws.com/train-images-idx3-ubyte.gz",
"8d4fb7e6c68d591d4c3dfef9ec88bf0d"),
("http://fashion-mnist.s3-website.eu-central-1.amazonaws.com/train-labels-idx1-ubyte.gz",
"25c81989df183df01b3e8a0aad5dffbe"),
("http://fashion-mnist.s3-website.eu-central-1.amazonaws.com/t10k-images-idx3-ubyte.gz",
"bef4ecab320f06d8554ea6380940ec79"),
("http://fashion-mnist.s3-website.eu-central-1.amazonaws.com/t10k-labels-idx1-ubyte.gz",
"bb300cfdad3c16e7a12a480ee83cd310")
("train-images-idx3-ubyte.gz", "8d4fb7e6c68d591d4c3dfef9ec88bf0d"),
("train-labels-idx1-ubyte.gz", "25c81989df183df01b3e8a0aad5dffbe"),
("t10k-images-idx3-ubyte.gz", "bef4ecab320f06d8554ea6380940ec79"),
("t10k-labels-idx1-ubyte.gz", "bb300cfdad3c16e7a12a480ee83cd310")
]
classes = ['T-shirt/top', 'Trouser', 'Pullover', 'Dress', 'Coat', 'Sandal',
'Shirt', 'Sneaker', 'Bag', 'Ankle boot']
Expand All @@ -236,11 +236,15 @@ class KMNIST(MNIST):
target_transform (callable, optional): A function/transform that takes in the
target and transforms it.
"""
mirrors = [
"http://codh.rois.ac.jp/kmnist/dataset/kmnist/"
]

resources = [
("http://codh.rois.ac.jp/kmnist/dataset/kmnist/train-images-idx3-ubyte.gz", "bdb82020997e1d708af4cf47b453dcf7"),
("http://codh.rois.ac.jp/kmnist/dataset/kmnist/train-labels-idx1-ubyte.gz", "e144d726b3acfaa3e44228e80efcd344"),
("http://codh.rois.ac.jp/kmnist/dataset/kmnist/t10k-images-idx3-ubyte.gz", "5c965bf0a639b31b8f53240b1b52f4d7"),
("http://codh.rois.ac.jp/kmnist/dataset/kmnist/t10k-labels-idx1-ubyte.gz", "7320c461ea6c1c855c0b718fb2a4b134")
("train-images-idx3-ubyte.gz", "bdb82020997e1d708af4cf47b453dcf7"),
("train-labels-idx1-ubyte.gz", "e144d726b3acfaa3e44228e80efcd344"),
("t10k-images-idx3-ubyte.gz", "5c965bf0a639b31b8f53240b1b52f4d7"),
("t10k-labels-idx1-ubyte.gz", "7320c461ea6c1c855c0b718fb2a4b134")
]
classes = ['o', 'ki', 'su', 'tsu', 'na', 'ha', 'ma', 'ya', 're', 'wo']

Expand Down

0 comments on commit 9acebc5

Please sign in to comment.