1{
2 lib,
3 linkFarm,
4 fetchurl,
5 writers,
6 torch,
7 torchvision,
8 runCommand,
9}:
10let
11 fashionMnistDataset = linkFarm "fashion-mnist-dataset" (
12 lib.mapAttrsToList
13 (name: hash: {
14 inherit name;
15 path = fetchurl {
16 url = "http://fashion-mnist.s3-website.eu-central-1.amazonaws.com/${name}";
17 inherit hash;
18 };
19 })
20 {
21 "train-images-idx3-ubyte.gz" = "sha256-Ou3jjWGGOQiteGE/ajLtJxYm3RKAC6JjZWlRI2kmioQ=";
22 "train-labels-idx1-ubyte.gz" = "sha256-oE8XE0rANWCkfjdk4RuS/JfeTRv6+LoaOqKa9UzJCEU=";
23 "t10k-images-idx3-ubyte.gz" = "sha256-NG5VuUjZc6l+WNI1Hd4WpIS9QV1FlSl2M7sI8D22oHM=";
24 "t10k-labels-idx1-ubyte.gz" = "sha256-Z9oXx26v/KVEbDNhqqtcPNbRwmCHZNNd+xhQsIa/jdU=";
25 }
26 );
27
28 mnist-script = writers.writePython3 "test_mnist" {
29 libraries = [
30 torch
31 torchvision
32 ];
33 flakeIgnore = [ "E501" ];
34 } (builtins.readFile ./script.py);
35in
36runCommand "mnist" { } ''
37 mkdir -p data/FashionMNIST/raw
38
39 for archive in `ls ${fashionMnistDataset}`; do
40 gzip -d < "${fashionMnistDataset}/$archive" > data/FashionMNIST/raw/"''${archive%.*}"
41 done
42
43 ${mnist-script}
44
45 touch $out
46''