<jupyter_start><jupyter_text>Detecting labels using VisionThis notebooks shows how you can use the Google Cloud Vision API to add content labels to images.We'll use the Google Cloud Client Library for Vision to perform label detection on some cute animal pictures. What does vision think of my cat, Tillie?<jupyter_code>cat_picture = open('data/cat.jpg', 'rb').read()

# Display our cat picture
Image(cat_picture, width=800)
client = vision.ImageAnnotatorClient()
response = client.label_detection(image=vision.types.Image(content=cat_picture))
response<jupyter_output><empty_output><jupyter_text>Slightly more readableLet's us jupyter's features to make this raw data a bit more readable:<jupyter_code>def print_labels(response):
    labels = [(label.description, label.score) for label in response.label_annotations]
    return pd.DataFrame(labels, columns=['label', 'score'])
print_labels(response)<jupyter_output><empty_output><jupyter_text>What does Vision think about this wonderful goat that lives at Carmel Valley Ranch?<jupyter_code>goat_picture = open('data/goat.jpg', 'rb').read()

# Display our goat picture
Image(goat_picture, width=800)
response = client.label_detection(image=vision.types.Image(content=goat_picture))
print_labels(response)<jupyter_output><empty_output><jupyter_text>Okay, but how about something that isn't an animal?<jupyter_code>concert_picture = open('data/concert.jpg', 'rb').read()

# Display our concert picture
Image(concert_picture, width=800)
response = client.label_detection(image=vision.types.Image(content=concert_picture))
print_labels(response)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10110974106041924, 'fraction_numerical': 0.005548705302096177, 'mean_word_length': 8.221590909090908, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '304198', 'license': 'Apache-2.0', 'n_tokens_mistral': 509, 'n_tokens_neox': 483, 'n_words': 129, 'path': 'vision-labels.ipynb', 'repo_name': 'jonparrott/pycon2018-notebooks', 'size': '1622'}