コード例 #1
0
        /// <summary>
        /// Read and upload images to <paramref name="project"/> based on <paramref name="options"/>
        /// </summary>
        public static async Task <CreateImageSummaryModel> ReadAndUploadImagesAsync(this ITrainingApi trainingApi,
                                                                                    Project project, TrainingOptions options, ICollection <string> allowedTagNames)
        {
            var images = ImagesLoaderGenerator.GenerateImagesLoader(options, allowedTagNames).LoadImages();

            return(await ImagesUploaderGenerator.GenerateImagesUploader(options, trainingApi).UploadImagesAsync(images, project.Id));
        }
コード例 #2
0
        static void Main(string[] args)
        {
            var options = Options.InitializeOptions <PredictionOptions>(args);

            if (options == null)
            {
                return;
            }

            var images             = ImagesLoaderGenerator.GenerateImagesLoader(options, options.AllowedTagNames).LoadImages();
            var predictionEndpoint = new PredictionEndpoint(new PredictionEndpointCredentials(options.PredictionKey));

            if (options.BaseUri != null)
            {
                Console.WriteLine($"The default base uri is {predictionEndpoint.BaseUri}. Changed it to {options.BaseUri}.");
                predictionEndpoint.BaseUri = options.BaseUri;
            }

            PrecisionAndRecall precisionAndRecall;

            using (var predictor = ConstructPredictor(predictionEndpoint, options.WorkDir + options.PredictionFileName, options.MilliSecondsBetweenPredictions))
            {
                var batchPredictor = new BatchPredictorWithRateLimit(predictor, options.MilliSecondsBetweenPredictions);
                precisionAndRecall = PrecisionAndRecall.ComputeAsync(
                    images,
                    options.Threshold,
                    async imgs => await batchPredictor.PredictWithImagesAsync(imgs, options.ProjectId, options.IterationId),
                    options.AllowedTagNames).Result;
            }

            Console.WriteLine($"Precision: {precisionAndRecall.Precision}");
            Console.WriteLine($"Recall: {precisionAndRecall.Recall}");
            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
        }