Esempio n. 1
0
        public async Task Init(System.Net.DownloadProgressChangedEventHandler onDownloadProgressChanged = null)
#endif
        {
            _blobFile = new DownloadableFile(
                "https://github.com/emgucv/models/raw/master/DepthAI/mobilenet-ssd/mobilenet-ssd.blob.sh14cmx14NCE1",
                _modelFolderName,
                "952C8AA1759CAB442D82781579EE4B9BA828CBED8AB9AD3C94D5222AA45DCA6E");
            _blobConfigFile = new DownloadableFile(
                "https://github.com/emgucv/models/raw/master/DepthAI/mobilenet-ssd/mobilenet-ssd.json",
                _modelFolderName,
                "606A965DDF539857D3477AED659A69948D8B310A20B38C3B794F2369ECC685FE");

            if (_manager == null)
            {
                _manager = new FileDownloadManager();
            }
            else
            {
                _manager.Clear();
            }

            _manager.AddFile(_blobFile);
            _manager.AddFile(_blobConfigFile);
            if (onDownloadProgressChanged != null)
            {
                _manager.OnDownloadProgressChanged += onDownloadProgressChanged;
            }
#if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE || UNITY_WEBGL
            yield return(_manager.Download());
#else
            await _manager.Download();
#endif
        }
Esempio n. 2
0
        Init(
            DownloadableFile modelFile = null)
        {
            if (_graph == null)
            {
                String defaultLocalSubfolder = "Stylize";
                if (modelFile == null)
                {
                    modelFile = new DownloadableFile(
                        "https://github.com/emgucv/models/raw/master/stylize_v1/stylize_quantized.pb",
                        defaultLocalSubfolder,
                        "6753E2BFE7AA1D9FCFE01D8235E848C8201E54C6590423893C8124971E7C7DB0"
                        );
                }

                _downloadManager.Clear();
                _downloadManager.AddFile(modelFile);

#if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE
                yield return(_downloadManager.Download());
#else
                await _downloadManager.Download();
#endif
                if (_downloadManager.AllFilesDownloaded)
                {
                    ImportGraph();
                }
                else
                {
                    System.Diagnostics.Trace.WriteLine("Failed to download files");
                }
            }
        }
Esempio n. 3
0
        Init(String[] modelFiles = null, String downloadUrl = null, String localModelFolder = "MaskRcnn")
        {
            if (_graph == null)
            {
                _downloadManager.Clear();
                String url = downloadUrl == null
                    ? "https://github.com/emgucv/models/raw/master/mask_rcnn_inception_v2_coco_2018_01_28/"
                    : downloadUrl;
                String[] fileNames = modelFiles == null
                    ? new string[] { "frozen_inference_graph.pb", "coco-labels-paper.txt" }
                    : modelFiles;
                for (int i = 0; i < fileNames.Length; i++)
                {
                    _downloadManager.AddFile(url + fileNames[i], localModelFolder);
                }

#if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE
                yield return(_downloadManager.Download());
#else
                await _downloadManager.Download();

                ImportGraph();
#endif
            }
        }
Esempio n. 4
0
        Init(String[] modelFiles     = null,
             String downloadUrl      = null,
             String inputName        = null,
             String outputName       = null,
             String localModelFolder = "Inception"
             )
        {
            _inputName  = inputName == null ? "input" : inputName;
            _outputName = outputName == null ? "output" : outputName;

            _downloadManager.Clear();
            String url = downloadUrl == null ? "https://github.com/emgucv/models/raw/master/inception/" : downloadUrl;

            String[] fileNames = modelFiles == null ? new string[] { "tensorflow_inception_graph.pb", "imagenet_comp_graph_label_strings.txt" } : modelFiles;
            for (int i = 0; i < fileNames.Length; i++)
            {
                _downloadManager.AddFile(url + fileNames[i], localModelFolder);
            }

#if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE
            yield return(_downloadManager.Download());
#else
            await _downloadManager.Download();
#endif
            ImportGraph();
        }
Esempio n. 5
0
        Init(
            DownloadableFile modelFile = null,
            DownloadableFile labelFile = null,
            IDelegate optDelegate      = null)
        {
            if (!Imported)
            {
                _downloadManager.Clear();

                _downloadManager.AddFile(modelFile);
                _downloadManager.AddFile(labelFile);

#if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE
                yield return(_downloadManager.Download());
#else
                await _downloadManager.Download();
#endif
                if (_downloadManager.AllFilesDownloaded)
                {
                    ImportGraph(optDelegate);
                }
                else
                {
                    System.Diagnostics.Trace.WriteLine("Failed to download all files");
                }
            }
        }
