Files
2nd/10_Wiki/Topics/AI_and_ML/미드저니 및 스테이블 디퓨전의 부분 편집 기법.md
T
Antigravity Agent f8b21af4be Wiki cleanup: error-doc removal, dedup merge, link normalization
10_Wiki/Topics 대규모 정리:
- 오류 캡처/미완성 stub 문서 227개 제거
- 교차폴더 중복 43클러스터 병합 (63파일 → redirect)
- 링크명 정규화: 깨진 링크 수정·redirect 직결·개념 매핑 ~2,400건
- 카테고리 MOC 6개 신규 생성
- Graph 섹션 미해결 related-keyword 링크 10,058건 제거

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-20 23:52:15 +09:00

6.4 KiB
Raw Blame History

id, title, category, status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, verification_status, tags, raw_sources, last_reinforced, github_commit, tech_stack
id title category status canonical_id aliases duplicate_of source_trust_level confidence_score verification_status tags raw_sources last_reinforced github_commit tech_stack
wiki-2026-0508-미드저니-및-스테이블-디퓨전의-부분-편집-기법 미드저니 및 스테이블 디퓨전의 부분 편집 기법 10_Wiki/Topics verified self
Inpainting
Outpainting
Vary Region
Partial Edit
none A 0.9 applied
diffusion
inpainting
midjourney
sdxl
flux
2026-05-10 pending
language framework
python diffusers

미드저니 및 스테이블 디퓨전의 부분 편집 기법

매 한 줄

"매 부분 편집 매 mask × prompt × denoise 의 3축 control". Inpainting/outpainting 매 image 의 일부 만 regenerate — 매 mask region 의 latent 의 noise 의 추가 후 conditional denoise. 매 2026 의 FLUX.1 Fill, SDXL Inpaint, MJ "Vary Region" / "Vary Subtle" 매 production-ready.

매 핵심

매 3가지 mode

  • Inpainting: existing region 의 mask 의 그리고 prompt 로 replace.
  • Outpainting: image 의 canvas 의 확장 의 새 region 의 채움.
  • Vary Region (MJ): subset 의 selective regeneration — context-aware.

매 control axis

  • Mask shape: hard edge vs feathered (blur radius).
  • Denoise strength: 0.3 (subtle tweak) — 1.0 (full replace).
  • Prompt scope: full-image prompt vs masked-only prompt.

매 응용

  1. Object 추가/제거 — 매 background 의 보존 의 selective replace.
  2. Outpaint 의 wide aspect — 16:9 → 21:9 cinematic.
  3. Face/hand fix — adetailer 의 auto-detect mask + inpaint pass.

💻 패턴

SDXL Inpaint pipeline

from diffusers import StableDiffusionXLInpaintPipeline
from PIL import Image
import torch

pipe = StableDiffusionXLInpaintPipeline.from_pretrained(
    "diffusers/stable-diffusion-xl-1.0-inpainting-0.1",
    torch_dtype=torch.float16,
).to("cuda")

img = Image.open("photo.png").convert("RGB")
mask = Image.open("mask.png").convert("L")  # white = replace, black = keep

result = pipe(
    prompt="a red ceramic vase with white flowers",
    image=img,
    mask_image=mask,
    strength=0.95,        # full replace inside mask
    guidance_scale=7.0,
    num_inference_steps=30,
).images[0]

FLUX.1 Fill (2024-2026 SOTA)

from diffusers import FluxFillPipeline

pipe = FluxFillPipeline.from_pretrained(
    "black-forest-labs/FLUX.1-Fill-dev",
    torch_dtype=torch.bfloat16,
).to("cuda")

result = pipe(
    prompt="a vintage brass lamp on the desk",
    image=img,
    mask_image=mask,
    height=1024, width=1024,
    guidance_scale=30,    # FLUX Fill specific
    num_inference_steps=50,
).images[0]

Outpainting — canvas 확장

from PIL import Image, ImageOps

