Giter VIP home page Giter VIP logo

clarifai-python's Introduction

Clarifai logo

Clarifai API Python Client

This is the official Python client for interacting with our powerful recognition API. The Clarifai API offers image and video recognition as a service. Whether you have one image or billions, you are only steps away from using artificial intelligence to recognize your visual content.

PyPi version Build Status

Installation

Install the API client:

pip install clarifai --upgrade

Note: If you cannot use pip, you can download the latest release manually or using git.

Setup

Firstly, generate your Clarifai API key on the API keys page. The client uses it for authentication.

Then, to authenticate, either:

  • initialize the ClarifaiApp with your API key
    from clarifai.rest import ClarifaiApp
    app = ClarifaiApp(api_key='YOUR_API_KEY')
  • or set the environment variable named CLARIFAI_API_KEY
  • or run the script ./scripts/clarifai config which will, after you input the API key, create a file ~/.clarifai/config with your key

Note: If you have both the environmental variable CLARIFAI_API_KEY and a file ~/.clarifai/config, the environmental variable will be used.

For AWS or Windows users, please refer to the documentation for more instructions.

Getting Started

The following example will setup the client and predict concepts on an image from a URL, using the general model

from clarifai.rest import ClarifaiApp

app = ClarifaiApp()
model = app.public_models.general_model
response = model.predict_by_url(url='https://samples.clarifai.com/metro-north.jpg')

Use model.predict_by_filename to predict concepts on a local file.

The response is a JSON structure. Here's how to print all the predicted concepts associated with the image, together with their confidence values.

concepts = response['outputs'][0]['data']['concepts']
for concept in concepts:
    print(concept['name'], concept['value'])

Documentation

See many more code examples in the developer guide and in the Python client tutorial.

Also see the Python client reference.

clarifai-python's People

Contributors

adamberenzweig avatar bryanclarifai avatar camiwilliams avatar hammygoonan avatar harmon758 avatar jimreesman avatar kaushal avatar larsyencken avatar orapouso avatar robert-clarifai avatar rok-povsic avatar stegoo avatar taik 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.