DEV Community

xiaodong Zhang
xiaodong Zhang

Posted on

The hardest part of AI garment extraction is the shoulder you never saw

This article was written with the help of AI. The spec analysis is mine, and every command below was run on my own machine before publishing.

The problem

图 1 · 输入与输出(示例来自仓库 docs/clothing-extraction/)
You have 140 SKUs going live next week. What you have is supplier photos and on-model shots. What the listing needs is flat-lays: garment laid out, centred, front-facing, symmetric, no human in frame.
The classic answer is a photographer and a retoucher. The other classic answer is your designer spending twenty minutes per item in Photoshop, most of it not removing the model but inventing the parts of the garment the model was standing in front of.
That second half is the interesting problem, and it's the one most "AI background remover" tools don't touch at all.
TL;DR
• clothing-extraction is a skill spec (a Markdown file an agent reads) from dlazyai/ecommerce-skills, MIT licensed
• It fixes the extraction prompt into four segments, and the doc is explicit that segment two — the deletion list — must name every element individually
• It runs gpt-image-2 with --size 1024x1024 --quality high --batch 2~3
• The batch 2~3 is the tell: this is a generate-several-pick-one workflow, not a one-shot converter
• The occluded regions are inferred from symmetry and standard patterns, not recovered. Plan a human review step
Install

everything in the repo (19 skills)

npx skills add https://github.com/dlazyai/ecommerce-skills --all

or just what you need

npx skills add https://github.com/dlazyai/ecommerce-skills \
--skill clothing-extraction

or scope it to one agent

npx skills add https://github.com/dlazyai/ecommerce-skills --agent claude-code

The skill shells out to the dLazy CLI, pinned to @dlazy/cli@1.2.3. Auth is a device-code flow that works over SSH:
dlazy login # device-code flow, writes ~/.dlazy/config.json

or

dlazy auth set YOUR_API_KEY

or per-invocation

DLAZY_API_KEY=... dlazy gpt-image-2 ...

You can also skip the installer entirely and paste the contents of skill.md into an agent conversation. It's a spec, not a binary.
The actual call, straight from the doc:
dlazy gpt-image-2 \
--prompt '' \
--images docs/clothing-extraction/source-photo.jpg \
--size 1024x1024 --quality high --imageFormat png \
--batch 2 \
--save docs/clothing-extraction/output-dress.png

--dry-run prints the payload and the cost without executing. Use it first.
How the prompt is structured

图 2 · 四段式提取指令
This is the part worth stealing even if you never install the skill.
Segment Job
1 Name the single target garment, with enough detail to disambiguate it
2 List every element to remove, one by one
3 State the output form: laid flat, centred, front view, left-right symmetric, unoccluded
4 State the fidelity constraints: same colour, same knit texture, same neckline and armhole shape, same waist seam and hem length

Written out, a segment-two list for a street-style shot looks roughly like this:
[Segment 1 · target] Output only [the single item to keep: category + colour + key features].
[Segment 2 · remove] Remove the model, [every other element in frame: accessories/bag/shoes/props/background].
[Segment 3 · form] Laid flat and centred, front view, symmetric, fully unoccluded.
[Segment 4 · fidelity] Keep the garment 100% faithful: same [colour], [knit/fabric],
[neckline and sleeve], [waist seam and hem length].

Filled in against the example image that ships with the skill — a street shot of a model in a light-grey knit mini dress, wearing a pearl necklace, carrying a tote bag, in silver heels, with a fountain behind her:
Output only the light-grey textured sleeveless knit mini dress with the mock neckline,
laid flat and centred, front view, symmetric, fully unoccluded — remove the model,
the pearl necklace, the tote bag, the shoes, the fountain and the whole background.
Keep the garment 100% faithful: same light-grey colour, same knit texture,
same neckline and armhole shape, same waist seam and hem length.
Pure white seamless background, even soft studio light, subtle contact shadow.
No person, no props, no text.

Every removal target is a noun the model can act on. "Remove everything except the dress" is not — it hands the disambiguation problem back to the model, and the model makes a choice you never get to see.
The doc is blunt about this: write only remove the background and the necklace, bag and shoes stay in frame as part of the product.
For a full outfit, you loop: one pass per garment, one flat-lay out per pass.
Why segment two is the load-bearing one
Here is the argument for the sceptical reader, because there is a good sceptical reading here.
The obvious objection: this is just a prompt. When the next model ships, the prompt is obsolete, and maybe today's model doesn't need this much hand-holding anyway.
Half right. Segments three and four are model-dependent — they're compensating for current failure tendencies, and a better model needs less of them.
Segment two is not. Segment two solves referential ambiguity, and that isn't a capability problem, it's a language problem. Any time the input frame contains more than one object, someone has to say which one survives. A stronger model guesses better. It still guesses.
That's why the deletion list is the part of this spec I'd expect to still be true in two years.
Input constraints
Straight from the spec:
Constraint Value
File size 20 KB – 15 MB
Resolution > 400 × 400
Formats jpg / jpeg / png / webp

Plus three soft requirements that matter more than the hard ones: the garment should occupy a large share of the frame, the angle should be front-on or slightly off-axis, and the lighting should be even.
Also useful: the repo's CLI supports --dry-run for a cost estimate before you commit, and per-image cost lands somewhere in the 3–60 credit range depending on model and quality tier.
The repair table is the other thing worth stealing

图 3 · 症状 → 追加句
The spec ships a lookup table mapping each failure symptom to a sentence you append to the prompt. This is the part that turns a prompt into a debuggable artifact:
Symptom Append to the prompt
Accessories survived Nothing but the garment may remain in the frame.
Output still has body volume The garment must be laid completely flat — no body volume, no invisible mannequin effect.
Sleeves don't match Mirror-symmetric layout: both sleeves at the same angle and length, collar centred.
Print got rearranged Keep the print at its original position and scale relative to the garment body; do not tile or recentre it.
Colour drifted brighter Sample the colour from the source photo under neutral light; do not brighten or saturate.

Note what these have in common: every one is a constraint you forgot to state, not a model failure. That framing is doing real work.
What went wrong
[需人工补:把下面三条换成你自己跑出来的报错和修法,附截图。Dev.to 的信任度全在这一节。]
Three failure modes the spec itself flags, which map cleanly onto what you should be watching for:

  1. Occlusion is inference, not recovery. Arms crossed, hand in pocket, a tote bag across the hip — the model returns a plausible standard-pattern seam. Plausible is not the same as correct. The spec says this itself, in its own input-rules table: occluded regions are inferred, not recovered, and need human confirmation when a key design feature is behind the obstruction. That's a fairly honest thing for a tool's docs to admit.
  2. Prints don't survive reconstruction cleanly. When a pattern crosses a seam, the reconstructed flat-lay tends to shift it. "Pattern position accurate" is in the QA checklist for a reason. Graphic tees and placement prints are where you'll spend your review time.
  3. "Symmetric" fights asymmetric design. Segment three asks for left-right symmetry. Wrap fronts, one-shoulder cuts, layered hems and sheer panels all disagree with that instruction, and the model resolves the conflict in favour of the instruction. For those pieces, rewrite segment three rather than accepting the default.
  4. A full outfit is N runs, not one. The doc is explicit — one garment per pass, segment one names it, segment two lists everything else including the other garments. Asking for the dress, the bag and the shoes in a single call does not work. When not to use this

图 4 · 执行流程
• As-is on a listing's hero image. In most jurisdictions, advertising law expects product imagery to represent the actual product. A seam the model invented is not the product. Treat these as supporting images or as a base for retouching, and keep a real photo as the hero.
• Stripping someone else's branding. The spec draws this line itself, in its own "does not do" list: not for erasing another brand's marks and passing the garment off as your own. Worth repeating because the competitor-screenshot use case makes it very easy to drift there.
• Complex construction. Pleating, draping, transparency, heavy texture layering — the reconstruction step is where these lose their identity.
• Anything you won't review. The batch 2~3 default exists because you're expected to look at the candidates and choose. A pipeline that auto-publishes the first result is using this wrong.
Wrap-up
The reusable idea here is not the model choice. It's that a working image-editing prompt has four jobs — keep this, delete these, output in this form, preserve these properties — that the deletion list is the one that has to be exhaustive, and that every recurring failure gets its own append-this sentence rather than a rewrite.
Worth noting the skill is the exact inverse of another one in the same repo, flat-lay, which goes from flat-lay to on-model. Same four-segment shape, opposite direction. That symmetry is a decent sign the structure generalises.
One caveat on maturity: the repo is MIT licensed with 19 skills covering the whole chain from flat-lay through on-model to pre-launch QA, but it's sitting at 2 stars as of August 2026. This is early software. Read the spec, steal the structure, don't assume it's battle-tested.
Question for anyone who's done this at volume: how do you handle placement prints? I haven't found a segment-four phrasing that reliably pins a graphic to its original position across a seam, and I'd rather learn yours than keep guessing.

Disclosure: I work on dLazy, which is the CLI this skill calls. This post is about the prompt structure, not the product. Repo: https://github.com/dlazyai/ecommerce-skills

Top comments (0)