Files
membank/.trae/skills/image-tools/SKILL.md
12600k-rog-d4 3688e40383 修正image-tools技能并新增NAS U盘主图素材
- 清理万相相关内容(SKILL.md、wan_image_edit.py),仅保留豆包Seedream
- 修正豆包万相误称,明确为火山引擎豆包Seedream
- 新增文字渲染技巧章节(双引号包裹、逐字拼写、清晰度约束)
- 更新doubao-api-reference.md模型ID和参数说明
- 新增产品/NAS U盘目录(实拍图、主图、产品名称)
- 清理旧的nascab目录冗余图片和脚本
2026-07-06 07:48:03 +08:00

8.1 KiB
Raw Blame History

## 豆包 Seedream字节跳动/火山引擎) 使用火山引擎 Ark API 的 Doubao Seedream 模型,支持文生图、图生图、多图融合、图片编辑。 ### 前提条件 - curl.exeWindows内置 - Ark API Key: ark-119a37ed-f123-42fc-aea6-b38d47d47fc0-f7ddf - API端点: https://ark.cn-beijing.volces.com/api/v3/images/generations ### 模式一览 | 模式 | image参数 | 用途 | |---|---|---| | 文生图 | 省略或[] | 从文字描述生成图片 | | 图生图 | ["url1"] | 基于参考图生成新图可通过prompt控制保留原图产品外观 | | 多图融合 | ["url1","url2",...] | 最多10张参考图融合prompt中用"图1/图2"指代 | | 图片编辑 | ["url1"] + 编辑提示词 | 移除/替换元素、换背景等 | 默认模型: doubao-seedream-5-0-260128 ### 图生图说明 Seedream 的 image 参数传入的是参考图,模型会根据 prompt 重新生成图片,不能100%像素级保留原图。但通过精确的 prompt 可在一定程度上保持产品形态: - 好的做法:"保留图1中U盘产品的外观和形态不变仅更换背景为白色添加科技光效" - 不好的做法:"U盘插在电脑上"(描述太笼统,产品外观会偏离原图) ### 文生图Windows PowerShell powershell $tmpFile = "$env:TEMP\request.json" $prompt = "YOUR_PROMPT_HERE" $json = @" {"model":"doubao-seedream-5-0-260128","prompt":"$prompt","size":"2k","sequential_image_generation":"disabled","response_format":"url","stream":false,"watermark":false} "@ $sw = [System.IO.StreamWriter]::new($tmpFile, $false, (New-Object System.Text.UTF8Encoding $false)) $sw.Write($json); $sw.Close() $response = curl.exe -s -X POST https://ark.cn-beijing.volces.com/api/v3/images/generations ` -H "Content-Type: application/json" ` -H "Authorization: Bearer ark-119a37ed-f123-42fc-aea6-b38d47d47fc0-f7ddf" ` -d "@$tmpFile" | ConvertFrom-Json $imageUrl = $response.data[0].url $outputPath = Join-Path (Get-Location) "output-name.png" curl.exe -s -o $outputPath $imageUrl Write-Output $outputPath ### 图生图/图片编辑本地文件输入Windows PowerShell powershell $imgBytes = [System.IO.File]::ReadAllBytes((Resolve-Path "path\to\input.png")) $imgBase64 = [System.Convert]::ToBase64String($imgBytes) $tmpFile = "$env:TEMP\request.json" $sw = [System.IO.StreamWriter]::new($tmpFile, $false, (New-Object System.Text.UTF8Encoding $false)) $sw.WriteLine('{') $sw.WriteLine(' "model": "doubao-seedream-5-0-260128",') $sw.WriteLine(' "prompt": "保留图1中产品的外观和形态不变更换背景为白色",') $sw.WriteLine(' "image": ["data:image/png;base64,' + $imgBase64 + '"],') $sw.WriteLine(' "size": "2048x2048",') $sw.WriteLine(' "sequential_image_generation": "disabled",') $sw.WriteLine(' "response_format": "url",') $sw.WriteLine(' "stream": false,') $sw.WriteLine(' "watermark": false') $sw.WriteLine('}') $sw.Close() $response = curl.exe -s -X POST https://ark.cn-beijing.volces.com/api/v3/images/generations ` -H "Content-Type: application/json" ` -H "Authorization: Bearer ark-119a37ed-f123-42fc-aea6-b38d47d47fc0-f7ddf" ` -d "@$tmpFile" | ConvertFrom-Json $imageUrl = $response.data[0].url $outputPath = Join-Path (Get-Location) "output-name.png" curl.exe -s -o $outputPath $imageUrl Write-Output $outputPath > 注意:当 prompt 中包含中文引号等特殊字符时,不要用 PowerShell 的 @"..."@ here-string 拼接 JSON应改用 StreamWriter.WriteLine() 逐行写入,避免解析错误。 ### 多图融合 json { "model": "doubao-seedream-5-0-260128", "prompt": "把图1的人物穿上图2的衣服站在图3的场景中", "image": ["url1", "url2", "url3"], "size": "2k", "sequential_image_generation": "disabled", "response_format": "url", "stream": false, "watermark": false } ### 批量生成最多15张 json { "model": "doubao-seedream-5-0-260128", "prompt": "一个女孩和她的布偶牛在过山车上,分别呈现早晨、中午、傍晚的场景", "sequential_image_generation": "auto", "sequential_image_generation_options": { "max_images": 3 }, "size": "2k", "response_format": "url", "stream": false, "watermark": false } ### Seedream 参数参考 | 参数 | 类型 | 必填 | 说明 | |---|---|---|---| | model | string | 是 | doubao-seedream-5-0-260128默认5.0)、doubao-seedream-4-5-2511284.5)、doubao-seedream-4-0-2508284.0 | | prompt | string | 是 | 文本提示词,最多300中文字或600英文词 | | image | string[] | 否 | 参考图片URL或Base64data:image/jpeg;base64,...最多10张prompt中用"图1/图2"指代顺序 | | size | string | 否 | 2k(默认)、3k仅5.0)、4k4.5/4.0WIDTHxHEIGHT(如2048x2048 | | response_format | string | 否 | url下载链接24h有效b64_json | | output_format | string | 否 | jpeg(默认)或 png仅5.0支持) | | sequential_image_generation | string | 否 | disabled(默认,单图)或 auto(模型决定批量数) | | sequential_image_generation_options | object | 否 | { "max_images": N } N为1-15仅auto模式 | | stream | boolean | 否 | false(等待全部)或 true(逐张返回) | | watermark | boolean | 否 | 添加"AI Generated"水印,默认true(建议设false | | tools | array | 否 | [{ "type": "web_search" }] 联网搜索仅5.0 | ### Seedream 尺寸指南 | 别名 | 近似分辨率 | 适用场景 | |---|---|---| | 2k | ~2048px | 默认 — 质量与速度平衡 | | 3k | ~3072px | 高质量产品图仅5.0 | | 4k | ~4096px | 最终生产质量4.5/4.0 | | WIDTHxHEIGHT | 自定义 | 如2048x20482048x1024 | 像素约束 - 方式1别名2k/3kprompt中描述宽高比 - 方式2精确像素总像素范围 [3686400, 16777216],宽高比 [1/16, 16],每个维度 [1280, 4096] - 两种方式不可混用 ### Seedream 提示词技巧 - 描述场景: 主体、动作、环境、氛围 - 指定风格: "电影大片感"、"水彩画风"、"赛博朋克"、"oc渲染"、"超现实主义" - 质量关键词: "光线追踪"、"景深"、"极致的光影"、"动态模糊" - 编辑指令: "保留图1中产品外观不变把背景换成海滩"、"移除画面中的人物" - 多图指代: 多图输入时用"图1""图2"明确指代,如"保留图1的U盘放到图2的笔记本上" - 中文提示词原生支持 — 无需翻译为英文 ### 文字渲染技巧(重要) Seedream 对文字渲染有特殊优化,但需要正确的提示词写法: - 必须用双引号包裹文字内容Seedream 对双引号内的文字有特殊渲染优先级,准确率远高于不加引号 - 正确:标题文字"NAS U盘"标签显示"自动内网穿透" - 错误:标题文字NAS U盘标签显示自动内网穿透 - 强制清晰度约束:加"笔画清晰醒目、无乱码无模糊"等约束条件 - 指定字体样式:明确"黑色加粗印刷体"、"白色大号粗体"等,避免模糊描述 - 避免过多小字:小字号文字像素占比太低,极易模糊出错;尽量只生成少量大号标题文字 - 商用场景建议:对文字精度要求高时,采用"AI生成无文字底图 + 手动/程序叠加文字"的工作流 ### Windows注意事项 | 问题 | 解决方案 | |---|---| | PowerShell 5.1给JSON加UTF-8 BOM | 不要Set-Content[System.Text.Encoding]::UTF8,用[System.IO.StreamWriter]::new($path, $false, (New-Object System.Text.UTF8Encoding $false)) | | PowerShell破坏curl中的" | 始终写JSON到临时文件-d "@$tmpFile" | | prompt含中文引号/特殊字符 | 用StreamWriter.WriteLine()逐行写JSON不要用@"..."@ here-string | | curl别名冲突 | 用curl.exe而非curl | | 续行符 | 用反引号` | ### Seedream 错误处理 - 401: API Key无效 — 检查Authorization头 - 400: 请求错误 — 检查提示词长度、图片格式、尺寸值像素不低于3686400 - 429: 限流 — 等待后重试 - 500: 服务器错误 — 稍后重试