Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save SQLDBAWithABeard/07e986565807caa9ae337e2bba757dfb to your computer and use it in GitHub Desktop.
Save SQLDBAWithABeard/07e986565807caa9ae337e2bba757dfb to your computer and use it in GitHub Desktop.
$Webpage = iwr http://tugait.pt/2017/speakers/
$SpeakersImages = $webpage.Images.Where{$_.class -eq 'speaker-image lazyOwl wp-post-image'}.src
$Faces = @()
foreach($URL in $SpeakersImages)
{
$jsonBody = @{url = $URL} | ConvertTo-Json
$apiUrl = "https://westus.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"
$apiKey = 'c9c98da91bbb4b1490bd24e136353766'
$headers = @{ "Ocp-Apim-Subscription-Key" = $apiKey }
#$analyticsResults =
$analyticsResults = Invoke-RestMethod -Method Post -Uri $apiUrl -Headers $headers -Body $jsonBody -ContentType "application/json" -ErrorAction Stop
#$analyticsResults.documents.keyPhrases
$face = [pscustomobject]@{
Name = $url.split("/")[-1].replace(".jpg",'').replace(".png").replace("-262x272","")
FaceAttributes = $analyticsResults.FaceAttributes
}
$Faces += $Face
Start-Sleep -Seconds 4
Get-Date
}
$beard = @{Name = 'Beard' ; Expression = { [decimal]$_.faceattributes.facialhair.beard }}
$Faces | Select Name, $beard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment