Detect face's sentiment from given image uri or base64 image data
Follow the steps below to setup the credential and GCP project
- Make sure you have install
node
,npm
andserverless
- Make sure you have create a project on GCP with service account key
- Copy your service account's json file to
~/.gcloud/keyfile.json
- Change
provider.project
inserverless.yml
to match yourproject-key
(you can get it from JSON file)
Have a read at https://cloud.google.com/functions/docs/emulator
# Install functions-emulator
npm install -g @google-cloud/functions-emulator
# Config the GCP project
# Replace $YOUR_PROJECT_ID with GCP project id
functions config set projectId $YOUR_PROJECT_ID
# Start emulator
functions start
# Deploy a function locally
functions deploy http --trigger-http
# Execute a function
# Replace $BASE64 with base64 encoded image data
functions call http --data='{"content": "$BASE64"}'
npm i
serverless deploy
You will get function endpoint in the console
# GET endpoint with image URI
# Replace $FUNCTION_URI with actual function URI endpoint
# Replace $URI with actual image URI
curl -G $FUNCTION_URI --data-urlencode "uri=$URI"
# POST endpoint with image URI
# Replace $FUNCTION_URI with actual function URI endpoint
# Replace $BASE64 with base64 encoded image data
curl -X POST \
$FUNCTION_URI \
-H 'Content-Type: application/json' \
-H 'cache-control: no-cache' \
-d '{
"content": "$BASE64"
}'