Title: | Access to Clarifai API |
---|---|
Description: | Get description of images from Clarifai API. For more information, see <http://clarifai.com>. Clarifai uses a large deep learning cloud to come up with descriptive labels of the things in an image. It also provides how confident it is about each of the labels. |
Authors: | Gaurav Sood [aut, cre] |
Maintainer: | Gaurav Sood <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.4.3 |
Built: | 2024-11-11 05:30:50 UTC |
Source: | https://github.com/gojiplus/clarifai |
Get Description of Images. Understand what is in the images. See http://clarifai.com/. Details about results of calls to the API can be found at https://developer.clarifai.com.
Your need credentials to use this application. If you haven't already, you can get this at https://developer.clarifai.com/.
Gaurav Sood
Check if authentication information is in the environment
clarifai_check_auth()
clarifai_check_auth()
Check results
clarifai_check_results(res)
clarifai_check_results(res)
res |
results being returned by the API |
Check if authentication token is in the environment
clarifai_check_token()
clarifai_check_token()
GET
clarifai_GET(path, query, ...)
clarifai_GET(path, query, ...)
path |
path to specific API request URL |
query |
query list |
... |
Additional arguments passed to |
list
POST
clarifai_POST(path, query = NULL, ...)
clarifai_POST(path, query = NULL, ...)
path |
path to specific API request URL |
query |
query list |
... |
Additional arguments passed to |
list
Suggest tags, suggest removal of tags, suggest (dis)similar documents, or let clarifai know which tag was clicked on
feedback(file_path = "", feedback_type = "add_tags", feedback_value = "", ...)
feedback(file_path = "", feedback_type = "add_tags", feedback_value = "", ...)
file_path |
image on which the feedback is being provided |
feedback_type |
must be one of the following types:
|
feedback_value |
what tags to add, remove etc. |
... |
Additional arguments passed to |
https://developer.clarifai.com/guide/
## Not run: # Before calling the function, set API secret and id via secret_id(c("client_id", "secret")) # and get token via get_token() feedback(file_path="path_to_image", feedback_type="add_tags", feedback_value="suggested_tag") ## End(Not run)
## Not run: # Before calling the function, set API secret and id via secret_id(c("client_id", "secret")) # and get token via get_token() feedback(file_path="path_to_image", feedback_type="add_tags", feedback_value="suggested_tag") ## End(Not run)
Get the dominant colors present in images or videos
get_color(file_paths = NULL, ...)
get_color(file_paths = NULL, ...)
file_paths |
a vactor of paths to image file(s) for which you want tags |
... |
Additional arguments passed to |
Named list of length 3: status_code
, status_msg
, and results
.
results
is a named list of length 12. Contains information about max. and
min. image and video size allowed etc.
Prints status_msg
by default
https://developer.clarifai.com/
## Not run: # Before calling the function, set API secret and id via secret_id(c("client_id", "secret")) # and get token via get_token() get_color(file_paths="path_to_image") ## End(Not run)
## Not run: # Before calling the function, set API secret and id via secret_id(c("client_id", "secret")) # and get token via get_token() get_color(file_paths="path_to_image") ## End(Not run)
Get the dominant colors present in images or videos
get_color_urls(img_urls = NULL, meta = FALSE, ...)
get_color_urls(img_urls = NULL, meta = FALSE, ...)
img_urls |
A string or character vector of URLs of images for which you want tags |
meta |
Boolean that toggles whether or not you want the entire object. Default is FALSE. When FALSE, the function returns just a data.frame of results |
... |
Additional arguments passed to |
Named list of length 3: status_code
, status_msg
, and results
.
results
is a named list of length 12. Contains information about max. and
min. image and video size allowed etc.
Prints status_msg
by default
https://developer.clarifai.com/
## Not run: # Before calling the function, set API secret and id via secret_id(c("client_id", "secret")) # and get token via get_token() get_color_urls("https://samples.clarifai.com/metro-north.jpg") get_color_urls(c("https://samples.clarifai.com/metro-north.jpg", "https://samples.clarifai.com/metro-north.jpg")) ## End(Not run)
## Not run: # Before calling the function, set API secret and id via secret_id(c("client_id", "secret")) # and get token via get_token() get_color_urls("https://samples.clarifai.com/metro-north.jpg") get_color_urls(c("https://samples.clarifai.com/metro-north.jpg", "https://samples.clarifai.com/metro-north.jpg")) ## End(Not run)
Basic information about the application — what are maximum sizes allowed, default language, max. and min. image and video size, max. batch size, etc.
get_info(...)
get_info(...)
... |
Additional arguments passed to |
Named list of length 3: status_code
, status_msg
, and results
.
results
is a named list of length 12. Contains information about max. and
min. image and video size allowed etc.
Prints status_msg
by default
https://developer.clarifai.com/
## Not run: # Before calling the function, set API secret and id via secret_id(c("client_id", "secret")) # and get token via get_token() get_info() ## End(Not run)
## Not run: # Before calling the function, set API secret and id via secret_id(c("client_id", "secret")) # and get token via get_token() get_info() ## End(Not run)
List all the languages that the tag API call supports
get_langs(...)
get_langs(...)
... |
Additional arguments passed to |
character vector listing all the languages that tag API call supports. See tag_images
and codetag_image_urls
https://developer.clarifai.com/
## Not run: # Before calling the function, set API secret and id via secret_id(c("client_id", "secret")) # and get token via get_token() get_langs() ## End(Not run)
## Not run: # Before calling the function, set API secret and id via secret_id(c("client_id", "secret")) # and get token via get_token() get_langs() ## End(Not run)
Once you have set your Application ID and Secret via secret_id
, get the access token.
get_token(...)
get_token(...)
... |
Additional arguments passed to |
a list with 4 things: access_token, token_type, expires_in, scope
https://developer.clarifai.com/
## Not run: # Before calling the function, set API secret and id via secret_id(c("client_id", "secret")) get_token() ## End(Not run)
## Not run: # Before calling the function, set API secret and id via secret_id(c("client_id", "secret")) get_token() ## End(Not run)
Get API usage for the current month and hour
get_usage(...)
get_usage(...)
... |
Additional arguments passed to |
named list with four items status_code
, status_msg
, results
(user and application details — credits consumed, total credit)
https://developer.clarifai.com/
## Not run: # Before calling the function, set API secret and id via secret_id(c("client_id", "secret")) # and get token via get_token() get_usage() ## End(Not run)
## Not run: # Before calling the function, set API secret and id via secret_id(c("client_id", "secret")) # and get token via get_token() get_usage() ## End(Not run)
Set Client ID and Secret. Needed for interfacing with Clarifai. Run this before anything else.
secret_id(appdetails = NULL, force = FALSE)
secret_id(appdetails = NULL, force = FALSE)
appdetails |
A vector of client_id, client_secret. Get these from https://developer.clarifai.com/. Set them before you use other functions. |
force |
force reset client id and secret |
The function looks for ClarifaiId
and ClarifaiSecret
in the environment. If it doesn't find them and if we don't want to force
change in them, it looks for arguments. And if no arguments are passed, it asks for user to input the values.
https://developer.clarifai.com/
## Not run: setapp(c("client_id", "client_secret")) ## End(Not run)
## Not run: setapp(c("client_id", "client_secret")) ## End(Not run)
Tag Remote Images
tag_image_urls(img_urls = NULL, model = NULL, language = NULL, meta = FALSE, simplify = TRUE, ...)
tag_image_urls(img_urls = NULL, model = NULL, language = NULL, meta = FALSE, simplify = TRUE, ...)
img_urls |
A string or character vector of URLs of images for which you want tags |
model |
For topic specific answers. Optional. Can be one of the following: general-v1.3, nsfw-v1.0, weddings-v1.0, travel-v1.0, food-items-v0.1 Default is NULL |
language |
Return tag in another language than english. 2 digit code. Optional.
See |
meta |
Boolean that toggles whether or not you want the entire object. |
simplify |
Boolean that toggles whether or not you want a simplified data frame with each label and associated probability in a separate row. Default is TRUE. |
... |
Additional arguments passed to The entire object returned by the API contains a lot of meta data. By default a simplified data.frame with img_url, associated labels, and probabilities is returned. |
If meta is TRUE, a named list of length 4 with following elements is returned:
status_code
OK or not
status_msg
Successful or not
meta
Named list of 1 containing another list named tag
Sublist tag
has three elements: timestamp
, model
and config
results
is a data.frame of length 6 and 1 row. Column names are:
docid
, status_code
, status_msg
, local_id
and
a data.frame named tag which has a data.frame result which contains two columns:
labels and probabilities
If meta
is FALSE and simplify
is TRUE,
a data.frame with three columns: img_urls
, labels
and probs
returned
If meta
is FALSE and simplify
is FALSE,
a data.frame with two columns carrying a vector of labels, vector of probs is returned
for each image
https://developer.clarifai.com/
## Not run: # Before calling the function, set API secret and id via secret_id(c("client_id", "secret")) # and get token via get_token() tag_image_urls(img_urls="url_of_image") tag_image_urls("https://samples.clarifai.com/metro-north.jpg") tag_image_urls("https://samples.clarifai.com/metro-north.jpg", language="es") tag_image_urls("https://samples.clarifai.com/nsfw.jpg", model="nsfw-v1.0") ## End(Not run)
## Not run: # Before calling the function, set API secret and id via secret_id(c("client_id", "secret")) # and get token via get_token() tag_image_urls(img_urls="url_of_image") tag_image_urls("https://samples.clarifai.com/metro-north.jpg") tag_image_urls("https://samples.clarifai.com/metro-north.jpg", language="es") tag_image_urls("https://samples.clarifai.com/nsfw.jpg", model="nsfw-v1.0") ## End(Not run)
Tag Images on the Computer
tag_images(file_paths = NULL, model = NULL, language = NULL, meta = FALSE, simplify = TRUE, ...)
tag_images(file_paths = NULL, model = NULL, language = NULL, meta = FALSE, simplify = TRUE, ...)
file_paths |
a vactor of paths to image file(s) for which you want tags |
model |
For topic specific answers. Optional. Can be one of the following: general-v1.3, nsfw-v1.0, weddings-v1.0, travel-v1.0, food-items-v0.1 Default is NULL |
language |
Return tag in another language than english. 2 digit code. Optional.
See |
meta |
Boolean that toggles whether or not you want the entire object. |
simplify |
Boolean that toggles whether or not you want a simplified data frame with each label and associated probability in a separate row. Default is TRUE. |
... |
Additional arguments passed to The entire object returned by the API contains a lot of meta data. By default a simplified data.frame with img_url, associated labels, and probabilities is returned. |
If meta is TRUE, a named list of length 4 with following elements is returned:
status_code
OK or not
status_msg
Successful or not
meta
Named list of 1 containing another list named tag
Sublist tag
has three elements: timestamp, model and config
results
is a data.frame of length 6 and 1 row. Column names are:
docid
, status_code
, status_msg
, local_id
and
a data.frame named tag which has a data.frame result which contains two columns:
labels and probabilities
If meta is FALSE and simplify is TRUE, a data.frame with three columns: file_paths, labels and probs returned
If meta is FALSE and simplify is FALSE, a data.frame with two columns carrying a vector of labels, vector of probs is returned for each image
https://developer.clarifai.com/
## Not run: # Before calling the function, set API secret and id via secret_id(c("client_id", "secret")) # and get token via get_token() tag_images(file_paths="path_to_image") ## End(Not run)
## Not run: # Before calling the function, set API secret and id via secret_id(c("client_id", "secret")) # and get token via get_token() tag_images(file_paths="path_to_image") ## End(Not run)