Copyright | (c) Joseph Canero, 2015 |
---|---|
License | MIT |
Maintainer | caneroj1@tcnj.edu |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Provides functionality for interacting with Clarifai's Image Tagging API. Allows users to submit images/videos to be recognized and tagged by Clarifai. Users will need a Clarifai account to make full use of this client.
- data VerificationStatus
- data Client
- data TagSet = TagSet {}
- data Info = Info {}
- data Tag = Tag String Double
- verifyImageBatchSize :: Info -> [FilePath] -> Bool
- verifyVideoBatchSize :: Info -> [FilePath] -> Bool
- verifyFiles :: Info -> [FilePath] -> IO [(FilePath, IO VerificationStatus)]
- authorize :: Client -> IO (Either Errors Client)
- info :: Client -> IO (Either Errors Info)
- tag :: Client -> [FilePath] -> IO (Either Errors (Vector TagSet))
Documentation
data VerificationStatus Source
Enum type for verifying FilePaths before sending to the API.
The Client data type has two constructors. The first should be used when constructing a client with an access token. The second constructor should be used when passing in an application's client id and client secret. The flow usually proceeds by creating an App and then authorizing it.
A TagSet represents a single result from the Tag endpoint. A TagSet is identified uniquely by its docID, and uniquely within a request by its localID. The most important feature of the TagSet is the vector of Tags.
The Info data type is used to encapsulate a response from the /info endpoint. This type contains information about the various usage limits for the API.
A Tag is a pair of String and Double and represents a word class from the Clarifai model and the associated probability.
verifyImageBatchSize :: Info -> [FilePath] -> Bool Source
Given an API Info type and a list of FilePaths, we verify the length of the list with what the Info type specifies is acceptable batch size for images. This function assumes that the FilePaths all point to images.
verifyVideoBatchSize :: Info -> [FilePath] -> Bool Source
Given an API Info type and a list of FilePaths, we verify the length of the list with what the Info type specifies is acceptable batch size for videos. This function assumes that the FilePaths all point to videos.
verifyFiles :: Info -> [FilePath] -> IO [(FilePath, IO VerificationStatus)] Source
Given an API Info type and a list of FilePaths, we verify each of the files. If the file has an extension, we decide which Info attribute to use to verify the file. If it has no extension, we choose not to verify. This function maps each FilePath to a tuple of (FilePath, VerificationStatus), where VerificationStatus = Good | Bad | Unknown
authorize :: Client -> IO (Either Errors Client) Source
Authorize an application Sends a POST request to Clarifai's authentication endpoint. If we have a Client, we just return the client because I'm assuming the client was constructed with a valid access token. If we have an App, we would POST the client ID and client secret to Clarifai to get an access token.