-
Notifications
You must be signed in to change notification settings - Fork 19
Description
根据百炼平台的图像局部重绘的python demo https://help.aliyun.com/zh/model-studio/user-guide/vary-region?spm=0.0.0.i1#3dc15c8345qbt ,这里设置的base_image_url和mask_image_url服务器无法访问,因此我想从本地加载图片
参考代码:
`from http import HTTPStatus
from urllib.parse import urlparse, unquote
from pathlib import PurePosixPath
import requests
from dashscope import ImageSynthesis
prompt = "a dog wearing red glasses"
model = "wanx-x-painting"
task = "image2image"
image_path = "/root/llms/Bailian/source3.jpg"
mask_path = "/root/llms/Bailian/glasses.png"
extra_input = {
"base_image_url": image_path,
"mask_image_url": mask_path
}
print('----sync call, please wait a moment----')
rsp = ImageSynthesis.call(model=model,
prompt=prompt,
n=1,
size='1024*1024',
task=task,
extra_input=extra_input)
if rsp.status_code == HTTPStatus.OK:
print(rsp.output)
# save file to current directory
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))`
错误信息
----sync call, please wait a moment----
Traceback (most recent call last):
File "/root/llms/Bailian/test_wanx.py", line 25, in
rsp = ImageSynthesis.call(model=model,
File "/root/miniconda3/envs/wanx/lib/python3.10/site-packages/dashscope/aigc/image_synthesis.py", line 67, in call
return super().call(model,
File "/root/miniconda3/envs/wanx/lib/python3.10/site-packages/dashscope/client/base_api.py", line 219, in call
response = cls.wait(task_response,
File "/root/miniconda3/envs/wanx/lib/python3.10/site-packages/dashscope/aigc/image_synthesis.py", line 198, in wait
response = super().wait(task, api_key, workspace=workspace)
File "/root/miniconda3/envs/wanx/lib/python3.10/site-packages/dashscope/client/base_api.py", line 379, in wait
task_id = cls._get_task_id(task)
File "/root/miniconda3/envs/wanx/lib/python3.10/site-packages/dashscope/client/base_api.py", line 232, in _get_task_id
raise InvalidTask('Invalid task, task create failed: %s' %
dashscope.common.error.InvalidTask: Invalid task, task create failed: {"status_code": 400, "request_id": "8af1fd62-8664-925e-9e37-5d71185c986c", "code": "InvalidParameter.DataInspection", "message": "The media format is not supported or incorrect for the data inspection.", "output": null, "usage": null}
我看ImageSynthesis的images参数还不支持,是否只支持extra_input参数来传递图片,请介绍一下具体用法,谢谢!