Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Imports the Google Cloud client library
- from google.cloud import vision
- from google.cloud.vision import types
- def is_cat(content):
- labels = fetch_data(content)
- if labels[0].description == "cat":
- return True
- else:
- return False
- def fetch_data(content):
- # Instantiates a client
- client = vision.ImageAnnotatorClient()
- # Tell Google Vision that our content is of type Image
- image = types.Image(content=content)
- # Performs label detection on the image file
- response = client.label_detection(image=image)
- return response.label_annotations
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement