小编Zoh*_*zan的帖子

使用 Azure OpenAI GPT4 进行图像到文本转换

我部署了 Azure 开放 AI 帐户和 GPT4 模型。我可以使用它的API进行图像到文本的描述吗?如果是,我将如何给它图像?我正在使用这段代码。但它给我一个错误。

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
Run Code Online (Sandbox Code Playgroud)

错误就像;APIError:来自 API 的无效响应对象:“不支持的数据类型\n”(HTTP 响应代码为 400)

我在解释里面提到过。

python openai-api azure-openai gpt-4

5
推荐指数
1
解决办法
2592
查看次数

标签 统计

azure-openai ×1

gpt-4 ×1

openai-api ×1

python ×1