国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

分享幾張Openai生成的圖片

2023-03-18 19:27 作者:老張你去哪兒  | 我要投稿


夕陽西下,斷腸人在天涯
一個小男孩在吃玉米,小男孩黃皮膚,黑頭發(fā),玉米烤的有點糊
畫一個帥氣逼人的亞洲青年男子
畫一個帥氣的亞洲青年,寸頭。

輸入的中文,翻譯使用的openai的text-davinci-003.

import requests

from requests.structures import CaseInsensitiveDict

import openai

import json

import datetime

# 導入os

import os

from dotenv import load_dotenv


def openai_translate(text):

? ? text="Translate this into English:\n\n"+text+"\n\n"

? ? response = openai.Completion.create(

? ? ? ? engine="text-davinci-003",

? ? ? ? prompt=text,

? ? ? ? temperature=0.9,

? ? ? ? max_tokens=1024,

? ? ? ? top_p=1,

? ? ? ? frequency_penalty=0,

? ? ? ? presence_penalty=0.6,

? ? )

? ? return response['choices'][0]['text']


def generate_image(question):

? ? prompt = openai_translate(question)

? ? response = openai.Image.create(

? ? ? ? prompt=prompt,

? ? ? ? n=1,

? ? ? ? size="1024x1024"

? ? ? ? )

? ? image_url = response['data'][0]['url']

? ? return image_url


def download_image(url, file_name):

? ? response = requests.get(url)

? ? if response.status_code == 200:

? ? ? ? with open(file_name, 'wb') as f:

? ? ? ? ? ? f.write(response.content)


if __name__ == "__main__":

? ? # 加載配置文件

? ? load_dotenv()

? ? # 讀取 API key

? ? openai.api_key = os.getenv("KEY")

? ? # 生成圖像

? ? question = input()

? ? image_url = generate_image(question)

? ? now=datetime.datetime.now().strftime("%Y%m%d%H%M") #當前時間作為文件名

? ? imgname='d:\desktop\image%s.png'%now

? ? download_image(image_url, imgname)

? ? # 使用系統(tǒng)默認的圖片瀏覽器打開圖片# 啟動系統(tǒng)默認的圖片瀏覽器打開圖片

? ? os.startfile(imgname)



分享幾張Openai生成的圖片的評論 (共 條)

分享到微博請遵守國家法律
从化市| 耿马| 犍为县| 岳普湖县| 周至县| 滦平县| 上饶县| 玛沁县| 大姚县| 乐至县| 宜阳县| 固镇县| 岳普湖县| 崇明县| 廊坊市| 祁连县| 郴州市| 阳泉市| 浦北县| 潞城市| 响水县| 博乐市| 大埔县| 康保县| 凌云县| 道孚县| 盖州市| 孝昌县| 东乡族自治县| 左云县| 长寿区| 融水| 东台市| 大庆市| 老河口市| 三都| 襄汾县| 太和县| 崇左市| 玉林市| 烟台市|