Exemplo n.º 1
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();
            }
        }
Exemplo n.º 2
0
        public async void CreateImagesFromPredictions()
        {
            using (MockContext context = MockContext.Start(this.GetType()))
            {
                HttpMockServer.Initialize(this.GetType(), "CreateImagesFromPredictions", RecorderMode);

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

                    string imageUrl         = "https://raw.githubusercontent.com/Microsoft/Cognitive-CustomVision-Windows/master/Samples/Images/Test/test_image.jpg";
                    var    predictionResult = await client.QuickTestImageUrlAsync(project.ProjectId, new ImageUrl(imageUrl), project.IterationId);

                    var i      = new ImageIdCreateEntry[] { new ImageIdCreateEntry(predictionResult.Id) };
                    var result = await client.CreateImagesFromPredictionsAsync(project.ProjectId, new ImageIdCreateBatch(i));

                    Assert.Equal(1, result.Images.Count);
                    Assert.NotEmpty(result.Images[0].SourceUrl);
                }
            }
        }