Aesthetic Post-Op Simulation
Core workflow for generating believable 术后效果预览 from a single frontal or 45° photo.
Procedure Map
| Procedure |
Primary warp region |
Key parameters |
| 隆鼻 Rhinoplasty |
Nose bridge, tip, nostril width |
bridge height, tip rotation, alar width |
| 双眼皮 Blepharoplasty |
Upper eyelid crease |
crease height, fold depth, eye openness |
| 唇填充 Lip filler |
Upper/lower lip volume |
volume %, cupid's bow definition |
| 下颌线 Jawline |
Mandible contour |
angle sharpness, chin projection |
| 苹果肌 Cheek filler |
Malar region |
projection, lateral fullness |
| 下巴 Chin implant |
Chin tip |
forward/down projection |
Workflow
- [ ] Normalize lighting (see lighting-normalize skill if before/after compare)
- [ ] Detect 468 face landmarks (MediaPipe Face Mesh)
- [ ] Analyze proportions (optional: facial-proportion-analysis skill)
- [ ] Apply region-specific warp (TPS or piecewise affine)
- [ ] Preserve skin texture (realistic-skin-blend skill)
- [ ] Export still + optional morph video (before-after-morph skill)
- [ ] Add disclaimer watermark for consultation use
Implementation Stack
Default (local, no API):
- MediaPipe Face Mesh → landmarks
- OpenCV
warpAffine / custom TPS on ROI masks
- Poisson seamless clone for texture preservation
Enhanced (when quality matters):
- Stable Diffusion inpainting with face mask + low denoise (0.25–0.35)
- ControlNet depth + canny to lock identity
- Always compare against landmark-warp baseline to avoid identity drift
Region Warp Template
import cv2
import mediapipe as mp
import numpy as np
mp_face = mp.solutions.face_mesh
NOSE_TIP = 1
NOSE_BRIDGE = 6
def simulate_nose_bridge(img, lift_px=8):
with mp_face.FaceMesh(static_image_mode=True) as mesh:
rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
result = mesh.process(rgb)
if not result.multi_face_landmarks:
raise ValueError("No face detected")
lm = result.multi_face_landmarks[0].landmark
h, w = img.shape[:2]
pts = np.array([[lm[i].x * w, lm[i].y * h] for i in [6, 168, 197, 195, 5]], np.float32)
# Shift bridge points upward, TPS warp nose ROI — see scripts/nose_lift.py
return img # placeholder; agent implements full TPS
Quality Rules
- Identity lock: eye spacing, ear position unchanged
- Subtle by default: consult preview ≠ marketing exaggeration
- Side-by-side: always export before | after with same crop
- No race morphing: respect ethnic features; adjust within anatomical norms
- Watermark:
SIMULATION ONLY · 效果模拟 · 非手术保证
Output Format
Deliver to user:
- Annotated landmark overlay (optional, for doctor review)
- High-res still comparison (PNG)
- Parameter JSON
{procedure, params, landmark_version}
- One-line clinical caveat in Chinese + English
Scripts
python scripts/detect_landmarks.py input.jpg --output landmarks.json
python scripts/nose_lift.py input.jpg --lift 8 --output simulated.jpg
See procedures.md for per-procedure landmark indices and warp strategies.
1---2name: aesthetic-postop-sim3description: Simulate post-operative aesthetic medicine outcomes (rhinoplasty, double eyelid, lip filler, jawline, cheek/chin contour) from patient photos. Use when the user mentions 医美, 术后模拟, 隆鼻, 双眼皮, 填充, 下颌线, cosmetic surgery preview, or aesthetic procedure visualization.4---56# Aesthetic Post-Op Simulation78Core workflow for generating believable **术后效果预览** from a single frontal or 45° photo.910## Procedure Map1112| Procedure | Primary warp region | Key parameters |13|-----------|-------------------|----------------|14| 隆鼻 Rhinoplasty | Nose bridge, tip, nostril width | bridge height, tip rotation, alar width |15| 双眼皮 Blepharoplasty | Upper eyelid crease | crease height, fold depth, eye openness |16| 唇填充 Lip filler | Upper/lower lip volume | volume %, cupid's bow definition |17| 下颌线 Jawline | Mandible contour | angle sharpness, chin projection |18| 苹果肌 Cheek filler | Malar region | projection, lateral fullness |19| 下巴 Chin implant | Chin tip | forward/down projection |2021## Workflow2223```24- [ ] Normalize lighting (see lighting-normalize skill if before/after compare)25- [ ] Detect 468 face landmarks (MediaPipe Face Mesh)26- [ ] Analyze proportions (optional: facial-proportion-analysis skill)27- [ ] Apply region-specific warp (TPS or piecewise affine)28- [ ] Preserve skin texture (realistic-skin-blend skill)29- [ ] Export still + optional morph video (before-after-morph skill)30- [ ] Add disclaimer watermark for consultation use31```3233## Implementation Stack3435**Default (local, no API)**:361. MediaPipe Face Mesh → landmarks372. OpenCV `warpAffine` / custom TPS on ROI masks383. Poisson seamless clone for texture preservation3940**Enhanced (when quality matters)**:41- Stable Diffusion inpainting with face mask + low denoise (0.25–0.35)42- ControlNet depth + canny to lock identity43- Always compare against landmark-warp baseline to avoid identity drift4445## Region Warp Template4647```python48import cv249import mediapipe as mp50import numpy as np5152mp_face = mp.solutions.face_mesh53NOSE_TIP = 154NOSE_BRIDGE = 65556def simulate_nose_bridge(img, lift_px=8):57 with mp_face.FaceMesh(static_image_mode=True) as mesh:58 rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)59 result = mesh.process(rgb)60 if not result.multi_face_landmarks:61 raise ValueError("No face detected")62 lm = result.multi_face_landmarks[0].landmark63 h, w = img.shape[:2]64 pts = np.array([[lm[i].x * w, lm[i].y * h] for i in [6, 168, 197, 195, 5]], np.float32)65 # Shift bridge points upward, TPS warp nose ROI — see scripts/nose_lift.py66 return img # placeholder; agent implements full TPS67```6869## Quality Rules7071- **Identity lock**: eye spacing, ear position unchanged72- **Subtle by default**: consult preview ≠ marketing exaggeration73- **Side-by-side**: always export before | after with same crop74- **No race morphing**: respect ethnic features; adjust within anatomical norms75- **Watermark**: `SIMULATION ONLY · 效果模拟 · 非手术保证`7677## Output Format7879Deliver to user:801. Annotated landmark overlay (optional, for doctor review)812. High-res still comparison (PNG)823. Parameter JSON `{procedure, params, landmark_version}`834. One-line clinical caveat in Chinese + English8485## Scripts8687```bash88python scripts/detect_landmarks.py input.jpg --output landmarks.json89python scripts/nose_lift.py input.jpg --lift 8 --output simulated.jpg90```9192See [procedures.md](procedures.md) for per-procedure landmark indices and warp strategies.