From 0ca0bf909e9e9bf7fda236811188027f1cf60c89 Mon Sep 17 00:00:00 2001 From: Kerry Jiang Date: Wed, 24 Jul 2019 22:48:35 -0700 Subject: [PATCH] fixed the path combining issue --- src/TensorFlowHub/MnistModelLoader.cs | 6 ++++++ src/TensorFlowHub/Utils.cs | 3 +++ 2 files changed, 9 insertions(+) diff --git a/src/TensorFlowHub/MnistModelLoader.cs b/src/TensorFlowHub/MnistModelLoader.cs index d3341f32..670fb0ac 100644 --- a/src/TensorFlowHub/MnistModelLoader.cs +++ b/src/TensorFlowHub/MnistModelLoader.cs @@ -93,6 +93,9 @@ namespace Tensorflow.Hub private NDArray ExtractImages(string file, int? limit = null) { + if (!Path.IsPathRooted(file)) + file = Path.Combine(AppContext.BaseDirectory, file); + using (var bytestream = new FileStream(file, FileMode.Open)) { var magic = Read32(bytestream); @@ -118,6 +121,9 @@ namespace Tensorflow.Hub private NDArray ExtractLabels(string file, bool one_hot = false, int num_classes = 10, int? limit = null) { + if (!Path.IsPathRooted(file)) + file = Path.Combine(AppContext.BaseDirectory, file); + using (var bytestream = new FileStream(file, FileMode.Open)) { var magic = Read32(bytestream); diff --git a/src/TensorFlowHub/Utils.cs b/src/TensorFlowHub/Utils.cs index 92828f0d..10aaf958 100644 --- a/src/TensorFlowHub/Utils.cs +++ b/src/TensorFlowHub/Utils.cs @@ -42,6 +42,9 @@ namespace Tensorflow.Hub if (!Directory.Exists(saveTo)) Directory.CreateDirectory(saveTo); + + if (!Path.IsPathRooted(zipFile)) + zipFile = Path.Combine(AppContext.BaseDirectory, zipFile); var destFilePath = Path.Combine(saveTo, Path.GetFileNameWithoutExtension(zipFile));