[G1-Sync] Manual knowledge update
This commit is contained in:
@@ -2,72 +2,224 @@
|
||||
id: wiki-2026-0508-해부학적-오류-디버깅-워크플로우
|
||||
title: 해부학적 오류 디버깅 워크플로우
|
||||
category: 10_Wiki/Topics
|
||||
status: needs_review
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: []
|
||||
aliases: [Anatomy Error Debugging, Anatomy Fix Workflow]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.92
|
||||
tags: [uncategorized]
|
||||
confidence_score: 0.9
|
||||
verification_status: applied
|
||||
tags: [image-generation, stable-diffusion, flux, controlnet, inpainting, workflow]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-05-08
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
inferred_by: Claude Opus 4.7 (auto-normalize 2026-05-08)
|
||||
tech_stack:
|
||||
language: python
|
||||
framework: comfyui
|
||||
---
|
||||
|
||||
# [[해부학적 오류 디버깅 워크플로우|해부학적 오류 디버깅 워크플로우]]
|
||||
# 해부학적 오류 디버깅 워크플로우
|
||||
|
||||
## 📌 한 줄 통찰 (The Karpathy Summary)
|
||||
해부학적 오류 디버깅 워크플로우는 AI 이미지 생성 시 발생하는 인체의 구조적 왜곡(여분의 손가락, 비대칭적인 눈, 중복된 사지 등)을 식별하고 교정하는 체계적인 과정입니다. 이 워크플로우는 모호한 지시어 대신 명확하고 구체적인 네거티브 프롬프트를 설정하며, 필요에 따라 인페인팅 도구 국소 수정 및 ControlNet과 같은 픽셀 단위의 구조적 제어 도구를 결합하여 일관되고 완성도 높은 결과물을 도출합니다.
|
||||
## 매 한 줄
|
||||
> **"매 anatomy 깨진 region 의 의 isolate → controlnet pose 의 enforce → low-denoise inpaint 의 surgical fix"**. 매 2026 image-gen 의 anatomy artifact (extra finger, fused limb, broken hand, twisted neck) 의 의 매 entire image 의 regenerate 의 X — 매 mask + ControlNet (OpenPose / DWPose / DensePose) + low-strength img2img 의 combine 의 의 fix 한 이후 매 surrounding pixel 의 preserve.
|
||||
|
||||
## 📖 구조화된 지식 (Synthesized Content)
|
||||
* **오류의 시각적 진단 및 구체적 용어 변환**
|
||||
깨끗한 포지티브 프롬프트로 베이스라인 이미지를 생성한 후, 여러 결과물에서 반복적으로 나타나는 해부학적 오류를 우선적으로 파악합니다 [1]. "나쁜 손(bad hands)"이나 "못생긴 얼굴(ugly face)"과 같이 모호한 표현을 사용하는 대신, "여분의 손가락(extra fingers)", "정렬되지 않은 눈(misaligned eyes)", "융합된 손가락(fused fingers)", "여분의 사지(extra limbs)"와 같이 결함을 구체적인 명사나 시각적 특성으로 정확히 번역해야 합니다 [2-4].
|
||||
## 매 핵심
|
||||
|
||||
* **최소주의적 네거티브 프롬프트 적용 및 가중치 최적화**
|
||||
발견된 오류를 겨냥하는 최소한의 네거티브 프롬프트 세트를 추가합니다 [1]. 문제 해결을 위해 가중치를 활용하여(예: `(deformed hands:1.2)`) 모델이 해당 결함을 피하도록 유도할 수 있습니다 [5]. 생성 결과를 비교한 뒤, 이미지 개선에 실질적인 도움을 주지 않는 네거티브 키워드는 즉시 과감하게 삭제(Pruning)하여 프롬프트의 꼬임을 방지합니다 [1, 6].
|
||||
### 매 common anatomy failure
|
||||
- **Hand**: 매 6 finger / 4 finger / fused / extra thumb — 매 most common.
|
||||
- **Limb**: 매 missing arm / 3 leg / asymmetric.
|
||||
- **Face**: 매 misaligned eye / 3 eye / merged feature.
|
||||
- **Joint**: 매 inverted knee / impossible bend.
|
||||
- **Topology**: 매 long neck / floating head / mid-body merge.
|
||||
|
||||
* **국소적 수정을 위한 인페인팅(Inpainting) 활용**
|
||||
이미지의 전체적인 구도와 스타일은 만족스럽지만 특정 해부학적 부위에만 오류가 발생했다면, 미드저니(Midjourney)의 'Vary (Region)' 기능과 같은 인페인팅 기능을 사용합니다 [7]. 결함이 있는 영역만 선택하고 짧고 직접적인 텍스트 프롬프트(Remix Mode 활용)를 입력하면 나머지 이미지는 그대로 유지한 채 해당 부분만 매끄럽게 교정할 수 있습니다 [7, 8].
|
||||
### 매 fix strategy ladder (cheap → expensive)
|
||||
- **Step 0 — Prevent**: better prompt + negative + LoRA (RealHands, GoodHands).
|
||||
- **Step 1 — Detail upscale**: face/hand detailer (ADetailer, FaceDetailer node).
|
||||
- **Step 2 — Mask + inpaint**: 매 region only 의 redraw, denoise 0.4-0.6.
|
||||
- **Step 3 — ControlNet pose**: 매 OpenPose skeleton 의 enforce — 매 limb count 의 lock.
|
||||
- **Step 4 — Reference + IP-Adapter**: 매 good-anatomy reference 의 inject.
|
||||
- **Step 5 — Manual sketch + ControlNet Scribble**: 매 hand-drawn skeleton overlay.
|
||||
- **Step 6 — External tool (Photoshop Generative Fill, Krita AI)**: 매 brush-driven local edit.
|
||||
|
||||
* **구조적 제어 도구(ControlNet 및 임베딩)로의 전환**
|
||||
특정 오류(예: 지속적으로 잘못 생성되는 손)가 네거티브 프롬프트만으로 해결되지 않는 경우, 네거티브 프롬프트 목록을 끝없이 부풀리는 대신 컨트롤넷(ControlNet)이나 해부학 보정 전용 임베딩으로 전환해야 합니다 [9, 10]. 특히 ControlNet은 이미지의 뼈대(Pose)나 윤곽선(Canny Edge) 정보를 강제로 주입하여 인체의 자세나 사물의 배치를 픽셀 단위로 통제할 수 있어 해부학적 오류를 근본적으로 차단합니다 [11].
|
||||
### 매 응용
|
||||
1. Portrait commission post-processing.
|
||||
2. Comic / manga panel correction.
|
||||
3. Product mockup hand fix.
|
||||
4. Concept art iteration.
|
||||
5. Batch dataset cleanup (매 1000 image 의 anatomy QC).
|
||||
|
||||
## 🔗 지식 연결 (Graph)
|
||||
- **Related Topics:** [[Negative Prompt|Negative Prompt]], [[Vary Region (인페인팅)|Vary (Region)]], [[ControlNet|ControlNet]], [[Prompt Weighting|Prompt Weighting]]
|
||||
- **Projects/Contexts:** 안정적인 인물 및 캐릭터 생성을 위한 반복적 프롬프트 최적화 파이프라인 구축
|
||||
- **Contradictions/Notes:** 많은 초보자들이 해부학적 오류를 수정하기 위해 무작정 "bad anatomy"와 같은 포괄적이고 긴 네거티브 프롬프트 목록을 복사해 붙여넣지만, 소스에 따르면 이러한 방식은 오히려 모델의 구성력을 혼란스럽게 만들고 디테일을 평면적으로 만들어 이미지의 품질을 떨어뜨릴 수 있으므로 피해야 한다고 경고합니다 [12-15].
|
||||
## 💻 패턴
|
||||
|
||||
---
|
||||
*Last updated: 2026-04-30*
|
||||
### Prompt-level prevention
|
||||
```text
|
||||
Positive: "detailed hands, anatomically correct, five fingers, perfect anatomy"
|
||||
Negative: "extra fingers, fused fingers, six fingers, missing fingers, deformed hand,
|
||||
mutated, extra limb, malformed, bad anatomy, twisted, asymmetric"
|
||||
LoRA: <lora:GoodHands-beta2:0.7>
|
||||
```
|
||||
|
||||
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
|
||||
### ComfyUI — automated hand detailer
|
||||
```python
|
||||
# pseudo-graph (ComfyUI workflow JSON)
|
||||
# 1. Generate base image (FLUX.1-dev or SDXL)
|
||||
# 2. UltralyticsDetectorProvider("hand_yolov8n.pt") → bbox of hands
|
||||
# 3. SAMSegment → precise mask
|
||||
# 4. DetailerForEach:
|
||||
# - guide_size: 512, max_size: 768
|
||||
# - denoise: 0.5
|
||||
# - cfg: 7.0
|
||||
# - prompt: "perfect hand, five fingers, detailed"
|
||||
# 5. Composite back into original
|
||||
```
|
||||
|
||||
**언제 이 지식을 쓰는가:**
|
||||
- *(TODO)*
|
||||
### Manual mask + inpaint (Diffusers)
|
||||
```python
|
||||
from diffusers import StableDiffusionXLInpaintPipeline
|
||||
import torch
|
||||
from PIL import Image
|
||||
|
||||
**언제 쓰면 안 되는가:**
|
||||
- *(TODO)*
|
||||
pipe = StableDiffusionXLInpaintPipeline.from_pretrained(
|
||||
"stabilityai/stable-diffusion-xl-base-1.0",
|
||||
torch_dtype=torch.float16
|
||||
).to("cuda")
|
||||
|
||||
## 🧪 검증 상태 (Validation)
|
||||
img = Image.open("broken_hand.png")
|
||||
mask = Image.open("hand_mask.png") # white = inpaint, black = keep
|
||||
|
||||
- **정보 상태:** needs_review
|
||||
- **출처 신뢰도:** A
|
||||
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
|
||||
fixed = pipe(
|
||||
prompt="perfect human hand, five fingers, detailed knuckles, anatomically correct",
|
||||
negative_prompt="extra fingers, fused fingers, deformed",
|
||||
image=img,
|
||||
mask_image=mask,
|
||||
strength=0.55, # 매 low denoise — 매 surrounding 의 preserve
|
||||
num_inference_steps=30,
|
||||
guidance_scale=7.5
|
||||
).images[0]
|
||||
```
|
||||
|
||||
## 🧬 중복 검사 (Duplicate Check)
|
||||
### ControlNet OpenPose enforcement
|
||||
```python
|
||||
from diffusers import StableDiffusionXLControlNetInpaintPipeline, ControlNetModel
|
||||
from controlnet_aux import OpenposeDetector
|
||||
|
||||
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
|
||||
- **처리 방식:** UPDATE (자동 정규화)
|
||||
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
|
||||
pose_detector = OpenposeDetector.from_pretrained("lllyasviel/Annotators")
|
||||
controlnet = ControlNetModel.from_pretrained(
|
||||
"thibaud/controlnet-openpose-sdxl-1.0", torch_dtype=torch.float16
|
||||
)
|
||||
|
||||
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
|
||||
# 매 reference image (good pose) 의 의 pose extract
|
||||
pose_map = pose_detector(reference_img, hand_and_face=True)
|
||||
|
||||
- **과거 데이터와의 충돌:** 없음
|
||||
- **정책 변화:** 없음
|
||||
pipe = StableDiffusionXLControlNetInpaintPipeline.from_pretrained(
|
||||
"stabilityai/stable-diffusion-xl-base-1.0",
|
||||
controlnet=controlnet, torch_dtype=torch.float16
|
||||
).to("cuda")
|
||||
|
||||
## 🕓 변경 이력 (Changelog)
|
||||
fixed = pipe(
|
||||
prompt=prompt, image=img, mask_image=mask,
|
||||
control_image=pose_map,
|
||||
controlnet_conditioning_scale=0.8,
|
||||
strength=0.6
|
||||
).images[0]
|
||||
```
|
||||
|
||||
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|
||||
|------|-----------|-----------|--------|
|
||||
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
|
||||
### IP-Adapter reference injection
|
||||
```python
|
||||
from diffusers import StableDiffusionXLPipeline
|
||||
pipe.load_ip_adapter("h94/IP-Adapter", subfolder="sdxl_models",
|
||||
weight_name="ip-adapter-plus_sdxl_vit-h.safetensors")
|
||||
pipe.set_ip_adapter_scale(0.6)
|
||||
|
||||
reference = Image.open("good_anatomy_ref.png")
|
||||
fixed = pipe(prompt=prompt, ip_adapter_image=reference, ...).images[0]
|
||||
```
|
||||
|
||||
### YOLO-based hand detection mask
|
||||
```python
|
||||
from ultralytics import YOLO
|
||||
import numpy as np
|
||||
import cv2
|
||||
|
||||
model = YOLO('hand_yolov8n.pt')
|
||||
results = model(img_np)
|
||||
|
||||
mask = np.zeros(img_np.shape[:2], dtype=np.uint8)
|
||||
for box in results[0].boxes.xyxy:
|
||||
x1, y1, x2, y2 = map(int, box)
|
||||
# pad 의 inpaint context 의 give
|
||||
pad = 20
|
||||
mask[max(0,y1-pad):y2+pad, max(0,x1-pad):x2+pad] = 255
|
||||
|
||||
cv2.imwrite("hand_mask.png", mask)
|
||||
```
|
||||
|
||||
### FLUX.1 Fill (2026 native inpaint)
|
||||
```python
|
||||
from diffusers import FluxFillPipeline
|
||||
pipe = FluxFillPipeline.from_pretrained(
|
||||
"black-forest-labs/FLUX.1-Fill-dev",
|
||||
torch_dtype=torch.bfloat16
|
||||
).to("cuda")
|
||||
|
||||
fixed = pipe(
|
||||
prompt="perfect anatomically correct hand",
|
||||
image=img, mask_image=mask,
|
||||
height=1024, width=1024,
|
||||
guidance_scale=30, # 매 FLUX 의 high CFG OK
|
||||
num_inference_steps=50
|
||||
).images[0]
|
||||
```
|
||||
|
||||
### Batch anatomy QC pipeline
|
||||
```python
|
||||
def qc_pipeline(image_paths):
|
||||
for p in image_paths:
|
||||
img = Image.open(p)
|
||||
# 1. detect anatomy issues
|
||||
issues = anatomy_classifier(img) # custom CLIP-based or YOLO
|
||||
if not issues: continue
|
||||
# 2. mask offending region
|
||||
mask = build_mask(img, issues)
|
||||
# 3. inpaint with ControlNet pose
|
||||
fixed = controlnet_inpaint(img, mask, pose_from_ref(img))
|
||||
fixed.save(p.replace('.png', '_fixed.png'))
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
| 상황 | Approach |
|
||||
|---|---|
|
||||
| Single hand artifact | ADetailer / FaceDetailer node |
|
||||
| Pose 의 corrupt | ControlNet OpenPose + inpaint |
|
||||
| 매 specific style 의 reference | IP-Adapter + low denoise |
|
||||
| 매 fine detail (eye, finger) | Mask + denoise 0.3-0.5 |
|
||||
| 매 entire pose 의 wrong | Re-generate with ControlNet from start |
|
||||
| FLUX-based pipeline | FLUX.1 Fill native |
|
||||
|
||||
**기본값**: ADetailer (auto) + ControlNet OpenPose (manual fallback) + 0.5 denoise.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[Image-Generation]] · [[Inpainting]]
|
||||
- 변형: [[Outpainting]] · [[Img2Img]] · [[Region-Prompting]]
|
||||
- 응용: [[Stable Diffusion]] · [[FLUX]] · [[ComfyUI-Workflow]]
|
||||
- Adjacent: [[ControlNet]] · [[IP-Adapter]] · [[ADetailer]] · [[LoRA]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: 매 prompt rewrite (anatomy negative 의 expand); 매 ComfyUI graph 의 LLM 의 emit; 매 batch QC 의 caption-based filter.
|
||||
**언제 X**: 매 actual pixel 의 fix 의 X — 매 image model 의 job. LLM 의 의 graph orchestrate 만.
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **High denoise (>0.8)**: 매 surrounding 의 destroy — 매 seam 의 visible.
|
||||
- **No mask padding**: 매 hard edge — context 의 lose.
|
||||
- **Re-roll only**: 매 매 same prompt 의 의 broken anatomy 의 re-generate — 매 root cause 의 X fix.
|
||||
- **Negative prompt overload**: 매 negative 의 50 token — model 의 confuse.
|
||||
- **No ControlNet on bad pose**: 매 inpaint alone 의 의 같은 pose 의 same fail 의 재생산.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (Diffusers docs 0.30+; ComfyUI ADetailer extension; FLUX.1 Fill model card; Civitai workflows).
|
||||
- 신뢰도 A.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — ADetailer + ControlNet OpenPose + FLUX.1 Fill patterns 추가 |
|
||||
|
||||
Reference in New Issue
Block a user