Last active
March 28, 2018 15:34
-
-
Save revodavid/722dd0f00c6d8c3ad2a15b97db8dead3 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
| image_caption <- function(URL) { | |
| reqURL = paste0(vision_api_endpoint, | |
| "/analyze?visualFeatures=Description", | |
| "&details=Celebrities,Landmarks") | |
| APIresponse = POST(url = reqURL, | |
| content_type('application/json'), | |
| add_headers(.headers = c('Ocp-Apim-Subscription-Key' = vision_api_key)), | |
| body=list(url = URL), | |
| encode = "json") | |
| df = content(APIresponse) | |
| cat(URL, "\n") | |
| cat(paste0("Confidence: ",df$description$captions[[1]]$confidence,"\n")) | |
| cat("Wikimedia Commons description:\n", attr(URL,"desc"), "\n") | |
| cat("Vision API description:\n", df$description$captions[[1]]$text,"\n") | |
| invisible(df) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment