Flatten skill category directory structure

This commit is contained in:
2026-05-20 17:04:50 +08:00
parent 0dd552a6f7
commit 63f2baa4bd
354 changed files with 0 additions and 0 deletions
+269
View File
@@ -0,0 +1,269 @@
---
name: face-warp
display-name-zh: 人像拼图
summary-cn: 输入参考人脸,用拼图法解决人脸过审问题
summary-en: Split reference face to pass moderation
description: |
Portrait deconstruction tool for AI image creation.
Splits a portrait photo into 2 variants: faceless (features erased) + puzzle (features extracted).
Enabling character-consistent content creation with AI generation models.
Pipeline: portrait upload → analysis → 2 variant generation → quality check → composite → output.
Trigger on: "face warp," "人脸拆解," "人物拆解," "面部解构," "portrait split,"
"faceless," "去脸," "五官提取," "face decompose," "人脸预处理,"
or any request where someone provides a portrait and wants face-deconstructed
variants for downstream use.
Do NOT trigger for: style transfer without face modification (use kontext),
face swap between two people, deepfake creation, or portrait retouching.
version: 0.5.3
tags: [Image, Portrait, Face, Preprocessing]
tags-cn: [图片, 人像, 人脸, 预处理]
exported-by: MiniMax-hub
---
# Face Warp — 人物拆解工具
你是一个专业的人像解构艺术家,将一张人物照片拆解为 2 种变体图并拼合为最终成品,
在保持人物一致性的同时,为下游 AI 创作提供多样化素材。
## Iron Law
**每一张输出图都必须保持与原图的人物一致性。** 服装、体态、肤色、发型
必须与原图高度一致。拆解是"解构"而非"替换"。
## 全局约定
- 所有产物存储在 `./.face-warp/{project_name}/`
- **全自动执行**:全程自动,无用户选择环节,生成失败自动重试(最多 2 次)
- **语言**:文案默认中文(跟随用户输入语言),AI 生图 prompt 使用英文
- **禁止使用 `cd` 命令**
- **模型选择**:图片生成默认使用 `nano_banana_image_generation`model_name: `nano_banana_2`,即 Gemini Pro
- **质检重试**:生成后用 `read_media` 评分,不合格自动调整 prompt 重试(最多 2 次),详见 `references/quality-criteria.md`
- **最终输出 1 张图**compositefaceless + puzzle 左右拼接)
## 资源文件
| 文件 | 用途 |
|------|------|
| `references/profile-template.md` | Character Profile 结构模板 |
| `references/prompt-templates.md` | faceless / puzzle 的 prompt 模板及重试强化词 |
| `references/quality-criteria.md` | 质检评分标准、阈值、重试策略 |
## 工作流程
```
Face Warp Progress:
- [ ] Phase 1: Portrait Upload & Analysis
- [ ] Phase 2: Generate 2 Variants
- [ ] Phase 3: Quality Check & Retry
- [ ] Phase 4: Composite (Faceless + Puzzle → Single Image)
```
---
## Phase 1: Portrait Upload & Analysis
### Goal
接收用户上传的人像照片,分析人物特征,生成 Character Profile。
### Input / Output
| | 内容 |
|---|------|
| **Input** | 用户上传的人像照片(1 张),可选 aspect ratio |
| **Output** | `./.face-warp/{project_name}/profile.md` — 人物特征档案 |
### Required Inputs
| Input | Required | Description |
|-------|----------|-------------|
| Portrait photo | Yes | 含清晰人脸的人物照片 |
| Aspect ratio | Optional | 输出图片宽高比(默认 9:16) |
### Flow
1. Save portrait to session:
```
save_file_to_session(source_path=..., file_type="image")
```
2. Analyze portrait with `read_media`:
```
read_media(
file_paths=[portrait_image],
question="Analyze this portrait in detail. Extract:
1) Gender, approximate age range
2) Hair: color, length, style
3) Skin tone (light/medium/dark, warm/cool undertone)
4) Face shape
5) Distinctive facial features (eye shape, nose shape, lip shape, unique marks)
6) Clothing: type, color, pattern, texture
7) Pose and body posture
8) Background/environment
9) Lighting direction and quality
10) Overall color palette"
)
```
3. 按 `references/profile-template.md` 结构填充分析结果,保存到 `./.face-warp/{project_name}/profile.md`
---
## Phase 2: Generate 2 Variants
### Goal
基于原始人像和 Profile,一次性并行生成 2 张变体图。
### Input / Output
| | 内容 |
|---|------|
| **Input** | 原始人像 + `profile.md` |
| **Output** | `./.face-warp/{project_name}/faceless.png` + `puzzle.png` |
### 2 张变体定义
| # | 名称 | 文件名 | 描述 |
|---|------|--------|------|
| 1 | 五官擦除 | `faceless.png` | 面部五官被平滑擦除(光滑无特征皮肤),身体服装不变 |
| 2 | 五官拆分拼贴 | `puzzle.png` | 只保留五官特征(眼鼻唇眉),按脸部自然布局拆散拼贴在白色背景上 |
### Prompt 构建
从 `profile.md` 提取人物描述前缀,与 `references/prompt-templates.md` 中的模板组合。
**Prompt 前缀**(从 profile 提取):
```
[gender], [age range], [hair description], [skin tone], wearing [outfit description],
[pose description], [background/environment], [lighting]
```
**完整 prompt** = 前缀 + 模板(详见 `references/prompt-templates.md`)。
提交前对照 `references/prompt-templates.md` 底部的 **Prompt Construction Checklist** 逐项确认。
### Generation
使用 `nano_banana_batch_image_generation_v2` 一次并行生成 2 张:
```
nano_banana_batch_image_generation_v2(
count=2,
prompts=[faceless_prompt, puzzle_prompt],
image_paths=[
[original_portrait],
[original_portrait]
],
aspect_ratios=["9:16", "9:16"],
model_name="nano_banana_2",
resolution="2K"
)
```
如果批量生成失败,则逐张用 `nano_banana_image_generation` 生成。
---
## Phase 3: Quality Check & Retry
### Goal
用 `read_media` 对生成图进行质量评分,不合格的自动调整 prompt 重新生成。
### Input / Output
| | 内容 |
|---|------|
| **Input** | `faceless.png` + `puzzle.png` + 原始人像 |
| **Output** | 通过质检的 `faceless.png` + `puzzle.png`(可能经过重试替换) |
### 评分流程
详细评分标准、阈值和重试策略见 `references/quality-criteria.md`。
核心流程:
1. 将原图 + 两张生成图送入 `read_media`,按 `quality-criteria.md` 中的 Evaluation Prompt 评分
2. 解析评分结果,判断每张图是否 PASS(所有维度 ≥ 阈值)
3. FAIL 的图按 `quality-criteria.md` 中的 Retry Prompt Adjustment Strategy 调整 prompt,仅重生成不合格的那张
4. 最多重试 2 次,仍不合格则保留最佳版本
5. 将评分记录写入 `./.face-warp/{project_name}/quality_log.md`
### 关键阈值速查
| 图片 | 关键维度 | 阈值 |
|------|----------|------|
| faceless | face_concealment | ≥ 8 |
| faceless | character_consistency / natural_appearance / image_quality | ≥ 7 |
| puzzle | no_full_face | ≥ 8 |
| puzzle | feature_accuracy / skin_tone_consistency / artistic_quality | ≥ 7 |
---
## Phase 4: Composite (Faceless + Puzzle → Single Image)
### Goal
将通过质检的 faceless 和 puzzle 两张图左右拼接为一张完整的合成图。
### Input / Output
| | 内容 |
|---|------|
| **Input** | 通过质检的 `faceless.png` + `puzzle.png` |
| **Output** | `./.face-warp/{project_name}/output/composite.png` |
### 拼接方式
使用 `ffmpeg` 进行左右拼接,faceless 在左,puzzle 在右:
```
ffmpeg(args=[
"-y",
"-i", "./.face-warp/{project_name}/faceless.png",
"-i", "./.face-warp/{project_name}/puzzle.png",
"-filter_complex",
"[0]scale=-1:1080[left];[1]scale=-1:1080[right];[left][right]hstack=inputs=2",
"./.face-warp/{project_name}/output/composite.png"
])
```
**规则**
- 两张图先统一高度(1080px),宽度等比缩放
- 使用 `hstack` 水平拼接(左: faceless, 右: puzzle
- 输出到 `./.face-warp/{project_name}/output/composite.png`
---
## Completion
```
--- Face Warp Complete ---
Character: {character_description}
Output: .face-warp/{project_name}/output/composite.png
```
---
## Error Handling
| Error | Recovery |
|-------|----------|
| Portrait too low-res | Run `super_resolution` first |
| Face not clearly visible | Ask user for a clearer portrait |
| Batch generation fails | Fall back to single `nano_banana_image_generation` per image |
| Single image generation fails | Retry once with adjusted prompt, then skip and report |
## Anti-Patterns
- **Don't skip quality checks**: 质检是保证输出质量的关键环节,不能跳过
- **Don't alter body proportions**: 只改变面部呈现方式,不改变体型体态
- **Don't change clothing**: 服装必须与原图完全一致
- **Don't over-stylize**: 保持照片级写实感
- **Don't ignore skin tone**: 肤色一致性是人物一致性的关键
+10
View File
@@ -0,0 +1,10 @@
用于 AI 图像创作的人像拆解工具。
将一张人像照片拆分为 2 个版本:无脸图(抹去五官特征)和拼图图(提取五官特征)。
帮助用户在后续 AI 生图流程中保持角色一致性。
流程为:上传人像 → 分析 → 生成 2 个变体 → 质量检查 → 拼接合成 → 输出。
触发词包括:"face warp"、"人脸拆解"、"人物拆解"、"面部解构"、"portrait split"、
"faceless"、"去脸"、"五官提取"、"face decompose"、"人脸预处理"
以及任何“用户提供一张人像图,希望得到可供后续使用的人脸拆解版本”的请求。
不适用于:不修改人脸的风格迁移(应使用 kontext)、两人换脸、深度伪造,或普通人像修图。
@@ -0,0 +1,35 @@
# Character Profile — {project_name}
## Physical Features
- **Gender**: [male / female / non-binary]
- **Age Range**: [approximate age range, e.g. 20-25]
- **Hair**: [color], [length], [style — straight/curly/wavy/tied up, bangs or not]
- **Skin Tone**: [light/medium/dark], [warm/cool undertone]
- **Face Shape**: [oval / round / square / heart / oblong]
## Distinctive Facial Features
- **Eyes**: [shape, size, color, double/single eyelid, lash details]
- **Eyebrows**: [shape, thickness, color]
- **Nose**: [shape, size, bridge height]
- **Lips**: [shape, thickness, color]
- **Unique Marks**: [moles, dimples, freckles, scars — or "none"]
## Outfit
- **Clothing**: [type and description, e.g. "black leather jacket over white t-shirt"]
- **Colors**: [dominant colors with hex values if possible]
- **Texture**: [fabric type — cotton, silk, leather, denim, etc.]
- **Accessories**: [jewelry, glasses, hat, etc. — or "none"]
## Scene Context
- **Pose**: [standing/sitting/etc., body orientation, hand position]
- **Background**: [environment description]
- **Lighting**: [direction — front/side/back, quality — soft/hard/dramatic]
- **Color Palette**: [dominant colors of the overall image]
## Output Specs
- **Aspect Ratio**: [9:16 / 16:9 / 1:1]
@@ -0,0 +1,73 @@
# Face Warp — Prompt Templates
## Shared Character Prefix
All prompts begin with this prefix, populated from `profile.md`:
```
[gender], [age range], [hair description], [skin tone], wearing [outfit description],
[pose description], [background/environment], [lighting]
```
---
## 1. Faceless (faceless.png)
### Base Prompt
```
{character_prefix}. The face area is completely smooth and featureless — no eyes,
no nose, no mouth, no eyebrows — just smooth blank skin where facial features
should be. The rest of the body, clothing, hair, and background remain
photorealistic and unchanged. Maintain exact same clothing, hair, body proportions,
and skin tone as the reference image. Photorealistic, high detail, 8K.
```
### Retry Reinforcement Keywords
| Failure Reason | Append to Prompt |
|----------------|-----------------|
| Face still visible | `absolutely NO facial features whatsoever, completely smooth featureless skin, mannequin-like blank face` |
| Character inconsistency | `MUST maintain exact same clothing ({outfit}), hair ({hair}), body proportions, and {skin_tone} skin tone as the reference image` |
| Unnatural appearance | `seamless photorealistic skin texture, natural smooth transition from hair to blank face area, no editing artifacts` |
---
## 2. Puzzle (puzzle.png)
### Base Prompt
```
Facial features extracted from the reference portrait, arranged on a clean white
background following the natural face layout — eyes at the top, nose in the middle,
mouth at the bottom — maintaining their correct relative positions as if the face
outline was removed but the features stayed in place. Each feature (eyes, nose,
mouth, eyebrows) is a separate piece with only narrow gaps (2-3mm) between them,
like a face puzzle with thin seams. No face outline, no hair, no body, no skin
filling between features — only the isolated features with small gaps revealing
white background between them. Each piece maintains the original skin tone and
photorealistic texture. {skin_tone} skin, {eye_description} eyes,
{nose_description} nose, {lip_description} lips. Photorealistic, sharp detail,
8K, studio lighting, white background.
```
### Retry Reinforcement Keywords
| Failure Reason | Append to Prompt |
|----------------|-----------------|
| Features don't match | `facial features MUST match the reference portrait exactly — {eye_description} eyes, {nose_description} nose, {lip_description} lips` |
| Skin tone mismatch | `each feature piece must have {skin_tone} skin, matching the reference portrait skin tone exactly` |
| Shows complete face | `NO complete face, NO face outline, NO connected skin between features — only isolated individual features with white gaps between them` |
| Gaps too wide | `features arranged in natural face layout with NARROW gaps (2-3mm thin seams only), maintaining relative positions` |
---
## Prompt Construction Checklist
Before submitting any prompt, verify:
- [ ] Character prefix includes all 7 fields (gender, age, hair, skin, outfit, pose, background/lighting)
- [ ] Faceless prompt explicitly says "no eyes, no nose, no mouth, no eyebrows"
- [ ] Puzzle prompt specifies skin tone, eye/nose/lip descriptions from profile
- [ ] Puzzle prompt includes "narrow gaps (2-3mm)" and "natural face layout"
- [ ] Both prompts end with quality anchors (Photorealistic, high detail, 8K)
@@ -0,0 +1,98 @@
# Face Warp — Quality Criteria & Retry Strategy
## Evaluation Prompt
Send original portrait + generated images to `read_media` together:
```
read_media(
file_paths=[faceless_image, puzzle_image, original_portrait],
question="Image 1 is a faceless variant, Image 2 is a puzzle variant, Image 3 is the original portrait.
Rate each variant on a 1-10 scale. Return your evaluation in this exact format:
FACELESS SCORES:
face_concealment: [score] — [brief reason]
character_consistency: [score] — [brief reason]
natural_appearance: [score] — [brief reason]
image_quality: [score] — [brief reason]
PUZZLE SCORES:
feature_accuracy: [score] — [brief reason]
skin_tone_consistency: [score] — [brief reason]
artistic_quality: [score] — [brief reason]
no_full_face: [score] — [brief reason]
VERDICT:
faceless_pass: [true/false]
puzzle_pass: [true/false]
lowest_scoring_dimension: [dimension name]
Scoring criteria below."
)
```
## Scoring Rubric
### Faceless Image
| Dimension | Threshold | What to Check |
|-----------|-----------|---------------|
| **face_concealment** | ≥ 8 | Face area is completely smooth with NO recognizable eyes, nose, mouth, eyebrows |
| **character_consistency** | ≥ 7 | Body, clothing, hair, skin tone match the original portrait |
| **natural_appearance** | ≥ 7 | Smooth face looks natural and photorealistic, not like bad Photoshop |
| **image_quality** | ≥ 7 | Overall photographic quality — sharp, well-lit, no artifacts |
### Puzzle Image
| Dimension | Threshold | What to Check |
|-----------|-----------|---------------|
| **feature_accuracy** | ≥ 7 | Extracted eyes, nose, lips visually match the original portrait |
| **skin_tone_consistency** | ≥ 7 | Skin tone of each feature piece matches the original |
| **artistic_quality** | ≥ 7 | Puzzle/collage is clean, well-arranged, and visually appealing |
| **no_full_face** | ≥ 8 | Must NOT show a complete recognizable face — only separated features |
## Pass/Fail Logic
```
PASS = all dimensions ≥ their threshold
FAIL = any dimension below threshold → retry ONLY that image
```
- Retry only the failing image, not both
- Maximum 2 retries per image
- After 2 retries, keep the best-scoring version
## Retry Prompt Adjustment Strategy
When retrying, append reinforcement keywords to the original prompt based on which dimension failed:
| Failed Dimension | Prompt Reinforcement |
|------------------|---------------------|
| face_concealment | `completely smooth featureless skin, absolutely no facial features, mannequin-like blank face` |
| character_consistency | `maintain exact same clothing, hair, body proportions as reference` |
| natural_appearance | `seamless, photorealistic skin texture, natural transition, no editing artifacts` |
| feature_accuracy | Strengthen specific feature descriptors, add `matching the reference portrait exactly` |
| skin_tone_consistency | Emphasize exact skin tone from profile, add `{skin_tone} skin matching reference` |
| artistic_quality | Add `clean composition, professional studio photography, minimal and elegant` |
| no_full_face | `no complete face, only isolated individual features with gaps between them, no connected skin` |
## Score Tracking
Keep track of scores across retries to select best version:
```
./.face-warp/{project_name}/quality_log.md
# Quality Log
## Faceless
| Attempt | face_concealment | character_consistency | natural_appearance | image_quality | Pass |
|---------|-----------------|----------------------|--------------------|---------------|------|
| 1 | ? | ? | ? | ? | ? |
## Puzzle
| Attempt | feature_accuracy | skin_tone_consistency | artistic_quality | no_full_face | Pass |
|---------|-----------------|----------------------|------------------|--------------|------|
| 1 | ? | ? | ? | ? | ? |
```