Ejemplo n.º 1
0
        static async Task Main(string[] args)
        {
            try
            {
                var modelBuilder = new ModelTrainer(
                    ModelHelpers.GetAssetsPath("data", "tags.tsv"),
                    ModelHelpers.GetAssetsPath("images"),
                    ModelHelpers.GetAssetsPath("model", "tensorflow_inception_graph.pb"),
                    ModelHelpers.GetAssetsPath("model", "imageClassifier.zip"));

                await modelBuilder.BuildAndTrain();

                var modelEvaluator = new ModelEvaluator(
                    ModelHelpers.GetAssetsPath("data", "tags.tsv"),
                    ModelHelpers.GetAssetsPath("images"),
                    ModelHelpers.GetAssetsPath("model", "imageClassifier.zip"));

                await modelEvaluator.Evaluate();
            } catch (Exception ex)
            {
                Console.WriteLine("InnerException: {0}", ex.InnerException.ToString());
                throw;
            }

            Console.WriteLine("End of process");
            Console.ReadKey();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            var assetsPath = ModelHelpers.GetAssetsPath(@"..\..\..\assets");

            var tagsTsv      = Path.Combine(assetsPath, "inputs", "images", "tags.tsv");
            var imagesFolder = Path.Combine(assetsPath, "inputs", "images");
            var inceptionPb  = Path.Combine(assetsPath, "inputs", "custom-vision-tensorflow", "model.pb");
            var labelsTxt    = Path.Combine(assetsPath, "inputs", "custom-vision-tensorflow", "labels.txt");

            //var inceptionPb = Path.Combine(assetsPath, "inputs", "inception", "tensorflow_inception_graph.pb");
            //var labelsTxt = Path.Combine(assetsPath, "inputs", "inception", "imagenet_comp_graph_label_strings.txt");

            var customInceptionPb = Path.Combine(assetsPath, "inputs", "inception_custom", "model_tf.pb");
            var customLabelsTxt   = Path.Combine(assetsPath, "inputs", "inception_custom", "labels.txt");

            try
            {
                var modelScorer = new TFModelScorer(tagsTsv, imagesFolder, inceptionPb, labelsTxt);
                modelScorer.Score();
            }
            catch (Exception ex)
            {
                ConsoleHelpers.ConsoleWriteException(ex.Message);
            }

            ConsoleHelpers.ConsolePressAnyKey();
        }
        static async Task Main(string[] args)
        {
            // Running inside Visual Studio, $SolutionDir/assets is automatically passed as argument
            // If you execute from the console, pass as argument the location of the assets folder
            // Otherwise, it will search for assets in the executable's folder
            var assetsPath = args.Length > 0 ? args[0] : ModelHelpers.GetAssetsPath();

            var tagsTsv            = Path.Combine(assetsPath, "inputs", "data", "tags.tsv");
            var imagesFolder       = Path.Combine(assetsPath, "inputs", "data");
            var inceptionPb        = Path.Combine(assetsPath, "inputs", "inception", "tensorflow_inception_graph.pb");
            var imageClassifierZip = Path.Combine(assetsPath, "outputs", "imageClassifier.zip");

            try
            {
                var modelBuilder = new ModelTrainer(tagsTsv, imagesFolder, inceptionPb, imageClassifierZip);
                await modelBuilder.BuildAndTrain();

                //var modelEvaluator = new ModelEvaluator(
                //    ModelHelpers.GetAssetsPath("data", "tags.tsv"),
                //    ModelHelpers.GetAssetsPath("images"),
                //    ModelHelpers.GetAssetsPath("model", "imageClassifier.zip"));
                //await modelEvaluator.Evaluate();
            } catch (Exception ex)
            {
                Console.WriteLine($"Exception: {ex.Message}");
            }
            Console.ReadKey();
        }
Ejemplo n.º 4
0
        static async Task Main(string[] args)
        {
            var assetsPath = ModelHelpers.GetAssetsPath(@"..\..\..\assets");

            var tagsTsv            = Path.Combine(assetsPath, "inputs", "data", "tags.tsv");
            var imagesFolder       = Path.Combine(assetsPath, "inputs", "data");
            var imageClassifierZip = Path.Combine(assetsPath, "inputs", "imageClassifier.zip");

            try
            {
                var modelEvaluator = new ModelEvaluator(tagsTsv, imagesFolder, imageClassifierZip);
                modelEvaluator.EvaluateStaticApi();
            }
            catch (Exception ex)
            {
                ConsoleWriteException(ex.Message);
            }

            ConsolePressAnyKey();
        }