Esempio n. 6
0
 public void Init(String[] modelFiles = null, String downloadUrl = null)
 {
     _downloadManager.Clear();
     String url = downloadUrl == null ? "https://github.com/emgucv/models/raw/master/stylize_v1/" : downloadUrl;
     String[] fileNames = modelFiles == null ? new string[] { "stylize_quantized.pb" } : modelFiles;
     for (int i = 0; i < fileNames.Length; i++)
         _downloadManager.AddFile(url + fileNames[i]);
     _downloadManager.Download();
 }
Esempio n. 7
0
        Init(DownloadableFile modelFile = null,
             DownloadableFile labelFile = null
             )
        {
            if (_session == null)
            {
                _downloadManager.Clear();

                String defaultLocalSubfolder = "MaskRcnn";
                if (modelFile == null)
                {
                    modelFile = new DownloadableFile(
                        "https://emgu-public.s3.amazonaws.com/mask_rcnn_inception_v2_coco_saved_model/mask_rcnn_inception_v2_coco_saved_model.zip",
                        defaultLocalSubfolder,
                        "4F043142473125E3758BCF9042AFF6F14C0C04A5D2273F20D1831A337176DAAC"
                        );
                }

                if (labelFile == null)
                {
                    labelFile = new DownloadableFile(
                        "https://emgu-public.s3.amazonaws.com/mask_rcnn_inception_v2_coco_saved_model/coco-labels-paper.txt",
                        defaultLocalSubfolder,
                        "8925173E1B0AABFAEFDA27DE2BB908233BB8FB6E7582323D72988E4BE15A5F0B"
                        );
                }

                _downloadManager.AddFile(modelFile);
                _downloadManager.AddFile(labelFile);

#if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE
                yield return(_downloadManager.Download());
#else
                await _downloadManager.Download();
#endif
                if (_downloadManager.AllFilesDownloaded)
                {
                    System.IO.FileInfo localZipFile = new System.IO.FileInfo(_downloadManager.Files[0].LocalFile);

                    _savedModelDir = System.IO.Path.Combine(localZipFile.DirectoryName, "SavedModel");
                    if (!System.IO.Directory.Exists(_savedModelDir))
                    {
                        System.IO.Directory.CreateDirectory(_savedModelDir);

                        System.IO.Compression.ZipFile.ExtractToDirectory(
                            localZipFile.FullName,
                            _savedModelDir);
                    }

                    CreateSession();
                }
                else
                {
                    System.Diagnostics.Trace.WriteLine("Failed to download files");
                }
            }
        }
Esempio n. 8
0
        Init(DownloadableFile modelFile = null,
             DownloadableFile labelFile = null,
             String inputName           = null,
             String outputName          = null
             )
        {
            if (_graph == null)
            {
                _inputName  = inputName == null ? "input" : inputName;
                _outputName = outputName == null ? "output" : outputName;

                _downloadManager.Clear();

                String defaultLocalSubfolder = "Inception";
                if (modelFile == null)
                {
                    modelFile = new DownloadableFile(
                        "https://github.com/emgucv/models/raw/master/inception/tensorflow_inception_graph.pb",
                        defaultLocalSubfolder,
                        "A39B08B826C9D5A5532FF424C03A3A11A202967544E389ACA4B06C2BD8AEF63F"
                        );
                }

                if (labelFile == null)
                {
                    labelFile = new DownloadableFile(
                        "https://github.com/emgucv/models/raw/master/inception/imagenet_comp_graph_label_strings.txt",
                        defaultLocalSubfolder,
                        "DA2A31ECFE9F212AE8DD07379B11A74CB2D7A110EBA12C5FC8C862A65B8E6606"
                        );
                }

                _downloadManager.AddFile(modelFile);
                _downloadManager.AddFile(labelFile);

#if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE
                yield return(_downloadManager.Download());
#else
                await _downloadManager.Download();
#endif
                if (_downloadManager.AllFilesDownloaded)
                {
                    ImportGraph();
                }
                else
                {
                    System.Diagnostics.Trace.WriteLine("Failed to download files");
                }
            }
        }
