/// <summary> /// Loads the model. /// </summary> /// <exception cref="Exception">Invalid model selected!</exception> public void LoadModel() { try { string modelFile = ""; string baseFolder = string.Format("{0}\\SiaNet\\models", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)); switch (model) { case Cifar10Model.ResNet110: Downloader.DownloadModel(PreTrainedModelPath.Cifar10Path.ResNet110); modelFile = baseFolder + "\\" + Path.GetFileName(PreTrainedModelPath.Cifar10Path.ResNet110); break; case Cifar10Model.ResNet20: Downloader.DownloadModel(PreTrainedModelPath.Cifar10Path.ResNet20); modelFile = baseFolder + "\\" + Path.GetFileName(PreTrainedModelPath.Cifar10Path.ResNet20); break; default: throw new Exception("Invalid model selected!"); } modelFunc = Function.Load(modelFile, GlobalParameters.Device); Logging.WriteTrace("Model loaded."); } catch (Exception ex) { Logging.WriteTrace(ex); throw ex; } }
/// <summary> /// Loads the model. /// </summary> /// <exception cref="Exception">Invalid model selected!</exception> public void LoadModel() { try { string modelFile = ""; string baseFolder = string.Format("{0}\\SiaNet\\models", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)); switch (model) { case ImageNetModel.AlexNet: Downloader.DownloadModel(PreTrainedModelPath.ImageNetPath.AlexNet); modelFile = baseFolder + "\\" + Path.GetFileName(PreTrainedModelPath.ImageNetPath.AlexNet); break; case ImageNetModel.InceptionV3: Downloader.DownloadModel(PreTrainedModelPath.ImageNetPath.InceptionV3); modelFile = baseFolder + "\\" + Path.GetFileName(PreTrainedModelPath.ImageNetPath.InceptionV3); break; case ImageNetModel.ResNet18: Downloader.DownloadModel(PreTrainedModelPath.ImageNetPath.ResNet18); modelFile = baseFolder + "\\" + Path.GetFileName(PreTrainedModelPath.ImageNetPath.ResNet18); break; case ImageNetModel.ResNet34: Downloader.DownloadModel(PreTrainedModelPath.ImageNetPath.ResNet34); modelFile = baseFolder + "\\" + Path.GetFileName(PreTrainedModelPath.ImageNetPath.ResNet34); break; case ImageNetModel.ResNet50: Downloader.DownloadModel(PreTrainedModelPath.ImageNetPath.ResNet50); modelFile = baseFolder + "\\" + Path.GetFileName(PreTrainedModelPath.ImageNetPath.ResNet50); break; case ImageNetModel.ResNet101: Downloader.DownloadModel(PreTrainedModelPath.ImageNetPath.ResNet101); modelFile = baseFolder + "\\" + Path.GetFileName(PreTrainedModelPath.ImageNetPath.ResNet101); break; case ImageNetModel.ResNet152: Downloader.DownloadModel(PreTrainedModelPath.ImageNetPath.ResNet152); modelFile = baseFolder + "\\" + Path.GetFileName(PreTrainedModelPath.ImageNetPath.ResNet152); break; case ImageNetModel.VGG16: Downloader.DownloadModel(PreTrainedModelPath.ImageNetPath.VGG16); modelFile = baseFolder + "\\" + Path.GetFileName(PreTrainedModelPath.ImageNetPath.VGG16); break; case ImageNetModel.VGG19: Downloader.DownloadModel(PreTrainedModelPath.ImageNetPath.VGG19); modelFile = baseFolder + "\\" + Path.GetFileName(PreTrainedModelPath.ImageNetPath.VGG19); break; default: throw new Exception("Invalid model selected!"); } modelFunc = Function.Load(modelFile, GlobalParameters.Device); Logging.WriteTrace("Model loaded."); } catch (Exception ex) { Logging.WriteTrace(ex); throw ex; } }