diff --git a/THIRD-PARTY-NOTICES.TXT b/THIRD-PARTY-NOTICES.TXT
index 778dd888df..ae6f0a7ec3 100644
--- a/THIRD-PARTY-NOTICES.TXT
+++ b/THIRD-PARTY-NOTICES.TXT
@@ -42,4 +42,27 @@ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+License notice for SharpZipLib
+------------------------------
+
+https://github.com/icsharpcode/SharpZipLib
+
+Copyright © 2000-2018 SharpZipLib Contributors
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this
+software and associated documentation files (the "Software"), to deal in the Software
+without restriction, including without limitation the rights to use, copy, modify, merge,
+publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
+to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or
+substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
+FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
\ No newline at end of file
diff --git a/docs/samples/Microsoft.ML.Samples/Dynamic/TensorFlow/ImageClassification.cs b/docs/samples/Microsoft.ML.Samples/Dynamic/TensorFlow/ImageClassification.cs
index 6b22c5816c..d97d7391a6 100644
--- a/docs/samples/Microsoft.ML.Samples/Dynamic/TensorFlow/ImageClassification.cs
+++ b/docs/samples/Microsoft.ML.Samples/Dynamic/TensorFlow/ImageClassification.cs
@@ -1,5 +1,9 @@
using System;
+using System.IO;
using System.Linq;
+using System.Net;
+using ICSharpCode.SharpZipLib.GZip;
+using ICSharpCode.SharpZipLib.Tar;
using Microsoft.ML.Data;
namespace Microsoft.ML.Samples.Dynamic
@@ -13,7 +17,14 @@ public static void Example()
{
// Download the ResNet 101 model from the location below.
// https://storage.googleapis.com/download.tensorflow.org/models/tflite_11_05_08/resnet_v2_101.tgz
- var modelLocation = @"resnet_v2_101/resnet_v2_101_299_frozen.pb";
+
+ string modelLocation = "resnet_v2_101_299_frozen.pb";
+ if (!File.Exists(modelLocation))
+ {
+ modelLocation = Download(@"https://storage.googleapis.com/download.tensorflow.org/models/tflite_11_05_08/resnet_v2_101.tgz", @"resnet_v2_101_299_frozen.tgz");
+ Unzip(Path.Join(Directory.GetCurrentDirectory(), modelLocation), Directory.GetCurrentDirectory());
+ modelLocation = "resnet_v2_101_299_frozen.pb";
+ }
var mlContext = new MLContext();
var data = GetTensorData();
@@ -22,7 +33,7 @@ public static void Example()
// Create a ML pipeline.
var pipeline = mlContext.Model.LoadTensorFlowModel(modelLocation).ScoreTensorFlowModel(
new[] { nameof(OutputScores.output) },
- new[] { nameof(TensorData.input) });
+ new[] { nameof(TensorData.input) }, addBatchDimensionInput: true);
// Run the pipeline and get the transformed values.
var estimator = pipeline.Fit(idv);
@@ -86,5 +97,31 @@ class OutputScores
{
public float[] output { get; set; }
}
+
+ private static string Download(string baseGitPath, string dataFile)
+ {
+ using (WebClient client = new WebClient())
+ {
+ client.DownloadFile(new Uri($"{baseGitPath}"), dataFile);
+ }
+
+ return dataFile;
+ }
+
+ ///
+ /// Taken from https://github.com/icsharpcode/SharpZipLib/wiki/GZip-and-Tar-Samples.
+ ///
+ private static void Unzip(string path, string targetDir)
+ {
+ Stream inStream = File.OpenRead(path);
+ Stream gzipStream = new GZipInputStream(inStream);
+
+ TarArchive tarArchive = TarArchive.CreateInputTarArchive(gzipStream);
+ tarArchive.ExtractContents(targetDir);
+ tarArchive.Close();
+
+ gzipStream.Close();
+ inStream.Close();
+ }
}
}
\ No newline at end of file
diff --git a/src/Microsoft.ML.SamplesUtils/Microsoft.ML.SamplesUtils.csproj b/src/Microsoft.ML.SamplesUtils/Microsoft.ML.SamplesUtils.csproj
index b7c0a83577..3fb71a6442 100644
--- a/src/Microsoft.ML.SamplesUtils/Microsoft.ML.SamplesUtils.csproj
+++ b/src/Microsoft.ML.SamplesUtils/Microsoft.ML.SamplesUtils.csproj
@@ -5,6 +5,10 @@
Microsoft.ML.SampleUtils
+
+
+
+