Ejemplo n.º 5
0
        static async Task Main(string[] args)
        {
            try
            {
                var modelBuilder = new ModelTrainer(
                    ModelHelpers.GetAssetsPath("data", "tags.tsv"),
                    ModelHelpers.GetAssetsPath("images"),
                    ModelHelpers.GetAssetsPath("model", "tensorflow_inception_graph.pb"),
                    ModelHelpers.GetAssetsPath("model", "imageClassifier.zip"));
                await modelBuilder.BuildAndTrain();

                var modelEvaluator = new ModelEvaluator(
                    ModelHelpers.GetAssetsPath("data", "tags.tsv"),
                    ModelHelpers.GetAssetsPath("images"),
                    ModelHelpers.GetAssetsPath("model", "imageClassifier.zip"));
                await modelEvaluator.Evaluate();
            } catch (Exception ex)
            {
            }
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            var assetsPath = ModelHelpers.GetAssetsPath(@"..\..\..\assets");

            var tagsTsv            = Path.Combine(assetsPath, "inputs", "data", "tags.tsv");
            var imagesFolder       = Path.Combine(assetsPath, "inputs", "data");
            var inceptionPb        = Path.Combine(assetsPath, "inputs", "inception", "tensorflow_inception_graph.pb");
            var imageClassifierZip = Path.Combine(assetsPath, "outputs", "imageClassifier.zip");

            try
            {
                var modelBuilder = new ModelBuilder(tagsTsv, imagesFolder, inceptionPb, imageClassifierZip);
                modelBuilder.BuildAndTrain();
            }
            catch (Exception ex)
            {
                ConsoleWriteException(ex.Message);
            }

            ConsolePressAnyKey();
        }
Ejemplo n.º 7
0
        static async Task Main(string[] args)
        {
            // Running inside Visual Studio, $SolutionDir/assets is automatically passed as argument
            // If you execute from the console, pass as argument the location of the assets folder
            // Otherwise, it will search for assets in the executable's folder
            var assetsPath = args.Length > 0 ? args[0] : ModelHelpers.GetAssetsPath();

            var salesCsv = Path.Combine(assetsPath, "inputs", "orderItems.csv");
            var modelZip = Path.Combine(assetsPath, "outputs", "productRecommendation.zip");

            try
            {
                var modelBuilder = new ModelBuilder(salesCsv, modelZip);
                await modelBuilder.BuildAndTrain();
            } catch (Exception ex)
            {
                Console.Out.WriteLine(ex.Message);
            }

            Console.ReadKey();
        }
        static async Task Main(string[] args)
        {
            // Running inside Visual Studio, $SolutionDir/assets is automatically passed as argument
            // If you execute from the console, pass as argument the location of the assets folder
            // Otherwise, it will search for assets in the executable's folder
            var assetsPath = args.Length > 0 ? args[0] : ModelHelpers.GetAssetsPath();

            var tagsTsv      = Path.Combine(assetsPath, "inputs", "data", "tags.tsv");
            var imagesFolder = Path.Combine(assetsPath, "inputs", "data");
            var inceptionPb  = Path.Combine(assetsPath, "inputs", "inception", "tensorflow_inception_graph.pb");
            var labelsTxt    = Path.Combine(assetsPath, "inputs", "inception", "imagenet_comp_graph_label_strings.txt");

            try
            {
                var modelEvaluator = new ModelScorer(tagsTsv, imagesFolder, inceptionPb, labelsTxt);
                modelEvaluator.Score();
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Exception: {ex.Message}");
            }
            Console.ReadKey();
        }
Ejemplo n.º 9
0
        static async Task Main(string[] args)
        {
            try
            {
                if (typeof(TensorFlowTransform) == null)
                {
                    throw new Exception("Tensorflow not loaded correctly");
                }

                if (typeof(ImageLoaderTransform) == null)
                {
                    throw new Exception("ImageAnalytics not loaded correctly");
                }

                var modelBuilder = new ModelTrainer(
                    ModelHelpers.GetAssetsPath("data", "tags.tsv"),
                    ModelHelpers.GetAssetsPath("images"),
                    ModelHelpers.GetAssetsPath("model", "tensorflow_inception_graph.pb"),
                    ModelHelpers.GetAssetsPath("model", "imageClassifier.zip"));

                await modelBuilder.BuildAndTrain();

                var modelEvaluator = new ModelEvaluator(
                    ModelHelpers.GetAssetsPath("data", "tags.tsv"),
                    ModelHelpers.GetAssetsPath("images"),
                    ModelHelpers.GetAssetsPath("model", "imageClassifier.zip"));

                await modelEvaluator.Evaluate();
            } catch (Exception ex)
            {
                Console.WriteLine("InnerException: {0}", ex.InnerException.ToString());
                throw;
            }

            Console.WriteLine("End of process");
            Console.ReadKey();
        }