Skip to content

Instantly share code, notes, and snippets.

@devStepsize
Last active May 5, 2016 16:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devStepsize/a1ecd3538a632a4446ffb1c9f6627bc4 to your computer and use it in GitHub Desktop.
Save devStepsize/a1ecd3538a632a4446ffb1c9f6627bc4 to your computer and use it in GitHub Desktop.
Public image tagging with Clarifai's Python client
"""
Tagging a few public images from the web using the Clarifai API and the
clarifai-python client.
"""
from clarifai.client import ClarifaiApi
pictures = ['http://i.imgur.com/jJWlcnR.jpg', 'http://i.imgur.com/BflW5HQ.jpg']
clarifai_api = ClarifaiApi()
results = clarifai_api.tag_image_urls(pictures)
# Uncomment the below to print the whole JSON returned
# from pprint import pprint
# pprint(result)
for i, result in enumerate(results['results']):
tags = result['result']['tag']
print '\nTags for %s (Tag - Probability)' % pictures[i]
for j in range(len(tags['classes'])):
print '%s - %0.4f' % (tags['classes'][j], tags['probs'][j])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment