Init( DownloadableFile modelFile = null, DownloadableFile labelFile = null, IDelegate optDelegate = null) { String defaultLocalSubfolder = "CocoSsdMobilenetV1"; if (modelFile == null) { modelFile = new DownloadableFile( "https://github.com/emgucv/models/raw/master/coco_ssd_mobilenet_v1_1.0_quant_2018_06_29/detect.tflite", defaultLocalSubfolder, "E4B118E5E4531945DE2E659742C7C590F7536F8D0ED26D135ABCFE83B4779D13" ); } if (labelFile == null) { labelFile = new DownloadableFile( "https://github.com/emgucv/models/raw/master/coco_ssd_mobilenet_v1_1.0_quant_2018_06_29/labelmap.txt", defaultLocalSubfolder, "C7E79C855F73CBBA9F33D649D60E1676EB0A974021A41696D1AC0D4B7F7E0211" ); } #if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE return(base.Init(modelFile, labelFile, optDelegate)); #else await base.Init(modelFile, labelFile, optDelegate); #endif }
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"); } } }
Init( String[] modelFiles, String downloadUrl, String localModelFolder = "Multibox") { DownloadableFile[] downloadableFiles; if (modelFiles == null) { downloadableFiles = new DownloadableFile[2]; } else { String url = downloadUrl ?? "https://github.com/emgucv/models/raw/master/mobile_multibox_v1a/"; String[] fileNames = modelFiles ?? new string[] { "multibox_model.pb", "multibox_location_priors.txt" }; downloadableFiles = new DownloadableFile[fileNames.Length]; for (int i = 0; i < fileNames.Length; i++) { downloadableFiles[i] = new DownloadableFile(url + fileNames[i], localModelFolder); } } #if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE return(Init(downloadableFiles[0], downloadableFiles[1])); #else await Init(downloadableFiles[0], downloadableFiles[1]); #endif }
Init( DownloadableFile modelFile = null, DownloadableFile labelFile = null, IDelegate optDelegate = null) { String defaultLocalSubfolder = "CocoSsdMobilenetV3"; if (modelFile == null) { modelFile = new DownloadableFile( "https://github.com/emgucv/models/raw/master/coco_ssd_mobilenet_v3_small_2020_01_14/model.tflite", defaultLocalSubfolder, "0F52F7A4884DD6426D38F4AFC06DA75105EFE77F7C83E470254C267FE34CC43C" ); } if (labelFile == null) { labelFile = new DownloadableFile( "https://github.com/emgucv/models/raw/master/coco_ssd_mobilenet_v3_small_2020_01_14/labelmap.txt", defaultLocalSubfolder, "C7E79C855F73CBBA9F33D649D60E1676EB0A974021A41696D1AC0D4B7F7E0211" ); } #if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE return(base.Init(modelFile, labelFile, optDelegate)); #else await base.Init(modelFile, labelFile, optDelegate); #endif }
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"); } } }
Init(String[] modelFiles, String downloadUrl, String inputName, String outputName, String localModelFolder = "Inception" ) { DownloadableFile[] downloadableFiles; if (modelFiles == null) { downloadableFiles = new DownloadableFile[2]; } else { 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; downloadableFiles = new DownloadableFile[fileNames.Length]; for (int i = 0; i < fileNames.Length; i++) { downloadableFiles[i] = new DownloadableFile(url + fileNames[i], localModelFolder); } } #if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE return(Init(downloadableFiles[0], downloadableFiles[1], inputName, outputName)); #else await Init(downloadableFiles[0], downloadableFiles[1], inputName, outputName); #endif }
private static void DownloadFileVersion2(DownloadableFile file, FileStream destination) { var tasks = new List<Task>(); foreach (int i in Enumerable.Range(0, file.ChunkCount)) { int chunkIndex = i; tasks.Add(Task.Run(async delegate { byte[] chunkContents; await _concurrentDownloadSemaphore.WaitAsync(); try { chunkContents = await new HttpClient().GetByteArrayAsync(file.GetChunkUrl(chunkIndex)); } finally { _concurrentDownloadSemaphore.Release(); } lock (_writeLock) destination.Write(chunkContents, 0, chunkContents.Length); })); } Task.WaitAll(tasks.ToArray()); }
Init( String[] modelFiles, String downloadUrl, String localModelFolder = "MaskRcnn") { DownloadableFile[] downloadableFiles; if (modelFiles == null) { downloadableFiles = new DownloadableFile[2]; } else { String url = downloadUrl == null ? "https://emgu-public.s3.amazonaws.com/mask_rcnn_inception_v2_coco_saved_model/" : downloadUrl; String[] fileNames = modelFiles == null ? new string[] { "mask_rcnn_inception_v2_coco_saved_model.zip", "coco-labels-paper.txt" } : modelFiles; downloadableFiles = new DownloadableFile[fileNames.Length]; for (int i = 0; i < fileNames.Length; i++) { downloadableFiles[i] = new DownloadableFile(url + fileNames[i], localModelFolder); } } #if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE return(Init(downloadableFiles[0], downloadableFiles[1])); #else await Init(downloadableFiles[0], downloadableFiles[1]); #endif }
Init( String[] modelFiles, String downloadUrl, String inputName = null, String outputName = null, String localModelFolder = "Resnet") { DownloadableFile[] downloadableFiles; if (modelFiles == null) { downloadableFiles = new DownloadableFile[2]; } else { 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; downloadableFiles = new DownloadableFile[fileNames.Length]; for (int i = 0; i < fileNames.Length; i++) { downloadableFiles[i] = new DownloadableFile(url + fileNames[i], localModelFolder); } } #if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE return(Init(downloadableFiles[0], downloadableFiles[1], inputName, outputName)); #else await Init(downloadableFiles[0], downloadableFiles[1], inputName, outputName); #endif }
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 }
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"); } } }
public ToolUpdate( ToolUpdateStatus status, Version localVersion, string destinationPath, DownloadableFile latestDownload) { Status = status; LocalVersion = localVersion; DestinationPath = destinationPath ?? throw new ArgumentNullException(nameof(destinationPath)); LatestDownload = latestDownload ?? throw new ArgumentNullException(nameof(latestDownload)); }
public void Title_Is_Correctly_Determined_From_Filename(string fileName, string expectedTitle) { // Arrange var testableDownloadableFile = new DownloadableFile(fileName); // Act var actualTitle = testableDownloadableFile.Title; // Assert Assert.AreEqual(expectedTitle, actualTitle); }
public void Description_Is_Correctly_Determined_From_Filename(string fileName, string expectedDescription) { // Arrange var testableDownloadableFile = new DownloadableFile(fileName); // Act var actualDescription = testableDownloadableFile.Description; // Assert Assert.AreEqual(expectedDescription, actualDescription); }
public void When_Name_Is_Not_Set_Returns_Last_Section_Of_FilePath(string filePath, string expectedName) { // Arrange var testableDownloadableFile = new DownloadableFile(filePath); // Act var actualName = testableDownloadableFile.Name; // Assert Assert.AreEqual(expectedName, actualName); }
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"); } } }
public DownloadableFile GetFileWithUsers() { DownloadableFile fileModel = new DownloadableFile() { Type = "text/plain", FileName = "All users" }; var text = GenerateTextForFile(); fileModel.Data = Encoding.ASCII.GetBytes(text); return(fileModel); }
private void AddUrlForDownload(string url) { DownloadableFile file; try { file = new DownloadableFile(url, AsyncSaveHandlerFactory.GetInstance().GetAudioSaveHandler()); } catch (SystemException) { MessageBox.Show("Are you sure the video resided on YouTube?", "Error downloading file", MessageBoxButtons.OK); return; } fileBinding.Add(file); downloader.DownloadAsync(file); }
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"); } } }
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"); } }
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"); } }
/// <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); }
private static void Main() { var file = new DownloadableFile(); using (var stream = File.Create("Output.txt")) { DownloadFileVersion4(file, stream); } }
private static void DownloadFileVersion4(DownloadableFile file, FileStream destination) { var tasks = new List<Task>(); foreach (int i in Enumerable.Range(0, file.ChunkCount)) { int chunkIndex = i; tasks.Add(Task.Run(async delegate { byte[] chunkContents; using (await SemaphoreLock.TakeAsync(_concurrentDownloadSemaphore)) chunkContents = await new HttpClient().GetByteArrayAsync(file.GetChunkUrl(chunkIndex)); using (await SemaphoreLock.TakeAsync(_fileWriteSemaphore)) destination.Write(chunkContents, 0, chunkContents.Length); })); } Task.WaitAll(tasks.ToArray()); }
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"); } } }