From cffc950509495c8687d0173bd70944d38de514df Mon Sep 17 00:00:00 2001 From: Oceania2018 Date: Wed, 31 Jul 2019 06:59:49 -0500 Subject: [PATCH] Add TensorFlowDatasets project. --- TensorFlow.NET.sln | 8 +- src/TensorFlowDatasets/DatasetBuilder.cs | 24 ++++++ src/TensorFlowDatasets/DownloadConfig.cs | 10 +++ .../TensorFlowDatasets.csproj | 19 +++++ .../ImageProcessing/CIFAR10-CNN.cs | 74 +++++++++++++++++++ .../ImageProcessing/DigitRecognitionCNN.cs | 2 +- .../ImageProcessing/DigitRecognitionNN.cs | 2 +- .../ImageProcessing/DigitRecognitionRNN.cs | 2 +- .../ImageProcessing/ImageBackgroundRemoval.cs | 2 +- .../ImageProcessing/RetrainImageClassifier.cs | 2 +- .../TensorFlowNET.Examples.csproj | 1 + 11 files changed, 140 insertions(+), 6 deletions(-) create mode 100644 src/TensorFlowDatasets/DatasetBuilder.cs create mode 100644 src/TensorFlowDatasets/DownloadConfig.cs create mode 100644 src/TensorFlowDatasets/TensorFlowDatasets.csproj create mode 100644 test/TensorFlowNET.Examples/ImageProcessing/CIFAR10-CNN.cs diff --git a/TensorFlow.NET.sln b/TensorFlow.NET.sln index 5d6e5fe7..542d09c1 100644 --- a/TensorFlow.NET.sln +++ b/TensorFlow.NET.sln @@ -17,7 +17,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TensorFlowBenchmark", "src\ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TensorFlowHub", "src\TensorFlowHub\TensorFlowHub.csproj", "{8FD59A5A-97EB-457E-B9F1-D88B0C822C6E}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TensorFlowText", "src\TensorFlowText\TensorFlowText.csproj", "{B598E5D5-BD2D-4191-8532-F2FBAC31AB81}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TensorFlowText", "src\TensorFlowText\TensorFlowText.csproj", "{B598E5D5-BD2D-4191-8532-F2FBAC31AB81}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TensorFlowDatasets", "src\TensorFlowDatasets\TensorFlowDatasets.csproj", "{DF151A51-E9FD-41BD-B0F4-08A743755D44}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -57,6 +59,10 @@ Global {B598E5D5-BD2D-4191-8532-F2FBAC31AB81}.Debug|Any CPU.Build.0 = Debug|Any CPU {B598E5D5-BD2D-4191-8532-F2FBAC31AB81}.Release|Any CPU.ActiveCfg = Release|Any CPU {B598E5D5-BD2D-4191-8532-F2FBAC31AB81}.Release|Any CPU.Build.0 = Release|Any CPU + {DF151A51-E9FD-41BD-B0F4-08A743755D44}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DF151A51-E9FD-41BD-B0F4-08A743755D44}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DF151A51-E9FD-41BD-B0F4-08A743755D44}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DF151A51-E9FD-41BD-B0F4-08A743755D44}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/TensorFlowDatasets/DatasetBuilder.cs b/src/TensorFlowDatasets/DatasetBuilder.cs new file mode 100644 index 00000000..bfb78d6e --- /dev/null +++ b/src/TensorFlowDatasets/DatasetBuilder.cs @@ -0,0 +1,24 @@ +using System; + +namespace TensorFlowDatasets +{ + /// + /// Abstract base class for all datasets. + /// + public class DatasetBuilder + { + /// + /// Downloads and prepares dataset for reading. + /// + /// + /// directory where downloaded files are stored. + /// + /// + /// further configuration for downloading and preparing dataset. + /// + public void download_and_prepare(string download_dir = null, DownloadConfig download_config = null) + { + + } + } +} diff --git a/src/TensorFlowDatasets/DownloadConfig.cs b/src/TensorFlowDatasets/DownloadConfig.cs new file mode 100644 index 00000000..0488e273 --- /dev/null +++ b/src/TensorFlowDatasets/DownloadConfig.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace TensorFlowDatasets +{ + public class DownloadConfig + { + } +} diff --git a/src/TensorFlowDatasets/TensorFlowDatasets.csproj b/src/TensorFlowDatasets/TensorFlowDatasets.csproj new file mode 100644 index 00000000..1b839c1f --- /dev/null +++ b/src/TensorFlowDatasets/TensorFlowDatasets.csproj @@ -0,0 +1,19 @@ + + + + netcoreapp2.2 + SciSharp.TensorFlowDatasets + 0.0.1 + SciSharp Team + TensorFlow Datasets + true + https://avatars3.githubusercontent.com/u/44989469?s=200&v=4 + http://scisharpstack.org + TensorFlow Datasets provides many public datasets as tf.data.Datasets. + https://github.com/SciSharp/TensorFlow.NET + git + SciSharp, Dataset, TensorFlow + Apache 2.0 + + + diff --git a/test/TensorFlowNET.Examples/ImageProcessing/CIFAR10-CNN.cs b/test/TensorFlowNET.Examples/ImageProcessing/CIFAR10-CNN.cs new file mode 100644 index 00000000..a77a5b00 --- /dev/null +++ b/test/TensorFlowNET.Examples/ImageProcessing/CIFAR10-CNN.cs @@ -0,0 +1,74 @@ +/***************************************************************************** + Copyright 2018 The TensorFlow.NET Authors. All Rights Reserved. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +******************************************************************************/ + +using System; +using System.Collections.Generic; +using System.Text; +using Tensorflow; +using TensorFlowDatasets; +using static Tensorflow.Python; + +namespace TensorFlowNET.Examples +{ + /// + /// https://www.tensorflow.org/tutorials/images/deep_cnn + /// + public class CIFAR10_CNN : IExample + { + public bool Enabled { get; set; } = true; + public bool IsImportingGraph { get; set; } = false; + + public string Name => "CIFAR-10 CNN"; + + public bool Run() + { + PrepareData(); + + return true; + } + + public Graph BuildGraph() + { + throw new NotImplementedException(); + } + + public Graph ImportGraph() + { + throw new NotImplementedException(); + } + + public void Predict(Session sess) + { + throw new NotImplementedException(); + } + + public void PrepareData() + { + var tfds = new DatasetBuilder(); + tfds.download_and_prepare(); + } + + public void Test(Session sess) + { + throw new NotImplementedException(); + } + + public void Train(Session sess) + { + throw new NotImplementedException(); + } + } +} diff --git a/test/TensorFlowNET.Examples/ImageProcessing/DigitRecognitionCNN.cs b/test/TensorFlowNET.Examples/ImageProcessing/DigitRecognitionCNN.cs index d2a1b9f4..ac763da2 100644 --- a/test/TensorFlowNET.Examples/ImageProcessing/DigitRecognitionCNN.cs +++ b/test/TensorFlowNET.Examples/ImageProcessing/DigitRecognitionCNN.cs @@ -21,7 +21,7 @@ using Tensorflow; using Tensorflow.Hub; using static Tensorflow.Python; -namespace TensorFlowNET.Examples.ImageProcess +namespace TensorFlowNET.Examples { /// /// Convolutional Neural Network classifier for Hand Written Digits diff --git a/test/TensorFlowNET.Examples/ImageProcessing/DigitRecognitionNN.cs b/test/TensorFlowNET.Examples/ImageProcessing/DigitRecognitionNN.cs index 059c5419..e604afff 100644 --- a/test/TensorFlowNET.Examples/ImageProcessing/DigitRecognitionNN.cs +++ b/test/TensorFlowNET.Examples/ImageProcessing/DigitRecognitionNN.cs @@ -20,7 +20,7 @@ using Tensorflow; using Tensorflow.Hub; using static Tensorflow.Python; -namespace TensorFlowNET.Examples.ImageProcess +namespace TensorFlowNET.Examples { /// /// Neural Network classifier for Hand Written Digits diff --git a/test/TensorFlowNET.Examples/ImageProcessing/DigitRecognitionRNN.cs b/test/TensorFlowNET.Examples/ImageProcessing/DigitRecognitionRNN.cs index babf62f3..f769371a 100644 --- a/test/TensorFlowNET.Examples/ImageProcessing/DigitRecognitionRNN.cs +++ b/test/TensorFlowNET.Examples/ImageProcessing/DigitRecognitionRNN.cs @@ -20,7 +20,7 @@ using Tensorflow; using Tensorflow.Hub; using static Tensorflow.Python; -namespace TensorFlowNET.Examples.ImageProcess +namespace TensorFlowNET.Examples { /// /// Recurrent Neural Network for handwritten digits MNIST. diff --git a/test/TensorFlowNET.Examples/ImageProcessing/ImageBackgroundRemoval.cs b/test/TensorFlowNET.Examples/ImageProcessing/ImageBackgroundRemoval.cs index c43c853a..db148f14 100644 --- a/test/TensorFlowNET.Examples/ImageProcessing/ImageBackgroundRemoval.cs +++ b/test/TensorFlowNET.Examples/ImageProcessing/ImageBackgroundRemoval.cs @@ -4,7 +4,7 @@ using Tensorflow; using TensorFlowNET.Examples.Utility; using static Tensorflow.Python; -namespace TensorFlowNET.Examples.ImageProcess +namespace TensorFlowNET.Examples { /// /// This example removes the background from an input image. diff --git a/test/TensorFlowNET.Examples/ImageProcessing/RetrainImageClassifier.cs b/test/TensorFlowNET.Examples/ImageProcessing/RetrainImageClassifier.cs index 4d3a858f..96da8d1c 100644 --- a/test/TensorFlowNET.Examples/ImageProcessing/RetrainImageClassifier.cs +++ b/test/TensorFlowNET.Examples/ImageProcessing/RetrainImageClassifier.cs @@ -25,7 +25,7 @@ using Tensorflow; using TensorFlowNET.Examples.Utility; using static Tensorflow.Python; -namespace TensorFlowNET.Examples.ImageProcess +namespace TensorFlowNET.Examples { /// /// In this tutorial, we will reuse the feature extraction capabilities from powerful image classifiers trained on ImageNet diff --git a/test/TensorFlowNET.Examples/TensorFlowNET.Examples.csproj b/test/TensorFlowNET.Examples/TensorFlowNET.Examples.csproj index 6184d4ad..f4e2340a 100644 --- a/test/TensorFlowNET.Examples/TensorFlowNET.Examples.csproj +++ b/test/TensorFlowNET.Examples/TensorFlowNET.Examples.csproj @@ -16,6 +16,7 @@ +