Esempio n. 9
0
        public async Task Init(String[] modelFiles = null, String downloadUrl = null, String localModelFolder = "stylize")
        {
            _downloadManager.Clear();
            String url = downloadUrl == null ? "https://github.com/emgucv/models/raw/master/stylize_v1/" : downloadUrl;

            String[] fileNames = modelFiles == null ? new string[] { "stylize_quantized.pb" } : modelFiles;
            for (int i = 0; i < fileNames.Length; i++)
            {
                _downloadManager.AddFile(url + fileNames[i], localModelFolder);
            }
            await _downloadManager.Download();

            ImportGraph();
        }
Esempio n. 10
0
        Init(String[] modelFiles = null, String downloadUrl = null)
        {
            _downloadManager.Clear();
            String url = downloadUrl == null ? "https://github.com/emgucv/models/raw/master/mobile_multibox_v1a/" : downloadUrl;

            String[] fileNames = modelFiles == null ? new string[] { "multibox_model.pb", "multibox_location_priors.txt" } : modelFiles;
            for (int i = 0; i < fileNames.Length; i++)
            {
                _downloadManager.AddFile(url + fileNames[i]);
            }
#if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE
            yield return(_downloadManager.Download());
#else
            _downloadManager.Download();
#endif
        }
Esempio n. 11
0
        Init(String[] modelFiles = null, String downloadUrl = null)
        {
            _downloadManager.Clear();
            String url = downloadUrl == null ? "https://github.com/emgucv/models/raw/master/inception_flower_retrain/" : downloadUrl;

            String[] fileNames = modelFiles == null ? new string[] { "optimized_graph.tflite", "output_labels.txt" } : modelFiles;
            for (int i = 0; i < fileNames.Length; i++)
            {
                _downloadManager.AddFile(url + fileNames[i]);
            }

#if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE
            yield return(_downloadManager.Download());
#else
            _downloadManager.Download();
#endif
        }
Esempio n. 12
0
        Init(String[] modelFiles = null, String downloadUrl = null)
        {
            _downloadManager.Clear();
            String url = downloadUrl == null ? "https://github.com/emgucv/models/raw/master/mobilenet_v1_1.0_224_float_2017_11_08/" : downloadUrl;

            String[] fileNames = modelFiles == null ? new string[] { "mobilenet_v1_1.0_224.tflite", "labels.txt" } : modelFiles;
            for (int i = 0; i < fileNames.Length; i++)
            {
                _downloadManager.AddFile(url + fileNames[i]);
            }

#if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE
            yield return(_downloadManager.Download());
#else
            _downloadManager.Download();
#endif
        }
Esempio n. 13
0
        Init(
            DownloadableFile modelFile = null,
            DownloadableFile labelFile = null,
            String localModelFolder    = "Multibox")
        {
            if (_graph == null)
            {
                //String defaultLocalSubfolder = "Multibox";
                if (modelFile == null)
                {
                    modelFile = new DownloadableFile(
                        "https://github.com/emgucv/models/raw/master/mobile_multibox_v1a/multibox_model.pb",
                        localModelFolder,
                        "D1466DF5497E722E4A49E3839F667F07C579DD4C049258018E5F8EE9E01943A7"
                        );
                }

                if (labelFile == null)
                {
                    labelFile = new DownloadableFile(
                        "https://github.com/emgucv/models/raw/master/mobile_multibox_v1a/multibox_location_priors.txt",
                        localModelFolder,
                        "8742979FBAAAAB73CDDE4FAB55126AD78C6D9F84F310D8D51566BDF3F48F1E65"
                        );
                }

                _downloadManager.Clear();
                _downloadManager.AddFile(modelFile);
                _downloadManager.AddFile(labelFile);

#if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE
                yield return(_downloadManager.Download());
#else
                await _downloadManager.Download();
#endif
                if (_downloadManager.AllFilesDownloaded)
                {
                    ImportGraph();
                }
                else
                {
                    System.Diagnostics.Trace.WriteLine("Failed to download files");
                }
            }
        }
Esempio n. 14
0
        Init(
            String[] modelFiles     = null,
            String downloadUrl      = null,
            String inputName        = null,
            String outputName       = null,
            String localModelFolder = "Resnet")
        {
            if (_session == null)
            {
                _inputName  = inputName == null ? "serving_default_input_1" : inputName;
                _outputName = outputName == null ? "StatefulPartitionedCall" : outputName;

                _downloadManager.Clear();
                String url = downloadUrl == null
                    ? "https://github.com/emgucv/models/raw/master/resnet/"
                    : downloadUrl;
                String[] fileNames = modelFiles == null
                    ? new string[] { "resnet_50_classification_1.zip", "ImageNetLabels.txt" }
                    : modelFiles;
                for (int i = 0; i < fileNames.Length; i++)
                {
                    _downloadManager.AddFile(url + fileNames[i], localModelFolder);
                }

#if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE
                yield return(_downloadManager.Download());
#else
                await _downloadManager.Download();

                System.IO.FileInfo localZipFile = new System.IO.FileInfo(_downloadManager.Files[0].LocalFile);

                _savedModelDir = System.IO.Path.Combine(localZipFile.DirectoryName, "SavedModel");
                if (!System.IO.Directory.Exists(_savedModelDir))
                {
                    System.IO.Directory.CreateDirectory(_savedModelDir);

                    System.IO.Compression.ZipFile.ExtractToDirectory(
                        localZipFile.FullName,
                        _savedModelDir);
                }

                CreateSession();
#endif
            }
        }
Esempio n. 15
0
        Init(
            DownloadableFile modelFile = null,
            DownloadableFile labelFile = null)
        {
            _downloadManager.Clear();

            String defaultLocalSubfolder = "Inception";

            if (modelFile == null)
            {
                modelFile = new DownloadableFile(
                    "https://github.com/emgucv/models/raw/master/inception_flower_retrain/optimized_graph.tflite",
                    defaultLocalSubfolder,
                    "9E4F5BF63CC7975EB17ECA1398C3046AC39451F462976750258CE7072BB0ECCD"
                    );
            }

            if (labelFile == null)
            {
                labelFile = new DownloadableFile(
                    "https://github.com/emgucv/models/raw/master/inception_flower_retrain/output_labels.txt",
                    defaultLocalSubfolder,
                    "298454B11DBEE503F0303367F3714D449855071DF9ECAC16AB0A01A0A7377DB6"
                    );
            }

            _downloadManager.AddFile(modelFile);
            _downloadManager.AddFile(labelFile);

#if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE
            yield return(_downloadManager.Download());
#else
            await _downloadManager.Download();
#endif

            if (_downloadManager.AllFilesDownloaded)
            {
                ImportGraph();
            }
            else
            {
                System.Diagnostics.Trace.WriteLine("Failed to download all files");
            }
        }
Esempio n. 16
0
        Init(
            DownloadableFile modelFile = null,
            DownloadableFile labelFile = null)
        {
            _downloadManager.Clear();

            String defaultLocalSubfolder = "Mobilenet";

            if (modelFile == null)
            {
                modelFile = new DownloadableFile(
                    "https://github.com/emgucv/models/raw/master/mobilenet_v1_1.0_224_float_2017_11_08/mobilenet_v1_1.0_224.tflite",
                    defaultLocalSubfolder,
                    "FDACE547B17907FA22821F4898F2AF49DCE7787FE688AD7C5D8D0220F3781C65"
                    );
            }

            if (labelFile == null)
            {
                labelFile = new DownloadableFile(
                    "https://github.com/emgucv/models/raw/master/mobilenet_v1_1.0_224_float_2017_11_08/labels.txt",
                    defaultLocalSubfolder,
                    "536FEACC519DE3D418DE26B2EFFB4D75694A8C4C0063E36499A46FA8061E2DA9"
                    );
            }

            _downloadManager.AddFile(modelFile);
            _downloadManager.AddFile(labelFile);

#if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE
            yield return(_downloadManager.Download());
#else
            await _downloadManager.Download();
#endif
            if (_downloadManager.AllFilesDownloaded)
            {
                ImportGraph();
            }
            else
            {
                System.Diagnostics.Trace.WriteLine("Failed to download all files");
            }
        }
Esempio n. 17
0
        Init(
            String[] modelFiles     = null,
            String downloadUrl      = null,
            String localModelFolder = "CocoSsdMobilenet")
        {
            _downloadManager.Clear();
            String url = downloadUrl == null ? "https://github.com/emgucv/models/raw/master/coco_ssd_mobilenet_v1_1.0_quant_2018_06_29/" : downloadUrl;

            String[] fileNames = modelFiles == null ? new string[] { "detect.tflite", "labelmap.txt" } : modelFiles;
            for (int i = 0; i < fileNames.Length; i++)
            {
                _downloadManager.AddFile(url + fileNames[i], localModelFolder);
            }

#if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE
            yield return(_downloadManager.Download());
#else
            await _downloadManager.Download();
#endif
            ImportGraph();
        }