orig = Image.open("portrait.png")  # 1024x1024
# 매 좌우 512px 확장 → 2048x1024
canvas = Image.new("RGB", (2048, 1024), (0, 0, 0))
canvas.paste(orig, (512, 0))

mask = Image.new("L", (2048, 1024), 255)  # all white
mask.paste(0, (512, 0, 1536, 1024))       # original area = keep

# 매 feather mask edge 의 seam 회피
mask = mask.filter(ImageFilter.GaussianBlur(radius=16))

result = pipe(
    prompt="extended cinematic landscape, mountains, golden hour",
    image=canvas, mask_image=mask,
    strength=1.0,
).images[0]

Adetailer pattern — auto face/hand fix

# 매 ComfyUI / A1111 — YOLO detect → mask → inpaint
from ultralytics import YOLO

face_det = YOLO("face_yolov8n.pt")
boxes = face_det(img)[0].boxes.xyxy

for box in boxes:
    x1, y1, x2, y2 = map(int, box)
    face_mask = Image.new("L", img.size, 0)
    ImageDraw.Draw(face_mask).rectangle([x1, y1, x2, y2], fill=255)
    face_mask = face_mask.filter(ImageFilter.GaussianBlur(8))
    img = pipe(
        prompt="detailed face, sharp eyes, natural skin",
        image=img, mask_image=face_mask,
        strength=0.4,  # subtle — preserve identity
    ).images[0]

Differential diffusion — soft mask

# 매 mask 의 grayscale 의 per-pixel strength 으로 처리
soft_mask = Image.open("gradient_mask.png").convert("L")
# 매 black=0% strength, white=100% — smooth blend
result = pipe(prompt=p, image=img, mask_image=soft_mask, strength=0.8).images[0]

Midjourney Vary Region (UI workflow)

1. /imagine 로 base image 생성.
2. U1 (upscale) 후 "Vary (Region)" 클릭.
3. 매 lasso/rectangle 의 region 선택.
4. Prompt 의 edit (optional) 후 submit.
5. 매 4 variant 의 seed 만 region 의 regenerate.

Mask preprocessing — clean edge

import numpy as np
import cv2

mask_np = np.array(mask)
# 매 dilate (확장) 의 seam 의 hide
mask_np = cv2.dilate(mask_np, np.ones((5,5), np.uint8), iterations=2)
# 매 feather
mask_np = cv2.GaussianBlur(mask_np, (21, 21), 0)
mask = Image.fromarray(mask_np)

매 결정 기준

상황 Approach
Object 교체 (vase) hard mask + strength=0.95 + SDXL Inpaint
Background extension feathered mask + outpaint + strength=1.0
Face detail fix YOLO-detect mask + strength=0.3-0.5
Subtle texture tweak strength=0.2 + soft mask
Photoreal fill FLUX.1 Fill > SDXL Inpaint
Stylized iteration MJ Vary Region

기본값: photoreal → FLUX.1 Fill, stylized → MJ Vary Region, batch automation → SDXL Inpaint + adetailer.

🔗 Graph

🤖 LLM 활용

언제: object replacement, background extension, face/hand defect fix, brand asset iteration. 언제 X: identity preservation 의 strict requirement — IP-Adapter / instantID 의 사용 의 추천.

안티패턴

  • Hard mask 의 seam visible: feather + dilate 의 누락.
  • Strength=1.0 의 face: identity 의 파괴 — 0.3-0.5 의 사용.
  • Full-image prompt 만: masked region 의 context 의 누락 — masked-specific term 의 추가.
  • Square mask 의 organic object: SAM 의 사용 의 정확 mask.
  • Outpaint 의 strength<1.0: 매 black 영역 의 noise 의 incomplete fill.

🧪 검증 / 중복

  • Verified (Diffusers SDXL Inpaint docs, FLUX.1 Fill model card, Midjourney v6 docs).
  • 신뢰도 A.

🕓 Changelog

날짜 변경
2026-05-08 Phase 1
2026-05-10 Manual cleanup — inpaint/outpaint/vary 3-mode + FLUX Fill