--- id: wiki-2026-0508-vary-region-인페인팅 title: Vary Region (인페인팅) category: 10_Wiki/Topics status: verified canonical_id: self aliases: [Inpainting, Midjourney Vary Region, Region-Based Editing] duplicate_of: none source_trust_level: A confidence_score: 0.9 verification_status: applied tags: [image-generation, inpainting, midjourney, editing, diffusion] raw_sources: [] last_reinforced: 2026-05-10 github_commit: pending tech_stack: language: text framework: Midjourney/FLUX-Fill/SDXL-Inpainting --- # Vary Region (인페인팅) ## 매 한 줄 > **"매 Vary Region 의 핵심 = 'mask 의 selective regeneration with prompt 의 re-injection'."**. 매 2023 Midjourney 의 introduction 의 since 매 industry standard 의 region-aware editing 의 became. 2026 era 매 FLUX.1 Fill / SDXL Inpainting / Adobe Firefly Generative Fill 의 mainstream — 매 entire image 의 regenerate 의 X 의 specific area 만 의 modify. ## 매 핵심 ### 매 동작 원리 - **Mask**: 매 binary image (white = edit, black = preserve) 의 user-drawn or auto-segmented. - **Latent blending**: 매 unmasked region 의 original latent 의 preserve, masked region 만 의 noise → denoise. - **Prompt re-injection**: 매 new prompt 의 masked area 의 conditioning 의 only. - **Boundary blending**: 매 mask edge 의 soft blur 의 seamless transition. ### 매 Use cases - **Object removal**: unwanted person / watermark / logo 의 remove. - **Object addition**: empty desk 의 coffee cup 의 add. - **Object replacement**: red car → blue car. - **Detail enhancement**: face / hand 의 specific 의 refinement. - **Outpainting**: 매 canvas 의 expand 의 logical extension. ### 매 Variants 1. **Vary Region (Subtle)**: 매 minor change — color / texture. 2. **Vary Region (Strong)**: 매 major regeneration — different object. 3. **Remix mode**: 매 prompt 의 swap 의 enable. ## 💻 패턴 ### Pattern 1: Midjourney 의 Vary Region workflow ```text 1. /imagine prompt: cozy living room, modern minimalist 2. Upscale → click "Vary (Region)" 3. Draw mask over old TV 4. Edit prompt: "large bookshelf with plants" 5. Submit → MJ regenerates only masked area ``` ### Pattern 2: SDXL inpainting (diffusers) ```python 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") init_image = Image.open("room.png").convert("RGB") mask_image = Image.open("mask.png").convert("RGB") # white = inpaint result = pipe( prompt="large oak bookshelf filled with leather books and potted plants", image=init_image, mask_image=mask_image, strength=0.95, guidance_scale=8.0, num_inference_steps=40, ).images[0] result.save("inpainted.png") ``` ### Pattern 3: FLUX.1 Fill (2026 SOTA) ```python import replicate output = replicate.run( "black-forest-labs/flux-fill-pro", input={ "image": open("room.png", "rb"), "mask": open("mask.png", "rb"), "prompt": "vintage typewriter on wooden desk", "guidance_scale": 30, # FLUX uses higher guidance "num_inference_steps": 50, }, ) ``` ### Pattern 4: Auto-mask via SAM 2 (Segment Anything) ```python from segment_anything_2 import SAM2ImagePredictor import numpy as np predictor = SAM2ImagePredictor.from_pretrained("facebook/sam2-hiera-large") predictor.set_image(image) # Click point on object to remove point_coords = np.array([[450, 300]]) point_labels = np.array([1]) masks, scores, _ = predictor.predict( point_coords=point_coords, point_labels=point_labels, multimask_output=True, ) best_mask = masks[scores.argmax()] ``` ### Pattern 5: Outpainting (canvas expansion) ```python from PIL import Image # Expand canvas to right original = Image.open("portrait.png") # 512x512 expanded = Image.new("RGB", (1024, 512), (0, 0, 0)) expanded.paste(original, (0, 0)) # Mask: black on left half (preserve), white on right half (generate) mask = Image.new("L", (1024, 512), 0) for x in range(512, 1024): for y in range(512): mask.putpixel((x, y), 255) result = pipe( prompt="continuation of mountain landscape, same lighting and style", image=expanded, mask_image=mask, strength=1.0, ).images[0] ``` ### Pattern 6: ControlNet Inpaint (preserve structure) ```python from diffusers import StableDiffusionXLControlNetInpaintPipeline, ControlNetModel controlnet = ControlNetModel.from_pretrained("destitech/controlnet-inpaint-dreamer-sdxl") pipe = StableDiffusionXLControlNetInpaintPipeline.from_pretrained( "stabilityai/stable-diffusion-xl-base-1.0", controlnet=controlnet, ) # Preserves edges / depth while regenerating result = pipe( prompt="red sports car, same angle and lighting", image=original, mask_image=mask, control_image=canny_edge_map, ).images[0] ``` ### Pattern 7: Adobe Firefly Generative Fill (Photoshop API) ```javascript const response = await fetch('https://firefly-api.adobe.io/v3/images/generative-fill', { method: 'POST', headers: { Authorization: `Bearer ${token}` }, body: JSON.stringify({ image: { source: { url: imageUrl } }, mask: { source: { url: maskUrl } }, prompt: 'a vase of fresh tulips', }), }); ``` ## 매 결정 기준 | 상황 | Approach | |---|---| | Casual / no-code | Midjourney Vary Region | | Photoshop integrated | Adobe Firefly Generative Fill | | API / batch | FLUX.1 Fill Pro (Replicate) | | Local / private | SDXL Inpainting + diffusers | | Auto-mask | SAM 2 + inpainting pipe | | Preserve structure | ControlNet Inpaint variant | **기본값**: FLUX.1 Fill Pro (quality) 또는 SDXL Inpainting (local/free). ## 🔗 Graph - 부모: [[Generative-AI]] · [[Diffusion-Models]] - 변형: [[Outpainting]] - Adjacent: [[image-prompt-작성-방법]] · [[Adobe-Firefly]] ## 🤖 LLM 활용 **언제**: mask region 의 prompt 의 generation / what-to-remove decision / multi-region edit planning. **언제 X**: 매 mask itself 의 drawing — 매 visual / spatial task 의 LLM 의 weak. ## ❌ 안티패턴 - **Mask too tight**: 매 boundary artifact — 매 8-16px feather 의 add. - **Strength=1.0 with same prompt**: 매 unnecessary regeneration. strength=0.7-0.95 의 prefer. - **Ignoring lighting consistency**: 매 inpainted region 의 lighting 의 mismatch — 매 prompt 의 explicit "same lighting" 의 add. - **No reference to surroundings**: prompt 의 isolated description — 매 context 의 mention ("matching the wooden desk"). ## 🧪 검증 / 중복 - Verified: Midjourney docs (2026), Black Forest Labs FLUX Fill paper, diffusers documentation. - 신뢰도 A. ## 🕓 Changelog | 날짜 | 변경 | |---|---| | 2026-05-08 | Phase 1 | | 2026-05-10 | Manual cleanup — full inpainting / Vary Region guide |