Esempio n. 18
0
        Init(
            String[] modelFiles,
            String downloadUrl,
            String localModelFolder)
        {
            _downloadManager.Clear();
            String url = downloadUrl;

            String[] fileNames = modelFiles;
            for (int i = 0; i < fileNames.Length; i++)
            {
                _downloadManager.AddFile(url + fileNames[i], localModelFolder);
            }

#if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE
            yield return(_downloadManager.Download());
#else
            await _downloadManager.Download();
#endif
            ImportGraph();
        }
Esempio n. 19
0
        /// <summary>
        /// Download and initialize the mobilenet model for depth AI
        /// </summary>
        /// <param name="onDownloadProgressChanged">Call back method during download</param>
        /// <returns>Asyn task</returns>
        public async Task <Config> Init(System.Net.DownloadProgressChangedEventHandler onDownloadProgressChanged = null)
        {
            _blobFile = new DownloadableFile(
                "https://github.com/emgucv/models/raw/master/DepthAI/mobilenet-ssd/mobilenet-ssd.blob.sh14cmx14NCE1",
                _modelFolderName,
                "952C8AA1759CAB442D82781579EE4B9BA828CBED8AB9AD3C94D5222AA45DCA6E");
            _blobConfigFile = new DownloadableFile(
                "https://github.com/emgucv/models/raw/master/DepthAI/mobilenet-ssd/mobilenet-ssd.json",
                _modelFolderName,
                "606A965DDF539857D3477AED659A69948D8B310A20B38C3B794F2369ECC685FE");

            if (_manager == null)
            {
                _manager = new FileDownloadManager();
            }
            else
            {
                _manager.Clear();
            }

            _manager.AddFile(_blobFile);
            _manager.AddFile(_blobConfigFile);
            if (onDownloadProgressChanged != null)
            {
                _manager.OnDownloadProgressChanged += onDownloadProgressChanged;
            }
            await _manager.Download();

            if (!_manager.AllFilesDownloaded)
            {
                return(null);
            }

            Config config = GetConfig(_blobFile.LocalFile, _blobConfigFile.LocalFile);

            return(config);
        }
Esempio n. 20
0
        Init(
            DownloadableFile modelFile = null,
            DownloadableFile labelFile = null,
            String inputName           = null,
            String outputName          = null
            )
        {
            if (_session == null)
            {
                _inputName  = inputName == null ? "serving_default_input_1" : inputName;
                _outputName = outputName == null ? "StatefulPartitionedCall" : outputName;

                _downloadManager.Clear();

                String defaultLocalSubfolder = "Resnet";
                if (modelFile == null)
                {
                    modelFile = new DownloadableFile(
                        "https://github.com/emgucv/models/raw/master/resnet/resnet_50_classification_1.zip",
                        defaultLocalSubfolder,
                        "861BA3BA5F18D8985A5611E5B668A0A020998762DD5A932BD4D0BCBBC1823A83"
                        );
                }

                if (labelFile == null)
                {
                    labelFile = new DownloadableFile(
                        "https://github.com/emgucv/models/raw/master/resnet/ImageNetLabels.txt",
                        defaultLocalSubfolder,
                        "536FEACC519DE3D418DE26B2EFFB4D75694A8C4C0063E36499A46FA8061E2DA9"
                        );
                }

                _downloadManager.AddFile(modelFile);
                _downloadManager.AddFile(labelFile);

#if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE
                yield return(_downloadManager.Download());
#else
                await _downloadManager.Download();
#endif
                if (_downloadManager.AllFilesDownloaded)
                {
                    System.IO.FileInfo localZipFile = new System.IO.FileInfo(_downloadManager.Files[0].LocalFile);

                    _savedModelDir = System.IO.Path.Combine(localZipFile.DirectoryName, "SavedModel");
                    if (!System.IO.Directory.Exists(_savedModelDir))
                    {
                        System.IO.Directory.CreateDirectory(_savedModelDir);

                        System.IO.Compression.ZipFile.ExtractToDirectory(
                            localZipFile.FullName,
                            _savedModelDir);
                    }

                    CreateSession();
                }
                else
                {
                    System.Diagnostics.Trace.WriteLine("Failed to download files");
                }
            }
        }