You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
1.0 KiB
26 lines
1.0 KiB
from http import HTTPStatus
|
|
from urllib.parse import urlparse, unquote
|
|
from pathlib import PurePosixPath
|
|
import requests
|
|
from dashscope import ImageSynthesis
|
|
from WxMini.Milvus.Config.MulvusConfig import *
|
|
|
|
prompt = "高山,直上云端。少年,御剑飞行。怪物,紧追不放,大战,一触即发。"
|
|
|
|
|
|
print('----sync call, please wait a moment----')
|
|
rsp = ImageSynthesis.call(api_key=MODEL_API_KEY,
|
|
model="wanx2.1-t2i-turbo",
|
|
prompt=prompt,
|
|
n=1,
|
|
size='1024*1024')
|
|
print('response: %s' % rsp)
|
|
if rsp.status_code == HTTPStatus.OK:
|
|
# 在当前目录下保存图片
|
|
for result in rsp.output.results:
|
|
file_name = PurePosixPath(unquote(urlparse(result.url).path)).parts[-1]
|
|
#with open('./%s' % file_name, 'wb+') as f:
|
|
# f.write(requests.get(result.url).content)
|
|
else:
|
|
print('sync_call Failed, status_code: %s, code: %s, message: %s' %
|
|
(rsp.status_code, rsp.code, rsp.message)) |