1
0
forked from s434596/CatOrNot
CatOrNot/app/cat_recognition.py
2018-12-11 00:32:28 +01:00

21 lines
621 B
Python

# 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 array of labels
return response.label_annotations