Advertisement
Guest User

Untitled

a guest
Dec 10th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. # Imports the Google Cloud client library
  2. from google.cloud import vision
  3. from google.cloud.vision import types
  4.  
  5. def is_cat(content):
  6.     labels = fetch_data(content)
  7.     if labels[0].description == "cat":
  8.         return True
  9.     else:
  10.         return False
  11.  
  12. def fetch_data(content):
  13.     # Instantiates a client
  14.     client = vision.ImageAnnotatorClient()
  15.  
  16.     # Tell Google Vision that our content is of type Image
  17.     image = types.Image(content=content)
  18.  
  19.     # Performs label detection on the image file
  20.     response = client.label_detection(image=image)
  21.     return response.label_annotations
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement