예제 #1
0
        public async void QueryPredictionResults()
        {
            using (MockContext context = MockContext.Start(this.GetType()))
            {
                HttpMockServer.Initialize(this.GetType(), "QueryPredictionResults", RecorderMode);

                using (var project = CreateTrainedImageClassificationProject())
                {
                    ICustomVisionTrainingClient client = BaseTests.GetTrainingClient();

                    var token = new PredictionQueryToken()
                    {
                        OrderBy = "Newest",
                    };
                    var result = await client.QueryPredictionsAsync(project.ProjectId, token);

                    Assert.NotEqual(0, result.Results.Count);
                    foreach (var prediction in result.Results)
                    {
                        Assert.Equal(project.ProjectId, prediction.Project);
                        Assert.NotEqual(Guid.Empty, prediction.Id);
                        Assert.NotEqual(Guid.Empty, prediction.Iteration);
                        Assert.NotEmpty(prediction.ThumbnailUri);
                        Assert.NotEmpty(prediction.OriginalImageUri);
                        Assert.NotEmpty(prediction.ResizedImageUri);

                        Assert.NotEqual(0, prediction.Predictions.Count);
                    }
                }
            }
        }
예제 #2
0
        private async void btnSubirNuevosTags_Click(object sender, RoutedEventArgs e)
        {
            TrainingApi trainingApi = new TrainingApi()
            {
                ApiKey = localSettings.Values["apiKeyCVTraining"] as string
            };
            var domains = await trainingApi.GetDomainsAsync();

            var objDetectionDomain = domains.FirstOrDefault(d => d.Type == "ObjectDetection");
            var project            = vs.First().ToString();

            try
            {
                Iteration iteration      = new Iteration();
                var       iterationsList = await trainingApi.GetIterationsAsync(new Guid(vsproject));

                var       iterationUltima = iterationsList.Last().ToString();
                ListaTags listaTags       = new ListaTags();
                var       TagsPred        = await trainingApi.GetTagsAsync(new Guid(vsproject));

                PredictionQueryTag predictionQueryTag = new PredictionQueryTag(new Guid(TagsPred.Last().Id.ToString()), 0.45, 1);

                StoredImagePrediction storedImagePredictiong = new StoredImagePrediction();
                listaTags.Add(predictionQueryTag);

                PredictionQueryToken predictionToken = new PredictionQueryToken()
                {
                    Application = null, Continuation = null, EndTime = null, StartTime = null, IterationId = new Guid(iterationUltima), MaxCount = 100, OrderBy = "Newest", Session = null, Tags = listaTags
                };
                PredictionQueryResult predictionQueryResult = new PredictionQueryResult(predictionToken, StoredImages());

                var imagePath        = System.IO.Path.Combine("Images", "fork");
                var imageFileEntries = new List <ImageIdCreateEntry>();
                ImageIdCreateEntry imageIdCreateEntry = new ImageIdCreateEntry();


                foreach (var item in region)
                {
                    imageIdCreateEntry.Id = new Guid(idPredictedImage);
                    //imageFileEntries.Add(new ImageFileCreateEntry(item, File.ReadAllBytes(item), null, new List<Region>(new Region[] { new Region(tagId, region[0], region[1], region[2], region[3])})));
                }


                ImageRegionCreateBatch imageRegionCreateBatch = new ImageRegionCreateBatch();
            }
            catch (Exception ex)
            {
                var error = ex.Message.ToString();
            }
        }
예제 #3
0
        public async void DeletePrediction()
        {
            using (MockContext context = MockContext.Start(this.GetType()))
            {
                HttpMockServer.Initialize(this.GetType(), "DeletePrediction", RecorderMode);

                using (var project = CreateTrainedImageClassificationProject())
                {
                    ICustomVisionTrainingClient client = BaseTests.GetTrainingClient();

                    var token = new PredictionQueryToken()
                    {
                        OrderBy = "Newest",
                    };
                    var result = client.QueryPredictionsAsync(project.ProjectId, token).Result;
                    Assert.NotEqual(0, result.Results.Count);

                    await client.DeletePredictionAsync(project.ProjectId, new Guid[] { result.Results[result.Results.Count - 1].Id });
                }
            }
        }