openai visgpt,chatgpt,DALLE2 使用测试

编程知识 行业动态 更新时间:2024-06-13 00:18:23

网络问题:openai-chatGPT的API调用异常处理
官方手册:https://platform.openai/docs/api-reference

visgpt

gitlab代码

https://github/microsoft/visual-chatgpt

visual_chatgpt.py运行前添加密匙

os.environ['OPENAI_API_KEY']=""

更改参数为cpu

parser.add_argument('--load', type=str, default="ImageCaptioning_cpu,Text2Image_cpu")

非常非常慢7min,而且根据控制台查看图片,发现已经生成,而UI上没有生成

chatGPT

import openai

# Apply the API key
openai.api_key = "xxx"

# Define the text prompt
prompt = "to be or not to be "

# Generate completions using the API
completions = openai.Completion.create(
    engine="text-davinci-002",
    prompt=prompt,
    max_tokens=100,
    n=1,
    stop=None,
    temperature=0.5,
)

# Extract the message from the API response
message = completions.choices[0].text
print(message)

结果

DALLE2

import requests
import openai
from PIL import Image
openai.api_key = "xxx"
response=openai.Image.create(
  prompt="the little prince and the fox in the story, they sit together",
  n=1,
  size="1024x1024"
)
image_url = response['data'][0]['url']
r = requests.get(image_url)
with open('test.png', 'wb') as f:
    f.write(r.content)
img = Image.open('test.png')
img.show()

结果:氛围有了,但是细节不够

更多推荐

openai visgpt,chatgpt,DALLE2 使用测试

本文发布于:2023-03-26 17:59:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/e8e7529ff562b75e9b17ecd93e2b7db0.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:测试   visgpt   openai   chatgpt

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!