Skip to content

Fixed #1105 -- datatsets downloaded and expanded to the wrong folder. #1107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Releases, starting with 9/2/2021, are listed with the most recent release at the
__Bug Fixes__:

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

## NuGet Version 0.100.5

Expand Down
2 changes: 1 addition & 1 deletion src/TorchVision/dsets/CIFAR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ protected void DownloadFile(string file, string target, string baseUrl)
if (!File.Exists(filePath)) {
lock (_httpClient) {
using var s = _httpClient.GetStreamAsync(netPath).Result;
using var fs = new FileStream(file, FileMode.CreateNew);
using var fs = new FileStream(filePath, FileMode.CreateNew);
s.CopyToAsync(fs).Wait();
}
}
Expand Down
12 changes: 12 additions & 0 deletions test/TorchSharpTest/TestTorchVisionDatasets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,17 @@ public void TestCelebaWithTransform()
}
});
}

[Fact]

public void TestMNISTDownload()
{
var data = torchvision.datasets.MNIST("TestMNISTDownload", true, true);

Assert.True(File.Exists(Path.Combine("TestMNISTDownload", "mnist", "train-images-idx3-ubyte.gz")));
Assert.True(File.Exists(Path.Combine("TestMNISTDownload", "mnist", "test_data", "train-images-idx3-ubyte")));
Assert.True(File.Exists(Path.Combine("TestMNISTDownload", "mnist", "t10k-images-idx3-ubyte.gz")));
Assert.True(File.Exists(Path.Combine("TestMNISTDownload", "mnist", "test_data", "t10k-images-idx3-ubyte")));
}
}
}