검색 응답 및 다중 감지 이해

Vision API 제품 검색은 검색 이미지에서 단일 제품의 일치하는 제품을 감지하고 찾거나, 이미지에 여러 제품이 존재하는 경우 여러 제품의 일치하는 제품을 식별하고 목록화할 수 있습니다.

단일 제품 이미지 및 응답

이 검색 이미지에는 하나의 제품이 포함되어 있습니다.

Cloud Storage 버킷의 옷 이미지
gs://cloud-ai-vision-data/product-search-tutorial/images/468f782e70ba11e8941fd20059124800.jpg

Vision API 제품 검색으로 비슷한 제품을 검색하면 이미지에서 제품 주변에 하나, 전체 이미지에 하나, 총 두 개의 경계 상자를 나타내는 응답이 반환됩니다.

전체 응답을 보려면 아래 섹션을 확장하세요.

    {
      "responses": [
        {
          "productSearchResults": {
            "indexTime": "2018-12-04T22:33:53.673600055Z",
            "results": [
              {
                "product": {
                  "name": "projects/project-id/locations/location-id/products/product_id16",
                  "displayName": " ",
                  "productCategory": "apparel",
                  "productLabels": [
                    {
                      "key": "style",
                      "value": "women"
                    },
                    {
                      "key": "category",
                      "value": "dress"
                    }
                  ]
                },
                "score": 1,
                "image": "projects/project-id/locations/location-id/products/product_id16/referenceImages/image16"
              },
              {
                "product": {
                  "name": "projects/project-id/locations/location-id/products/product_id29",
                  "displayName": " ",
                  "productCategory": "apparel",
                  "productLabels": [
                    {
                      "key": "style",
                      "value": "women"
                    },
                    {
                      "key": "category",
                      "value": "dress"
                    }
                  ]
                },
                "score": 0.34263745,
                "image": "projects/project-id/locations/location-id/products/product_id29/referenceImages/image29"
              },
              ...
              {
                "product": {
                  "name": "projects/project-id/locations/location-id/products/product_id89",
                  "displayName": " ",
                  "productCategory": "apparel",
                  "productLabels": [
                    {
                      "key": "style",
                      "value": "women"
                    },
                    {
                      "key": "category",
                      "value": "dress"
                    }
                  ]
                },
                "score": 0.20485385,
                "image": "projects/project-id/locations/location-id/products/product_id89/referenceImages/image89"
              }
            ],
            "productGroupedResults": [
              {
                "boundingPoly": {
                  "normalizedVertices": [
                    {
                      "x": 0.25610325,
                      "y": 0.1357359
                    },
                    {
                      "x": 0.77213204,
                      "y": 0.1357359
                    },
                    {
                      "x": 0.77213204,
                      "y": 0.9287346
                    },
                    {
                      "x": 0.25610325,
                      "y": 0.9287346
                    }
                  ]
                },
                "results": [
                  {
                    "product": {
                      "name": "projects/project-id/locations/location-id/products/product_id16",
                      "displayName": " ",
                      "productCategory": "apparel",
                      "productLabels": [
                        {
                          "key": "style",
                          "value": "women"
                        },
                        {
                          "key": "category",
                          "value": "dress"
                        }
                      ]
                    },
                    "score": 1,
                    "image": "projects/project-id/locations/location-id/products/product_id16/referenceImages/image16"
                  },
                  {
                    "product": {
                      "name": "projects/project-id/locations/location-id/products/product_id29",
                      "displayName": " ",
                      "productCategory": "apparel",
                      "productLabels": [
                        {
                          "key": "style",
                          "value": "women"
                        },
                        {
                          "key": "category",
                          "value": "dress"
                        }
                      ]
                    },
                    "score": 0.3345438,
                    "image": "projects/project-id/locations/location-id/products/product_id29/referenceImages/image29"
                  },
                  ...
                  {
                    "product": {
                      "name": "projects/project-id/locations/location-id/products/product_id76",
                      "displayName": " ",
                      "productCategory": "apparel",
                      "productLabels": [
                        {
                          "key": "style",
                          "value": "women"
                        },
                        {
                          "key": "category",
                          "value": "shoe"
                        }
                      ]
                    },
                    "score": 0.20218614,
                    "image": "projects/project-id/locations/location-id/products/product_id76/referenceImages/image76"
                  }
                ]
              },
              {
                "boundingPoly": {
                  "normalizedVertices": [
                    {},
                    {
                      "x": 1
                    },
                    {
                      "x": 1,
                      "y": 1
                    },
                    {
                      "y": 1
                    }
                  ]
                },
                "results": [
                  {
                    "product": {
                      "name": "projects/project-id/locations/location-id/products/product_id16",
                      "displayName": " ",
                      "productCategory": "apparel",
                      "productLabels": [
                        {
                          "key": "style",
                          "value": "women"
                        },
                        {
                          "key": "category",
                          "value": "dress"
                        }
                      ]
                    },
                    "score": 1,
                    "image": "projects/project-id/locations/location-id/products/product_id16/referenceImages/image16"
                  },
                  {
                    "product": {
                      "name": "projects/project-id/locations/location-id/products/product_id29",
                      "displayName": " ",
                      "productCategory": "apparel",
                      "productLabels": [
                        {
                          "key": "style",
                          "value": "women"
                        },
                        {
                          "key": "category",
                          "value": "dress"
                        }
                      ]
                    },
                    "score": 0.3507311,
                    "image": "projects/project-id/locations/location-id/products/product_id29/referenceImages/image29"
                  },
                  {
                    "product": {
                      "name": "projects/project-id/locations/location-id/products/product_id8",
                      "displayName": " ",
                      "productCategory": "apparel",
                      "productLabels": [
                        {
                          "key": "style",
                          "value": "women"
                        },
                        {
                          "key": "category",
                          "value": "dress"
                        }
                      ]
                    },
                    "score": 0.26709077,
                    "image": "projects/project-id/locations/location-id/products/product_id8/referenceImages/image8"
                  },
                  ...
                  {
                    "product": {
                      "name": "projects/project-id/locations/location-id/products/product_id51",
                      "displayName": " ",
                      "productCategory": "apparel",
                      "productLabels": [
                        {
                          "key": "style",
                          "value": "women"
                        },
                        {
                          "key": "category",
                          "value": "dress"
                        }
                      ]
                    },
                    "score": 0.21597815,
                    "image": "projects/project-id/locations/location-id/products/product_id51/referenceImages/image51"
                  }
                ]
              }
            ]
          }
        }
      ]
    }

