Skip to content

Commit 23ea326

Browse files
committed
fixed the path combining issue
1 parent 8f9f5e3 commit 23ea326

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

‎src/TensorFlowHub/MnistModelLoader.cs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ await this.UnzipAsync(Path.Combine(setting.TrainDir, TEST_LABELS), setting.Train
9393

9494
private NDArray ExtractImages(string file, int? limit = null)
9595
{
96+
if (!Path.IsPathRooted(file))
97+
file = Path.Combine(AppContext.BaseDirectory, file);
98+
9699
using (var bytestream = new FileStream(file, FileMode.Open))
97100
{
98101
var magic = Read32(bytestream);
@@ -118,6 +121,9 @@ private NDArray ExtractImages(string file, int? limit = null)
118121

119122
private NDArray ExtractLabels(string file, bool one_hot = false, int num_classes = 10, int? limit = null)
120123
{
124+
if (!Path.IsPathRooted(file))
125+
file = Path.Combine(AppContext.BaseDirectory, file);
126+
121127
using (var bytestream = new FileStream(file, FileMode.Open))
122128
{
123129
var magic = Read32(bytestream);

‎src/TensorFlowHub/Utils.cs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ public static async Task UnzipAsync<TDataSet>(this IModelLoader<TDataSet> modelL
4242

4343
if (!Directory.Exists(saveTo))
4444
Directory.CreateDirectory(saveTo);
45+
46+
if (!Path.IsPathRooted(zipFile))
47+
zipFile = Path.Combine(AppContext.BaseDirectory, zipFile);
4548

4649
var destFilePath = Path.Combine(saveTo, Path.GetFileNameWithoutExtension(zipFile));
4750

0 commit comments

Comments
 (0)