Created
May 16, 2019 16:28
-
-
Save crysxd/1073e33b6f2350bcf4c44834d719a6c3 to your computer and use it in GitHub Desktop.
Shell snippet to test a Google Cloud Vision Product Set with a test image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install gcloud: https://cloud.google.com/sdk/docs/quickstarts | |
gcloud auth activate-service-account $GOOGLE_APPLICATION_CREDENTIALS | |
# Make sure to update the file path as well as project-id, location-id and product-set-id | |
curl -X POST \ | |
-H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ | |
-H "Content-Type: application/json" \ | |
https://vision.googleapis.com/v1/images:annotate -d "{ | |
'requests': [ | |
{ | |
'image': { | |
'content': '$(base64 /path/to/the/test_image.jpg)' | |
}, | |
'features': [ | |
{ | |
'type': 'PRODUCT_SEARCH', | |
'maxResults': 30 | |
} | |
], | |
'imageContext': { | |
'productSearchParams': { | |
'productSet': 'projects/project-id/locations/location-id/productSets/product-set-id', | |
'productCategories': [ | |
'apparel' | |
] | |
} | |
} | |
} | |
] | |
}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment