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 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
Example #3
0
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)