2

I have an Azure open AI Account and GPT4 model deployed. Can I use its API for image-to-text description? If yes, how I will give it the image? I am using this code. But it throws me an error.

import openai
# open ai key
openai.api_type = "azure"
openai.api_version = "2023-03-15-preview"
openai.api_base = 'https://xxxxxx.openai.azure.com/'
openai.api_key = "xxxxxxxxxxxxx"

image_url="https://cdn.repliers.io/IMG-X5925532_9.jpg"

def generate_image_description(image_url):
    prompt = f"What is in this image? {image_url}"
    print(prompt)
    response = openai.ChatCompletion.create(
        engine="GPT4v0314",
        prompt=prompt,
        max_tokens=1024,
        n=1,
        stop=None,
        temperature=0.0,
    )
    description = response.choices[0].text.strip()
    return description

The error is like; APIError: Invalid response object from API: 'Unsupported data type\n' (HTTP response code was 400)

I mentioned it inside the explanation.

1 Answers1

2

At the moment, Azure OpenAI GPT-4 models are not multi-modal: you cannot pass an image directly, so you can't achieve what you are looking for.

See official documentation here

enter image description here

Nicolas R
  • 13,812
  • 2
  • 28
  • 57