Skip to content

Commit 824cc06

Browse files
Merge pull request #1107 from NiklasGustafsson/bugs
Fixed #1105 -- datatsets downloaded and expanded to the wrong folder.
2 parents fbb4b55 + aaa4161 commit 824cc06

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

RELEASENOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Releases, starting with 9/2/2021, are listed with the most recent release at the
77
__Bug Fixes__:
88

99
Update to SkiaSharp 2.88.6 to avoid the libwebp vulnerability.<br/>
10+
#1105: Dataset files get written to the wrong directory<br/>
1011

1112
## NuGet Version 0.100.5
1213

src/TorchVision/dsets/CIFAR.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ protected void DownloadFile(string file, string target, string baseUrl)
9292
if (!File.Exists(filePath)) {
9393
lock (_httpClient) {
9494
using var s = _httpClient.GetStreamAsync(netPath).Result;
95-
using var fs = new FileStream(file, FileMode.CreateNew);
95+
using var fs = new FileStream(filePath, FileMode.CreateNew);
9696
s.CopyToAsync(fs).Wait();
9797
}
9898
}

test/TorchSharpTest/TestTorchVisionDatasets.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,17 @@ public void TestCelebaWithTransform()
6666
}
6767
});
6868
}
69+
70+
[Fact]
71+
72+
public void TestMNISTDownload()
73+
{
74+
var data = torchvision.datasets.MNIST("TestMNISTDownload", true, true);
75+
76+
Assert.True(File.Exists(Path.Combine("TestMNISTDownload", "mnist", "train-images-idx3-ubyte.gz")));
77+
Assert.True(File.Exists(Path.Combine("TestMNISTDownload", "mnist", "test_data", "train-images-idx3-ubyte")));
78+
Assert.True(File.Exists(Path.Combine("TestMNISTDownload", "mnist", "t10k-images-idx3-ubyte.gz")));
79+
Assert.True(File.Exists(Path.Combine("TestMNISTDownload", "mnist", "test_data", "t10k-images-idx3-ubyte")));
80+
}
6981
}
7082
}

0 commit comments

Comments
 (0)