clarifai: API Client for the Clarifai API.

[ library, mit, network ] [ Propose Tags ] [ Report a vulnerability ]

Provides functionality for interacting with Clarifai's Image Tagging API. Users need a Clarifai account to use this, as the endpoints require an access token.


[Skip to Readme]

Modules

[Last Documentation]

  • Network
    • Network.Clarifai

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.0.1, 0.1.1.0, 0.2.0.0 (info)
Dependencies aeson, base (>=4.8 && <4.9), bytestring (>=0.10.6.0), containers (>=0.5.6.2), easy-file (>=0.2.1), HTTP (>=4000.2.22), http-client (>=0.4.26.2), lens (>=4.13), lens-aeson (>=1.0.0.5), scientific (>=0.3.3.8), text (>=1.2.1.3), unordered-containers (>=0.2.5.1), vector (>=0.11.0.0), wreq (>=0.4.1.0) [details]
License MIT
Author Joseph Canero
Maintainer caneroj1@tcnj.edu
Category Network
Source repo head: git clone https://github.com/caneroj1/clarifai-hs
Uploaded by jcanero at 2015-12-31T18:32:26Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 2114 total (6 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
All reported builds failed as of 2016-11-05 [all 3 reports]

Readme for clarifai-0.2.0.0

[back to package description]

clarifai-hs

Haskell API Client for Clarifai.

Clarifai provides image/video recognition services, and this library provides a web client to their API.

All endpoints other than the feedback endpoint are implemented. This includes

  • /info
  • /token
  • /tag

Installation

cabal install clarifai

Example Usage

Authorization

First create an App and then call the authorize function to authenticate your application. You must provide your client id and client secret.


import Network.Clarifai
import Data.Either

clientID = "id"
clientSecret = "secret"

main = do
  let myApp = App clientID clientSecret
  resp <- authorize myApp

Then you can check the response for errors, or use the access token it provides back in the form of a Client.

Getting API Info

-- Omitted previous code
main = do
  -- Be sure to check for errors
  let client = head $ rights [resp]
  infoResponse <- info client

If there are no errors, you will get back an Info containing various information about the statistics and limits of the Clarifai API, like maximum video size, maximum image size, etc. You can use this verify any files you may want to tag, before you send a tagging request.

Verification

When going to verify batch sizes, it is important not to mix and match between videos and images. The batch sizes for images and videos are different, so you cannot verify the sizes of the batches together even though you can send them in the same request. I don't do any differentiating between what kind of file the FilePath points to.

If you are calling the verifyFiles function, however, you can have a list of both videos AND images, as long as the extensions of each FilePath indicate the type of the file.

-- Omitted previous code
main = do
  -- Be sure to check for errors
  let apiInfo = head $ rights [infoResponse]
  let filePaths = [filePath1, filePath2, filePath3]

  -- Verify the image batch size
  -- The return value is a Bool indicating whether your list is of appropriate size for the API.
  verifyImageBatchSize apiInfo filePaths

  -- Verify the sizes of the files in the list. As long as each FilePath indicates whether the file is a video or an image,
  -- the size of the file will be checked to make sure it is within the appropriate bounds according to the API Info.
  verifyFiles infoData fileNames

Tagging

We can send a tag request with our list of FilePaths. I've omitted any steps where we may have filtered out which files verifyFiles marked as inappropriate for the request.

-- Omitted previous code
tagResponse <- tag client fileNames

Contributing

I'll gladly take contributions/improvements/pull requests.

License

The MIT License (MIT)

Copyright (c) 2015 Joe Canero

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.