Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Vision API Product search

Following is vision API product search request json

{
 "requests": [
{
  "image": {
    "content": base64-encoded-image
  },
  "features": [
    {
      "type": "PRODUCT_SEARCH",
      "maxResults": 5
    }
  ],
  "imageContext": {
    "productSearchParams": {
      "productSet": "projects/project-id/locations/location-id/productSets/product-set-id",
      *"productCategories": [
           "apparel"
      ]*,
      "filter": "style = womens"
    }
  }
}
]
}

For ImageContext, ProductCategories(apparel in this request) is mandatory in API. My concern is if I want product search from all the available ProductCategories, do I need to set multiple requests?

 ImageContext imageContext =
    ImageContext.newBuilder()
        .setProductSearchParams(
            ProductSearchParams.newBuilder()
                .setProductSet(productSetPath)
                .addProductCategories("apparel-v2")
                .setFilter(filter))
        .build();

For example, addProductCategories("apparel") can have only one productcategory at a time. But I want product search from all the category something like addProductCategories("apparel-v2").addProductCategories("toys-v2").addProductCategories("general-v1") etc.

1 4 1,745
4 REPLIES 4

As shown in the documentation, it will “only consider the first category”:

The list of product categories to search in. Currently, we only consider the first category, and either "homegoods-v2", "apparel-v2", "toys-v2", "packagedgoods-v1", or "general-v1" should be specified. The legacy categories "homegoods", "apparel", and "toys" are still supported but will be deprecated. For new products, please use "homegoods-v2", "apparel-v2", or "toys-v2" for better product search accuracy. It is recommended to migrate existing products to these categories as well.

See also:

Yes we have migrated product to "homegoods-v2", "apparel-v2", "toys-v2", "packagedgoods-v1", "general-v1" etc. but basic issue is, if we have data-set of multiple category Vision-API don't have provision of product search. So it is dependent on product category whereas filter is optional. It is a blocker since we have to request vision API multiple times based on category and all the responses need to be combined and reprocess further for actual response. So please provide any alternates Google Team already working on this scenario.

Also considered another scenario where we want safe search over this data-set, again we need to collect all the previous response, reprocess the previous response by adding

Feature.Type.SAFE_SEARCH_DETECTION

 Only after that we will get any results. Looks like currently vision API is limited to work on these scenario. Individual has to manage it at application level rather than API itself support it.

exactly, it make application slow by requesting multiple times and reprocess the request to display end results.