Last active
May 5, 2016 16:23
-
-
Save devStepsize/a1ecd3538a632a4446ffb1c9f6627bc4 to your computer and use it in GitHub Desktop.
Public image tagging with Clarifai's Python client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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