照片 → 線稿 → 向量
設計發想
推薦Qwen-Image-Edit-2511 40 步畫乾淨黑白平面圖,再用中心線描邊(每條線一條路徑、可直接改線寬)轉 SVG:節點比外框描邊少 52~58%,貼合度不變。左右對稱的款式可選「半邊鏡像」再少約三成。試過的 Coloring Book LoRA、Qwen 4 步都不採用(會畫出織紋或多畫口袋)。所有結論經程式量測+TypeSafe Jev 驗證,17/17 條通過。

Fashion technical flat drawing (CAD flat sketch) of the V-neck button-front knit cardigan with ribbed cuffs and hem, front view, laid out symmetrically. Pure black line art on a pure white background: crisp uniform black outlines, main construction seams and topstitching as thin lines, buttons as small circles. The inside of the garment is completely white and unfilled. No color, no gray, no shading, no fabric or knit texture, no hatching, no person, no hanger, no text.
| 模型 | Qwen-Image-Edit-2511 int8(不掛 Lightning) |
|---|---|
| 步數/cfg | 40/4 |
| 取線 | HSV 明度 < 110 且彩度 < 80;去掉 < 150 px 的碎點(保留扣子等封閉圓) |
| 向量化 | autotrace -centerline -error-threshold 4(單線、可改線寬) |
| SVG | 116 節點(外框法 275) |
| 耗時 | 48 秒生成+0.2 秒向量化 |



把模特照或商品照變成可編輯的線稿:tech pack 平面圖、設計稿存檔、刺繡與印花前置。輸出要能直接進 Illustrator 修改,所以「節點少、線條閉合、沒有雜點」比細節多更重要。
Best practice 實驗(2026-10-05,OpenSpec:lineart-best-practice)
Section titled “Best practice 實驗(2026-10-05,OpenSpec:lineart-best-practice)”依 Reddit/GitHub/O’Reilly 整理的做法,在同樣三件單品上對照現行做法(Qwen 40 步+potrace 外框)。
生成:Coloring Book LoRA 與 Qwen 4 步
Section titled “生成:Coloring Book LoRA 與 Qwen 4 步”
每列一件單品:基準 Qwen 40 步、Qwen 4 步、4 步+Coloring Book LoRA 0.75/1.0、LoRA+作者提示、另一個 seed
| 做法 | 每張(熱跑) | GU 開襟衫:口袋 | GU:織紋(0 無~2 滿版) | 出現人物 | 結論 |
|---|---|---|---|---|---|
| Qwen 40 步(基準) | 48 秒 | 0.02 | 1.3(淡,取線時濾掉) | 0.03 | ✅ 保留 |
| Qwen 4 步 | 2.8 秒 | 0.98/0.98 | 1.0 | 0.03 | ❌ 兩個 seed 都多畫口袋 |
| 4 步+Coloring Book LoRA 1.0 | 2.8 秒(換 LoRA 首次約 11 秒) | 0.02 | 2.0 | 0.03 | ❌ 滿版麻花織紋,SVG 節點 ×5 |
| LoRA+作者建議提示 | 2.8 秒 | 0.02 | 2.0 | 0.93 | ❌ 整張照片連人一起轉成著色頁 |
口袋/人物為 Jev 依 gemma4 觀察筆記給出的機率(> 0.5 視為有);照片中的開襟衫沒有口袋。LoRA 線條最粗最俐落,托特包效果好,但會替針織衫「補」上不存在的麻花紋,不適合當技術平面圖。
向量化:外框、中心線、簡化、半邊鏡像
Section titled “向量化:外框、中心線、簡化、半邊鏡像”
同一張基準平面圖:外框 potrace、中心線、中心線+簡化、半邊鏡像+簡化;圖下為節點數與召回率
| 做法 | GU 開襟衫 節點(召回) | Old Navy 襯衫裙 | GAP 托特包 |
|---|---|---|---|
| 外框 potrace(舊) | 275(0.96) | 564(0.98) | 383(0.90) |
| 中心線 | 144(0.96) | 315(0.99) | 185(0.91) |
| 中心線+簡化(新預設) | 116(0.96) | 272(0.99) | 169(0.91) |
| 半邊鏡像+簡化 | 84(0.96) | 182(0.97) | 107(0.90) |
召回=點陣線條有多少被 SVG 蓋到(3 px 容差);精確度全部 ≥ 0.99。中心線輸出是 stroke 路徑、沒有填色,線寬改一個屬性即可。
- 中心線前要先去碎點:autotrace 沒有 potrace 的
-t,不先去掉 < 150 px 的織紋碎點,節點反而更多;但扣子小圓也 < 150 px,要用「填洞後面積變大=封閉圓」保留下來。 - 半邊鏡像:只描左半、右半用 SVG
<use>翻轉,節點只存一次;中軸 ±4% 的門襟與扣子要另外描,不然會被切掉。鏡像前由 Jev 判斷照片有沒有單邊細節(三件都沒有)。接縫處偶有小錯位。 - 托特包的中心線版被判「線條斷續」:上緣的虛線明線被描成碎段;舊的外框版同樣被判斷續,所以不是退步,但這類細虛線仍需人工修。
驗證(TypeSafe Jev)
Section titled “驗證(TypeSafe Jev)”| 結論 | 判定 | 由 |
|---|---|---|
| Qwen-Edit 4 steps adds pockets to the GU cardigan (both seeds); the 40-step baseline does not. | ✅ | 程式 |
| The Coloring Book LoRA draws a dense knit/cable pattern across the GU cardigan at strength 0.75 and 1.0. | ✅ | 程式 |
| With the LoRA author’s prompt the GU and Old Navy outputs contain a person, so they are not technical flats. | ✅ | 程式 |
| On the GU cardigan the LoRA output needs over 4x the SVG nodes of the baseline (centerline + simplify). | ✅ | 程式 |
| Once loaded, the LoRA adds no time: 4-step generation stays under 3 s. | ✅ | 程式 |
| Baseline flats contain no colored pixels. | ✅ | 程式 |
| The GU baseline raster still has faint gray knit marks above the 2% spec threshold; the line mask removes them before tracing. | ✅ | 程式 |
| Centerline + simplify needs at most 50% of the outline nodes on all three items. | ✅ | 程式 |
| Centerline + simplify keeps recall within 0.01 of the outline method and above 0.9, precision above 0.99. | ✅ | 程式 |
| Centerline SVGs use stroked paths with no fill, so line width is one attribute. | ✅ | 程式 |
| Half-mirroring cuts nodes further (below centerline + simplify) while recall stays above 0.9. | ✅ | 程式 |
| None of the three source photos is judged to have one-sided details, so mirroring is allowed for all of them. | ✅ | 程式 |
| The GU cardigan centerline SVG shows a cardigan with a white inside, no texture lines, no pockets and continuous lines. | ✅ | Jev 0.89 |
| The tote centerline SVG has sketchy or broken lines. | ✅ | Jev 0.87 |
| Both outputs made with the LoRA author’s prompt show a person. | ✅ | Jev 0.71・人工確認 |
| The mirrored GU SVG shows a cardigan with continuous lines, no pockets and no texture. | ✅ | Jev 0.99 |
| With the Coloring Book LoRA the cardigan is drawn with dense knit and cable patterns. | ✅ | Jev 0.66・人工確認 |
- 流程:gemma4:12b 對每張輸出寫固定欄位筆記(填色、織紋、口袋、人物、線條、單邊細節)→ Jev 轉成型別化判斷 → 程式套用規格門檻;數字類結論由程式核對、語意類由 Jev 判定,信心 < 0.8 送人工看圖。
- 一條規格沒過也照實寫:GU 基準點陣圖淡灰織紋占 9%(規格 < 2%),是靠取線步驟濾掉的。
- 第一輪「作者提示的開襟衫輸出有人物」被判證據不足:筆記寫的是 sweater 不是 cardigan,Jev 照字面拒絕;改窄說法後通過。
虛線明線(2026-10-05,OpenSpec:lineart-dashed-stitch)
Section titled “虛線明線(2026-10-05,OpenSpec:lineart-dashed-stitch)”原本的問題:托特包上緣的細虛線明線,中心線和外框描邊都會描成碎段,或被當成雜點刪掉(虛線保留率只有 0.5~22%)。依網路做法改成三步:先把虛線和實線分開(r/computervision)、用方向與間距把虛線點串成一條線(O’Reilly《Learning OpenCV》的 HoughLinesP maxLineGap 原理,延伸到曲線)、輸出成一條帶 stroke-dasharray 的路徑(O’Reilly《Illustrator Classroom in a Book》、r/Inkscape 的做法:虛線是線的樣式,不是一段段的形狀)。

每欄一件:點陣、舊中心線、Hough 直線基準、新串接(2× 放大);第一欄是原本出問題的托特包
| 單品 | 碎段(舊 → 新) | 虛線保留率 | 實線召回 | 虛線路徑數(Hough → 串接) | Jev「斷續」機率 |
|---|---|---|---|---|---|
| 托特包(原問題圖) | 20 → 0 | 0.20 → 0.60 | 0.97 → 0.99 | 44 → 26 | 0.97 → 0.16 |
| 托特包 | 39 → 0 | 0.22 → 0.97 | 0.98 → 1.00 | 96 → 10 | 0.96 → 0.21 |
| 牛仔襯衫裙(雙針細車線) | 86 → 1 | 0.09 → 1.00 | 0.93 → 0.99 | 125 → 41 | 0.18 → 0.13 |
| 寬褲 | 34 → 0 | 0.01 → 1.00 | 0.99 → 0.99 | 105 → 18 | 0.16 → 0.21 |
| 牛仔襯衫 | 43 → 0 | 0.11 → 1.00 | 0.88 → 0.99 | 129 → 22 | 0.97 → 0.35 |
碎段=短於 15 px 的路徑;虛線保留率=虛線點被 SVG 蓋到的比例(3 px 容差)。原問題托特包的點陣沒有要求畫虛線,候選裡混了布料皺褶,所以保留率看起來偏低;實際輸出已沒有碎段、皺褶也沒有被誤判成車線(見上圖第一欄)。
分開虛線與實線
短、細長、不封閉的小塊是虛線候選(扣子等封閉小圓排除);雙針細車線的小點也算。
串接
相鄰虛線點的間距 ≤ 3.5 倍虛線長、方向差 ≤ 30°、連線方向和虛線方向一致才連起來,至少 3 點成一條;直線或弧線都可以。剩下的再用 Hough 補直線段。
排除皺褶
一條虛線要嘛貼著實線(≤ 40 px,明線一定沿著車縫或邊緣),要嘛虛線長度和整張圖的虛線一致(0.5~1.6 倍)且間距均勻;皺褶是較長的筆觸,會被排除。
2× 放大再描
先把點陣放大兩倍:雙針車線的兩排小點才不會黏在一起,實線也更平滑(實線召回 0.93~0.98 → 0.99)。
輸出
虛線:每條一個 path,stroke-dasharray 用圖上量到的虛線長與間距;實線:中心線描邊並去掉交叉處的小殘段。

Fashion Lab「照片 → 線稿 → SVG」實測:托特包上緣與提把兩側的明線都是連續的虛線(212 節點)
驗證(TypeSafe Jev)
Section titled “驗證(TypeSafe Jev)”| 結論 | 判定 | 由 |
|---|---|---|
| Dash chaining removes at least 95% of the short broken fragments on every test item. | ✅ | 程式 |
| On the four flats drawn with dashed topstitching, at least 97% of the dash pixels are covered by the dashed paths; the previous method kept at most 22%. | ✅ | 程式 |
| Solid-line recall does not drop: it is at least as high as the previous method on every item and at least 0.99. | ✅ | 程式 |
| Chaining needs 3-6x fewer dashed paths than the straight-line Hough baseline and fewer nodes. | ✅ | 程式 |
| The chaining step runs in under 2 seconds per image on the CPU. | ✅ | 程式 |
| Jev judges none of the chained SVGs as broken or sketchy, including the three items the previous method left broken. | ✅ | 程式 |
| Jev judges every chained SVG as having even dashed stitching. | ✅ | 程式 |
| The VLM note alone is not enough: for the previous method’s dress and jeans it reported even dashed lines although under 9% of the dash pixels survived. | ✅ | 程式 |
| The tote SVG made with chaining shows even dashed topstitching and continuous outlines with no stray marks. | ✅ | Jev 0.37・人工確認 |
| The original problem tote, after chaining, shows dashed stitching and is not described as broken or sketchy. | ✅ | Jev 0.59・人工確認 |
| With the previous method the tote’s stitching was broken or sketchy. | ✅ | Jev 0.91 |
- 「平行於縫線」這題 Jev 一律給 0.5 左右(筆記明明寫 yes),問法不好,沒有拿來判定。
- VLM 會看走眼:舊做法的襯衫裙與寬褲,gemma 寫「均勻虛線」,但程式量到虛線只剩 < 9%——所以保留率一律以程式量測為準,VLM+Jev 只判斷「看起來斷不斷」。

每列:原圖、舊提示的模型輸出、舊 SVG(灰階閾值 150)、新提示 Qwen 40 步、新 SVG(只取暗且無彩度像素+potrace 平滑);圖下為 SVG 節點數
| 品項 | 舊做法 SVG 節點 | 新做法 SVG 節點 | 新 SVG 檔案 |
|---|---|---|---|
| GU 開襟衫 | 12,053 | 275 | 6.4 KB |
| Old Navy 襯衫裙 | 766 | 564 | 11.3 KB |
| GAP 托特包 | 258 | 383 | 8.1 KB |
節點數=SVG 路徑的線段數(每段貝茲曲線算 1)。托特包舊版本來就是白底線稿,所以節點本來就少;問題主要出在有顏色、有織紋的衣服。
生成模型對照(同一個新提示)
Section titled “生成模型對照(同一個新提示)”| 模型 | 每張 | GU 開襟衫 SVG 節點 | 結果 |
|---|---|---|---|
| Qwen-Edit 40 步 | 48 秒 | 275 | 最乾淨;織紋只是淡灰點,取線時自動濾掉 |
| Qwen-Edit 4 步(Lightning) | 2.8 秒 | 988 | 常多畫兩個口袋,羅紋畫成密集直線 → 節點多 |
| Klein 4B | 5–7 秒 | 1,226 | 忠實但線條太細,二值化後斷線、毛邊 |
- 品項描述裡寫「no pockets」反而容易畫出口袋(否定詞讓模型想到口袋),改成只描述有的東西。
- 提示裡不要出現顏色詞,否則模型會把顏色填回去。
Fashion technical flat drawing (CAD flat sketch) of the {品項,不含顏色}, front view, laid out symmetrically. Pure black line art on a pure white background: crisp uniform black outlines, main construction seams and topstitching as thin lines, buttons as small circles. The inside of the garment is completely white and unfilled. No color, no gray, no shading, no fabric or knit texture, no hatching, no person, no hanger, no text.import numpy as np; from PIL import Image, ImageFilter; from scipy import ndimagehsv = np.asarray(Image.open('flat.png').convert('RGB').convert('HSV')).astype(int)m = (hsv[..., 2] < 110) & (hsv[..., 1] < 80) # 暗且不帶顏色=線條lab, n = ndimage.label(m, structure=np.ones((3, 3)))keep = np.bincount(lab.ravel()) >= 150 # 去掉織紋碎點for i, sl in enumerate(ndimage.find_objects(lab), 1): # 但保留扣子等封閉小圓 c = lab[sl] == i keep[i] |= ndimage.binary_fill_holes(c).sum() > 1.5 * c.sum()keep[0] = FalseImage.fromarray((~keep[lab] * 255).astype(np.uint8)).convert('1').save('flat.pbm')# autotrace -centerline -background-color FFFFFF -error-threshold 4 -line-threshold 2 -output-format svg -output-file flat.svg flat.pbm# 舊做法(外框,節點約兩倍):potrace flat.pbm -s -t 150 -a 1.2 -O 1.0 -o flat.svg輸入
模特照或商品照(1024 px 左右)。
品項名稱
用 VLM 或人工寫出品項與結構(領型、門襟、袖口),不含顏色、不寫否定。
Qwen-Image-Edit-2511 40 步
cfg 4、euler、simple;趕時間可用 Lightning 4 步,但要檢查有沒有多畫。
取線+向量化
放大 2× → 只取暗且無彩度的像素 → 虛線串成 dashed 路徑 → 實線去碎點(保留扣子圓)後 autotrace -centerline,約 0.5 秒;對稱款可只描左半再鏡像。
試跑
Fashion Lab →「照片 → 線稿 → SVG」:直接輸出乾淨線稿、SVG 下載與節點數;方法可選中心線(預設)、半邊鏡像、外框。
舊版實驗(2026-10-03):色塊法、邊緣法、第一輪提示
| 做法 | 流程 | 結果 |
|---|---|---|
| M1 色塊法 | PIL 量化 6/12 色 → vtracer | 剪影與色塊 |
| M4 邊緣法 | Canny → potrace | 斷線與點點 |
| M2 Qwen 第一輪 | 「clean fashion technical flat」→ 閾值 150 | 有細節但帶顏色、多畫口袋 |
| M3 Klein 4B | 同上 | 開襟衫變襯衫 |

GU 開襟衫舊版各做法

Old Navy 舊版

GAP 托特包舊版