Exemplo n.º 1
0
        public void DescribeImageTest()
        {
            using (MockContext context = MockContext.Start(this.GetType()))
            {
                HttpMockServer.Initialize(this.GetType(), "DescribeImageTest");

                string imageUrl = GetTestImageUrl("dog.jpg");

                using (IComputerVisionClient client = GetComputerVisionClient(HttpMockServer.CreateInstance()))
                {
                    const int maxCandidates = 2;

                    ImageDescription result = client.DescribeImageAsync(imageUrl, maxCandidates).Result;

                    Assert.Matches("^\\d{4}-\\d{2}-\\d{2}(-preview)?$", result.ModelVersion);
                    Assert.Equal(result.Tags, new string[] {
                        "dog",
                        "tree",
                        "outdoor",
                        "sitting",
                        "ground",
                        "animal",
                        "mammal",
                        "close"
                    });
                    Assert.Equal(1, result.Captions.Count);
                    Assert.Equal("a dog with its mouth open", result.Captions[0].Text);
                    Assert.True(result.Captions[0].Confidence > 0.5);
                }
            }
        }
Exemplo n.º 2
0
        public void DescribeImageTest()
        {
            using (MockContext context = MockContext.Start(this.GetType()))
            {
                HttpMockServer.Initialize(this.GetType(), "DescribeImageTest");

                string imageUrl = GetTestImageUrl("dog.jpg");

                using (IComputerVisionClient client = GetComputerVisionClient(HttpMockServer.CreateInstance()))
                {
                    const int maxCandidates = 2;

                    ImageDescription result = client.DescribeImageAsync(imageUrl, maxCandidates).Result;

                    Assert.Equal(result.Tags, new string[] {
                        "dog",
                        "outdoor",
                        "sitting",
                        "animal",
                        "mammal",
                        "looking",
                        "brown",
                        "bench",
                        "yellow",
                        "front",
                        "large",
                        "wooden",
                        "small",
                        "white",
                        "standing",
                        "close",
                        "table",
                        "orange",
                        "laying",
                        "park",
                        "head"
                    });
                    Assert.Equal(2, result.Captions.Count);
                    Assert.Equal("a close up of a dog", result.Captions[0].Text);
                    Assert.Equal("close up of a dog", result.Captions[1].Text);
                    Assert.True(result.Captions[0].Confidence > result.Captions[1].Confidence);
                }
            }
        }
Exemplo n.º 3
0
        public void DescribeImageInJapaneseTest()
        {
            using (MockContext context = MockContext.Start(this.GetType()))
            {
                HttpMockServer.Initialize(this.GetType(), "DescribeImageInJapaneseTest");

                string imageUrl = GetTestImageUrl("dog.jpg");

                using (IComputerVisionClient client = GetComputerVisionClient(HttpMockServer.CreateInstance()))
                {
                    const int maxCandidates = 1;

                    ImageDescription result = client.DescribeImageAsync(imageUrl, maxCandidates, "ja").Result;

                    Assert.Equal(result.Tags, new string[] {
                        "犬",
                        "屋外",
                        "座る",
                        "動物",
                        "哺乳類",
                        "探す",
                        "茶色",
                        "ベンチ",
                        "イエロー",
                        "フロント",
                        "大きい",
                        "木製",
                        "小さい",
                        "ホワイト",
                        "立つ",
                        "閉じる",
                        "テーブル",
                        "オレンジ",
                        "横たわる",
                        "公園",
                        "頭"
                    });
                    Assert.Equal(1, result.Captions.Count);
                    Assert.Equal("犬の顔", result.Captions[0].Text);
                    Assert.True(result.Captions[0].Confidence > 0.8);
                }
            }
        }