Title: ImageSynthesis的extra_input参数如何设置本地图片路径 · Issue #5 · dashscope/dashscope-sdk-python · GitHub
Open Graph Title: ImageSynthesis的extra_input参数如何设置本地图片路径 · Issue #5 · dashscope/dashscope-sdk-python
X Title: ImageSynthesis的extra_input参数如何设置本地图片路径 · Issue #5 · dashscope/dashscope-sdk-python
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 urlpar...
Open Graph 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 HT...
X 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 HT...
Opengraph URL: https://github.com/dashscope/dashscope-sdk-python/issues/5
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ImageSynthesis的extra_input参数如何设置本地图片路径","articleBody":"根据百炼平台的图像局部重绘的python demo [https://help.aliyun.com/zh/model-studio/user-guide/vary-region?spm=0.0.0.i1#3dc15c8345qbt](url) ,这里设置的base_image_url和mask_image_url服务器无法访问,因此我想从本地加载图片\n### 参考代码:\n`from http import HTTPStatus\nfrom urllib.parse import urlparse, unquote\nfrom pathlib import PurePosixPath\nimport requests\nfrom dashscope import ImageSynthesis\n\nprompt = \"a dog wearing red glasses\"\nmodel = \"wanx-x-painting\"\ntask = \"image2image\"\n\nimage_path = \"/root/llms/Bailian/source3.jpg\"\nmask_path = \"/root/llms/Bailian/glasses.png\"\n\nextra_input = {\n \"base_image_url\": image_path,\n \"mask_image_url\": mask_path\n}\n\n\nprint('----sync call, please wait a moment----')\nrsp = ImageSynthesis.call(model=model,\n prompt=prompt,\n n=1,\n size='1024*1024',\n task=task,\n extra_input=extra_input)\nif rsp.status_code == HTTPStatus.OK:\n print(rsp.output)\n # save file to current directory\n for result in rsp.output.results:\n file_name = PurePosixPath(unquote(urlparse(result.url).path)).parts[-1]\n with open('./%s' % file_name, 'wb+') as f:\n f.write(requests.get(result.url).content)\nelse:\n print('sync_call Failed, status_code: %s, code: %s, message: %s' %\n (rsp.status_code, rsp.code, rsp.message))`\n### 错误信息\n----sync call, please wait a moment----\nTraceback (most recent call last):\n File \"/root/llms/Bailian/test_wanx.py\", line 25, in \u003cmodule\u003e\n rsp = ImageSynthesis.call(model=model,\n File \"/root/miniconda3/envs/wanx/lib/python3.10/site-packages/dashscope/aigc/image_synthesis.py\", line 67, in call\n return super().call(model,\n File \"/root/miniconda3/envs/wanx/lib/python3.10/site-packages/dashscope/client/base_api.py\", line 219, in call\n response = cls.wait(task_response,\n File \"/root/miniconda3/envs/wanx/lib/python3.10/site-packages/dashscope/aigc/image_synthesis.py\", line 198, in wait\n response = super().wait(task, api_key, workspace=workspace)\n File \"/root/miniconda3/envs/wanx/lib/python3.10/site-packages/dashscope/client/base_api.py\", line 379, in wait\n task_id = cls._get_task_id(task)\n File \"/root/miniconda3/envs/wanx/lib/python3.10/site-packages/dashscope/client/base_api.py\", line 232, in _get_task_id\n raise InvalidTask('Invalid task, task create failed: %s' %\ndashscope.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}\n我看ImageSynthesis的images参数还不支持,是否只支持extra_input参数来传递图片,请介绍一下具体用法,谢谢!","author":{"url":"https://github.com/LiYufengzz","@type":"Person","name":"LiYufengzz"},"datePublished":"2025-04-23T03:06:27.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/5/dashscope-sdk-python/issues/5"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ed6ebcb6-6311-20ca-276d-af4dee200243 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C53A:3351E0:10F475B:180BAAF:6978D2BF |
| html-safe-nonce | 4bc19175371665745454a7a6232ed180878449df258a9ef99542ec57dd836859 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNTNBOjMzNTFFMDoxMEY0NzVCOjE4MEJBQUY6Njk3OEQyQkYiLCJ2aXNpdG9yX2lkIjoiODEzMTExNjE5MTE1OTIxMDY4NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 63efa4483de4028fb6b83b940d98d42898f095bc67a9677f61c86f728eb8b751 |
| hovercard-subject-tag | issue:3012563978 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/dashscope/dashscope-sdk-python/5/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d2ef82c24716d8e6bb8a577c929834d0ca903ea3065ca69128d77305c11c4079/dashscope/dashscope-sdk-python/issues/5 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d2ef82c24716d8e6bb8a577c929834d0ca903ea3065ca69128d77305c11c4079/dashscope/dashscope-sdk-python/issues/5 |
| og:image:alt | 根据百炼平台的图像局部重绘的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 HT... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | LiYufengzz |
| hostname | github.com |
| expected-hostname | github.com |
| None | 8a71ca1f7ab5436216e1df86f398ef7a51ed3152c90e3f7332fc70cf97fcb9d6 |
| turbo-cache-control | no-preview |
| go-import | github.com/dashscope/dashscope-sdk-python git https://github.com/dashscope/dashscope-sdk-python.git |
| octolytics-dimension-user_id | 127009744 |
| octolytics-dimension-user_login | dashscope |
| octolytics-dimension-repository_id | 944303085 |
| octolytics-dimension-repository_nwo | dashscope/dashscope-sdk-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 944303085 |
| octolytics-dimension-repository_network_root_nwo | dashscope/dashscope-sdk-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | eaed570eead52a9920afef75dc3eb6d826fdc5ef |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width