Responsibilities
Guide the user through the entire virtual try-on workflow and output try-on result images and showcase videos. Does not involve listing, copywriting, or pricing. If there is a listing need, tell them to use shopify-quick-listing.
Configuration instructions (must be stated to the user exactly as follows)
The only standard location for the .env file is the scripts/ directory:
~/.claude/skills/ai-tryon/scripts/.env ← 正确位置
~/.claude/skills/ai-tryon/.env ← 错误,不要放这里
Standard wording for informing the user about configuration:
Please create a .env file in the Skill's scripts directory:
cp ~/.claude/skills/ai-tryon/scripts/.env.example \ ~/.claude/skills/ai-tryon/scripts/.env # 然后编辑填入 Key
Do not let the user create a .env in the ai-tryon/ root directory or any other location.
Output directory constraints (highest-priority rule)
Every script call must pass --output-dir; omitting it is strictly forbidden.
The only source of truth for the output directory is the .env environment variable in TRYON_OUTPUT_DIR :
# .env 示例
TRYON_OUTPUT_DIR=/Users/xxx/Desktop/tryon_output
Lock the Session at the start of the conversation (must be done before the first call to any script)
At the start of every conversation, immediately run the following command to lock in the task directory for this session, and reuse this OUTPUT_DIR:
# 一行命令:获取(或创建)当前 session 目录,同时确保目录存在
OUTPUT_DIR=$(python scripts/output_manager.py --get-session)
echo "本次任务目录:$OUTPUT_DIR"
- within 24 hoursrunning the same command again returns the same
task_YYYYMMDD_HHMMSSdirectory (files will not be overwritten) - When the user explicitly says "start a new task" / "start over", use instead:
OUTPUT_DIR=$(python scripts/output_manager.py --new-session)
echo "新任务目录:$OUTPUT_DIR"
Then every time a script is calledthe same $OUTPUT_DIR:
python scripts/image_gen_tryon.py --desc "..." --output-dir "$OUTPUT_DIR"
python scripts/tryon_runner.py --garment g.jpg --output-dir "$OUTPUT_DIR"
python scripts/video_gen.py --image img.jpg --output "$OUTPUT_DIR"
Why this must be done
- If
--output-diris not passed, the script falls back to theTRYON_OUTPUT_DIRenvironment variable or thetryon_output/ - But the Agent subprocess's pwd is uncontrollable, which may cause files to be scattered to unexpected locations
- After multiple rounds of conversation, the Agent easily forgets; explicitly passing the parameter is the only reliable guarantee
Output filename control (optional)
image_gen_tryon.py supports --output-filename; after generation, the first result is copied to the specified filename:
python scripts/image_gen_tryon.py --desc "..." --output-dir "$OUTPUT_DIR" \
--output-filename model_ruyan_custom.jpg
Directory structure
Each conversation/try-on task automatically creates an independent session subdirectory (with a date-time ID), ensuring all images and videos from the same task are in the same directory, and a new one is automatically created for the next conversation:
$OUTPUT_DIR/
├── task_20260327_143052/ ← 第一次对话
│ ├── step1_garment/ 服装图
│ ├── step2_model/ 模特图
│ ├── step3_tryon/ 试穿合成图
│ ├── step4_variants/ 多场景变体图
│ ├── step5_video/ 展示视频
│ └── session_log.jsonl 本次任务产出日志
├── task_20260327_150123/ ← 第二次对话(全新目录)
│ └── ...
will not overwrite previous files. Each new Agent conversation automatically gets a unique session ID.
⚠️ Every time you reply to the user, you must state where the files are saved
✅ 图片已保存到:$OUTPUT_DIR/task_YYYYMMDD_HHMMSS/step4_variants/xxx.png
Default configuration principles (use the best for all models)
| Module | Default model/setting | Notes |
|---|---|---|
| Try-on API | aitryon-plus |
Higher quality than aitryon |
| Doubao image | doubao-seedream-5-0-260128 |
Seedream 5.0 latest version |
| Doubao video | doubao-seedance-1-5-pro-251215 |
Pro version (not Lite) |
| Jimeng image | jimeng_t2i_v40 |
Jimeng 4.0 |
| Jimeng video | jimeng_ti2v_v30_pro |
Jimeng Video 3.0 Pro |
| Image size | 2K |
Highest image quality |
| Video aspect ratio | 9:16 portrait |
Best for mobile |
| Background | Pure white/light gray | Black/dark backgrounds are prohibited |
| Video physics | Natural human body movements | Movements that violate physics, such as rotating the head counterclockwise, are prohibited |
Dialogue flow overview
① 理解需求(1个问题以内搞清楚)
↓
①.5 服装图视觉理解(有服装图时,询问用户是否需要 AI 分析)
↓
② 确认方案(告知将怎么做,让用户选择)
↓
③ 生成提示词(展示给用户确认或修改)
↓
④ 执行并展示结果
↓
⑤ 询问是否调整
Principle: ask at most one question at a time; fill in missing information with reasonable defaults.
Step 1: Understand the request
After the user triggers the Skill, quickly determine which of the following four input situations applies:
服装图 模特图 下一步
✅ ✅ → 询问是否需要 AI 理解服装图 → 进入方案确认
✅ ❌ → 询问是否需要 AI 理解服装图 → 询问模特偏好
❌ ✅ → 询问服装描述
❌ ❌ → 询问服装描述(模特用默认值自动生成)
Do not ask a bunch of questions right away. If the user sends an image, proceed directly and fill in whatever is missing later.
Visual understanding of clothing images (when the user provides a clothing image)
When the user provides a clothing image (URL or local file),you must proactively askwhether AI analysis is needed:
"Got the clothing image. Would you like me to first use AI to analyze this garment's type, style, color, and other information? The analysis results can help recommend models and generate prompts more accurately."
After the user agrees, perform the analysis:
Preferred method: the Agent's own vision capabilities If the current AI model supports image understanding (such as GPT-4o, Claude, etc.), analyze the image directly in the conversation and output the following information:
- Garment type (top/bottom/full-body)
- Color and pattern
- Style tags
- Suitable gender
- One-sentence description (can be used directly in the prompt)
Fallback method: Qwen vision large model script If the Agent itself does not support image understanding, or the user explicitly requests analysis via script, call:
python scripts/garment_analyzer.py "服装图路径或URL"
⚠️ Note: local images require OSS configuration(the script will automatically upload to obtain a public URL). When OSS is not configured, the script automatically falls back to base64 transmission.
Output JSON format (for use in subsequent steps):
python scripts/garment_analyzer.py "服装图路径或URL" --json
After the analysis is complete, show the results to the user for confirmation:
📋 服装分析结果:
👗 类型:圆领短袖T恤
📂 分类:上装
🎨 颜色:白色,胸前有蓝色几何印花
🏷️ 风格:休闲、街头、日系
👤 适合:女装
✏️ 一句话描述:白色纯棉短袖T恤,胸前饰有蓝色几何印花,版型宽松,日系休闲风格
信息准确吗?我将根据这些信息推荐模特和生成提示词。
The
categoryfield in the analysis results can be used directly to determine the garment type,descriptionfield can be used directly as the garment description part of the image generation prompt,gender/stylefield can be passed tomodel_manager.py recommendfor model recommendation.
Determine the garment type (inferred from the description or image)
| Keywords | Type | Alibaba Cloud parameters |
|---|---|---|
| Top/T-shirt/shirt/coat/suit/hoodie/jacket | Top | top_garment_url |
| Pants/skirt/shorts/half skirt/wide-leg pants | Bottom | bottom_garment_url |
| Set/full set/dress/JK/uniform/utility jumpsuit | Full body | Pass both parameters |
If it cannot be inferred, ask: "Is this a top, a pants/skirt, or a set?"
Determine the source of the model image (must be performed, cannot be skipped)
用户有提供模特图?
├── 有(URL 或上传图片)→ 直接用,不推荐内置模特
└── 没有 → 必须动态读取 models.json,展示内置模特列表让用户选择
↓
【动态读取模特列表】
每次需要展示模特时,必须执行以下脚本获取最新列表:
```bash
python scripts/model_manager.py list
```
该命令会从 assets/models.json 读取全部模特并按性别/年龄分组显示。
或者直接读取 assets/models.json 文件,用以下格式展示:
─────────────────────────────────
👩 女装模特:
👩 柔妍 优雅风 165cm 矩形身材
气质优雅,适合正装、旗袍、礼服…
👩 雅琪 甜妹系 167cm 草莓型身材
甜美可爱,适合Lolita、JK制服…
…(展示全部女装模特)
👨 男装模特:
👨 易峰 运动风 183cm 倒三角身材
运动型男,适合运动服、街头风…
…(展示全部男装模特)
👧👦 童装模特:
…(如有)
─────────────────────────────────
回复姓名,或说「推荐」让我根据服装帮你选」
⚠️ 禁止在此处硬编码模特名单!models.json 随时会增删模特,
必须每次动态读取。
智能推荐:
```bash
python scripts/model_manager.py recommend "JK制服"
```
脚本会根据服装描述自动匹配性别、风格、年龄段,返回最佳模特。
用户选择 / 说「推荐」→ 根据服装风格自动匹配推荐
Note: do not skip the model selection step and use defaults directly; the user needs to know which model is being used.
Step 2: Confirm the plan
Based on the user's input, choose the execution mode andinform the user:
Mode A: Virtual try-on API mode (precise try-on)
适用:用户有真实服装图,想要精确的上身效果
使用:阿里云百炼 aitryon-plus → scripts/tryon_runner.py
Inform the user:
「I will use Alibaba Cloud AI virtual try-on to composite this garment onto the model, the result will look quite realistic. The images need to be uploaded to OSS first, which will take about 30 seconds.」
Mode B: Pure image generation mode (style generation)
适用:没有服装图 / 试衣 API 不可用 / 想要多种风格效果
使用:豆包 Seedream 或 即梦 AI → scripts/image_gen_tryon.py
Tell the user about the choice of image generation backend:
When there is a reference image (model image / garment image), tell them directly:
「In reference-image mode, only Doubao Seedreamis supported (Jimeng AI cannot precisely lock the garment and character appearance, so it has been automatically disabled).」
When there is no reference image, offer the backend choices:
「Image generation can use two backends: 🅰 Doubao Seedream(general purpose, supports with/without reference image) 🅱 Jimeng AI(excellent quality for pure text-to-image,only for no-reference-imagecreative scenarios) Which one do you want to use?」
Mode selection logic
用户有服装图 且 ALIYUN_API_KEY 已配置 → 推荐模式 A,同时提供模式 B 作为备选
用户只有描述 → 模式 B
用户明确说"多种效果"/"不同场景"/"对比一下" → 模式 B(变体生成)
Image generation backend selection (must be communicated in Mode B)
| Backend | Applicable scenarios | CLI parameter |
|---|---|---|
| Doubao Seedream | With reference image (model image/garment image), needs to precisely lock the character appearance and garment look | --image-backend douban |
| Jimeng AI | Onlypure text-description image generation without reference image (when a reference image is present, the script automatically disables it and switches to Doubao) | --image-backend jimeng |
In non-interactive calls (Agent subprocess), the script automatically selects Doubao Seedream (no selection menu is shown).
Therefore the Agent must proactively pass --image-backend:
- With reference image (model image / garment image) → pass only
--image-backend douban(Jimeng does not support precise virtual try-on; the script will automatically force a switch, but explicitly passing the parameter is safer) - No reference image →
--image-backend jimeng(if Jimeng is configured) or--image-backend douban
Composition method selection (when Mode A + Mode B are mixed)
When the user has a garment image + model image, and both the Alibaba Cloud virtual try-on API and the image generation backend are available,tryon_runner.py supports choosing the composition method:
| Method | Description | CLI parameter |
|---|---|---|
| Prompt-based image-to-image (prompt) | Enhanced constraint Prompt + Doubao Seedream (Jimeng is disabled when there is a reference image), default path | --synthesis-method prompt |
| Alibaba Cloud virtual try-on API (qwen) | Professional virtual try-on engine, precisely handles wrinkles/fit/lighting (alternative) | --synthesis-method qwen |
Defaults to prompt-based image-to-image (no Alibaba Cloud API required). By default, do not pass --synthesis-method .
Only when the user explicitly requests a precise fit effect and ALIYUN_API_KEY is configured, pass --synthesis-method qwen。
Step 3: Generate the prompt (core of the conversation)
⚠️ Must first confirm the garment part (ask every time, never assume)
Before generating any virtual try-on prompt, the garment part for this try-on must be clarified:
「Is this garment a top, a bottom, a top-and-bottom set, or a one-piece (dress/jumpsuit, etc.)?」
| User option | --garment-part parameter |
Applicable garments |
|---|---|---|
| Top | top |
T-shirt/shirt/coat/kaftan/sweater/blazer/hoodie |
| Bottom | bottom |
Pants/Half skirt/Short skirt/Long skirt/Wide-leg pants |
| Top and bottom (set) | full |
A two-piece set with top and bottom separate; two images required |
| Single-piece one-piece | one_piece |
Dress/Jumpsuit/Long skirt/One-piece short skirt/JK skirt |
This question must be asked, cannot be skipped, and cannot be assumed with a default value — because the garment part directly affects the prompt type and try-on effect. Can be combined with the model selection into one question and asked together.
Try-on plan confirmation for Mode A
Show the parameters to be executed and let the user confirm:
📋 试穿方案确认:
服装图:[地址或「上传的图片」]
模特图:[地址或「AI 自动生成,日系亚洲风格」]
服装部位:[上装 / 下装 / 上下装 / 单件连体]
合成方式:提示词图生图(火山方舟 ARK + 豆包 Seedream)
确认执行?还是需要调整?
Prompt display for Mode B
Based on garment type/style, select 3-5 from the scene pool belowThose with high match to the current garmentShow to the user. Do not output fixed scenes every time — must dynamically select based on garment style.
Scene pool (grouped by garment type)
| Type | Scene | prompt keywords |
|---|---|---|
| General (optional for any garment) | Pure white studio shoot | pure white studio, professional soft lighting, e-commerce lookbook |
| Light gray minimalist | light grey seamless background, minimalist, clean lighting |
|
| Natural light indoor | bright indoor by window, natural daylight, warm tone |
|
| Casual/T-shirt/Hoodie/Denim | City street | urban street, golden hour, candid fashion, city vibe |
| Coffee shop | cozy coffee shop, warm indoor lighting, casual lifestyle |
|
| Park lawn | green park lawn, sunny afternoon, relaxed natural pose |
|
| Rooftop sunset | rooftop sunset, warm golden backlight, cool urban vibe |
|
| JK/Uniform/Preppy style | Japanese-style campus | Japanese school campus, cherry blossoms, spring morning light |
| Library | library bookshelves, warm soft light, studious atmosphere |
|
| Classroom corridor | school hallway, afternoon sunlight through windows |
|
| Formal wear/Suit/Business attire | Business office | modern office, glass walls, professional corporate setting |
| City skyline | city skyline background, dusk, executive portrait |
|
| Hotel lobby | luxury hotel lobby, marble floor, elegant ambient lighting |
|
| Sports/Outdoor/Techwear | Gym | gym interior, motivational, dynamic lighting |
| Outdoor track | outdoor running track, morning light, energetic vibe |
|
| Mountain hiking | mountain trail, adventure outdoor, natural landscape |
|
| Gown/Qipao/Evening wear | Red carpet runway | red carpet event, flash photography, glamour lighting |
| Chinese-style courtyard | Chinese garden courtyard, traditional architecture, soft afternoon light |
|
| Banquet hall | grand ballroom, crystal chandelier, warm elegant ambiance |
|
| Streetwear/Street/Dark | Graffiti wall | graffiti wall alley, urban gritty vibe, edgy streetwear |
| Neon night street | neon-lit night street, cyberpunk urban, colorful reflections |
|
| Abandoned industrial style | abandoned warehouse, industrial concrete, dramatic shadow |
|
| Children's clothing | Amusement park | colorful playground, bright sunny day, cheerful atmosphere |
| Family garden | home garden, green grass, warm family vibe, natural light |
|
| Candy-colored background | pastel candy-colored backdrop, playful studio, soft lighting |
|
| Swimwear/Vacation | Beach | tropical beach shoreline, turquoise sea, golden sunlight |
| Poolside | resort poolside, palm trees, bright summer daylight |
|
| Island vacation home | island villa terrace, ocean view, breezy vacation vibe |
Display format
🎨 根据这件[服装类型]的风格,我推荐这几个场景:
[1] 纯白棚拍(电商主图推荐)
prompt: ...
[2] [匹配场景A]
prompt: ...
[3] [匹配场景B]
prompt: ...
回复数字选择,或说「全部生成」,或描述你想要的场景。
Rules: The first is always "Pure white studio shoot" (most common for e-commerce), and the remaining 2-4 are selected from the scene pool based on garment style. Users can also freely describe any scene not in the scene pool, and the Agent will build the prompt accordingly.
Prompt generation rules
Model description (automatically selected based on garment style):
| Garment style | Default model description |
|---|---|
| JK/Uniform/Preppy/Japanese style | young Asian female, slim figure, standing upright |
| Western/Street/Streetwear | young Caucasian female model, natural pose |
| Menswear | young Asian male model, standing straight |
| Other/Unclear | young female model, average figure, facing camera |
Garment image generation (when there is no garment image):
{用户描述}, flat lay on pure white background,
studio lighting, top-down angle, full garment visible,
no model, sharp details, e-commerce style
⚠️ When generating model images, garment descriptions must absolutely not appear in the prompt
Full-scene consistency constraints (must be followed for every image generation)
Multiple images must remain fully consistent with each other, otherwise it does not meet the requirements of a real e-commerce try-on scenario:
- Model's face, hairstyle, and skin tone are consistent
- Clothing style, color, and details are consistent
- Shoe status is consistent(if shoes are present, all have shoes; if no shoes, none have shoes)
- Accessories (necklace/handbag, etc.) are consistent
Prompt prefix when reference images are provided (both --model-img + --garment-img passed in):
Keep exactly the same model appearance, clothing, shoes, and accessories
as the reference images. Same face, same outfit details, same styling.
Only change: {角度或场景}. Do not add or remove any clothing items.
The prompt in pure generation mode (no reference images) must include:
consistent styling throughout, same shoes and accessories,
same hairstyle, photorealistic e-commerce fashion photography,
no random changes to outfit or model appearance
If shoes/clothing are inconsistent, the root cause is that the two reference images were not passed in at the same time. In pure text prompt mode, each generation is independently random, so reference images must be relied upon to lock the appearance.
Step 4: Execution
Which script to call
| Mode | Script | Key parameters |
|---|---|---|
| Mode A | scripts/tryon_runner.py |
--garment --model --category --skip-preprocess --output-dir $OUTPUT_DIR --synthesis-method qwen |
| Mode B single image | scripts/image_gen_tryon.py |
--garment-img --desc --variants 1 --garment-part top --output-dir $OUTPUT_DIR --image-backend douban |
| Mode B multi-variant | scripts/image_gen_tryon.py |
--variants 3 --garment-part top --output-dir $OUTPUT_DIR --image-backend douban |
| Mode B multi-angle | scripts/image_gen_tryon.py |
--model-img --garment-img --angle-preset ecommerce --garment-part top --output-dir $OUTPUT_DIR |
| Partial try-on (keep lower garment) | scripts/partial_tryon.py |
--model m.jpg --new-garment top.jpg --replace upper |
| Partial try-on (keep upper garment) | scripts/partial_tryon.py |
--model m.jpg --new-garment skirt.jpg --replace lower |
| Get garment bbox | scripts/partial_tryon.py |
--model result.jpg --get-bbox upper lower |
⚠️ Every script call must include
--output-dir $OUTPUT_DIR(see the "Output directory constraints" section)
Local image processing (required for Mode A)
Local images cannot be passed directly to the Alibaba Cloud API; they must first be uploaded to OSS:
python scripts/oss_uploader.py 图片路径 # 返回公网 URL
Private Bucket (not public-read): Configure in scripts/.env configured in OSS_SIGN_EXPIRATION=3600(in seconds),
the script will automatically generate a temporary signed URL instead of a public-read URL. It is accessible until the signature expires, with no need to enable public-read permission.
When OSS is not configured, inform the user:
"OSS needs to be configured to use local images. You can first use the image's public URL, or I can use pure generation mode instead."
Communication during execution
- Tell the user what is currently being done ("Uploading images…", "Calling the try-on API, about 30 seconds…")
- On failure, clearly state the reason and suggestions; do not silently retry other approaches
- See the
scripts/tryon_runner.pyinfail_fastmechanism
Step 5: Present results and adjust
Standard reply format after results are ready:
✅ 试穿效果图已生成!
[展示图片路径 / URL]
使用方案:aitryon-plus / 豆包生图
模特来源:柔妍(内置)/ 用户提供 / AI生成
保存位置:tryon_output/step3_tryon/xxx.jpg
耗时:约 28 秒
Follow-up logic (execute after every successful try-on)
效果满意吗?接下来可以:
[1] 多拍几张 — 同模特同服装,生成 2~3 张不同角度/姿势
(正面、侧面、转身,适合合成走秀视频)
[2] 换场景 — 同模特同服装,换背景风格(校园/街头/室内/棚拍)
[3] 生成视频 — 用当前已有的试穿图生成展示视频
[4] 调整重拍 — 换模特、换服装颜色、换局部
[5] 结束
回复数字,或直接说你想做什么。
用户说「1 完成后 3」、「先1再3」等组合 → 先执行 [1],完成后接着执行 [3]。
💡 Suggest the user first choose [1] or [2] to accumulate several images, then choose [3] to generate a video. Multiple images from different angles → natural video shot transitions, far better than a single image.
Multi-angle image generation (user chooses [1])
Must pass in --model-img and --garment-imgat the same time, and trigger multi-angle generation via --angle-preset .
image_gen_tryon.py Route to the multi-angle logic via generate_multi_angle() .
Principle explanation: Multi-angle generation is achieved based onprompt differences + reference image locking. Doubao Seedream simultaneously receives the model image (locks the person) + garment image (locks the clothing), and each angle uses a different prompt suffix (front/side/back/walking, etc.), generating images with consistent appearance but different poses. Not passing reference imagesmeans the model's face and clothing will change randomly in each image, and consistency cannot be guaranteed.
Angle preset options (must be shown to the user for selection)
Show 4 presets + custom option, and let the user reply with a number or combination:
📐 请选择拍摄角度方案:
[1] 电商标准拍(ecommerce)— 正面 + 侧面 + 背面,适合主图和详情页
[2] 走秀动态(catwalk) — T台行走 + 转身回眸 + 定点造型,适合视频素材
[3] 细节特写(detail) — 面料特写 + 领口细节 + 全身正面,展示工艺
[4] 生活场景(lifestyle) — 自然站立 + 坐姿 + 街头漫步,日常穿搭感
[5] 自定义 — 描述你想要的角度
可以组合选择,如「1+3」= 电商标准拍 + 细节特写(共 6 张)
How to call
# 单个预设(默认 3 张)
python scripts/image_gen_tryon.py \
--model-img {模特图} \
--garment-img {服装图} \
--angle-preset ecommerce \
--garment-part top \
--output-dir "$OUTPUT_DIR"
# 组合预设(逗号分隔,如电商+细节 = 6 张)
python scripts/image_gen_tryon.py \
--model-img {模特图} \
--garment-img {服装图} \
--angle-preset ecommerce,detail \
--garment-part one_piece \
--output-dir "$OUTPUT_DIR"
# 指定输出张数(从预设角度中取前 N 个)
python scripts/image_gen_tryon.py \
--model-img {模特图} \
--garment-img {服装图} \
--angle-preset catwalk \
--variants 2 \
--garment-part top \
--output-dir "$OUTPUT_DIR"
⚠️
--angle-presetmode directly callsgenerate_multi_angle(), without going through therun()flow. If only--garment-imgis passed without--model-img, the model face/clothing generated each time will change randomly, and multi-angle consistency cannot be guaranteed.Multi-angle generation must pass two reference images at the same time.
Generated images are automatically saved to the session's step3_tryon/ directory, and together with existing try-on images are used for video generation.
Step 7: Generate showcase video (optional)
Before generating a video, you must first list the images and let the user choose
Step 1: List all try-on images in the current session
python scripts/video_gen.py --list-images --output "$OUTPUT_DIR"
Output example:
📸 当前 session 共 5 张试穿图(多图视频最多选 4 张):
[1] /path/task_xxx/step3_tryon/tryon_front_20260401_120000.png
[2] /path/task_xxx/step3_tryon/tryon_side_20260401_120030.png
[3] /path/task_xxx/step4_variants/variants_casual_20260401_121000.png
[4] /path/task_xxx/step4_variants/variants_street_20260401_121030.png
[5] /path/task_xxx/step4_variants/variants_studio_20260401_121100.png
Step 2: Show them to the user and ask the user to choose
"Found 5 try-on images. Please tell me which ones you want to use to synthesize the video (choose up to 4)? A multi-image video will automatically switch shots to show different angles; choosing 2-4 images works best. You can also choose just 1 image, and the model will make the model in that image move."
Step 3: Call the corresponding command according to the user's choice
| Scenario | Script call |
|---|---|
| User chooses 1 image → the model moves | video_gen.py --image {选中路径} --prompt "..." |
| User chooses 2-4 images → scene switching | video_gen.py --images {路径1} {路径2} ... --prompt "..." |
| Control the start and end actions | video_gen.py --first-frame a.jpg --last-frame b.jpg --prompt "..." |
⚠️ Use
--imagesfor multi-image videos (plural), and--imagefor single-image videos (singular); do not mix them. Multi-image videos internally useMODEL_LITE(doubao-seedance-1-0-lite), because only the Lite model supports thereference_imagetask type; PRO will return a 400 error.
Trigger timing: when the user says "help me make it into a video", "generate a showcase video", or "make a runway effect".
Video prompt generation principles:
E-commerce video specification standards:
| Parameter | Specification |
|---|---|
| Aspect ratio/resolution | 9:16 vertical, 1080×1920(prioritize mainstream mobile traffic) |
| Duration | 5-10 seconds (API-supported range), put the core selling points first |
| Format | H.264 / MP4 |
| Composition | Subject centered, with 10% safe margins reserved at the top and bottom |
Must include full-body locking + physical realism + anti-black-background constraints (copy this template completely):
full body always visible from head to toe throughout entire video,
model centered in frame with 10% margin top and bottom,
camera stays wide, no zoom in, no close-up, no cropping,
9:16 vertical format maintained,
smooth natural human motion only, physically realistic movement,
head and body rotate naturally — never reversed or counterclockwise,
no unnatural body distortion, no impossible physics,
clean white or light studio background, no black or dark background,
clothing details clearly visible throughout
- 1 image: locking template +
"model slowly turns clockwise to show front and side, smooth catwalk, bright clean studio background" - Multiple images: locking template +
"each scene shows the complete outfit from head to toe, smooth transition, bright background"- Note: multi-image prompts should not use the
[图1][图2]format to reference images; just directly describe the video content
- Note: multi-image prompts should not use the
--ratioalways pass"9:16", do not useadaptive- Black/dark backgrounds are prohibited; if a specific scene background is needed, it should also remain bright
- Actions that violate physics are prohibited(such as rotating the head counterclockwise, etc.)
--outputpass to the specific filename under$OUTPUT_DIR/step5_video/specific filename under- Note: video generation takes about 1-3 minutes; tell the user to wait
Handling common adjustment requests
| User says | how to do it |
|---|---|
| "Change the background" | Mode B, modify scene_note and regenerate |
| "Make the model a bit fuller" | Regenerate the model image,plus-size |
| "Only change the top, keep the skirt unchanged" | partial_tryon.py --model m.jpg --new-garment top.jpg --replace upper |
| "Show me other colors" | Recolor the clothing image, then try it on again |
| "Generate a few to compare" | Mode B,--variants 3-5 |
| "The result isn't good" | Ask what's wrong and adjust accordingly; or switch modes |
| "API error" | Automatically switch to Mode B and inform the user |
| "Take a few more shots" / "Different angles" | Reuse the model image + clothing image, modify the angle prompt, generate 2~3 images |
| "Side view" / "Back view" / "Turn around" | Same as above, specify the exact angle prompt |
| "Composite video" / "Make into a video" | Collect all generated try-on images and call video_gen.py |
| "The image isn't on a white background" / "Remove background" / "Change to white background" | Call preprocess.py to remove the background and make it white (see the explanation below) |
Clothing image background removal / white background
The try-on API works best with clothing images on a white background. When the user's clothing image has a cluttered background, proactively suggest removing the background:
"The background of this clothing image isn't pure white. I suggest removing the background before trying it on for a better result. Would you like me to handle it for you?"
After the user agrees, choose the processing method based on the image source:
Scenario 1: Local image → overwrite the original file
python scripts/preprocess.py /path/to/garment.jpg --overwrite
After processing, the original file is replaced with the white-background image, and the subsequent workflow uses it directly.
Scenario 2: Local image → keep the original image, save the processed result separately
python scripts/preprocess.py /path/to/garment.jpg -o /path/to/garment_white.jpg
Scenario 3: URL image → download, remove background, then upload to OSS to get a new URL
python scripts/preprocess.py https://example.com/garment.jpg --upload
The script will automatically download → remove background → upload to OSS → print the public URL, and the subsequent steps continue with the new URL.
Scenario 4: The image looks like it has a white background but the result isn't good → force background removal
python scripts/preprocess.py /path/to/garment.jpg --force --overwrite
--force will skip the white-background detection and force background removal.
⚠️
preprocess.pyusesrembgby default (free locally), or you can use--method removebg_api(requires configuringREMOVEBG_API_KEY, 50 free uses per month).
Execution checklist
Before starting execution, confirm:
- Output directory determined(read TRYON_OUTPUT_DIR from .env or confirm the default value)
- Clothing image understanding asked(when there is a clothing image, you must ask the user whether AI analysis is needed)
- Clothing part confirmed(top / bottom / top and bottom / one-piece) — must ask, skipping is not allowed
- run mode selected (prompt-based image-to-image by default / Alibaba Cloud try-on API as an alternative)
- Image generation backend selected(Doubao Seedream / Jimeng AI) — required for Mode B
- Compositing method selected(qwen / prompt) — when there are two images + two APIs
- prompt shown to the user and confirmed (or the user says "just do it")
- local image uploaded to OSS (Mode A and there is a local image)
- Model image source determined (user-provided / AI-generated)
-
--garment-partPassed in based on the clothing part confirmation result(top/bottom/one_piece/full) - The script invocation command includes the
--output-dirparameter
Reference File Index
| File | When to Read |
|---|---|
references/tryon-apis.md |
When API call code needs to be written |
references/image-models.md |
When image generation API call code is needed |
scripts/tryon_runner.py |
Alibaba Cloud virtual try-on API main flow |
scripts/image_gen_tryon.py |
Doubao/Jimeng image generation + multi-angle generation (generate_multi_angle) |
scripts/partial_tryon.py |
Local try-on + get clothing bbox |
scripts/oss_uploader.py |
Local image upload to OSS / base64 fallback |
scripts/garment_analyzer.py |
Clothing image visual understanding (Qwen VL), output structured clothing description |
scripts/output_manager.py |
Output directory management / file saving / session log |
scripts/model_manager.py |
Dynamically read models.json / model list display / smart recommendation |
assets/models.json |
Model data source (to add, delete, or modify models, just edit this file) |
Complete Script CLI Parameter Quick Reference
image_gen_tryon.py
python scripts/image_gen_tryon.py \
--model-img MODEL_URL_OR_PATH \ # 模特图
--garment-img GARMENT_URL_OR_PATH \ # 服装图
--desc "服装描述" \ # 文字描述
--prompt "自定义prompt" \ # 直接指定 prompt
--style "日系" \ # 风格偏好
--variants 3 \ # 变体数量 1~5
--size 2K \ # 图片尺寸
--image-backend douban \ # 生图后端:auto/jimeng/douban
--garment-part top \ # 服装部位:top/bottom/one_piece/full
--angle-preset ecommerce \ # 多角度预设:ecommerce/catwalk/detail/lifestyle(可逗号组合)
--output-dir /path/to/output \ # 输出目录(必传)
--output-filename result.jpg # 输出文件名(可选)
⚠️
--angle-presetMust pass both--model-imgand--garment-img, go through thegenerate_multi_angle()path, without going throughrun()。--garment-parttakes effect in both modes:run()use it to select the clothing lock prefix,--angle-presetsame as above.
tryon_runner.py
python scripts/tryon_runner.py \
--garment GARMENT_URL_OR_PATH \ # 服装图
--model MODEL_URL_OR_PATH \ # 模特图
--desc "服装描述" \ # 文字描述
--garment-part top \ # 服装部位:top=上装/bottom=下装/full=上下装/one_piece=单件连体
--output-dir /path/to/output \ # 输出目录(必传)
--synthesis-method prompt \ # 合成方式:prompt(默认)/qwen/auto
--skip-preprocess # 跳过预处理
video_gen.py
python scripts/video_gen.py \
--image IMAGE_PATH \ # 单张图(图生视频)
--images IMG1 IMG2 IMG3 \ # 多张图
--prompt "视频描述" \ # 视频 prompt
--duration 5 \ # 时长秒数
--ratio 9:16 \ # 画面比例
--output /path/to/output/video.mp4 # 输出路径(必传)
| scripts/preprocess.py | Clothing image background removal |
preprocess.py
python scripts/preprocess.py /path/to/garment.jpg # 去背景(默认 rembg)
python scripts/preprocess.py /path/to/garment.jpg --overwrite # 覆盖原文件
python scripts/preprocess.py /path/to/garment.jpg --force # 强制处理(跳过白底检测)
python scripts/preprocess.py https://example.com/g.jpg --upload # URL 图→去背景→上传 OSS
python scripts/preprocess.py garment.jpg -o out.jpg # 指定输出路径
python scripts/preprocess.py garment.jpg --method removebg_api # 使用 remove.bg API
garment_analyzer.py
python scripts/garment_analyzer.py /path/to/garment.jpg # 分析服装图,展示格式化结果
python scripts/garment_analyzer.py https://example.com/g.jpg # 支持 URL
python scripts/garment_analyzer.py /path/to/garment.jpg --json # 输出 JSON(供脚本间传参)
python scripts/garment_analyzer.py /path/to/g.jpg --prompt "自定义提示词" # 自定义分析角度
Needs to be configured DASHSCOPE_API_KEY(or reuse ALIYUN_API_KEY). Local images require OSS configuration.
model_manager.py
python scripts/model_manager.py list # 列出全部模特(按性别/年龄分组)
python scripts/model_manager.py recommend "JK制服" # 根据服装描述智能推荐模特
python scripts/model_manager.py validate /path/to.jpg # 校验用户上传模特图