Giter VIP home page Giter VIP logo

clarifai-python's Introduction

Clarifai Python Client

This Python client provides a simple wrapper around our powerful image recognition API.

The constructor takes your APP_ID and APP_SECRET created in your Clarifai Account. You can also set these variables in your environment as: CLARIFAI_APP_ID CLARIFAI_APP_SECRET

This client uses your APP_ID and APP_SECRET to get an access token. Since this expires every so often, the client is setup to renew the token for you automatically using your credentials so you don't have to worry about it. Additionally, we highly recommend that you have PIL or Pillow installed if you plan to send images from your local machine to our service. The client will automatically determine your allowed limits and resize any images you wish to process automatically before sending. If you do not have PIL or Pillow then you must do this yourself to ensure your API calls are processed without fail.

Installation

pip install git+git://github.com/Clarifai/clarifai-python.git
export CLARIFAI_APP_ID=<an_application_id_from_your_account>
export CLARIFAI_APP_SECRET=<an_application_secret_from_your_account>

Usage

A complete example of using this Python client is as follows. Suppose you want to tag an image on your local drive:

from clarifai.client import ClarifaiApi
clarifai_api = ClarifaiApi() # assumes environment variables are set.
result = clarifai_api.tag_images(open('/path/to/local/image.jpeg'))

This will return the tagging result for the given image read off your local storage system (see the Docs for response format). The operations supported by the client can all handle batches of images. Keeping tagging as the running example, this would look like:

result = clarifai_api.tag_images([open('/path/to/local/image.jpeg'),
                                  open('/path/to/local/image2.jpeg')])

The result will now contain all the results of the tagging for each image in the batch. When sending large batches of images, you must adhere to your application limits for the maximum batch size per request.

If your images live remotely at a public url, you can also use tag_image_urls:

from clarifai.client import ClarifaiApi
clarifai_api = ClarifaiApi()  # assumes environment variables are set.
result = clarifai_api.tag_image_urls('http://www.clarifai.com/img/metro-north.jpg')

The same result format is returned whether provided image bytes or urls.

Please check out the full documentation for our API at developer.clarifai.com.

clarifai-python's People

Contributors

adamberenzweig avatar camiwilliams avatar robert-clarifai avatar vinayan3 avatar zeiler avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.