avatar_gen/gen.py

30 lines
1.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from zhipuai import ZhipuAI
from image_downloader import download_image
import os
client = ZhipuAI(api_key="8a795f242987fb1388b61f7c1e104b0d.9goBSAn25glQZGLP") # 请填写您自己的APIKey
response = client.images.generations(
model="cogview-3", #填写需要调用的模型名称
# prompt=" 一个城市在水晶瓶中欢快生活的场景,水彩画风格,展现出微观与珠宝般的美丽。")
# prompt="一个中国女性35岁左右长发身材纤细细腰梨形身材身材曲线有致,,穿白色薄纱连衣短裙和肉色连裤袜躺姿卧于床上真实摄影效果富士XT30相机56mm长焦")
prompt="""
1. 人物形象:
- 两人之间存在一种秘密的亲密关系。
- 他们可能希望避免引起外界过多的注意。
2. 职业和场景:
- 提到“在课堂上”,暗示至少一方可能是学生或教育工作者。
- 可以构建的场景可能是一个学习环境,如学校或图书馆。
3. 提词构建:
- “两人坐在安静的角落,低声讨论着只有他们俩才知道的秘密计划。”
- “阳光透过图书馆的窗户,洒在认真阅读的两个人身上,他们偶尔交换一个意味深长的眼神。”"""
)
print(response.data[0].url)
filename = "avatar6.png"
# check if file exist, if so, make name surfix num + 1, for example avatar6.png exist, then avatar7.png
if os.path.exists(filename):
i = 1
while os.path.exists(filename):
filename = "avatar" + str(i) + ".png"
i += 1
download_image(response.data[0].url, filename)