경계 상자 및 일치하는 제품

이미지의 다음 두 제품(경계 상자)은 요청에서 반환된 두 개의 꼭지점 집합으로 지정됩니다.

Vision API 제품 검색에 의해 식별된 각 상자에 대해 일치하는 제품이 나열됩니다.

Cloud Storage 버킷의 드레스가 3개 있는 이미지
gs://cloud-samples-data/product_search/multiple_dresses.jpg

API 응답 경계 상자 및 일치하는 제품 결과가 productGroupedResults 필드에 나열되고 이미지에서 인식된 제품별로 그룹화됩니다. 각 boundingPoly 항목은 정규화된 꼭짓점으로 지정되는 구역을 나열합니다(0~1배율로 이미지의 실제 픽셀 값과 일치하지 않음). 그러면 이 특정 리전의 일치하는 제품이 나열됩니다.

응답의 다음 섹션은 드레스를 둘러싼 경계 상자에 해당합니다.

    ....
            "productGroupedResults": [
              {
                "boundingPoly": {
                  "normalizedVertices": [
                    {
                      "x": 0.25610325,
                      "y": 0.1357359
                    },
                    {
                      "x": 0.77213204,
                      "y": 0.1357359
                    },
                    {
                      "x": 0.77213204,
                      "y": 0.9287346
                    },
                    {
                      "x": 0.25610325,
                      "y": 0.9287346
                    }
                  ]
                },
                "results": [
                  {
                    "product": {
                      "name": "projects/project-id/locations/location-id/products/product_id16",
                      "displayName": " ",
                      "productCategory": "apparel",
                      "productLabels":...
                    "score": 1,
                    ...

일치하는 제품은 results 필드 뒤에 나열되며 일치 점수별로 내림차순으로 순위가 정해집니다. 점수는 0(신뢰도 없음)에서 1(완전 신뢰)까지입니다.

5개의 일치하는 제품 이미지
Several matching products for the dress

응답에 반환된 다른 boundingPoly는 전체 이미지를 둘러쌉니다. 정규화된 꼭지점은 다음과 같이 나열됩니다.

  • [{},{"x": 1},{"x": 1,"y": 1},{"y": 1}]

좌표 값이 0인 경우 생략됩니다. 따라서 위에 지정된 경계 폴리는 다음에 해당합니다.

  • [{"x": 0,"y": 0},{"x": 1, "y": 0},{"x": 1,"y": 1},{"y": 1}]

그러면 일치하는 제품은 이 경계 상자(전체 이미지)에 대해 비슷하게 나열됩니다.

다중 제품 이미지(다중 감지) 및 응답

다음 검색 이미지에는 여러 제품이 포함되어 있습니다.

Cloud Storage 버킷의 드레스가 3개 있는 이미지
gs://cloud-samples-data/product_search/multiple_dresses.jpg

Vision API 제품 검색을 사용하여 비슷한 제품을 검색하면 전체 이미지에 하나, 3개의 각 드레스에 대한 3개의 상자까지 이미지의 여러 경계 상자를 식별하는 응답이 반환됩니다.

전체 응답을 보려면 아래 섹션을 확장하세요.

    {
      "responses": [
        {
          "productSearchResults": {
            "indexTime": "2018-12-05T18:34:22.231193168Z",
            "results": [
              {
                "product": {
                  "name": "projects/project-id/locations/location-id/products/product_id89",
                  "displayName": " ",
                  "productCategory": "apparel",
                  "productLabels": [
                    {
                      "key": "style",
                      "value": "women"
                    },
                    {
                      "key": "category",
                      "value": "dress"
                    }
                  ]
                },
                "score": 0.40636745,
                "image": "projects/project-id/locations/location-id/products/product_id89/referenceImages/image89"
              },
              {
                "product": {
                  "name": "projects/project-id/locations/location-id/products/product_id56",
                  "displayName": " ",
                  "productCategory": "apparel",
                  "productLabels": [
                    {
                      "key": "style",
                      "value": "women"
                    },
                    {
                      "key": "category",
                      "value": "dress"
                    }
                  ]
                },
                "score": 0.35433072,
                "image": "projects/project-id/locations/location-id/products/product_id56/referenceImages/image56"
              },
              ...
              {
                "product": {
                  "name": "projects/project-id/locations/location-id/products/product_id92",
                  "displayName": " ",
                  "productCategory": "apparel",
                  "productLabels": [
                    {
                      "key": "style",
                      "value": "women"
                    },
                    {
                      "key": "category",
                      "value": "dress"
                    }
                  ]
                },
                "score": 0.30736163,
                "image": "projects/project-id/locations/location-id/products/product_id92/referenceImages/image92"
              }
            ],
            "productGroupedResults": [
              {
                "boundingPoly": {
                  "normalizedVertices": [
                    {
                      "x": 0.38727918,
                      "y": 0.10391616
                    },
                    {
                      "x": 0.57177967,
                      "y": 0.10391616
                    },
                    {
                      "x": 0.57177967,
                      "y": 0.94973093
                    },
                    {
                      "x": 0.38727918,
                      "y": 0.94973093
                    }
                  ]
                },
                "results": [
                  {
                    "product": {
                      "name": "projects/project-id/locations/location-id/products/product_id39",
                      "displayName": " ",
                      "productCategory": "apparel",
                      "productLabels": [
                        {
                          "key": "style",
                          "value": "women"
                        },
                        {
                          "key": "category",
                          "value": "dress"
                        }
                      ]
                    },
                    "score": 0.36689043,
                    "image": "projects/project-id/locations/location-id/products/product_id39/referenceImages/image39"
                  },
                  {
                    "boundingPoly": {
                      "normalizedVertices": [
                        {
                          "x": 0.63010275,
                          "y": 0.08650439
                        },
                        {
                          "x": 0.88989735,
                          "y": 0.08650439
                        },
                        {
                          "x": 0.88989735,
                          "y": 0.9285545
                        },
                        {
                          "x": 0.63010275,
                          "y": 0.9285545
                        }
                      ]
                    },
                    "results": [
                      {
                        "product": {
                          "name": "projects/project-id/locations/location-id/products/product_id89",
                          "displayName": " ",
                          "productCategory": "apparel",
                          "productLabels": [
                            {
                              "key": "style",
                              "value": "women"
                            },
                            {
                              "key": "category",
                              "value": "dress"
                            }
                          ]
                        },
                        "score": 0.4007347,
                        "image": "projects/project-id/locations/location-id/products/product_id89/referenceImages/image89"
                      },
                      ...
                      {
                        "product": {
                          "name": "projects/project-id/locations/location-id/products/product_id30",
                          "displayName": " ",
                          "productCategory": "apparel",
                          "productLabels": [
                            {
                              "key": "style",
                              "value": "women"
                            },
                            {
                              "key": "category",
                              "value": "dress"
                            }
                          ]
                        },
                        "score": 0.27045864,
                        "image": "projects/project-id/locations/location-id/products/product_id30/referenceImages/image30"
                      },
                      ...
                      {
                        "product": {
                          "name": "projects/project-id/locations/location-id/products/product_id63",
                          "displayName": " ",
                          "productCategory": "apparel",
                          "productLabels": [
                            {
                              "key": "style",
                              "value": "women"
                            },
                            {
                              "key": "category",
                              "value": "dress"
                            }
                          ]
                        },
                        "score": 0.23139484,
                        "image": "projects/project-id/locations/location-id/products/product_id63/referenceImages/image63"
                      }
                    ]
                  },
                  ...
                  {
                    "boundingPoly": {
                      "normalizedVertices": [
                        {},
                        {
                          "x": 1
                        },
                        {
                          "x": 1,
                          "y": 1
                        },
                        {
                          "y": 1
                        }
                      ]
                    },
                    "results": [
                      {
                        "product": {
                          "name": "projects/project-id/locations/location-id/products/product_id30",
                          "displayName": " ",
                          "productCategory": "apparel",
                          "productLabels": [
                            {
                              "key": "style",
                              "value": "women"
                            },
                            {
                              "key": "category",
                              "value": "dress"
                            }
                          ]
                        },
                        "score": 0.39522344,
                        "image": "projects/project-id/locations/location-id/products/product_id30/referenceImages/image30"
                      },
                      ...
                      {
                        "product": {
                          "name": "projects/project-id/locations/location-id/products/product_id4",
                          "displayName": " ",
                          "productCategory": "apparel",
                          "productLabels": [
                            {
                              "key": "style",
                              "value": "women"
                            },
                            {
                              "key": "category",
                              "value": "dress"
                            }
                          ]
                        },
                        "score": 0.34226564,
                        "image": "projects/project-id/locations/location-id/products/product_id4/referenceImages/image4"
                      }
                    ]
                  },
                  {
                    "boundingPoly": {
                      "normalizedVertices": [
                        {
                          "x": 0.030102689,
                          "y": 0.067680866
                        },
                        {
                          "x": 0.28942674,
                          "y": 0.067680866
                        },
                        {
                          "x": 0.28942674,
                          "y": 0.94973093
                        },
                        {
                          "x": 0.030102689,
                          "y": 0.94973093
                        }
                      ]
                    },
                    "results": [
                      {
                        "product": {
                          "name": "projects/project-id/locations/location-id/products/product_id89",
                          "displayName": " ",
                          "productCategory": "apparel",
                          "productLabels": [
                            {
                              "key": "style",
                              "value": "women"
                            },
                            {
                              "key": "category",
                              "value": "dress"
                            }
                          ]
                        },
                        "score": 0.42439392,
                        "image": "projects/project-id/locations/location-id/products/product_id89/referenceImages/image89"
                      },
                      ...
                      {
                        "product": {
                          "name": "projects/project-id/locations/location-id/products/product_id51",
                          "displayName": " ",
                          "productCategory": "apparel",
                          "productLabels": [
                            {
                              "key": "style",
                              "value": "women"
                            },
                            {
                              "key": "category",
                              "value": "dress"
                            }
                          ]
                        },
                        "score": 0.26797917,
                        "image": "projects/project-id/locations/location-id/products/product_id51/referenceImages/image51"
                      }
                    ]
                  }
                ]
              }
            }
          ]
    }

경계 상자 및 일치하는 제품

다음 이미지는 다중 제품 이미지에서 Vision API 제품 검색에 의해 식별된 모든 경계 상자를 보여줍니다.

Cloud Storage 버킷의 드레스가 3개 있는 이미지
gs://cloud-samples-data/product_search/multiple_dresses.jpg

단일 제품 이미지와 마찬가지로, 다중 제품 이미지의 응답은 경계 상자와 일치하는 제품 결과를 productGroupedResults 필드에 나열합니다. 각 제품은 경계 폴리에 의해 식별되며 일치는 감지된 각 제품별로 그룹화됩니다.

응답의 다음 섹션은 중간 드레스를 둘러싼 경계 상자에 해당합니다.

    "productGroupedResults": [
              {
                "boundingPoly": {
                  "normalizedVertices": [
                    {
                      "x": 0.38727918,
                      "y": 0.10391616
                    },
                    {
                      "x": 0.57177967,
                      "y": 0.10391616
                    },
                    {
                      "x": 0.57177967,
                      "y": 0.94973093
                    },
                    {
                      "x": 0.38727918,
                      "y": 0.94973093
                    }
                  ]
                },
                "results": [
                  {
                    "product": {
                      "name":...
                    "score": 0.36689043,
                    ...

다음 이미지는 Vision API 제품 검색에 의해 반환된 중간 드레스에 대한 일치 중 몇 가지입니다.

5개의 일치하는 제품 이미지
Several matching products for the middle dress

이미지에서 발견되는 다음 다른 경계 상자는 각각 자체적인 일치하는 제품 목록이 있습니다(여기에는 포함되지 않음).

  • 왼쪽 드레스: {"x":0.03, "y":0.07},{"x":0.29, "y":0.07},{"x":0.29, "y":0.95},{"x":0.03, "y":0.95}
  • 오른쪽 드레스: {"x":0.63, "y":0.09},{"x":0.89, "y":0.09},{"x":0.89, "y":0.93},{"x":0.63, "y":0.93}
  • 전체 이미지:
    • {},{"x": 1},{"x": 1,"y": 1},{"y": 1}. 또는 다음과 같이 표현됩니다.
    • {"x": 0, "y": 0},{"x": 1,"y:0"},{"x": 1,"y": 1},{"x": 0,"y": 1}