# LEDITS++

  

LEDITS++는 Manuel Brack, Felix Friedrich, Katharina Kornmeier, Linoy Tsaban, Patrick Schramowski, Kristian Kersting, Apolinário Passos가 [LEDITS++: Limitless Image Editing using Text-to-Image Models](https://huggingface.co/papers/2311.16711)에서 제안했습니다.

해당 논문의 초록은 다음과 같습니다:

*텍스트-이미지 확산 모델은 텍스트 입력만으로 높은 충실도의 이미지를 생성하는 놀라운 능력 덕분에 최근 큰 관심을 받고 있습니다. 후속 연구들은 이러한 기능을 활용하여 실제 이미지 편집에 적용하는 것을 목표로 합니다. 그러나 기존 이미지-이미지 방법은 비효율적이고 부정확하며 범용성이 제한적인 경우가 많습니다. 이들은 시간 소모적인 미세 조정을 요구하거나, 입력 이미지에서 불필요하게 크게 벗어나거나, 여러 개의 동시 편집을 지원하지 못합니다. 이러한 문제를 해결하기 위해, 효율적이면서도 범용적이고 정확한 텍스트 기반 이미지 조작 기법인 LEDITS++를 소개합니다. LEDITS++의 새로운 역전(inversion) 접근법은 튜닝이나 최적화가 필요하지 않으며, 몇 단계의 확산 단계만으로 높은 충실도의 결과를 생성합니다. 두 번째로, 우리의 방법론은 여러 개의 동시 편집을 지원하며 아키텍처에 무관합니다. 세 번째로, 변경 사항을 관련 이미지 영역으로 제한하는 새로운 암시적 마스킹 기법을 사용합니다. 포괄적인 평가의 일부로 새로운 TEdBench++ 벤치마크를 제안합니다. 우리의 결과는 LEDITS++의 기능과 이전 방법들에 비해의 개선점을 보여줍니다. 프로젝트 페이지는 https://leditsplusplus-project.static.hf.space 에서 확인할 수 있습니다.*

> [!TIP]
> LEDITS++에 대한 추가 정보는 [프로젝트 페이지](https://leditsplusplus-project.static.hf.space/index.html)에서 확인하고 [데모](https://huggingface.co/spaces/editing-images/leditsplusplus)에서 직접 사용해 볼 수 있습니다.

> [!WARNING]
> 현재 [DPMSolverMultistepScheduler](/docs/diffusers/main/ko/api/schedulers/multistep_dpm_solver#diffusers.DPMSolverMultistepScheduler)의 diffusers 구현과 일부 역방향 호환성 문제로 인해, 이 LEdits++ 구현은 더 이상 완벽한 역전(inversion)을 보장할 수 없습니다. 이 문제는 실제 적용되는 사용 사례에 눈에 띄는 영향을 미칠 가능성이 낮습니다. 그러나 완벽한 역전을 보장하는 대안 구현을 전용 [GitHub 저장소](https://github.com/ml-research/ledits_pp)에서 제공합니다.

…

## LEditsPPPipelineStableDiffusion[[diffusers.LEditsPPPipelineStableDiffusion]]

#### diffusers.LEditsPPPipelineStableDiffusion[[diffusers.LEditsPPPipelineStableDiffusion]]

```python
diffusers.LEditsPPPipelineStableDiffusion(vae: AutoencoderKL, text_encoder: CLIPTextModel, tokenizer: CLIPTokenizer, unet: UNet2DConditionModel, scheduler: diffusers.schedulers.scheduling_ddim.DDIMScheduler | diffusers.schedulers.scheduling_dpmsolver_multistep.DPMSolverMultistepScheduler, safety_checker: StableDiffusionSafetyChecker, feature_extractor: CLIPImageProcessorPil, requires_safety_checker: bool = True)
```

[소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/ledits_pp/pipeline_leditspp_stable_diffusion.py#L269)

**매개변수:**

vae ([AutoencoderKL](/docs/diffusers/main/ko/api/models/autoencoderkl#diffusers.AutoencoderKL)) : 이미지를 잠재 표현으로 인코딩하고 잠재 표현에서 이미지로 디코딩하는 Variational Auto-Encoder (VAE) 모델입니다.

text_encoder ([CLIPTextModel](https://huggingface.co/docs/transformers/main/en/model_doc/clip#transformers.CLIPTextModel)) : 고정된 텍스트 인코더. Stable Diffusion은 [CLIP](https://huggingface.co/docs/transformers/model_doc/clip#transformers.CLIPTextModel)의 텍스트 부분을 사용하며, 구체적으로 [clip-vit-large-patch14](https://huggingface.co/openai/clip-vit-large-patch14) 변형을 사용합니다.

tokenizer ([CLIPTokenizer](https://huggingface.co/docs/transformers/main/en/model_doc/clip#transformers.CLIPTokenizer)) : [CLIPTokenizer](https://huggingface.co/docs/transformers/v4.21.0/en/model_doc/clip#transformers.CLIPTokenizer) 클래스의 토크나이저.

unet ([UNet2DConditionModel](/docs/diffusers/main/ko/api/models/unet2d-cond#diffusers.UNet2DConditionModel)) : 인코딩된 이미지 레이턴트를 디노이즈하기 위한 조건부 U-Net 아키텍처.

scheduler ([DPMSolverMultistepScheduler](/docs/diffusers/main/ko/api/schedulers/multistep_dpm_solver#diffusers.DPMSolverMultistepScheduler) 또는 [DDIMScheduler](/docs/diffusers/main/ko/api/schedulers/ddim#diffusers.DDIMScheduler)) : `unet`와 함께 사용되어 인코딩된 이미지 latens의 노이즈를 제거하는 스케줄러입니다. [DPMSolverMultistepScheduler](/docs/diffusers/main/ko/api/schedulers/multistep_dpm_solver#diffusers.DPMSolverMultistepScheduler) 또는 [DDIMScheduler](/docs/diffusers/main/ko/api/schedulers/ddim#diffusers.DDIMScheduler) 중 하나여야 합니다. 다른 스케줄러가 전달되면 자동으로 [DPMSolverMultistepScheduler](/docs/diffusers/main/ko/api/schedulers/multistep_dpm_solver#diffusers.DPMSolverMultistepScheduler)로 설정됩니다.

safety_checker (`StableDiffusionSafetyChecker`) : 생성된 이미지가 offensive 또는 harmful로 간주될 수 있는지 추정하는 분류 모듈입니다. 자세한 내용은 [model card](https://huggingface.co/CompVis/stable-diffusion-v1-4)를 참조하세요.

feature_extractor ([CLIPImageProcessor](https://huggingface.co/docs/transformers/main/en/model_doc/clip#transformers.CLIPImageProcessor)) : 생성된 이미지에서 `safety_checker`의 입력으로 사용할 특징을 추출하는 모델입니다.

Stable Diffusion을 사용한 LEDits++ 텍스트 기반 이미지 편집을 위한 Pipeline입니다.

이 모델은 [DiffusionPipeline](/docs/diffusers/main/ko/api/pipelines/overview#diffusers.DiffusionPipeline)에서 상속되며 [StableDiffusionPipeline](/docs/diffusers/main/ko/api/pipelines/stable_diffusion/text2img#diffusers.StableDiffusionPipeline)을 기반으로 합니다. 모든 파이프라인에 구현된 일반적 메서드(다운로드, 저장, 특정 디바이스에서 실행 등)에 대해서는 상위 클래스 문서를 확인하세요.

#### __호출__[[diffusers.LEditsPPPipelineStableDiffusion.__call__]]

```python
__call__(negative_prompt: str | list[str] | None = None, generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = None, output_type: str | None = 'pil', return_dict: bool = True, editing_prompt: str | list[str] | None = None, editing_prompt_embeds: typing.Optional[torch.Tensor] = None, negative_prompt_embeds: typing.Optional[torch.Tensor] = None, reverse_editing_direction: bool | list[bool] | None = False, edit_guidance_scale: float | list[float] | None = 5, edit_warmup_steps: int | list[int] | None = 0, edit_cooldown_steps: int | list[int] | None = None, edit_threshold: float | list[float] | None = 0.9, user_mask: typing.Optional[torch.Tensor] = None, sem_guidance: list[torch.Tensor] | None = None, use_cross_attn_mask: bool = False, use_intersect_mask: bool = True, attn_store_steps: list[int] | None = [], store_averaged_over_steps: bool = True, cross_attention_kwargs: dict[str, typing.Any] | None = None, guidance_rescale: float = 0.0, clip_skip: int | None = None, callback_on_step_end: typing.Optional[typing.Callable[[int, int], NoneType]] = None, callback_on_step_end_tensor_inputs: list = ['latents'], **kwargs)
```

[소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/ledits_pp/pipeline_leditspp_stable_diffusion.py#L720)

**매개변수:**

negative_prompt (`str` 또는 `list[str]`, *선택 사항*) : 이미지 생성을 안내하지 않을 프롬프트입니다. 가이던스를 사용하지 않는 경우 무시됩니다(즉, `guidance_scale`이 `1`보다 작은 경우 무시됩니다).

generator (`torch.Generator`, *선택 사항*) : 생성을 결정적으로 만들기 위한 [torch generator](https://pytorch.org/docs/stable/generated/torch.Generator.html) 하나 또는 목록.

output_type (`str`, *선택 사항*, 기본값 `"pil"`) : 이미지 생성의 출력 형식입니다. [PIL](https://pillow.readthedocs.io/en/stable/): `PIL.Image.Image` 또는 `np.array` 중 하나를 선택합니다.

return_dict (`bool`, *선택 사항*, 기본값 `True`) : 일반 튜플 대신 [LEditsPPDiffusionPipelineOutput](/docs/diffusers/main/ko/api/pipelines/ledits_pp#diffusers.pipelines.LEditsPPDiffusionPipelineOutput)을 반환할지 여부.

editing_prompt (`str` 또는 `list[str]`, *선택 사항*) : 이미지 생성을 안내하는 프롬프트입니다. `editing_prompt = None`으로 설정하면 이미지가 재구성됩니다. 프롬프트의 가이드 방향은 `reverse_editing_direction`을 통해 지정해야 합니다.

editing_prompt_embeds (`torch.Tensor>`, *선택 사항*) : 이미지 생성을 안내하는 데 사용할 사전 계산된 임베딩. 임베딩의 안내 방향은 `reverse_editing_direction`을 통해 지정해야 합니다.

negative_prompt_embeds (`torch.Tensor`, *선택 사항*) : 미리 생성된 부정 텍스트 임베딩입니다. 텍스트 입력(프롬프트 가중치)을 쉽게 조정하는 데 사용할 수 있습니다. 제공되지 않으면 `negative_prompt` 입력 인수에서 `negative_prompt_embeds`가 생성됩니다.

reverse_editing_direction (`bool` 또는 `list[bool]`, *선택 사항*, 기본값 `False`) : `editing_prompt`의 해당 프롬프트를 증가시킬지 감소시킬지를 결정합니다.

edit_guidance_scale (`float` 또는 `list[float]`, *선택 사항*, 기본값 5) : 이미지 생성을 안내하는 guidance scale입니다. 리스트로 제공되는 경우 값은 `editing_prompt`에 대응해야 합니다. `edit_guidance_scale`은 [LEDITS++ Paper](https://huggingface.co/papers/2301.12247)의 방정식 12의 `s_e`로 정의됩니다.

edit_warmup_steps (`float` 또는 `list[float]`, *선택 사항*, 기본값 10) : 가이드가 적용되지 않는 확산 단계 수(프롬프트당).

edit_cooldown_steps (`float` 또는 `list[float]`, *선택 사항*, 기본값 `None`) : 각 프롬프트에 대해 가이던스가 더 이상 적용되지 않는 확산 단계 수.

edit_threshold (`float` 또는 `list[float]`, *선택 사항*, 기본값 0.9) : guidance의 마스킹 임계값입니다. 임계값은 수정되는 이미지 영역에 비례해야 합니다. 'edit_threshold'는 [LEDITS++ Paper](https://huggingface.co/papers/2301.12247)의 방정식 12에서 'λ'로 정의됩니다.

user_mask (`torch.Tensor`, *선택 사항*) : 편집 프로세스에 대한 더 정밀한 제어를 위해 사용자가 제공하는 마스크입니다. LEDITS++의 암시적 마스크가 사용자 선호도에 부합하지 않을 때 유용합니다.

sem_guidance (`list[torch.Tensor]`, *선택 사항*) : 생성 시 적용할 사전 생성된 guidance 벡터 목록. 목록의 길이는 `num_inference_steps`와 일치해야 합니다.

use_cross_attn_mask (`bool`, 기본값 `False`) : cross-attention mask를 사용할지 여부입니다. use_intersect_mask가 true로 설정되면 cross-attention mask는 항상 사용됩니다. cross-attention mask는 [LEDITS++ paper](https://huggingface.co/papers/2311.16711)의 방정식 12의 'M^1'로 정의됩니다.

use_intersect_mask (`bool`, 기본값 `True`) : 마스킹 항이 크로스 어텐션 마스크와 노이즈 추정에서 파생된 마스크의 교집합으로 계산되는지 여부입니다. 크로스 어텐션 마스크는 [LEDITS++ 논문](https://huggingface.co/papers/2311.16711)의 방정식 12에서 'M^1'로, 노이즈 추정에서 파생된 마스크는 'M^2'로 정의됩니다.

attn_store_steps (`list[int]`, *선택 사항*) : AttentionStore에 attention maps가 저장되는 단계. 시각화 목적으로만 사용됩니다.

store_averaged_over_steps (`bool`, 기본값 `True`) : 'attn_store_steps'에 대한 어텐션 맵이 디퓨전 스텝에 걸쳐 평균화된 상태로 저장될지 여부입니다. False인 경우 각 스텝의 어텐션 맵이 별도로 저장됩니다. 시각화 목적입니다.

cross_attention_kwargs (`dict`, *선택 사항*) : 지정된 경우 [`self.processor`](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/attention_processor.py)에서 정의된 `AttentionProcessor`로 전달되는 kwargs 사전입니다.

guidance_rescale (`float`, *선택 사항*, 기본값 0.0) : [Common Diffusion Noise Schedules and Sample Steps are Flawed](https://huggingface.co/papers/2305.08891)에서 제시한 Guidance rescale factor입니다. zero terminal SNR을 사용할 때 과노출 문제를 해결하기 위해 Guidance rescale factor를 사용해야 합니다.

clip_skip (`int`, *선택 사항*) : 프롬프트 임베딩을 계산할 때 CLIP에서 건너뛸 레이어 수. 값이 1이면 최종 레이어 바로 이전 레이어의 출력을 프롬프트 임베딩 계산에 사용합니다.

callback_on_step_end (`Callable`, *선택 사항*) : 추론 중 각 디노이징 단계의 끝에서 호출되는 함수입니다. 이 함수는 다음 인수를 받아 호출됩니다: `callback_on_step_end(self: DiffusionPipeline, step: int, timestep: int, callback_kwargs: Dict)`. `callback_kwargs`에는 `callback_on_step_end_tensor_inputs`로 지정된 모든 텐서 목록이 포함됩니다.

callback_on_step_end_tensor_inputs (`list`, *선택 사항*) : `callback_on_step_end` 함수의 텐서 입력 목록입니다. 목록에 지정된 텐서는 `callback_kwargs` 인수로 전달됩니다. 파이프라인 클래스의 `._callback_tensor_inputs` 속성에 나열된 변수만 포함할 수 있습니다.

**반환값:** [LEditsPPDiffusionPipelineOutput](/docs/diffusers/main/ko/api/pipelines/ledits_pp#diffusers.pipelines.LEditsPPDiffusionPipelineOutput) 또는 `tuple`

[LEditsPPDiffusionPipelineOutput](/docs/diffusers/main/ko/api/pipelines/ledits_pp#diffusers.pipelines.LEditsPPDiffusionPipelineOutput) if `return_dict` is True, otherwise a `tuple. When returning a tuple, the first element is a list with the generated images, and the second element is a list of `bool`s denoting whether the corresponding generated image likely represents "not-safe-for-work" (nsfw) content, according to the `safety_checker`.

편집을 위한 pipeline의 호출 함수. [invert()](/docs/diffusers/main/ko/api/pipelines/ledits_pp#diffusers.LEditsPPPipelineStableDiffusion.invert) 메서드를 먼저 호출해야 합니다. 편집은 항상 마지막으로 invert된 이미지(들)에 대해 수행됩니다.

예:
```py
>>> import torch

>>> from diffusers import LEditsPPPipelineStableDiffusion
>>> from diffusers.utils import load_image

>>> pipe = LEditsPPPipelineStableDiffusion.from_pretrained(
...     "stable-diffusion-v1-5/stable-diffusion-v1-5", variant="fp16", torch_dtype=torch.float16
... )
>>> pipe.vae.enable_tiling()
>>> pipe = pipe.to("cuda")

>>> img_url = "https://www.aiml.informatik.tu-darmstadt.de/people/mbrack/cherry_blossom.png"
>>> image = load_image(img_url).resize((512, 512))

>>> _ = pipe.invert(image=image, num_inversion_steps=50, skip=0.1)

>>> edited_image = pipe(
...     editing_prompt=["cherry blossom"], edit_guidance_scale=10.0, edit_threshold=0.75
... ).images[0]
```

#### 반전[[diffusers.LEditsPPPipelineStableDiffusion.invert]]

```python
invert(image: typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor]], source_prompt: str = '', source_guidance_scale: float = 3.5, num_inversion_steps: int = 30, skip: float = 0.15, generator: typing.Optional[torch.Generator] = None, cross_attention_kwargs: dict[str, typing.Any] | None = None, clip_skip: int | None = None, height: int | None = None, width: int | None = None, resize_mode: str | None = 'default', crops_coords: tuple[int, int, int, int] | None = None)
```

[소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/ledits_pp/pipeline_leditspp_stable_diffusion.py#L1223)

**매개변수:**

image (`PipelineImageInput`) : 편집할 이미지(들)의 입력값입니다. 여러 입력 이미지는 동일한 종횡비(aspect ratio)를 가져야 합니다.

source_prompt (`str`, 기본값 `""`) : 역전환 과정에서 가이던스에 사용될 입력 이미지를 설명하는 프롬프트입니다. `source_prompt`가 `""`인 경우 가이던스는 비활성화됩니다.

source_guidance_scale (`float`, 기본값 `3.5`) : 역전환 과정에서의 가이드 강도.

num_inversion_steps (`int`, 기본값 `30`) : 초기 `skip` 스텝을 제외하고 수행되는 총 역전(인버전) 스텝 수.

skip (`float`, 기본값 `0.15`) : 역전(inversion) 및 후속 생성에서 무시되는 초기 단계의 비율입니다. 값이 낮을수록 입력 이미지에 대한 변경이 더 강해집니다. `skip`은 `0`과 `1` 사이여야 합니다.

generator (`torch.Generator`, *선택 사항*) : 역전(inversion)을 결정적으로 만들기 위한 [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html).

cross_attention_kwargs (`dict`, *선택 사항*) : 지정된 경우 [`self.processor`](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/attention_processor.py)에서 정의된 `AttentionProcessor`로 전달되는 kwargs 사전입니다.

clip_skip (`int`, *선택 사항*) : 프롬프트 임베딩을 계산할 때 CLIP에서 건너뛸 레이어 수. 값이 1이면 최종 레이어 바로 이전 레이어의 출력을 프롬프트 임베딩 계산에 사용합니다.

height (`int`, *선택 사항*, 기본값 `None`) : 전처리된 이미지의 높이입니다. `None`인 경우 `get_default_height_width()`를 사용하여 기본 높이를 가져옵니다.

width (`int`, *optional*`, defaults to `None`) : The width in preprocessed. If `None`, will use get_default_height_width()` to get the default width.

resize_mode (`str`, *선택 사항*, 기본값 `default`) : 리사이즈 모드입니다. `default` 또는 `fill` 중 하나여야 합니다. `default`인 경우, 지정된 너비와 높이에 맞게 이미지를 리사이즈하며 원래의 종횡비를 유지하지 않을 수 있습니다. `fill`인 경우, 종횡비를 유지하면서 지정된 너비와 높이에 맞게 이미지를 리사이즈한 후, 해당 차원 내에서 이미지를 중앙 정렬하고 빈 공간을 이미지 데이터로 채웁니다. `crop`인 경우, 종횡비를 유지하면서 지정된 너비와 높이에 맞게 이미지를 리사이즈한 후, 해당 차원 내에서 이미지를 중앙 정렬하고 초과 부분을 잘라냅니다. resize_mode `fill`과 `crop`는 PIL 이미지 입력에서만 지원된다는 점에 유의하세요.

crops_coords (`list[tuple[int, int, int, int]]`, *선택 사항*, 기본값 `None`) : 배치 내 각 이미지의 크롭 좌표입니다. `None`인 경우 이미지를 크롭하지 않습니다.

**반환값:** [LEditsPPInversionPipelineOutput](/docs/diffusers/main/ko/api/pipelines/ledits_pp#diffusers.pipelines.LEditsPPInversionPipelineOutput)

Output에는 리사이즈된 입력 이미지와 각각의 VAE 재구성이 포함됩니다.

[LEDITS++ Paper](https://huggingface.co/papers/2301.12247)에 설명된 이미지 반전(pipeline)에 사용되는 함수입니다. 스케줄러가 [DDIMScheduler](/docs/diffusers/main/ko/api/schedulers/ddim#diffusers.DDIMScheduler)로 설정되어 있으면, 대신 [edit-friendly DPDM](https://huggingface.co/papers/2304.06140)에서 제안한 반전이 수행됩니다.

#### encode_prompt[[diffusers.LEditsPPPipelineStableDiffusion.encode_prompt]]

```python
encode_prompt(device, num_images_per_prompt, enable_edit_guidance, negative_prompt = None, editing_prompt = None, negative_prompt_embeds: typing.Optional[torch.Tensor] = None, editing_prompt_embeds: typing.Optional[torch.Tensor] = None, lora_scale: float | None = None, clip_skip: int | None = None)
```

[소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/ledits_pp/pipeline_leditspp_stable_diffusion.py#L521)

**매개변수:**

device : (`torch.device`): torch 디바이스

num_images_per_prompt (`int`) : 프롬프트당 생성할 이미지 수

enable_edit_guidance (`bool`) : 입력 이미지를 편집하거나 재구성할지 여부

negative_prompt (`str` 또는 `list[str]`, *선택 사항*) : 이미지 생성을 안내하지 않을 프롬프트입니다. 정의되지 않은 경우 대신 `negative_prompt_embeds`를 전달해야 합니다. 가이던스를 사용하지 않는 경우 무시됩니다(즉, `guidance_scale`이 `1`보다 작은 경우 무시됩니다).

editing_prompt (`str` 또는 `list[str]`, *선택 사항*) : 인코딩할 편집 프롬프트입니다. 정의되지 않은 경우 `editing_prompt_embeds`를 대신 전달해야 합니다.

editing_prompt_embeds (`torch.Tensor`, *선택 사항*) : 미리 생성된 텍스트 임베딩입니다. *예를 들어* 프롬프트 가중치와 같은 텍스트 입력을 쉽게 조정하는 데 사용할 수 있습니다. 제공되지 않으면 `prompt` 입력 인자에서 텍스트 임베딩이 생성됩니다.

negative_prompt_embeds (`torch.Tensor`, *선택 사항*) : 미리 생성된 부정 텍스트 임베딩입니다. 텍스트 입력을 쉽게 조정하는 데 사용할 수 있으며, *예를 들어* 프롬프트 가중치 설정에 활용할 수 있습니다. 제공되지 않으면 `negative_prompt` 입력 인수에서 negative_prompt_embeds가 생성됩니다.

lora_scale (`float`, *선택 사항*) : LoRA 레이어가 로드된 경우 텍스트 인코더의 모든 LoRA 레이어에 적용될 LoRA 스케일입니다.

clip_skip (`int`, *선택 사항*) : 프롬프트 임베딩을 계산할 때 CLIP에서 건너뛸 레이어 수. 값이 1이면 최종 레이어 바로 이전 레이어의 출력을 프롬프트 임베딩 계산에 사용합니다.

프롬프트를 텍스트 인코더의 히든 상태로 인코딩합니다.

## LEditsPPPipelineStableDiffusionXL[[diffusers.LEditsPPPipelineStableDiffusionXL]]

#### diffusers.LEditsPPPipelineStableDiffusionXL[[diffusers.LEditsPPPipelineStableDiffusionXL]]

```python
diffusers.LEditsPPPipelineStableDiffusionXL(vae: AutoencoderKL, text_encoder: CLIPTextModel, text_encoder_2: CLIPTextModelWithProjection, tokenizer: CLIPTokenizer, tokenizer_2: CLIPTokenizer, unet: UNet2DConditionModel, scheduler: diffusers.schedulers.scheduling_dpmsolver_multistep.DPMSolverMultistepScheduler | diffusers.schedulers.scheduling_ddim.DDIMScheduler, image_encoder: CLIPVisionModelWithProjection = None, feature_extractor: CLIPImageProcessorPil = None, force_zeros_for_empty_prompt: bool = True, add_watermarker: bool | None = None)
```

[소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/ledits_pp/pipeline_leditspp_stable_diffusion_xl.py#L273)

**매개변수:**

vae ([AutoencoderKL](/docs/diffusers/main/ko/api/models/autoencoderkl#diffusers.AutoencoderKL)) : 이미지를 잠재 표현으로 인코딩하고 잠재 표현에서 이미지로 디코딩하는 Variational Auto-Encoder (VAE) 모델입니다.

text_encoder ([CLIPTextModel](https://huggingface.co/docs/transformers/main/en/model_doc/clip#transformers.CLIPTextModel)) : 고정된 텍스트 인코더입니다. Stable Diffusion XL은 [CLIP](https://huggingface.co/docs/transformers/model_doc/clip#transformers.CLIPTextModel)의 텍스트 부분을 사용하며, 구체적으로 [clip-vit-large-patch14](https://huggingface.co/openai/clip-vit-large-patch14) 변형을 사용합니다.

text_encoder_2 ([CLIPTextModelWithProjection](https://huggingface.co/docs/transformers/main/en/model_doc/clip#transformers.CLIPTextModelWithProjection)) : 두 번째 고정된 텍스트 인코더입니다. Stable Diffusion XL은 [CLIP](https://huggingface.co/docs/transformers/model_doc/clip#transformers.CLIPTextModelWithProjection)의 텍스트 및 풀링 부분을 사용하며, 구체적으로 [laion/CLIP-ViT-bigG-14-laion2B-39B-b160k](https://huggingface.co/laion/CLIP-ViT-bigG-14-laion2B-39B-b160k) 변형을 사용합니다.

tokenizer ([CLIPTokenizer](https://huggingface.co/docs/transformers/main/en/model_doc/clip#transformers.CLIPTokenizer)) : [CLIPTokenizer](https://huggingface.co/docs/transformers/v4.21.0/en/model_doc/clip#transformers.CLIPTokenizer) 클래스의 토크나이저.

tokenizer_2 ([CLIPTokenizer](https://huggingface.co/docs/transformers/main/en/model_doc/clip#transformers.CLIPTokenizer)) : [CLIPTokenizer](https://huggingface.co/docs/transformers/v4.21.0/en/model_doc/clip#transformers.CLIPTokenizer) 클래스의 두 번째 Tokenizer.

unet ([UNet2DConditionModel](/docs/diffusers/main/ko/api/models/unet2d-cond#diffusers.UNet2DConditionModel)) : 인코딩된 이미지 레이턴트를 디노이즈하기 위한 조건부 U-Net 아키텍처.

scheduler ([DPMSolverMultistepScheduler](/docs/diffusers/main/ko/api/schedulers/multistep_dpm_solver#diffusers.DPMSolverMultistepScheduler) 또는 [DDIMScheduler](/docs/diffusers/main/ko/api/schedulers/ddim#diffusers.DDIMScheduler)) : `unet`와 함께 사용되어 인코딩된 이미지 latens의 노이즈를 제거하는 스케줄러입니다. [DPMSolverMultistepScheduler](/docs/diffusers/main/ko/api/schedulers/multistep_dpm_solver#diffusers.DPMSolverMultistepScheduler) 또는 [DDIMScheduler](/docs/diffusers/main/ko/api/schedulers/ddim#diffusers.DDIMScheduler) 중 하나여야 합니다. 다른 스케줄러가 전달되면 자동으로 [DPMSolverMultistepScheduler](/docs/diffusers/main/ko/api/schedulers/multistep_dpm_solver#diffusers.DPMSolverMultistepScheduler)로 설정됩니다.

force_zeros_for_empty_prompt (`bool`, *선택 사항*, 기본값 `"True"`) : negative prompt embeddings가 항상 0으로 설정되도록 강제할지 여부입니다. 또한 `stabilityai/stable-diffusion-xl-base-1-0`의 config를 참고하세요.

add_watermarker (`bool`, *선택 사항*) : 출력 이미지에 워터마크를 적용하기 위해 [invisible_watermark 라이브러리](https://github.com/ShieldMnt/invisible-watermark/)를 사용할지 여부입니다. 정의되지 않은 경우, 해당 패키지가 설치되어 있으면 기본값으로 True가 적용되고, 그렇지 않으면 워터마커가 사용되지 않습니다.

Stable Diffusion XL을 사용한 LEDits++ 텍스트 기반 이미지 편집을 위한 Pipeline

이 모델은 [DiffusionPipeline](/docs/diffusers/main/ko/api/pipelines/overview#diffusers.DiffusionPipeline)에서 상속되며 [StableDiffusionXLPipeline](/docs/diffusers/main/ko/api/pipelines/stable_diffusion/stable_diffusion_xl#diffusers.StableDiffusionXLPipeline)을 기반으로 합니다. 모든 파이프라인에 구현된 일반적 메서드(다운로드, 저장, 특정 디바이스에서 실행 등)에 대해서는 상위 클래스 문서를 확인하세요.

또한 pipeline은 다음 로딩 메서드를 상속합니다:
- *LoRA*: [LEditsPPPipelineStableDiffusionXL.load_lora_weights()](/docs/diffusers/main/ko/api/loaders/lora#diffusers.loaders.StableDiffusionXLLoraLoaderMixin.load_lora_weights)
- *체크포인트*: [loaders.FromSingleFileMixin.from_single_file()](/docs/diffusers/main/ko/api/loaders/single_file#diffusers.loaders.FromSingleFileMixin.from_single_file)

다음과 같은 저장 방법도 있습니다:
- *LoRA*: `loaders.StableDiffusionXLPipeline.save_lora_weights`

#### __호출__[[diffusers.LEditsPPPipelineStableDiffusionXL.__call__]]

```python
__call__(denoising_end: float | None = None, negative_prompt: str | list[str] | None = None, negative_prompt_2: str | list[str] | None = None, negative_prompt_embeds: typing.Optional[torch.Tensor] = None, negative_pooled_prompt_embeds: typing.Optional[torch.Tensor] = None, ip_adapter_image: typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor], NoneType] = None, output_type: str | None = 'pil', return_dict: bool = True, cross_attention_kwargs: dict[str, typing.Any] | None = None, guidance_rescale: float = 0.0, crops_coords_top_left: tuple = (0, 0), target_size: tuple[int, int] | None = None, editing_prompt: str | list[str] | None = None, editing_prompt_embeddings: typing.Optional[torch.Tensor] = None, editing_pooled_prompt_embeds: typing.Optional[torch.Tensor] = None, reverse_editing_direction: bool | list[bool] | None = False, edit_guidance_scale: float | list[float] | None = 5, edit_warmup_steps: int | list[int] | None = 0, edit_cooldown_steps: int | list[int] | None = None, edit_threshold: float | list[float] | None = 0.9, sem_guidance: list[torch.Tensor] | None = None, use_cross_attn_mask: bool = False, use_intersect_mask: bool = False, user_mask: typing.Optional[torch.Tensor] = None, attn_store_steps: list[int] | None = [], store_averaged_over_steps: bool = True, clip_skip: int | None = None, callback_on_step_end: typing.Optional[typing.Callable[[int, int], NoneType]] = None, callback_on_step_end_tensor_inputs: list = ['latents'], **kwargs)
```

[소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/ledits_pp/pipeline_leditspp_stable_diffusion_xl.py#L782)

**매개변수:**

denoising_end (`float`, *optional*) : When specified, determines the fraction (between 0.0 and 1.0) of the total denoising process to be completed before it is intentionally prematurely terminated. As a result, the returned sample will still retain a substantial amount of noise as determined by the discrete timesteps selected by the scheduler. The denoising_end parameter should ideally be utilized when this pipeline forms a part of a "Mixture of Denoisers" multi-pipeline setup, as elaborated in [**Refining the Image

negative_prompt (`str` 또는 `list[str]`, *선택 사항*) : 이미지 생성을 안내하지 않을 프롬프트입니다. 정의되지 않은 경우 대신 `negative_prompt_embeds`를 전달해야 합니다. 가이던스를 사용하지 않는 경우 무시됩니다(즉, `guidance_scale`이 `1`보다 작은 경우 무시됩니다).

negative_prompt_2 (`str` 또는 `list[str]`, *선택*) : 이미지 생성을 유도하지 않기 위해 `tokenizer_2`와 `text_encoder_2`에 전송할 프롬프트입니다. 정의되지 않은 경우, `negative_prompt`가 두 텍스트 인코더 모두에 사용됩니다.

negative_prompt_embeds (`torch.Tensor`, *선택 사항*) : 미리 생성된 부정 텍스트 임베딩입니다. 텍스트 입력을 쉽게 조정하는 데 사용할 수 있으며, *예를 들어* 프롬프트 가중치 설정에 활용할 수 있습니다. 제공되지 않으면 `negative_prompt` 입력 인수에서 negative_prompt_embeds가 생성됩니다.

negative_pooled_prompt_embeds (`torch.Tensor`, *선택*) : 미리 생성된 negative pooled text embeddings입니다. 텍스트 입력을 쉽게 조정하는 데 사용할 수 있으며, *예를 들어* 프롬프트 가중치 설정에 활용할 수 있습니다. 제공되지 않으면 `negative_prompt` 입력 인수로부터 pooled negative_prompt_embeds가 생성됩니다.

ip_adapter_image : (`PipelineImageInput`, *선택 사항*): IP Adapters와 함께 사용할 선택적 이미지 입력입니다.

output_type (`str`, *선택 사항*, 기본값 `"pil"`) : 이미지 생성의 출력 형식입니다. [PIL](https://pillow.readthedocs.io/en/stable/): `PIL.Image.Image` 또는 `np.array` 중 하나를 선택합니다.

return_dict (`bool`, *선택 사항*, 기본값 `True`) : 일반 튜플 대신 `~pipelines.stable_diffusion_xl.StableDiffusionXLPipelineOutput`을 반환할지 여부.

cross_attention_kwargs (`dict`, *선택 사항*) : 지정된 경우 [diffusers.models.attention_processor](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/attention_processor.py)의 `self.processor` 아래에서 정의된 `AttentionProcessor`로 전달되는 kwargs 사전입니다.

guidance_rescale (`float`, *선택 사항*, 기본값 0.7) : [Common Diffusion Noise Schedules and Sample Steps are Flawed](https://huggingface.co/papers/2305.08891)에서 제안한 Guidance rescale factor입니다. `guidance_scale`은 [Common Diffusion Noise Schedules and Sample Steps are Flawed](https://huggingface.co/papers/2305.08891)의 16번 식에서 `φ`로 정의됩니다. Guidance rescale factor는 zero terminal SNR을 사용할 때 과노출 문제를 해결해야 합니다.

crops_coords_top_left (`tuple[int]`, *선택 사항*, 기본값 (0, 0)) : `crops_coords_top_left`를 사용하면 `crops_coords_top_left` 위치에서 아래쪽으로 "잘린" 것처럼 보이는 이미지를 생성할 수 있습니다. (0, 0)으로 `crops_coords_top_left`를 설정하면 일반적으로 잘 중앙 정렬된 이미지를 얻을 수 있습니다. [https://huggingface.co/papers/2307.01952](https://huggingface.co/papers/2307.01952)의 2.2절에서 설명된 SDXL의 micro-conditioning의 일부입니다.

target_size (`tuple[int]`, *선택 사항*, 기본값 (1024, 1024)) : 대부분의 경우 `target_size`는 생성된 이미지의 원하는 높이와 너비로 설정해야 합니다. 지정되지 않으면 기본값으로 `(width, height)`가 사용됩니다. [https://huggingface.co/papers/2307.01952](https://huggingface.co/papers/2307.01952)의 2.2절에서 설명된 SDXL의 마이크로 컨디션닝(micro-conditioning)의 일부입니다.

editing_prompt (`str` 또는 `list[str]`, *선택 사항*) : 이미지 생성을 안내하는 프롬프트입니다. `editing_prompt = None`으로 설정하면 이미지가 재구성됩니다. 프롬프트의 가이드 방향은 `reverse_editing_direction`을 통해 지정해야 합니다.

editing_prompt_embeddings (`torch.Tensor`, *선택*) : 미리 생성된 편집 텍스트 임베딩입니다. 텍스트 입력을 쉽게 조정하는 데 사용할 수 있으며, *예를 들어* 프롬프트 가중치 설정에 활용할 수 있습니다. 제공되지 않으면 `editing_prompt` 입력 인자로부터 editing_prompt_embeddings가 생성됩니다.

editing_pooled_prompt_embeds (`torch.Tensor`, *optional*) : Pre-generated pooled edit text embeddings. Can be used to easily tweak text inputs, *e.g.* prompt weighting. If not provided, editing_prompt_embeddings will be generated from `editing_prompt` input argument.

reverse_editing_direction (`bool` 또는 `list[bool]`, *선택 사항*, 기본값 `False`) : `editing_prompt`의 해당 프롬프트를 증가시킬지 감소시킬지를 결정합니다.

edit_guidance_scale (`float` 또는 `list[float]`, *선택 사항*, 기본값 5) : 이미지 생성을 안내하는 guidance scale입니다. 리스트로 제공되는 경우 값은 `editing_prompt`에 대응해야 합니다. `edit_guidance_scale`은 [LEDITS++ Paper](https://huggingface.co/papers/2301.12247)의 방정식 12의 `s_e`로 정의됩니다.

edit_warmup_steps (`float` 또는 `list[float]`, *선택 사항*, 기본값 10) : 가이드가 적용되지 않는 확산 단계 수(프롬프트당).

edit_cooldown_steps (`float` 또는 `list[float]`, *선택 사항*, 기본값 `None`) : 각 프롬프트에 대해 가이던스가 더 이상 적용되지 않는 확산 단계 수.

edit_threshold (`float` 또는 `list[float]`, *선택 사항*, 기본값 0.9) : guidance의 마스킹 임계값입니다. 임계값은 수정되는 이미지 영역에 비례해야 합니다. 'edit_threshold'는 [LEDITS++ Paper](https://huggingface.co/papers/2301.12247)의 방정식 12에서 'λ'로 정의됩니다.

sem_guidance (`list[torch.Tensor]`, *선택 사항*) : 생성 시 적용할 사전 생성된 guidance 벡터 목록. 목록의 길이는 `num_inference_steps`와 일치해야 합니다.

use_cross_attn_mask : cross-attention 마스크가 사용되는지 여부입니다. use_intersect_mask가 true로 설정되면 cross-attention 마스크는 항상 사용됩니다. cross-attention 마스크는 [LEDITS++ 논문](https://huggingface.co/papers/2311.16711)의 방정식 12의 'M^1'로 정의됩니다.

use_intersect_mask : 크로스 어텐션 마스크와 노이즈 추정에서 유도된 마스크의 교집합으로 마스킹 항을 계산할지 여부입니다. 크로스 어텐션 마스크는 [LEDITS++ 논문](https://huggingface.co/papers/2311.16711)의 방정식 12에서 'M^1'로, 노이즈 추정에서 유도된 마스크는 'M^2'로 정의됩니다.

user_mask : 편집 과정에 대한 더 나은 제어를 위해 사용자가 직접 제공하는 마스크입니다. LEDITS++의 암시적 마스크가 사용자 선호도에 부합하지 않을 때 유용합니다.

attn_store_steps : AttentionStore에 어텐션 맵이 저장되는 단계. 시각화 목적으로만 사용됩니다.

store_averaged_over_steps : 'attn_store_steps'의 어텐션 맵이 디퓨전 스텝에 걸쳐 평균화된 형태로 저장되는지 여부입니다. False인 경우 각 스텝의 어텐션 맵이 개별적으로 저장됩니다. 시각화 목적에만 사용됩니다.

clip_skip (`int`, *선택 사항*) : 프롬프트 임베딩을 계산할 때 CLIP에서 건너뛸 레이어 수. 값이 1이면 최종 레이어 바로 이전 레이어의 출력을 프롬프트 임베딩 계산에 사용합니다.

callback_on_step_end (`Callable`, *선택 사항*) : 추론 중 각 디노이징 단계의 끝에서 호출되는 함수입니다. 이 함수는 다음 인수를 받아 호출됩니다: `callback_on_step_end(self: DiffusionPipeline, step: int, timestep: int, callback_kwargs: Dict)`. `callback_kwargs`에는 `callback_on_step_end_tensor_inputs`로 지정된 모든 텐서 목록이 포함됩니다.

callback_on_step_end_tensor_inputs (`list`, *선택 사항*) : `callback_on_step_end` 함수의 텐서 입력 목록입니다. 목록에 지정된 텐서는 `callback_kwargs` 인수로 전달됩니다. 파이프라인 클래스의 `._callback_tensor_inputs` 속성에 나열된 변수만 포함할 수 있습니다.

**반환값:** [LEditsPPDiffusionPipelineOutput](/docs/diffusers/main/ko/api/pipelines/ledits_pp#diffusers.pipelines.LEditsPPDiffusionPipelineOutput) 또는 `tuple`

`return_dict`가 True인 경우 [LEditsPPDiffusionPipelineOutput](/docs/diffusers/main/ko/api/pipelines/ledits_pp#diffusers.pipelines.LEditsPPDiffusionPipelineOutput), 그렇지 않으면 `tuple`입니다. tuple을 반환할 경우 첫 번째 요소는 생성된 이미지의 목록입니다.

편집을 위한 pipeline의 호출 함수. [invert()](/docs/diffusers/main/ko/api/pipelines/ledits_pp#diffusers.LEditsPPPipelineStableDiffusionXL.invert) 메서드를 먼저 호출해야 합니다. 편집은 항상 마지막으로 invert된 이미지(들)에 대해 수행됩니다.

예:
```py
>>> import torch

>>> from diffusers import LEditsPPPipelineStableDiffusionXL
>>> from diffusers.utils import load_image

>>> pipe = LEditsPPPipelineStableDiffusionXL.from_pretrained(
...     "stabilityai/stable-diffusion-xl-base-1.0", variant="fp16", torch_dtype=torch.float16
... )
>>> pipe.vae.enable_tiling()
>>> pipe = pipe.to("cuda")

>>> img_url = "https://www.aiml.informatik.tu-darmstadt.de/people/mbrack/tennis.jpg"
>>> image = load_image(img_url).resize((1024, 1024))

>>> _ = pipe.invert(image=image, num_inversion_steps=50, skip=0.2)

>>> edited_image = pipe(
...     editing_prompt=["tennis ball", "tomato"],
...     reverse_editing_direction=[True, False],
...     edit_guidance_scale=[5.0, 10.0],
...     edit_threshold=[0.9, 0.85],
... ).images[0]
```

#### 반전[[diffusers.LEditsPPPipelineStableDiffusionXL.invert]]

```python
invert(image: typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor]], source_prompt: str = '', source_guidance_scale = 3.5, negative_prompt: str = None, negative_prompt_2: str = None, num_inversion_steps: int = 50, skip: float = 0.15, generator: typing.Optional[torch.Generator] = None, crops_coords_top_left: tuple = (0, 0), num_zero_noise_steps: int = 3, cross_attention_kwargs: dict[str, typing.Any] | None = None, height: int | None = None, width: int | None = None, resize_mode: str | None = 'default', crops_coords: tuple[int, int, int, int] | None = None)
```

[소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/ledits_pp/pipeline_leditspp_stable_diffusion_xl.py#L1414)

**매개변수:**

image (`PipelineImageInput`) : 편집할 이미지(들)의 입력값입니다. 여러 입력 이미지는 동일한 종횡비(aspect ratio)를 가져야 합니다.

source_prompt (`str`, 기본값 `""`) : 역전환 과정에서 가이던스에 사용될 입력 이미지를 설명하는 프롬프트입니다. `source_prompt`가 `""`인 경우 가이던스는 비활성화됩니다.

source_guidance_scale (`float`, 기본값 `3.5`) : 역전환 과정에서의 가이드 강도.

negative_prompt (`str` 또는 `list[str]`, *선택 사항*) : 이미지 생성을 안내하지 않을 프롬프트입니다. 정의되지 않은 경우 대신 `negative_prompt_embeds`를 전달해야 합니다. 가이던스를 사용하지 않는 경우 무시됩니다(즉, `guidance_scale`이 `1`보다 작은 경우 무시됩니다).

negative_prompt_2 (`str` 또는 `list[str]`, *선택*) : 이미지 생성을 유도하지 않기 위해 `tokenizer_2`와 `text_encoder_2`에 전송할 프롬프트입니다. 정의되지 않은 경우, `negative_prompt`가 두 텍스트 인코더 모두에 사용됩니다.

num_inversion_steps (`int`, 기본값 `50`) : 초기 `skip` 스텝을 제외하고 수행할 총 역전(인버전) 스텝 수.

skip (`float`, 기본값 `0.15`) : 역전(inversion) 및 후속 생성에서 무시되는 초기 단계의 비율입니다. 값이 낮을수록 입력 이미지에 대한 변경이 더 강해집니다. `skip`은 `0`과 `1` 사이여야 합니다.

generator (`torch.Generator`, *선택 사항*) : 역전(inversion)을 결정적으로 만들기 위한 [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html).

crops_coords_top_left (`tuple[int]`, *선택 사항*, 기본값 (0, 0)) : `crops_coords_top_left`를 사용하면 `crops_coords_top_left` 위치에서 아래쪽으로 "잘린" 것처럼 보이는 이미지를 생성할 수 있습니다. (0, 0)으로 `crops_coords_top_left`를 설정하면 일반적으로 잘 중앙 정렬된 이미지를 얻을 수 있습니다. [https://huggingface.co/papers/2307.01952](https://huggingface.co/papers/2307.01952)의 2.2절에서 설명된 SDXL의 micro-conditioning의 일부입니다.

num_zero_noise_steps (`int`, 기본값 `3`) : 현재 이미지에 재노이즈를 적용하지 않는 최종 diffusion 단계의 수입니다. 단계를 0으로 설정하지 않으면 [DPMSolverMultistepScheduler](/docs/diffusers/main/ko/api/schedulers/multistep_dpm_solver#diffusers.DPMSolverMultistepScheduler)와 결합된 zero SD-XL은 노이즈 아티팩트를 생성할 수 있습니다.

cross_attention_kwargs (`dict`, *선택 사항*) : 지정된 경우 [diffusers.models.attention_processor](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/attention_processor.py)의 `self.processor` 아래에서 정의된 `AttentionProcessor`로 전달되는 kwargs 사전입니다.

**반환값:** [LEditsPPInversionPipelineOutput](/docs/diffusers/main/ko/api/pipelines/ledits_pp#diffusers.pipelines.LEditsPPInversionPipelineOutput)

Output에는 리사이즈된 입력 이미지와 각각의 VAE 재구성이 포함됩니다.

[LEDITS++ Paper](https://huggingface.co/papers/2301.12247)에 설명된 이미지 반전(pipeline)에 사용되는 함수입니다. 스케줄러가 [DDIMScheduler](/docs/diffusers/main/ko/api/schedulers/ddim#diffusers.DDIMScheduler)로 설정되어 있으면, 대신 [edit-friendly DPDM](https://huggingface.co/papers/2304.06140)에서 제안한 반전이 수행됩니다.

#### encode_prompt[[diffusers.LEditsPPPipelineStableDiffusionXL.encode_prompt]]

```python
encode_prompt(device: typing.Optional[torch.device] = None, num_images_per_prompt: int = 1, negative_prompt: str | None = None, negative_prompt_2: str | None = None, negative_prompt_embeds: typing.Optional[torch.Tensor] = None, negative_pooled_prompt_embeds: typing.Optional[torch.Tensor] = None, lora_scale: float | None = None, clip_skip: int | None = None, enable_edit_guidance: bool = True, editing_prompt: str | None = None, editing_prompt_embeds: typing.Optional[torch.Tensor] = None, editing_pooled_prompt_embeds: typing.Optional[torch.Tensor] = None)
```

[소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/ledits_pp/pipeline_leditspp_stable_diffusion_xl.py#L399)

**매개변수:**

device : (`torch.device`): torch 디바이스

num_images_per_prompt (`int`) : 프롬프트당 생성할 이미지 수

negative_prompt (`str` 또는 `list[str]`, *선택 사항*) : 이미지 생성을 유도하지 않을 프롬프트입니다. 정의되지 않은 경우, 대신 `negative_prompt_embeds`를 전달해야 합니다.

negative_prompt_2 (`str` 또는 `list[str]`, *선택*) : 이미지 생성을 유도하지 않기 위해 `tokenizer_2`와 `text_encoder_2`에 전송할 프롬프트입니다. 정의되지 않은 경우, `negative_prompt`가 두 텍스트 인코더 모두에 사용됩니다.

negative_prompt_embeds (`torch.Tensor`, *선택 사항*) : 미리 생성된 부정 텍스트 임베딩입니다. 텍스트 입력을 쉽게 조정하는 데 사용할 수 있으며, *예를 들어* 프롬프트 가중치 설정에 활용할 수 있습니다. 제공되지 않으면 `negative_prompt` 입력 인수에서 negative_prompt_embeds가 생성됩니다.

negative_pooled_prompt_embeds (`torch.Tensor`, *선택*) : 미리 생성된 negative pooled text embeddings입니다. 텍스트 입력을 쉽게 조정하는 데 사용할 수 있으며, *예를 들어* 프롬프트 가중치 설정에 활용할 수 있습니다. 제공되지 않으면 `negative_prompt` 입력 인수로부터 pooled negative_prompt_embeds가 생성됩니다.

lora_scale (`float`, *선택 사항*) : LoRA 레이어가 로드된 경우, 텍스트 인코더의 모든 LoRA 레이어에 적용될 LoRA 스케일입니다.

clip_skip (`int`, *선택 사항*) : 프롬프트 임베딩을 계산할 때 CLIP에서 건너뛸 레이어 수. 값이 1이면 최종 레이어 바로 이전 레이어의 출력을 프롬프트 임베딩 계산에 사용합니다.

enable_edit_guidance (`bool`) : 편집 프롬프트로 유도할지 여부.

editing_prompt (`str` 또는 `list[str]`, *선택*) : 인코딩할 편집 프롬프트입니다. 정의되지 않았고 'enable_edit_guidance'가 True인 경우, 대신 `editing_prompt_embeds`를 전달해야 합니다.

editing_prompt_embeds (`torch.Tensor`, *선택*) : 미리 생성된 편집 텍스트 임베딩입니다. 텍스트 입력을 쉽게 조정하는 데 사용할 수 있으며, *예를 들어* 프롬프트 가중치 설정에 활용할 수 있습니다. 값이 제공되지 않고 'enable_edit_guidance'가 True인 경우, `editing_prompt` 입력 인수로부터 editing_prompt_embeds가 생성됩니다.

editing_pooled_prompt_embeds (`torch.Tensor`, *선택*) : 미리 생성된 편집 풀링 텍스트 임베딩입니다. 텍스트 입력을 쉽게 조정하는 데 사용할 수 있으며, *예를 들어* 프롬프트 가중치 설정에 활용할 수 있습니다. 제공되지 않으면 `editing_prompt` 입력 인자로부터 pooled editing_pooled_prompt_embeds가 생성됩니다.

프롬프트를 텍스트 인코더의 히든 상태로 인코딩합니다.

#### get_guidance_scale_embedding[[diffusers.LEditsPPPipelineStableDiffusionXL.get_guidance_scale_embedding]]

```python
get_guidance_scale_embedding(w: Tensor, embedding_dim: int = 512, dtype: dtype = torch.float32)
```

[소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/ledits_pp/pipeline_leditspp_stable_diffusion_xl.py#L696)

**매개변수:**

w (`torch.Tensor`) : 지정된 guidance scale을 사용하여 임베딩 벡터를 생성하고, 이를 통해 timestep 임베딩을 풍부하게 만듭니다.

embedding_dim (`int`, *선택 사항*, 기본값 512) : 생성할 임베딩의 차원.

dtype (`torch.dtype`, *선택 사항*, 기본값 `torch.float32`) : 생성된 임베딩의 데이터 유형입니다.

**반환값:** `torch.Tensor`

`(len(w), embedding_dim)` 형태의 임베딩 벡터.

https://github.com/google-research/vdm/blob/dc27b98a554f65cdc654b800da5aa1846545d41b/model_vdm.py#L298 를 참조하세요.

## LEditsPPDiffusionPipelineOutput[[diffusers.pipelines.LEditsPPDiffusionPipelineOutput]]

#### diffusers.pipelines.LEditsPPDiffusionPipelineOutput[[diffusers.pipelines.LEditsPPDiffusionPipelineOutput]]

```python
diffusers.pipelines.LEditsPPDiffusionPipelineOutput(images: list[PIL.Image.Image] | numpy.ndarray, nsfw_content_detected: list[bool] | None)
```

[소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/ledits_pp/pipeline_output.py#L10)

**매개변수:**

images (`list[PIL.Image.Image]` 또는 `np.ndarray`) : `batch_size` 길이의 노이즈 제거된 PIL 이미지 목록 또는 `(batch_size, height, width, num_channels)` 모양의 NumPy 배열.

nsfw_content_detected (`list[bool]`) : 각 생성된 이미지에 “not-safe-for-work”(nsfw) 콘텐츠가 포함되어 있는지 여부를 나타내는 리스트. 안전 검사를 수행할 수 없는 경우 `None`.

LEdits++ Diffusion 파이프라인의 출력 클래스입니다.

## LEditsPPInversionPipelineOutput[[diffusers.pipelines.LEditsPPInversionPipelineOutput]]

#### diffusers.pipelines.LEditsPPInversionPipelineOutput[[diffusers.pipelines.LEditsPPInversionPipelineOutput]]

```python
diffusers.pipelines.LEditsPPInversionPipelineOutput(images: list[PIL.Image.Image] | numpy.ndarray, vae_reconstruction_images: list[PIL.Image.Image] | numpy.ndarray)
```

[소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/ledits_pp/pipeline_output.py#L28)

**매개변수:**

input_images (`list[PIL.Image.Image]` 또는 `np.ndarray`) : 길이가 `batch_size`인 PIL 이미지 목록 또는 ` (batch_size, height, width, num_channels)` 모양의 NumPy 배열로, 잘리고 리사이즈된 입력 이미지 목록

vae_reconstruction_images (`list[PIL.Image.Image]` 또는 `np.ndarray`) : `batch_size` 길이의 PIL 이미지 목록 또는 ` (batch_size, height, width, num_channels)` 모양의 NumPy 배열로, 모든 입력 이미지의 VAE 재구성 결과

LEdits++ Diffusion 파이프라인의 출력 클래스입니다.

