public void PrepareData()
        {
            // get model file
            string url = "http://download.tensorflow.org/models/object_detection/ssd_mobilenet_v1_coco_2018_01_28.tar.gz";

            Web.Download(url, modelDir, "ssd_mobilenet_v1_coco.tar.gz");

            Compress.ExtractTGZ(Path.Join(modelDir, "ssd_mobilenet_v1_coco.tar.gz"), "./");

            // download sample picture
            url = $"https://github.com/tensorflow/models/raw/master/research/object_detection/test_images/image2.jpg";
            Web.Download(url, imageDir, "input.jpg");

            // download the pbtxt file
            url = $"https://raw.githubusercontent.com/tensorflow/models/master/research/object_detection/data/mscoco_label_map.pbtxt";
            Web.Download(url, modelDir, "mscoco_label_map.pbtxt");
        }
        public override void PrepareData()
        {
            Directory.CreateDirectory(dir);

            // get model file
            string url = "https://storage.googleapis.com/download.tensorflow.org/models/inception_v3_2016_08_28_frozen.pb.tar.gz";

            Web.Download(url, dir, $"{pbFile}.tar.gz");

            Compress.ExtractTGZ(Path.Join(dir, $"{pbFile}.tar.gz"), dir);

            // download sample picture
            string pic = "grace_hopper.jpg";

            url = $"https://raw.githubusercontent.com/tensorflow/tensorflow/master/tensorflow/examples/label_image/data/{pic}";
            Web.Download(url, dir, pic);
        }
Beispiel #3
0
        public override void Train()
        {
            // get a set of images to teach the network about the new classes
            string fileName = "flower_photos.tgz";
            string dataDir  = "image_classification_v1";
            string url      = $"http://download.tensorflow.org/example_images/{fileName}";

            Web.Download(url, dataDir, fileName);
            Compress.ExtractTGZ(Path.Join(dataDir, fileName), dataDir);

            // using wizard to train model
            var wizard = new ModelWizard();
            var task   = wizard.AddImageClassificationTask <TransferLearning>(new TaskOptions
            {
                DataDir = @"image_classification_v1\flower_photos",
            });

            task.Train(new TrainingOptions());
        }
Beispiel #4
0
        public void PrepareData()
        {
            // get a set of images to teach the network about the new classes
            string fileName = "flower_photos.tgz";
            string url      = $"http://download.tensorflow.org/example_images/{fileName}";

            Web.Download(url, data_dir, fileName);
            Compress.ExtractTGZ(Path.Join(data_dir, fileName), data_dir);

            // download graph meta data
            url = "https://raw.githubusercontent.com/SciSharp/TensorFlow.NET/master/graph/InceptionV3.meta";
            Web.Download(url, "graph", "InceptionV3.meta");

            // download variables.data checkpoint file.
            url = "https://github.com/SciSharp/TensorFlow.NET/raw/master/data/tfhub_modules.zip";
            Web.Download(url, data_dir, "tfhub_modules.zip");
            Compress.UnZip(Path.Join(data_dir, "tfhub_modules.zip"), "tfhub_modules");

            // Prepare necessary directories that can be used during training
            Directory.CreateDirectory(summaries_dir);
            Directory.CreateDirectory(bottleneck_dir);

            // Look at the folder structure, and create lists of all the images.
            image_lists = create_image_lists();
            class_count = len(image_lists);
            if (class_count == 0)
            {
                print($"No valid folders of images found at {image_dir}");
            }
            if (class_count == 1)
            {
                print("Only one valid folder of images found at " +
                      image_dir +
                      " - multiple classes are needed for classification.");
            }
        }