Last active
May 13, 2016 06:54
-
-
Save louisje/86a6c382b0a89db7f97d to your computer and use it in GitHub Desktop.
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
| FROM ubuntu | |
| RUN apt-get update | |
| RUN apt-get install -y curl jq | |
| WORKDIR /root | |
| RUN curl -ksL https://gist.github.com/louisje/86a6c382b0a89db7f97d/raw/vision-adult.sh > vision-adult.sh | |
| RUN chmod a+x vision-adult.sh | |
| ENTRYPOINT [ "./vision-adult.sh" ] | |
| CMD [ "--help" ] |
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
| #!/bin/bash | |
| if test -z "$1" -o "$1" = "--help"; then | |
| echo "Usage: vision.sh < image_url | file >" | |
| exit 1 | |
| fi | |
| if [[ "$1" == http* ]]; then | |
| base64=$(curl -s -k "$1" | base64) | |
| else | |
| base64=$(base64 "$1") | |
| fi | |
| if test -z "${base64}"; then | |
| echo "Invalid Url <-- $1" | |
| exit 1 | |
| fi | |
| input="{ | |
| \"requests\":[ | |
| { | |
| \"image\":{ | |
| \"content\":\"${base64}\" | |
| }, | |
| \"features\":[ | |
| { | |
| \"type\":\"SAFE_SEARCH_DETECTION\" | |
| } | |
| ] | |
| } | |
| ] | |
| }" | |
| echo "$1 --> $(echo "${input}" \ | |
| | curl -X POST -k -s \ | |
| -H "Content-Length: ${#input}" \ | |
| -H "Content-Type: application/json" \ | |
| --data-binary @/dev/stdin \ | |
| "https://vision.googleapis.com/v1/images:annotate?key=AIzaSyDueOFzxeBGiJNgBmobtcy9zNBe-Y_LC2s" \ | |
| | jq -C '.responses | map(if .safeSearchAnnotation then .safeSearchAnnotation else {} end) | map(.adult) | .[]')" |
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
| FROM ubuntu | |
| RUN apt-get update | |
| RUN apt-get install -y curl jq | |
| WORKDIR /root | |
| RUN curl -ksL https://gist.github.com/louisje/86a6c382b0a89db7f97d/raw/vision-label.sh > vision-label.sh | |
| RUN chmod a+x vision-label.sh | |
| ENTRYPOINT [ "./vision-label.sh" ] | |
| CMD [ "--help" ] |
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
| #!/bin/bash | |
| if test -z "$1" -o "$1" = "--help"; then | |
| echo "Usage: vision.sh < image_url | file >" | |
| exit 1 | |
| fi | |
| if [[ "$1" == http* ]]; then | |
| base64=$(curl -s -k "$1" | base64) | |
| else | |
| base64=$(base64 "$1") | |
| fi | |
| if test -z "${base64}"; then | |
| echo "Invalid Url <-- $1" | |
| exit 1 | |
| fi | |
| input="{ | |
| \"requests\":[ | |
| { | |
| \"image\":{ | |
| \"content\":\"${base64}\" | |
| }, | |
| \"features\":[ | |
| { | |
| \"type\":\"LABEL_DETECTION\" | |
| } | |
| ] | |
| } | |
| ] | |
| }" | |
| echo "$1 --> $(echo "${input}" \ | |
| | curl -X POST -k -s \ | |
| -H "Content-Length: ${#input}" \ | |
| -H "Content-Type: application/json" \ | |
| --data-binary @/dev/stdin \ | |
| "https://vision.googleapis.com/v1/images:annotate?key=AIzaSyDueOFzxeBGiJNgBmobtcy9zNBe-Y_LC2s" \ | |
| | jq -c '.responses | map(if .labelAnnotations then .labelAnnotations else [] end) | .[] | map(.description)')" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment