Skip to content

Instantly share code, notes, and snippets.

@ptrstpp950
Created October 19, 2019 11:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ptrstpp950/0e37f32ecbfd955040282711843d9704 to your computer and use it in GitHub Desktop.
Save ptrstpp950/0e37f32ecbfd955040282711843d9704 to your computer and use it in GitHub Desktop.
#Start with https://docs.microsoft.com/pl-PL/azure/cognitive-services/face/quickstarts/curl
headerKey="26d2a6e268904e5085d200cb42ec5fef"
curl -H "Ocp-Apim-Subscription-Key: $headerKey" "https://westeurope.api.cognitive.microsoft.com/face/v1.0/detect?returnFaceId=true&returnFaceLandmarks=false&returnFaceAttributes=age,gender,headPose,smile,facialHair,glasses,emotion,hair,makeup,occlusion,accessories,blur,exposure,noise" -H "Content-Type: application/json" --data-ascii "{\"url\":\"https://upload.wikimedia.org/wikipedia/commons/c/c3/RH_Louise_Lillian_Gish.jpg\"}"
# https://dev.cognitive.azure.cn/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395239
## Person group
curl -X PUT -H "Ocp-Apim-Subscription-Key: $headerKey" "https://westeurope.api.cognitive.microsoft.com/face/v1.0/persongroups/stappy/" -H "Content-Type: application/json" --data-ascii "{\"name\":\"stappy\", \"userData\":\"Rodzina Stapp\", \"recognitionModel\": \"recognition_02\"}"
## Person
curl -H "Ocp-Apim-Subscription-Key: $headerKey" "https://westeurope.api.cognitive.microsoft.com/face/v1.0/persongroups/stappy/persons" -H "Content-Type: application/json" --data-ascii "{\"name\":\"Magdalena Stapp\", \"userData\":\"To jest Madzia\"}"
curl -H "Ocp-Apim-Subscription-Key: $headerKey" "https://westeurope.api.cognitive.microsoft.com/face/v1.0/persongroups/stappy/persons" -H "Content-Type: application/json" --data-ascii "{\"name\":\"Dominik Stapp\", \"userData\":\"To jest Dominik\"}"
curl -H "Ocp-Apim-Subscription-Key: $headerKey" "https://westeurope.api.cognitive.microsoft.com/face/v1.0/persongroups/stappy/persons" -H "Content-Type: application/json" --data-ascii "{\"name\":\"Mama Stapp\", \"userData\":\"To jest Mama\"}"
curl -H "Ocp-Apim-Subscription-Key: $headerKey" "https://westeurope.api.cognitive.microsoft.com/face/v1.0/persongroups/stappy/persons" -H "Content-Type: application/json" --data-ascii "{\"name\":\"Tata Stapp\", \"userData\":\"To jest Tata\"}"
## pobranie listy osób
curl -H "Ocp-Apim-Subscription-Key: $headerKey" "https://westeurope.api.cognitive.microsoft.com/face/v1.0/persongroups/stappy/persons" | jq '.'
curl -H "Ocp-Apim-Subscription-Key: $headerKey" "https://westeurope.api.cognitive.microsoft.com/face/v1.0/persongroups/stappy/persons/54519f8b-ad90-48ea-98db-bdb2d3ca6206/persistedFaces" -H "Content-Type: application/json" --data-ascii "{\"url\": \"https://storage0warsztaty0test.z20.web.core.windows.net/magdalena.stapp/1.jpg\"}"
curl -H "Ocp-Apim-Subscription-Key: $headerKey" "https://westeurope.api.cognitive.microsoft.com/face/v1.0/persongroups/stappy/persons/54519f8b-ad90-48ea-98db-bdb2d3ca6206/persistedFaces" -H "Content-Type: application/json" --data-ascii "{\"url\": \"https://storage0warsztaty0test.z20.web.core.windows.net/magdalena.stapp/2.jpg\"}"
curl -H "Ocp-Apim-Subscription-Key: $headerKey" "https://westeurope.api.cognitive.microsoft.com/face/v1.0/persongroups/stappy/persons/54519f8b-ad90-48ea-98db-bdb2d3ca6206/persistedFaces" -H "Content-Type: application/json" --data-ascii "{\"url\": \"https://storage0warsztaty0test.z20.web.core.windows.net/magdalena.stapp/3.jpg\"}"
curl -H "Ocp-Apim-Subscription-Key: $headerKey" "https://westeurope.api.cognitive.microsoft.com/face/v1.0/persongroups/stappy/persons/54519f8b-ad90-48ea-98db-bdb2d3ca6206/persistedFaces" -H "Content-Type: application/json" --data-ascii "{\"url\": \"https://storage0warsztaty0test.z20.web.core.windows.net/magdalena.stapp/4.jpg\"}"
curl -H "Ocp-Apim-Subscription-Key: $headerKey" "https://westeurope.api.cognitive.microsoft.com/face/v1.0/persongroups/stappy/persons/6cf106dd-e3ac-490f-9c16-789b3b6b062c/persistedFaces" -H "Content-Type: application/json" --data-ascii "{\"url\": \"https://storage0warsztaty0test.z20.web.core.windows.net/dominik.stapp/1.jpg\"}"
curl -H "Ocp-Apim-Subscription-Key: $headerKey" "https://westeurope.api.cognitive.microsoft.com/face/v1.0/persongroups/stappy/persons/6cf106dd-e3ac-490f-9c16-789b3b6b062c/persistedFaces" -H "Content-Type: application/json" --data-ascii "{\"url\": \"https://storage0warsztaty0test.z20.web.core.windows.net/dominik.stapp/2.jpg\"}"
curl -H "Ocp-Apim-Subscription-Key: $headerKey" "https://westeurope.api.cognitive.microsoft.com/face/v1.0/persongroups/stappy/persons/6cf106dd-e3ac-490f-9c16-789b3b6b062c/persistedFaces" -H "Content-Type: application/json" --data-ascii "{\"url\": \"https://storage0warsztaty0test.z20.web.core.windows.net/dominik.stapp/3.jpg\"}"
curl -H "Ocp-Apim-Subscription-Key: $headerKey" "https://westeurope.api.cognitive.microsoft.com/face/v1.0/persongroups/stappy/persons/ac05af80-a9b1-4816-8bcb-beadb51b06f2/persistedFaces" -H "Content-Type: application/json" --data-ascii "{\"url\": \"https://storage0warsztaty0test.z20.web.core.windows.net/piotr.stapp/1.jpg\"}"
curl -H "Ocp-Apim-Subscription-Key: $headerKey" "https://westeurope.api.cognitive.microsoft.com/face/v1.0/persongroups/stappy/persons/ac05af80-a9b1-4816-8bcb-beadb51b06f2/persistedFaces" -H "Content-Type: application/json" --data-ascii "{\"url\": \"https://storage0warsztaty0test.z20.web.core.windows.net/piotr.stapp/2.jpg\"}"
curl -H "Ocp-Apim-Subscription-Key: $headerKey" "https://westeurope.api.cognitive.microsoft.com/face/v1.0/persongroups/stappy/persons/ac05af80-a9b1-4816-8bcb-beadb51b06f2/persistedFaces" -H "Content-Type: application/json" --data-ascii "{\"url\": \"https://storage0warsztaty0test.z20.web.core.windows.net/piotr.stapp/3.jpg\"}"
## Train
header="Ocp-Apim-Subscription-Key: $headerKey"
endpoint="westeurope.api.cognitive.microsoft.com"
curl -X POST -H "$header" "https://${endpoint}/face/v1.0/persongroups/stappy/train" --data-ascii ""
curl -H "$header" "https://${endpoint}/face/v1.0/persongroups/stappy/training" | jq '.'
# lista twarzy
## utworzenie temp-list
#curl -X PUT -H "$header" "https://${endpoint}/face/v1.0/facelists/temp-list" -H "Content-Type: application/json" --data-ascii "{\"name\": \"temp-list\",\"userData\": \"temp\",\"recognitionModel\": \"recognition_02\"}"
## wgranie twarzy
#curl -H "$header" "https://${endpoint}/face/v1.0/facelists/temp-list/persistedFaces" -H "Content-Type: application/json" --data-ascii "{\"url\": \"https://pl.gravatar.com/userimage/48672464/c50835d7095c6bf97f05a434fa54cfca.jpg?size=512\"}"
# rozpoznanie osoby
faceId=$(curl -H "$header" "https://${endpoint}/face/v1.0/detect?recognitionModel=recognition_02" -H "Content-Type: application/json" --data-ascii "{\"url\": \"https://pl.gravatar.com/userimage/48672464/c50835d7095c6bf97f05a434fa54cfca.jpg?size=512\"}" | jq -r '.[0].faceId')
personId=$(curl -H "$header" "https://${endpoint}/face/v1.0/identify" -H "Content-Type: application/json" --data-ascii "{\"personGroupId\": \"stappy\",\"faceIds\": [\"$faceId\"],\"maxNumOfCandidatesReturned\": 1,\"confidenceThreshold\": 0.5}"| jq -r '.[0].candidates[0].personId')
curl -H "$header" "https://${endpoint}/face/v1.0/persongroups/stappy/persons/$personId"
curl -H "$header" "https://${endpoint}/face/v1.0/persongroups/stappy/persons/$personId" | jq '.name'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment