Last active
August 13, 2018 11:32
-
-
Save ghotz/019455bf725aa4c8d61e07bbf1970c89 to your computer and use it in GitHub Desktop.
Analyze image by URL with Clarifai API in PowerShell
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
# Analyze image by URL with Clarifai API in PowerShell | |
$ClarifaiAPIURL = "https://api.clarifai.com/v2"; | |
$ClarifaiAPIKey = "YOUR_KEY_GOES_HERE"; | |
$ClarifaiAPIPredictTemplateURL = ($ClarifaiAPIURL + "/models/{0}/outputs") | |
$PredictInputs = | |
@{ | |
inputs = @(@{ | |
data = @{ | |
image = @{ | |
url = "https://cloud.google.com/vision/images/rushmore.jpg" | |
} | |
} | |
}) | |
}; | |
$JSonPredictInputs = ConvertTo-Json $PredictInputs -Depth 4 | |
$ModelId = "aaa03c23b3724a16a56b629203edc62c"; # general-v1.3 model | |
$Response = Invoke-WebRequest ` | |
-Uri ($ClarifaiAPIPredictTemplateURL -f $ModelId) ` | |
-Headers @{'Authorization' = ("Key " + $ClarifaiAPIKey)} ` | |
-Body $JSonPredictInputs ` | |
-ContentType "application/json" ` | |
-Method "Post" ` | |
-ErrorAction Stop ` | |
-UseBasicParsing; | |
$Response.Content | Out-File "C:\Temp\cognitive\rushmore.predict.json" -Encoding UTF8; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment