# devtools::install_github("mgahan/WanderingEye")
library(WanderingEye)
In order to test the package, it is good to have a set of sample files. Feel free to use your own, but here some sample files that I uploaded to Google Cloud
# Download file
downloadURL <- "https://storage.googleapis.com/mike-public-data/SampleAnimalPhotos.zip"
destFile <- "SampleAnimalPhotos.zip"
if (!file.exists(destFile)) {
download.file(url=downloadURL, destfile = destFile)
}
# Unzip file
destDir <- gsub(".zip","",destFile)
if (!dir.exists(destDir)) {
unzip(zipfile=destFile)
}
We can first check out how many files we have available to us.
FileListDat <- data.table(Filename=list.files(path=destDir, recursive = TRUE, full.names = TRUE))
kable(head(FileListDat))
SampleAnimalPhotos/12227_tapir.jpg SampleAnimalPhotos/12231_porcupine.jpg SampleAnimalPhotos/3743-2.JPG SampleAnimalPhotos/ave rapaz-3734-19.JPG SampleAnimalPhotos/Cchinga B-Rancho Chico 3715-14.JPG SampleAnimalPhotos/chunga 3728-5.JPG
We can now forge ahead and attempt to detect labels of the image using Google Cloud Vision. If you have not gone through the process of extracting the Google Cloud Vision API keys, please do this before moving onto this next step.
SampleImage <- FileListDat[35, Filename]
GoogleOutput <-
googleCloudVision(
imagePath=SampleImage,
feature = "LABEL_DETECTION",
numResults = 10,
API_KEY = Sys.getenv("GCLOUD_VISION_API_KEY"))
kable(GoogleOutput[])
mid
description
score
/m/083jv
white
0.9630147
/m/019sc
black
0.9617918
/m/01g6gs
black and white
0.9549949
/m/04rky
mammal
0.9270029
/m/035qhg
fauna
0.9162718
/m/03d49p1
monochrome photography
0.9149839
/m/01280g
wildlife
0.9146594
/m/04hgtk
head
0.8594266
/m/0898b
zebra
0.8483723
/m/05wkw
photography
0.8124335
MicrosoftOutput <-
microsoftComputerVision(
imagePath=SampleImage,
feature = "analyze",
MICROSOFT_API_ENDPOINT = Sys.getenv("MICROSOFT_API_ENDPOINT"),
MICROSOFT_API_KEY1 = Sys.getenv("MICROSOFT_API_KEY1"))
kable(MicrosoftOutput$Tags[])
name
confidence
hint
zebra
0.9985831
animal
animal
0.9855506
NA
mammal
0.7482966
animal
kable(MicrosoftOutput$Descriptions[])
text
confidence
a zebra is looking at the camera
0.8817827
kable(MicrosoftOutput$Meta[])
width
height
format
1280
1024
Jpeg
AWSOutput <-
awsRekognition(
imagePath=SampleImage,
targetPath = NULL,
feature = "detect-labels",
AWS_ACCESS_KEY_ID = Sys.getenv("AWS_ACCESS_KEY_ID"),
AWS_SECRET_ACCESS_KEY = Sys.getenv("AWS_SECRET_ACCESS_KEY"),
AWS_BUCKET = Sys.getenv("AWS_BUCKET"),
AWS_DEFAULT_REGION = Sys.getenv("AWS_DEFAULT_REGION"))
kable(AWSOutput[])
Feature
Score
Description
File
LABELS
96.46909
Animal
SampleAnimalPhotos/IMG_0095.JPG
LABELS
96.46909
Mammal
SampleAnimalPhotos/IMG_0095.JPG
LABELS
96.46909
Zebra
SampleAnimalPhotos/IMG_0095.JPG
LABELS
84.84165
Ct Scan
SampleAnimalPhotos/IMG_0095.JPG
LABELS
84.84165
X-Ray
SampleAnimalPhotos/IMG_0095.JPG
IBMOutput <-IBMWatsonVision(
imagePath=SampleImage,
IBM_WATSON_API = Sys.getenv("IBM_WATSON_API"),
IBM_WATSON_VERSION = Sys.getenv("IBM_WATSON_VERSION"))
kable(IBMOutput[])
Class
Score
Hierarchy
zebra
0.893
/animal/mammal/odd-toed ungulate (hoofed mammal)/zebra
odd-toed ungulate (hoofed mammal)
0.992
NA
mammal
0.992
NA
animal
0.992
NA
grevy's zebra
0.803
/animal/mammal/odd-toed ungulate (hoofed mammal)/grevy's zebra
mountain zebra
0.5
/animal/mammal/odd-toed ungulate (hoofed mammal)/mountain zebra
coal black color
0.961
NA
black color
0.893
NA
ClarifaiOutput <- clarifaiPredict(
imagePath=SampleImage,
CLARIFAI_API_KEY = Sys.getenv("CLARIFAI_API_KEY"))
kable(ClarifaiOutput[])
id
name
value
app_id
File
ai_786Zr311
no person
0.9927144
main
SampleAnimalPhotos/IMG_0095.JPG
ai_RmpTltl9
stripe
0.9916375
main
SampleAnimalPhotos/IMG_0095.JPG
ai_8Z5lBHrh
zebra
0.9911756
main
SampleAnimalPhotos/IMG_0095.JPG
ai_fbqvMwRm
wildlife
0.9887770
main
SampleAnimalPhotos/IMG_0095.JPG
ai_tBcWlsCp
nature
0.9869842
main
SampleAnimalPhotos/IMG_0095.JPG
ai_vfV1Zf9w
horizontal
0.9857936
main
SampleAnimalPhotos/IMG_0095.JPG
ai_SzsXMB1w
animal
0.9585370
main
SampleAnimalPhotos/IMG_0095.JPG
ai_5DDJGZxT
skin
0.9446589
main
SampleAnimalPhotos/IMG_0095.JPG
ai_Zmhsv0Ch
outdoors
0.9396830
main
SampleAnimalPhotos/IMG_0095.JPG
ai_XNzGRk0F
side view
0.9283558
main
SampleAnimalPhotos/IMG_0095.JPG
ai_T85WqSNl
camouflage
0.9162262
main
SampleAnimalPhotos/IMG_0095.JPG
ai_43sQsmXM
safari
0.8985972
main
SampleAnimalPhotos/IMG_0095.JPG
ai_bBl132T0
zoo
0.8980871
main
SampleAnimalPhotos/IMG_0095.JPG
ai_6pRrC0WT
danger
0.8656015
main
SampleAnimalPhotos/IMG_0095.JPG
ai_j6rltf8j
elegant
0.8605607
main
SampleAnimalPhotos/IMG_0095.JPG
ai_xDm4LRvF
zoology
0.8495933
main
SampleAnimalPhotos/IMG_0095.JPG
ai_SVshtN54
one
0.8491527
main
SampleAnimalPhotos/IMG_0095.JPG
ai_N6BnC4br
mammal
0.8446153
main
SampleAnimalPhotos/IMG_0095.JPG
ai_0Ngv01Hf
contrast
0.8444433
main
SampleAnimalPhotos/IMG_0095.JPG
ai_wLQ7hLvK
identity
0.8337676
main
SampleAnimalPhotos/IMG_0095.JPG
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.