Let’s keep this very simple. First, pip install the API client.
Next, call face_detect_age and provide it with an input image.
from __future__ import print_function
from cloudmersive_image_api_client.rest import ApiException
from pprint import pprint# Configure API key authorization: Apikey
configuration = cloudmersive_image_api_client.Configuration()
configuration.api_key['Apikey'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['Apikey'] = 'Bearer'# create an instance of the API class
api_instance = cloudmersive_image_api_client.FaceApi(cloudmersive_image_api_client.ApiClient(configuration))
image_file = '/path/to/file' # file | Image file to perform the operation on. Common file formats such as PNG, JPEG are supported.try:
# Detect the age of people in an image
api_response = api_instance.face_detect_age(image_file)
except ApiException as e:
print("Exception when calling FaceApi->face_detect_age: %s\n" % e)
Pretty easy, huh? Let’s look at an example:
You will notice that the function supports multiple people, provides their location within the photo, age range, a best guess at their exact age, and confidence rating of the assessment.