Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- if [ $# != 1 ]; then
- echo "Invalid argument"
- exit 1
- fi
- uri=$1
- echo Image uri is ${uri}
- scode=$(curl "${uri}" -o /dev/null -w '%{http_code}\n' -s)
- if [ $scode != 200 ]; then
- echo HTTP status is ${scode}, abort.
- exit 1
- fi
- sed -e "s|@@URL_HERE@@|${uri}|" << EOF | curl -X POST -H "Authorization: Bearer "$(gcloud auth application-default print-access-token) -H "Content-Type: application/json; charset=utf-8" -d @- https://vision.googleapis.com/v1/images:annotate
- {
- "requests": [
- {
- "image": {
- "source": {
- "imageUri": "@@URL_HERE@@"
- }
- },
- "features": [
- {
- "type": "SAFE_SEARCH_DETECTION"
- }
- ]
- }
- ]
- }
- EOF
- echo ?:UNKNOWN, 1:VERY_UNLIKELY, 2:UNLIKELY, 3:POSSIBLE, 4LIKELY, 5:VERY_LIKELY
Add Comment
Please, Sign In to add comment