A cool API for Image and Video recognition

ClarifAI is an API developed by Matthew Zeiler a specialist of deep learning and image recognition.

This API isn’t free but as a developer, you can play with it for free, you just need to create an account there. Once you created your account and verified your mail go there to get a key and a secret. You first need to choose a model. For this article we’ll use the general-v1.3 model. Create then your application.

creation of an application.png

Open a terminal and run :

pip install clarifai

Now that ClarifAI is installed, pick the url of a picture in your favourite search engine. I chose this one for this article:


Copy/Paste the code below in your favourite python editor (atom rocks) and replace the url by the url of the image of your choice.

from clarifai import rest
from clarifai.rest import ClarifaiApp

import json


model = app.models.get("general-v1.3")

prediction = model.predict_by_url(url="https://s-media-cache-ak0.pinimg.com/originals/b0/d0/e8/b0d0e8ce3a8640de57e520f3d83c487c.jpg")

if prediction['status'] is not None and prediction['status']['description'] and prediction['status']['description'] == 'Ok':
concepts = prediction['outputs'][0]['data']['concepts']
for key in concepts:
print "%s -> %s" % (key['name'],key['value'])
elif prediction['status'] is not None and prediction['status']['description']:
print 'something went wrong'

Then run it, and you should get something like that :

result of clarifai.png

You can see a list of concepts with an associate score that represents the confidence of the information.

Now it’s up to you to create some smart apps with this API. Note that this is not the only API that offers this kind of service, Amazon, Google, and lot of other players provide the same kind of API’s.