コード例 #1
0
        /// <summary>
        /// Checks the and download.
        /// </summary>
        /// <param name="datasetName">Name of the dataset.</param>
        /// <param name="fileName">Name of the file.</param>
        /// <param name="force">if set to <c>true</c> [force].</param>
        private static void CheckAndDownload(SampleDataset datasetName, string fileName, bool force = false)
        {
            DatasetInfo datasetInfo = GetSamplePath(datasetName);

            if (force)
            {
                Directory.Delete(datasetInfo.BaseFolder);
            }
            else
            {
                if (Directory.Exists(datasetInfo.BaseFolder))
                {
                    return;
                }
            }

            if (!Directory.Exists(datasetInfo.BaseFolder))
            {
                Directory.CreateDirectory(datasetInfo.BaseFolder);
            }

            string localfile = string.Format("{0}\\data.zip", datasetInfo.BaseFolder);

            if (!File.Exists(localfile))
            {
                Logging.WriteTrace("Downloading sample data: " + fileName);
                DownloadFile(string.Format(serverUrl, fileName), localfile);
                Logging.WriteTrace("Download complete");
            }

            UnzipFile(datasetInfo.BaseFolder, "data.zip");
        }
コード例 #2
0
        /// <summary>
        /// Gets file path for sample dataset
        /// </summary>
        /// <param name="datasetName">Name of the dataset.</param>
        /// <returns>DatasetInfo.</returns>
        public static DatasetInfo GetSamplePath(SampleDataset datasetName)
        {
            DatasetInfo path       = new DatasetInfo();
            string      baseFolder = string.Format("{0}\\SiaNet\\dataset", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData));
            string      dataFolder = "";

            switch (datasetName)
            {
            case SampleDataset.HousingRegression:
                dataFolder      = string.Format("{0}\\housing", baseFolder);
                path.Train      = string.Format("{0}\\train.csv", dataFolder);
                path.Test       = string.Format("{0}\\test.csv", dataFolder);
                path.BaseFolder = dataFolder;
                break;

            case SampleDataset.MNIST:
                dataFolder      = string.Format("{0}\\mnist_data", baseFolder);
                path.TrainX     = string.Format("{0}\\train_images.bin", dataFolder);
                path.TrainY     = string.Format("{0}\\train_labels.bin", dataFolder);
                path.TestX      = string.Format("{0}\\test_images.bin", dataFolder);
                path.TestY      = string.Format("{0}\\test_labels.bin", dataFolder);
                path.BaseFolder = dataFolder;
                break;

            case SampleDataset.Cifar10:
                dataFolder      = string.Format("{0}\\Cifar10", baseFolder);
                path.Train      = string.Format("{0}\\train.txt", dataFolder);
                path.Test       = string.Format("{0}\\test.txt", dataFolder);
                path.BaseFolder = dataFolder;
                break;

            case SampleDataset.Cifar100:
                dataFolder      = string.Format("{0}\\Cifar100", baseFolder);
                path.Train      = string.Format("{0}\\train.txt", dataFolder);
                path.Test       = string.Format("{0}\\test.txt", dataFolder);
                path.BaseFolder = dataFolder;
                break;

            case SampleDataset.Flowers:
                dataFolder      = string.Format("{0}\\Flowers", baseFolder);
                path.Train      = string.Format("{0}\\6k_img_map.txt", dataFolder);
                path.Test       = string.Format("{0}\\val_map.txt", dataFolder);
                path.BaseFolder = dataFolder;
                break;

            case SampleDataset.Grocery:
                dataFolder      = string.Format("{0}\\Grocery", baseFolder);
                path.Train      = string.Format("{0}\\train.txt", dataFolder);
                path.Test       = string.Format("{0}\\test.txt", dataFolder);
                path.BaseFolder = dataFolder;
                break;

            default:
                break;
            }

            return(path);
        }