How do I call the Vision API and apply more than one feature on an image. I want to apply both Label Detection and the landmark detection on an image
You can define your request as below to incorporate multiple feature requests per image
"requests":[
{
"image":{
"content":"/9j/7QBEUGhvdG9zaG9...image contents...fXNWzvDEeYxxxzj/Coa6Bax//Z"
},
"features":[
{
"type":"FACE_DETECTION",
"maxResults":10
},
{
"type":"LABEL_DETECTION",
"maxResults":10
}
]
}
]
}
from google.cloud import vision
import os
os.environ["GOOGLE_APPLICATION_CREDENTIALS"]="/path/client.json"
client = vision.ImageAnnotatorClient()
response = client.annotate_image({
'image': {'source': {'image_uri': 'gs://yourbuket/1.jpg'}},
'features': [{'type': vision.enums.Feature.Type.LABEL_DETECTION},
{'type': vision.enums.Feature.Type.FACE_DETECTION}],
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With