def __init__(self): # Configure API key authorization: Apikey configuration = cloudmersive_image_api_client.Configuration() configuration.api_key['Apikey'] = CLOUDMERSIVE_API_KEY # Create an instance of the API class self.api_instance = cloudmersive_image_api_client.RecognizeApi( cloudmersive_image_api_client.ApiClient(configuration))
def match_image(check_image, target_image): # Configure API key authorization: Apikey configuration = cloudmersive_image_api_client.Configuration() #'YOUR_API_KEY' configuration.api_key['Apikey'] = apikey # create an instance of the API class api_instance = cloudmersive_image_api_client.FaceApi(cloudmersive_image_api_client.ApiClient(configuration)) try: # Compare and match faces api_response = api_instance.face_compare(check_image, target_image) except ApiException as e: #describe the error print("Exception when calling FaceApi->face_compare: %s\n" % e) return api_response
def match_image(check_image, target_image): """Connect to the cloudmersive host in order to ask to perform the match using the 2 image given as parameter. check_image is the image that will be machted with target_image. :param path: The path of the two images :type path: string :return: the Json containing infos about the match :rtype: Json """ # Configure API key authorization: Apikey configuration = cloudmersive_image_api_client.Configuration() configuration.api_key['Apikey'] = apikey # create an instance of the API class instance = cloudmersive_image_api_client.ApiClient(configuration) api_instance = cloudmersive_image_api_client.FaceApi(instance) try: # Compare and match faces api_response = api_instance.face_compare(check_image, target_image) except ApiException as e: # Describe the error print("Exception when calling FaceApi->face_compare: %s\n" % e) return api_response
def predict_image_to_caption(cloudmersive_api_key): # Configure API key authorization: Apikey configuration = cloudmersive_image_api_client.Configuration() configuration.api_key['Apikey'] = cloudmersive_api_key # create an instance of the API class api_instance = cloudmersive_image_api_client.RecognizeApi(cloudmersive_image_api_client.ApiClient(configuration)) image_file = "website-image.jpg" prediction = "" try: # Describe an image in natural language api_response = api_instance.recognize_describe(image_file) prediction = "Please listen to our prediction of your webpage. " if api_response.highconfidence == False: prediction = prediction + api_response.best_outcome.description + ". However, we are not very sure about this prediction." else: prediction = api_response.best_outcome.description except Exception as e: prediction = "Sorry, an error occured while we were trying to guess the content of the page. Please try again." return prediction
from __future__ import print_function import time import cloudmersive_image_api_client 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'] = '7cb7be78-35a6-4a37-98b0-d93098d9ddbb' # 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.RecognizeApi( cloudmersive_image_api_client.ApiClient(configuration)) image_file = 'hamburguer.jpg' # file | Image file to perform the operation on. Common file formats such as PNG, JPEG are supported. try: # Describe an image in natural language api_response = api_instance.recognize_describe(image_file) pprint(api_response) except ApiException as e: print("Exception when calling RecognizeApi->recognize_describe: %s\n" % e)