Buckets:

mishig's picture
|
download
raw
40.8 kB
# ์ด๋ฏธ์ง€-์ด๋ฏธ์ง€
Stable Diffusion ๋ชจ๋ธ์€ ํ…์ŠคํŠธ ํ”„๋กฌํ”„ํŠธ์™€ ์ดˆ๊ธฐ ์ด๋ฏธ์ง€๋ฅผ ์ „๋‹ฌํ•˜์—ฌ ์ƒˆ๋กœ์šด ์ด๋ฏธ์ง€ ์ƒ์„ฑ์„ ์กฐ๊ฑดํ™”ํ•จ์œผ๋กœ์จ ์ด๋ฏธ์ง€-์ด๋ฏธ์ง€ ์ƒ์„ฑ์—๋„ ์ ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
[StableDiffusionImg2ImgPipeline](/docs/diffusers/main/ko/api/pipelines/stable_diffusion/img2img#diffusers.StableDiffusionImg2ImgPipeline)๋Š” Chenlin Meng, Yutong He, Yang Song, Jiaming Song, Jiajun Wu, Jun-Yan Zhu, Stefano Ermon์ด ์ œ์•ˆํ•œ [SDEdit: Guided Image Synthesis and Editing with Stochastic Differential Equations](https://huggingface.co/papers/2108.01073)์˜ diffusion-denoising ๋ฉ”์ปค๋‹ˆ์ฆ˜์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
ํ•ด๋‹น ๋…ผ๋ฌธ์˜ ์ดˆ๋ก์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค:
*์ง€๋„ ๊ธฐ๋ฐ˜ ์ด๋ฏธ์ง€ ํ•ฉ์„ฑ์€ ์ผ๋ฐ˜ ์‚ฌ์šฉ์ž๊ฐ€ ์ตœ์†Œํ•œ์˜ ๋…ธ๋ ฅ์œผ๋กœ ์‚ฌ์ง„๊ณผ ๊ฐ™์€ ์‚ฌ์‹ค์ ์ธ ์ด๋ฏธ์ง€๋ฅผ ์ƒ์„ฑํ•˜๊ณ  ํŽธ์ง‘ํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•ฉ๋‹ˆ๋‹ค. ํ•ต์‹ฌ ๊ณผ์ œ๋Š” ์‚ฌ์šฉ์ž ์ž…๋ ฅ(์˜ˆ: ์†์œผ๋กœ ๊ทธ๋ฆฐ ์ƒ‰์น ๋œ ์ŠคํŠธ๋กœํฌ)์— ๋Œ€ํ•œ ์ถฉ์‹ค์„ฑ๊ณผ ํ•ฉ์„ฑ๋œ ์ด๋ฏธ์ง€์˜ ์‚ฌ์‹ค์„ฑ ์‚ฌ์ด์˜ ๊ท ํ˜•์„ ๋งž์ถ”๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. ๊ธฐ์กด GAN ๊ธฐ๋ฐ˜ ๋ฐฉ๋ฒ•์€ ์กฐ๊ฑด๋ถ€ GAN ๋˜๋Š” GAN ์—ญ์ „ํ™˜์„ ์‚ฌ์šฉํ•˜์—ฌ ์ด๋Ÿฌํ•œ ๊ท ํ˜•์„ ๋‹ฌ์„ฑํ•˜๋ ค ํ•˜์ง€๋งŒ, ์ด๋Š” ์–ด๋ ค์šธ ๋ฟ๋งŒ ์•„๋‹ˆ๋ผ ๊ฐœ๋ณ„ ์‘์šฉ ๋ถ„์•ผ์— ๋”ฐ๋ผ ์ถ”๊ฐ€์ ์ธ ํ•™์Šต ๋ฐ์ดํ„ฐ๋‚˜ ์†์‹ค ํ•จ์ˆ˜๊ฐ€ ํ•„์š”ํ•œ ๊ฒฝ์šฐ๊ฐ€ ๋งŽ์Šต๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด, ์šฐ๋ฆฌ๋Š” ํ™•๋ฅ  ๋ฏธ๋ถ„ ๋ฐฉ์ •์‹(SDE)์„ ํ†ตํ•ด ๋ฐ˜๋ณต์ ์œผ๋กœ ๋…ธ์ด์ฆˆ๋ฅผ ์ œ๊ฑฐํ•˜์—ฌ ์‚ฌ์‹ค์ ์ธ ์ด๋ฏธ์ง€๋ฅผ ํ•ฉ์„ฑํ•˜๋Š” ํ™•์‚ฐ ๋ชจ๋ธ ์ƒ์„ฑ ์‚ฌ์ „ ์ง€์‹์„ ๊ธฐ๋ฐ˜์œผ๋กœ ํ•œ ์ƒˆ๋กœ์šด ์ด๋ฏธ์ง€ ํ•ฉ์„ฑ ๋ฐ ํŽธ์ง‘ ๋ฐฉ๋ฒ•์ธ Stochastic Differential Editing(SDEdit)์„ ์†Œ๊ฐœํ•ฉ๋‹ˆ๋‹ค. ์–ด๋–ค ์œ ํ˜•์˜ ์‚ฌ์šฉ์ž ๊ฐ€์ด๋“œ๋ฅผ ๊ฐ€์ง„ ์ž…๋ ฅ ์ด๋ฏธ์ง€๊ฐ€ ์ฃผ์–ด์ง€๋ฉด, SDEdit์€ ๋จผ์ € ์ž…๋ ฅ์— ๋…ธ์ด์ฆˆ๋ฅผ ์ถ”๊ฐ€ํ•œ ๋‹ค์Œ, SDE ์‚ฌ์ „ ์ง€์‹์„ ํ†ตํ•ด ๊ฒฐ๊ณผ ์ด๋ฏธ์ง€๋ฅผ ์—ญ๋…ธ์ด์ฆˆํ™”ํ•˜์—ฌ ์‚ฌ์‹ค์„ฑ์„ ๋†’์ž…๋‹ˆ๋‹ค. SDEdit์€ ์ž‘์—…๋ณ„ ํ•™์Šต์ด๋‚˜ ์—ญ์ „ํ™˜์„ ์š”๊ตฌํ•˜์ง€ ์•Š์œผ๋ฉฐ, ์‚ฌ์‹ค์„ฑ๊ณผ ์ถฉ์‹ค์„ฑ ์‚ฌ์ด์˜ ๊ท ํ˜•์„ ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ๋‹ฌ์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. SDEdit์€ ์ŠคํŠธ๋กœํฌ ๊ธฐ๋ฐ˜ ์ด๋ฏธ์ง€ ํ•ฉ์„ฑ ๋ฐ ํŽธ์ง‘, ์ด๋ฏธ์ง€ ํ•ฉ์„ฑ์„ ํฌํ•จํ•œ ์—ฌ๋Ÿฌ ์ž‘์—…์—์„œ ์ธ๊ฐ„ ์ง€๊ฐ ์—ฐ๊ตฌ์— ๋”ฐ๋ผ ์‚ฌ์‹ค์„ฑ์—์„œ ์ตœ๋Œ€ 98.09%, ์ „๋ฐ˜์ ์ธ ๋งŒ์กฑ๋„์—์„œ 91.72%๊นŒ์ง€ ์ตœ์ฒจ๋‹จ GAN ๊ธฐ๋ฐ˜ ๋ฐฉ๋ฒ•๋ณด๋‹ค ํ˜„์ €ํžˆ ์šฐ์ˆ˜ํ•œ ์„ฑ๋Šฅ์„ ๋ณด์ž…๋‹ˆ๋‹ค.*
> [!TIP]
> ์Šค์ผ€์ค„๋Ÿฌ์˜ ์†๋„์™€ ํ’ˆ์งˆ ์‚ฌ์ด์˜ ํŠธ๋ ˆ์ด๋“œ์˜คํ”„๋ฅผ ํƒ์ƒ‰ํ•˜๋Š” ๋ฐฉ๋ฒ•๊ณผ ํŒŒ์ดํ”„๋ผ์ธ ๊ตฌ์„ฑ ์š”์†Œ๋ฅผ ํšจ์œจ์ ์œผ๋กœ ์žฌ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ๋ฐฐ์šฐ๋ ค๋ฉด Stable Diffusion [Tips](overview#tips) ์„น์…˜์„ ๊ผญ ํ™•์ธํ•˜์„ธ์š”!
## StableDiffusionImg2ImgPipeline[[diffusers.StableDiffusionImg2ImgPipeline]]
#### diffusers.StableDiffusionImg2ImgPipeline[[diffusers.StableDiffusionImg2ImgPipeline]]
```python
diffusers.StableDiffusionImg2ImgPipeline(vae: AutoencoderKL, text_encoder: CLIPTextModel, tokenizer: CLIPTokenizer, unet: UNet2DConditionModel, scheduler: KarrasDiffusionSchedulers, safety_checker: StableDiffusionSafetyChecker, feature_extractor: CLIPImageProcessorPil, image_encoder: CLIPVisionModelWithProjection = None, requires_safety_checker: bool = True)
```
[์†Œ์Šค](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_img2img.py#L182)
**๋งค๊ฐœ๋ณ€์ˆ˜:**
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)) : ๊ณ ์ •๋œ ํ…์ŠคํŠธ ์ธ์ฝ”๋” ([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`์ž…๋‹ˆ๋‹ค.
unet ([UNet2DConditionModel](/docs/diffusers/main/ko/api/models/unet2d-cond#diffusers.UNet2DConditionModel)) : ์ธ์ฝ”๋”ฉ๋œ ์ด๋ฏธ์ง€ latents์˜ ๋…ธ์ด์ฆˆ๋ฅผ ์ œ๊ฑฐํ•˜๊ธฐ ์œ„ํ•œ `UNet2DConditionModel`.
scheduler ([SchedulerMixin](/docs/diffusers/main/ko/api/schedulers/overview#diffusers.SchedulerMixin)) : `unet`์™€ ํ•จ๊ป˜ ์‚ฌ์šฉ๋˜์–ด ์ธ์ฝ”๋”ฉ๋œ ์ด๋ฏธ์ง€ latents์˜ ๋…ธ์ด์ฆˆ๋ฅผ ์ œ๊ฑฐํ•˜๋Š” ์Šค์ผ€์ค„๋Ÿฌ์ž…๋‹ˆ๋‹ค. [DDIMScheduler](/docs/diffusers/main/ko/api/schedulers/ddim#diffusers.DDIMScheduler), [LMSDiscreteScheduler](/docs/diffusers/main/ko/api/schedulers/lms_discrete#diffusers.LMSDiscreteScheduler), ๋˜๋Š” [PNDMScheduler](/docs/diffusers/main/ko/api/schedulers/pndm#diffusers.PNDMScheduler) ์ค‘ ํ•˜๋‚˜์ผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
safety_checker (`StableDiffusionSafetyChecker`) : ์ƒ์„ฑ๋œ ์ด๋ฏธ์ง€๊ฐ€ offensiveํ•˜๊ฑฐ๋‚˜ ์œ ํ•ดํ•œ ๊ฒƒ์œผ๋กœ ๊ฐ„์ฃผ๋  ์ˆ˜ ์žˆ๋Š”์ง€ ์ถ”์ •ํ•˜๋Š” ๋ถ„๋ฅ˜ ๋ชจ๋“ˆ์ž…๋‹ˆ๋‹ค. ๋ชจ๋ธ์˜ ์ž ์žฌ์  ์œ ํ•ด์„ฑ์— ๋Œ€ํ•œ ์ž์„ธํ•œ ๋‚ด์šฉ์€ [model card](https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5)๋ฅผ ์ฐธ๊ณ ํ•˜์„ธ์š”.
feature_extractor ([CLIPImageProcessor](https://huggingface.co/docs/transformers/main/en/model_doc/clip#transformers.CLIPImageProcessor)) : ์ƒ์„ฑ๋œ ์ด๋ฏธ์ง€์—์„œ ํŠน์ง•์„ ์ถ”์ถœํ•˜๊ธฐ ์œ„ํ•œ `CLIPImageProcessor`. `safety_checker`์˜ ์ž…๋ ฅ์œผ๋กœ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.
Stable Diffusion์„ ์‚ฌ์šฉํ•œ ํ…์ŠคํŠธ ๊ธฐ๋ฐ˜ ์ด๋ฏธ์ง€-์ด๋ฏธ์ง€ ์ƒ์„ฑ์„ ์œ„ํ•œ Pipeline
์ด ๋ชจ๋ธ์€ [DiffusionPipeline](/docs/diffusers/main/ko/api/pipelines/overview#diffusers.DiffusionPipeline)์—์„œ ์ƒ์†๋ฉ๋‹ˆ๋‹ค. ๋ชจ๋“  ํŒŒ์ดํ”„๋ผ์ธ์— ๋Œ€ํ•ด ๊ตฌํ˜„๋œ ์ผ๋ฐ˜์  ๋ฉ”์„œ๋“œ(๋‹ค์šด๋กœ๋“œ, ์ €์žฅ, ํŠน์ • ๋””๋ฐ”์ด์Šค์—์„œ ์‹คํ–‰ ๋“ฑ)์— ๋Œ€ํ•ด์„œ๋Š” ์ƒ์œ„ ํด๋ž˜์Šค ๋ฌธ์„œ๋ฅผ ํ™•์ธํ•˜์„ธ์š”.
ํŒŒ์ดํ”„๋ผ์ธ์€ ๋‹ค์Œ ๋กœ๋”ฉ ๋ฉ”์„œ๋“œ๋„ ์ƒ์†ํ•ฉ๋‹ˆ๋‹ค:
- ํ…์ŠคํŠธ ์ธ๋ฒ„์ „ ์ž„๋ฒ ๋”ฉ์„ ๋กœ๋“œํ•˜๋Š” [load_textual_inversion()](/docs/diffusers/main/ko/api/loaders/textual_inversion#diffusers.loaders.TextualInversionLoaderMixin.load_textual_inversion)
- LoRA ๊ฐ€์ค‘์น˜๋ฅผ ๋กœ๋“œํ•˜๋Š” [load_lora_weights()](/docs/diffusers/main/ko/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_weights)
- LoRA ๊ฐ€์ค‘์น˜๋ฅผ ์ €์žฅํ•˜๋Š” [save_lora_weights()](/docs/diffusers/main/ko/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.save_lora_weights)
- `.ckpt` ํŒŒ์ผ์„ ๋กœ๋“œํ•˜๊ธฐ ์œ„ํ•œ [from_single_file()](/docs/diffusers/main/ko/api/loaders/single_file#diffusers.loaders.FromSingleFileMixin.from_single_file)
- IP Adapter๋ฅผ ๋กœ๋“œํ•˜๊ธฐ ์œ„ํ•œ [load_ip_adapter()](/docs/diffusers/main/ko/api/loaders/ip_adapter#diffusers.loaders.IPAdapterMixin.load_ip_adapter)
#### __ํ˜ธ์ถœ__[[diffusers.StableDiffusionImg2ImgPipeline.__call__]]
```python
__call__(prompt: str | list[str] = None, image: typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor]] = None, strength: float = 0.8, num_inference_steps: int | None = 50, timesteps: list[int] = None, sigmas: list[float] = None, guidance_scale: float | None = 7.5, negative_prompt: str | list[str] | None = None, num_images_per_prompt: int | None = 1, eta: float | None = 0.0, generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = None, prompt_embeds: typing.Optional[torch.Tensor] = None, negative_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, ip_adapter_image_embeds: list[torch.Tensor] | None = None, output_type: str | None = 'pil', return_dict: bool = True, cross_attention_kwargs: dict[str, typing.Any] | None = None, clip_skip: int = None, callback_on_step_end: typing.Union[typing.Callable[[int, int], NoneType], diffusers.callbacks.PipelineCallback, diffusers.callbacks.MultiPipelineCallbacks, NoneType] = None, callback_on_step_end_tensor_inputs: list[str] = ['latents'], **kwargs)
```
[์†Œ์Šค](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_img2img.py#L858)
**๋งค๊ฐœ๋ณ€์ˆ˜:**
prompt (`str` ๋˜๋Š” `list[str]`, *์„ ํƒ ์‚ฌํ•ญ*) : ์ด๋ฏธ์ง€ ์ƒ์„ฑ์„ ์•ˆ๋‚ดํ•  ํ”„๋กฌํ”„ํŠธ์ž…๋‹ˆ๋‹ค. ์ •์˜๋˜์ง€ ์•Š์€ ๊ฒฝ์šฐ `prompt_embeds`๋ฅผ ์ „๋‹ฌํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
image (`torch.Tensor`, `PIL.Image.Image`, `np.ndarray`, `list[torch.Tensor]`, `list[PIL.Image.Image]`, ๋˜๋Š” `list[np.ndarray]`) : ์‹œ์ž‘์ ์œผ๋กœ ์‚ฌ์šฉํ•  ์ด๋ฏธ์ง€ ๋ฐฐ์น˜์˜ `Image`, numpy ๋ฐฐ์—ด ๋˜๋Š” ํ…์„œ๋ฅผ ๋‚˜ํƒ€๋ƒ…๋‹ˆ๋‹ค. numpy ๋ฐฐ์—ด๊ณผ pytorch ํ…์„œ ๋ชจ๋‘์—์„œ ์˜ˆ์ƒ ๊ฐ’ ๋ฒ”์œ„๋Š” `[0, 1]`์ž…๋‹ˆ๋‹ค. ํ…์„œ ๋˜๋Š” ํ…์„œ ๋ชฉ๋ก์ธ ๊ฒฝ์šฐ, ์˜ˆ์ƒ shape์€ `(B, C, H, W)` ๋˜๋Š” `(C, H, W)`์—ฌ์•ผ ํ•ฉ๋‹ˆ๋‹ค. numpy ๋ฐฐ์—ด ๋˜๋Š” ๋ฐฐ์—ด ๋ชฉ๋ก์ธ ๊ฒฝ์šฐ, ์˜ˆ์ƒ shape์€ `(B, H, W, C)` ๋˜๋Š” `(H, W, C)`์—ฌ์•ผ ํ•ฉ๋‹ˆ๋‹ค. `image`๋กœ ์ด๋ฏธ์ง€ latents๋„ ๋ฐ›์„ ์ˆ˜ ์žˆ์ง€๋งŒ, latents๋ฅผ ์ง์ ‘ ์ „๋‹ฌํ•˜๋Š” ๊ฒฝ์šฐ ๋‹ค์‹œ ์ธ์ฝ”๋”ฉ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
strength (`float`, *์„ ํƒ ์‚ฌํ•ญ*, ๊ธฐ๋ณธ๊ฐ’ 0.8) : ์ฐธ์กฐ `image`๋ฅผ ๋ณ€ํ™˜ํ•  ์ •๋„๋ฅผ ๋‚˜ํƒ€๋ƒ…๋‹ˆ๋‹ค. 0๊ณผ 1 ์‚ฌ์ด์—ฌ์•ผ ํ•ฉ๋‹ˆ๋‹ค. `image`๋Š” ์‹œ์ž‘์ ์œผ๋กœ ์‚ฌ์šฉ๋˜๋ฉฐ, `strength` ๊ฐ’์ด ๋†’์„์ˆ˜๋ก ๋” ๋งŽ์€ ๋…ธ์ด์ฆˆ๊ฐ€ ์ถ”๊ฐ€๋ฉ๋‹ˆ๋‹ค. ๋””๋…ธ์ด์ง• ๋‹จ๊ณ„์˜ ์ˆ˜๋Š” ์ดˆ๊ธฐ์— ์ถ”๊ฐ€๋œ ๋…ธ์ด์ฆˆ์˜ ์–‘์— ๋”ฐ๋ผ ๊ฒฐ์ •๋ฉ๋‹ˆ๋‹ค. `strength`๊ฐ€ 1์ด๋ฉด ์ถ”๊ฐ€๋˜๋Š” ๋…ธ์ด์ฆˆ๊ฐ€ ์ตœ๋Œ€๊ฐ€ ๋˜๋ฉฐ, `num_inference_steps`์— ์ง€์ •๋œ ์ „์ฒด ๋ฐ˜๋ณต ํšŸ์ˆ˜๋งŒํผ ๋””๋…ธ์ด์ง• ํ”„๋กœ์„ธ์Šค๊ฐ€ ์‹คํ–‰๋ฉ๋‹ˆ๋‹ค. 1์ด๋ผ๋Š” ๊ฐ’์€ ์‚ฌ์‹ค์ƒ `image`๋ฅผ ๋ฌด์‹œํ•˜๋Š” ๊ฒƒ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.
num_inference_steps (`int`, *์„ ํƒ ์‚ฌํ•ญ*, ๊ธฐ๋ณธ๊ฐ’ 50) : ๋””๋…ธ์ด์ง• ๋‹จ๊ณ„ ์ˆ˜์ž…๋‹ˆ๋‹ค. ๋””๋…ธ์ด์ง• ๋‹จ๊ณ„๊ฐ€ ๋งŽ์„์ˆ˜๋ก ์ผ๋ฐ˜์ ์œผ๋กœ ์ถ”๋ก  ์†๋„๊ฐ€ ๋А๋ ค์ง€๋Š” ๋Œ€์‹  ๋” ๋†’์€ ํ’ˆ์งˆ์˜ ์ด๋ฏธ์ง€๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค. ์ด ๋งค๊ฐœ๋ณ€์ˆ˜๋Š” `strength`์— ์˜ํ•ด ์กฐ์ ˆ๋ฉ๋‹ˆ๋‹ค.
timesteps (`list[int]`, *์„ ํƒ ์‚ฌํ•ญ*) : `set_timesteps` ๋ฉ”์„œ๋“œ์— `timesteps` ์ธ์ˆ˜๋ฅผ ์ง€์›ํ•˜๋Š” ์Šค์ผ€์ค„๋Ÿฌ์˜ ๋…ธ์ด์ฆˆ ์ œ๊ฑฐ ๊ณผ์ •์— ์‚ฌ์šฉํ•  ์ปค์Šคํ…€ ํƒ€์ž„์Šคํ…์ž…๋‹ˆ๋‹ค. ์ •์˜๋˜์ง€ ์•Š์€ ๊ฒฝ์šฐ, `num_inference_steps`๊ฐ€ ์ „๋‹ฌ๋  ๋•Œ์˜ ๊ธฐ๋ณธ ๋™์ž‘์ด ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. ๋‚ด๋ฆผ์ฐจ์ˆœ์œผ๋กœ ์ •๋ ฌ๋˜์–ด ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
sigmas (`list[float]`, *์„ ํƒ ์‚ฌํ•ญ*) : `set_timesteps` ๋ฉ”์„œ๋“œ์— `sigmas` ์ธ์ˆ˜๋ฅผ ์ง€์›ํ•˜๋Š” ์Šค์ผ€์ค„๋Ÿฌ์˜ ๋…ธ์ด์ฆˆ ์ œ๊ฑฐ ๊ณผ์ •์— ์‚ฌ์šฉํ•  ์ปค์Šคํ…€ ์‹œ๊ทธ๋งˆ์ž…๋‹ˆ๋‹ค. ์ •์˜๋˜์ง€ ์•Š์€ ๊ฒฝ์šฐ, `num_inference_steps`๊ฐ€ ์ „๋‹ฌ๋  ๋•Œ์˜ ๊ธฐ๋ณธ ๋™์ž‘์ด ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.
guidance_scale (`float`, *์„ ํƒ ์‚ฌํ•ญ*, ๊ธฐ๋ณธ๊ฐ’ 7.5) : guidance scale ๊ฐ’์ด ๋†’์„์ˆ˜๋ก ๋ชจ๋ธ์€ ์ด๋ฏธ์ง€ ํ’ˆ์งˆ์ด ๋‚ฎ์•„์ง€๋Š” ๋Œ€์‹  ํ…์ŠคํŠธ `prompt`์™€ ๋ฐ€์ ‘ํ•˜๊ฒŒ ์—ฐ๊ฒฐ๋œ ์ด๋ฏธ์ง€๋ฅผ ์ƒ์„ฑํ•˜๋„๋ก ์œ ๋„๋ฉ๋‹ˆ๋‹ค. `guidance_scale > 1`์ผ ๋•Œ guidance scale์ด ํ™œ์„ฑํ™”๋ฉ๋‹ˆ๋‹ค.
negative_prompt (`str` ๋˜๋Š” `list[str]`, *์„ ํƒ*) : ์ด๋ฏธ์ง€ ์ƒ์„ฑ์—์„œ ํฌํ•จํ•˜์ง€ ์•Š์„ ๋‚ด์šฉ์„ ์•ˆ๋‚ดํ•˜๋Š” ํ”„๋กฌํ”„ํŠธ์ž…๋‹ˆ๋‹ค. ์ •์˜๋˜์ง€ ์•Š์€ ๊ฒฝ์šฐ ๋Œ€์‹  `negative_prompt_embeds`๋ฅผ ์ „๋‹ฌํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๊ฐ€์ด๋˜์Šค๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š์„ ๋•Œ(`guidance_scale < 1`)์—๋Š” ๋ฌด์‹œ๋ฉ๋‹ˆ๋‹ค.
num_images_per_prompt (`int`, *์„ ํƒ ์‚ฌํ•ญ*, ๊ธฐ๋ณธ๊ฐ’ 1) : ํ”„๋กฌํ”„ํŠธ๋‹น ์ƒ์„ฑํ•  ์ด๋ฏธ์ง€์˜ ์ˆ˜.
eta (`float`, *์„ ํƒ ์‚ฌํ•ญ*, ๊ธฐ๋ณธ๊ฐ’ 0.0) : [DDIM](https://huggingface.co/papers/2010.02502) ๋…ผ๋ฌธ์—์„œ ์ •์˜ํ•œ ํŒŒ๋ผ๋ฏธํ„ฐ eta (ฮท)์— ํ•ด๋‹นํ•ฉ๋‹ˆ๋‹ค. [DDIMScheduler](/docs/diffusers/main/ko/api/schedulers/ddim#diffusers.DDIMScheduler)์—๋งŒ ์ ์šฉ๋˜๋ฉฐ, ๋‹ค๋ฅธ ์Šค์ผ€์ค„๋Ÿฌ์—์„œ๋Š” ๋ฌด์‹œ๋ฉ๋‹ˆ๋‹ค.
generator (`torch.Generator` ๋˜๋Š” `list[torch.Generator]`, *์„ ํƒ ์‚ฌํ•ญ*) : ์ƒ์„ฑ์„ ๊ฒฐ์ •์ ์œผ๋กœ ๋งŒ๋“ค๊ธฐ ์œ„ํ•œ [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html)์ž…๋‹ˆ๋‹ค.
prompt_embeds (`torch.Tensor`, *์„ ํƒ ์‚ฌํ•ญ*) : ๋ฏธ๋ฆฌ ์ƒ์„ฑ๋œ ํ…์ŠคํŠธ ์ž„๋ฒ ๋”ฉ์ž…๋‹ˆ๋‹ค. ํ…์ŠคํŠธ ์ž…๋ ฅ(ํ”„๋กฌํ”„ํŠธ ๊ฐ€์ค‘์น˜)์„ ์‰ฝ๊ฒŒ ์กฐ์ •ํ•˜๋Š” ๋ฐ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ œ๊ณต๋˜์ง€ ์•Š์œผ๋ฉด `prompt` ์ž…๋ ฅ ์ธ์ž์—์„œ ํ…์ŠคํŠธ ์ž„๋ฒ ๋”ฉ์ด ์ƒ์„ฑ๋ฉ๋‹ˆ๋‹ค.
negative_prompt_embeds (`torch.Tensor`, *์„ ํƒ ์‚ฌํ•ญ*) : ๋ฏธ๋ฆฌ ์ƒ์„ฑ๋œ ๋ถ€์ • ํ…์ŠคํŠธ ์ž„๋ฒ ๋”ฉ์ž…๋‹ˆ๋‹ค. ํ…์ŠคํŠธ ์ž…๋ ฅ(ํ”„๋กฌํ”„ํŠธ ๊ฐ€์ค‘์น˜)์„ ์‰ฝ๊ฒŒ ์กฐ์ •ํ•˜๋Š” ๋ฐ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ œ๊ณต๋˜์ง€ ์•Š์œผ๋ฉด `negative_prompt` ์ž…๋ ฅ ์ธ์ˆ˜์—์„œ `negative_prompt_embeds`๊ฐ€ ์ƒ์„ฑ๋ฉ๋‹ˆ๋‹ค.
ip_adapter_image : (`PipelineImageInput`, *์„ ํƒ ์‚ฌํ•ญ*): IP Adapters์™€ ํ•จ๊ป˜ ์‚ฌ์šฉํ•  ์„ ํƒ์  ์ด๋ฏธ์ง€ ์ž…๋ ฅ์ž…๋‹ˆ๋‹ค.
ip_adapter_image_embeds (`list[torch.Tensor]`, *์„ ํƒ*) : IP-Adapter๋ฅผ ์œ„ํ•œ ์‚ฌ์ „ ์ƒ์„ฑ๋œ ์ด๋ฏธ์ง€ ์ž„๋ฒ ๋”ฉ์ž…๋‹ˆ๋‹ค. IP-Adapter์˜ ์ˆ˜์™€ ๋™์ผํ•œ ๊ธธ์ด์˜ ๋ฆฌ์ŠคํŠธ์—ฌ์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๊ฐ ์š”์†Œ๋Š” `(batch_size, num_images, emb_dim)` ํ˜•ํƒœ์˜ ํ…์„œ์—ฌ์•ผ ํ•ฉ๋‹ˆ๋‹ค. `do_classifier_free_guidance`๊ฐ€ `True`๋กœ ์„ค์ •๋œ ๊ฒฝ์šฐ, ์Œ์˜ ์ด๋ฏธ์ง€ ์ž„๋ฒ ๋”ฉ์„ ํฌํ•จํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์ œ๊ณต๋˜์ง€ ์•Š์œผ๋ฉด `ip_adapter_image` ์ž…๋ ฅ ์ธ์ž๋กœ๋ถ€ํ„ฐ ์ž„๋ฒ ๋”ฉ์ด ๊ณ„์‚ฐ๋ฉ๋‹ˆ๋‹ค.
output_type (`str`, *์„ ํƒ ์‚ฌํ•ญ*, ๊ธฐ๋ณธ๊ฐ’ `"pil"`) : ์ƒ์„ฑ๋œ ์ด๋ฏธ์ง€์˜ ์ถœ๋ ฅ ํ˜•์‹์ž…๋‹ˆ๋‹ค. `PIL.Image` ๋˜๋Š” `np.array` ์ค‘ ํ•˜๋‚˜๋ฅผ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค.
return_dict (`bool`, *์„ ํƒ ์‚ฌํ•ญ*, ๊ธฐ๋ณธ๊ฐ’ `True`) : ์ผ๋ฐ˜ ํŠœํ”Œ ๋Œ€์‹  [StableDiffusionPipelineOutput](/docs/diffusers/main/ko/api/pipelines/stable_diffusion/upscale#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput)์„ ๋ฐ˜ํ™˜ํ• ์ง€ ์—ฌ๋ถ€.
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์ด๋ฉด ์ตœ์ข… ๋ ˆ์ด์–ด ๋ฐ”๋กœ ์ด์ „ ๋ ˆ์ด์–ด์˜ ์ถœ๋ ฅ์„ ํ”„๋กฌํ”„ํŠธ ์ž„๋ฒ ๋”ฉ ๊ณ„์‚ฐ์— ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
callback_on_step_end (`Callable`, `PipelineCallback`, `MultiPipelineCallbacks`, *optional*) : ์ถ”๋ก  ์ค‘ ๊ฐ denoising ๋‹จ๊ณ„์˜ ๋์—์„œ ํ˜ธ์ถœ๋˜๋Š” ํ•จ์ˆ˜ ๋˜๋Š” `PipelineCallback` ๋˜๋Š” `MultiPipelineCallbacks`์˜ ํ•˜์œ„ ํด๋ž˜์Šค์ž…๋‹ˆ๋‹ค. ๋‹ค์Œ ์ธ์ˆ˜๋ฅผ ๊ฐ€์ง‘๋‹ˆ๋‹ค: `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` ์†์„ฑ์— ๋‚˜์—ด๋œ ๋ณ€์ˆ˜๋งŒ ํฌํ•จํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
**๋ฐ˜ํ™˜๊ฐ’:** [StableDiffusionPipelineOutput](/docs/diffusers/main/ko/api/pipelines/stable_diffusion/upscale#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput) ๋˜๋Š” `tuple`
If `return_dict` is `True`, [StableDiffusionPipelineOutput](/docs/diffusers/main/ko/api/pipelines/stable_diffusion/upscale#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput) is returned, otherwise a `tuple` is returned where the first element is a list with the generated images and the second element is a list of `bool`s indicating whether the corresponding generated image contains "not-safe-for-work" (nsfw) content.
์ƒ์„ฑ์„ ์œ„ํ•œ pipeline์˜ ํ˜ธ์ถœ ํ•จ์ˆ˜.
์˜ˆ:
```py
>>> import requests
>>> import torch
>>> from PIL import Image
>>> from io import BytesIO
>>> from diffusers import StableDiffusionImg2ImgPipeline
>>> device = "cuda"
>>> model_id_or_path = "stable-diffusion-v1-5/stable-diffusion-v1-5"
>>> pipe = StableDiffusionImg2ImgPipeline.from_pretrained(model_id_or_path, torch_dtype=torch.float16)
>>> pipe = pipe.to(device)
>>> url = "https://raw.githubusercontent.com/CompVis/stable-diffusion/main/assets/stable-samples/img2img/sketch-mountains-input.jpg"
>>> response = requests.get(url)
>>> init_image = Image.open(BytesIO(response.content)).convert("RGB")
>>> init_image = init_image.resize((768, 512))
>>> prompt = "A fantasy landscape, trending on artstation"
>>> images = pipe(prompt=prompt, image=init_image, strength=0.75, guidance_scale=7.5).images
>>> images[0].save("fantasy_landscape.png")
```
#### enable_attention_slicing[[diffusers.StableDiffusionImg2ImgPipeline.enable_attention_slicing]]
```python
enable_attention_slicing(slice_size: str | int = 'auto')
```
[์†Œ์Šค](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/pipeline_utils.py#L2030)
**๋งค๊ฐœ๋ณ€์ˆ˜:**
slice_size (`str` ๋˜๋Š” `int`, *์„ ํƒ ์‚ฌํ•ญ*, ๊ธฐ๋ณธ๊ฐ’ `"auto"`) : `"auto"`์ธ ๊ฒฝ์šฐ attention heads์— ์ „๋‹ฌ๋˜๋Š” ์ž…๋ ฅ์„ ์ ˆ๋ฐ˜์œผ๋กœ ์ค„์—ฌ attention์„ ๋‘ ๋‹จ๊ณ„๋กœ ๊ณ„์‚ฐํ•ฉ๋‹ˆ๋‹ค. `"max"`์ธ ๊ฒฝ์šฐ ํ•œ ๋ฒˆ์— ํ•˜๋‚˜์˜ ์Šฌ๋ผ์ด์Šค๋งŒ ์‹คํ–‰ํ•˜์—ฌ ์ตœ๋Œ€์˜ ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ์ ˆ์•ฝํ•ฉ๋‹ˆ๋‹ค. ์ˆซ์ž๊ฐ€ ์ œ๊ณต๋˜๋ฉด `attention_head_dim // slice_size`๋งŒํผ์˜ ์Šฌ๋ผ์ด์Šค๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ์ด ๊ฒฝ์šฐ `attention_head_dim`์€ `slice_size`์˜ ๋ฐฐ์ˆ˜์—ฌ์•ผ ํ•ฉ๋‹ˆ๋‹ค.
์Šฌ๋ผ์ด์Šค๋œ ์–ดํ…์…˜ ๊ณ„์‚ฐ์„ ํ™œ์„ฑํ™”ํ•ฉ๋‹ˆ๋‹ค. ์ด ์˜ต์…˜์ด ํ™œ์„ฑํ™”๋˜๋ฉด ์–ดํ…์…˜ ๋ชจ๋“ˆ์€ ์ž…๋ ฅ ํ…์„œ๋ฅผ ์Šฌ๋ผ์ด์Šค๋กœ ๋ถ„ํ• ํ•˜์—ฌ ์—ฌ๋Ÿฌ ๋‹จ๊ณ„์— ๊ฑธ์ณ ์–ดํ…์…˜์„ ๊ณ„์‚ฐํ•ฉ๋‹ˆ๋‹ค. ์–ดํ…์…˜ ํ—ค๋“œ ํ•˜๋‚˜๊ฐ€ ๋„˜๋Š” ๊ฒฝ์šฐ, ๊ฐ ํ—ค๋“œ๋ฅผ ์ˆœ์ฐจ์ ์œผ๋กœ ๊ณ„์‚ฐํ•ฉ๋‹ˆ๋‹ค. ์ด๋Š” ์†๋„๊ฐ€ ์•ฝ๊ฐ„ ๊ฐ์†Œํ•˜๋Š” ๋Œ€์‹  ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ์ ˆ์•ฝํ•˜๋Š” ๋ฐ ์œ ์šฉํ•ฉ๋‹ˆ๋‹ค.
> [!WARNING] > โš ๏ธ ์ด๋ฏธ `scaled_dot_product_attention`(SDPA)๋ฅผ ์‚ฌ์šฉ ์ค‘์ด๋ผ๋ฉด attention slicing์„ ํ™œ์„ฑํ™”ํ•˜์ง€ ๋งˆ์„ธ์š”
from PyTorch > 2.0 or xFormers. ์ด๋Ÿฌํ•œ attention ๊ณ„์‚ฐ์€ ์ด๋ฏธ ๋ฉ”๋ชจ๋ฆฌ ํšจ์œจ์„ฑ์ด ๋งค์šฐ ๋†’์•„ ์ด ๊ธฐ๋Šฅ์„ ํ™œ์„ฑํ™”ํ•  ํ•„์š”๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค. SDPA ๋˜๋Š” xFormers์™€ ํ•จ๊ป˜ attention slicing์„ ํ™œ์„ฑํ™”ํ•˜๋ฉด ์‹ฌ๊ฐํ•œ ์„ฑ๋Šฅ ์ €ํ•˜๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค!
์˜ˆ:
```py
>>> import torch
>>> from diffusers import StableDiffusionPipeline
>>> pipe = StableDiffusionPipeline.from_pretrained(
... "stable-diffusion-v1-5/stable-diffusion-v1-5",
... dtype=torch.float16,
... use_safetensors=True,
... )
>>> prompt = "a photo of an astronaut riding a horse on mars"
>>> pipe.enable_attention_slicing()
>>> image = pipe(prompt).images[0]
```
#### disable_attention_slicing[[diffusers.StableDiffusionImg2ImgPipeline.disable_attention_slicing]]
```python
disable_attention_slicing()
```
[์†Œ์Šค](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/pipeline_utils.py#L2067)
์Šฌ๋ผ์ด์Šค๋œ ์–ดํ…์…˜ ๊ณ„์‚ฐ ๊ธฐ๋Šฅ์„ ๋น„ํ™œ์„ฑํ™”ํ•ฉ๋‹ˆ๋‹ค. `enable_attention_slicing`๊ฐ€ ์ด์ „์— ํ˜ธ์ถœ๋œ ๊ฒฝ์šฐ, ์–ดํ…์…˜์€ ํ•œ ๋ฒˆ์— ๊ณ„์‚ฐ๋ฉ๋‹ˆ๋‹ค.
#### enable_xformers_memory_efficient_attention[[diffusers.StableDiffusionImg2ImgPipeline.enable_xformers_memory_efficient_attention]]
```python
enable_xformers_memory_efficient_attention(attention_op: typing.Optional[typing.Callable] = None)
```
[์†Œ์Šค](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/pipeline_utils.py#L1975)
**๋งค๊ฐœ๋ณ€์ˆ˜:**
attention_op (`Callable`, *์„ ํƒ ์‚ฌํ•ญ*) : xFormers์˜ [`memory_efficient_attention()`](https://facebookresearch.github.io/xformers/components/ops.html#xformers.ops.memory_efficient_attention) ํ•จ์ˆ˜์— `op` ์ธ์ˆ˜๋กœ ์‚ฌ์šฉ๋  ๋•Œ ๊ธฐ๋ณธ `None` ์—ฐ์‚ฐ์ž๋ฅผ ์žฌ์ •์˜ํ•ฉ๋‹ˆ๋‹ค.
[xFormers](https://facebookresearch.github.io/xformers/)์—์„œ ๋ฉ”๋ชจ๋ฆฌ ํšจ์œจ์ ์ธ ์–ดํ…์…˜์„ ํ™œ์„ฑํ™”ํ•ฉ๋‹ˆ๋‹ค. ์ด ์˜ต์…˜์„ ํ™œ์„ฑํ™”ํ•˜๋ฉด ์ถ”๋ก  ์‹œ GPU ๋ฉ”๋ชจ๋ฆฌ ์‚ฌ์šฉ๋Ÿ‰์ด ๊ฐ์†Œํ•˜๊ณ  ์†๋„๊ฐ€ ํ–ฅ์ƒ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ํ•™์Šต ์‹œ ์†๋„ ํ–ฅ์ƒ์€ ๋ณด์žฅ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
> [!WARNING] > โš ๏ธ memory efficient attention๊ณผ sliced attention์ด ๋ชจ๋‘ ํ™œ์„ฑํ™”๋œ ๊ฒฝ์šฐ, memory efficient
attention์€ > ์šฐ์„ ์ˆœ์œ„๋ฅผ ๊ฐ€์ง‘๋‹ˆ๋‹ค.
์˜ˆ:
```py
>>> import torch
>>> from diffusers import DiffusionPipeline
>>> from xformers.ops import MemoryEfficientAttentionFlashAttentionOp
>>> pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2-1", dtype=torch.float16)
>>> pipe = pipe.to("cuda")
>>> pipe.enable_xformers_memory_efficient_attention(attention_op=MemoryEfficientAttentionFlashAttentionOp)
>>> # Workaround for not accepting attention shape using VAE for Flash Attention
>>> pipe.vae.enable_xformers_memory_efficient_attention(attention_op=None)
```
#### disable_xformers_memory_efficient_attention[[diffusers.StableDiffusionImg2ImgPipeline.disable_xformers_memory_efficient_attention]]
```python
disable_xformers_memory_efficient_attention()
```
[์†Œ์Šค](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/pipeline_utils.py#L2006)
[xFormers](https://facebookresearch.github.io/xformers/)์—์„œ ๋ฉ”๋ชจ๋ฆฌ ํšจ์œจ์  ์–ดํ…์…˜์„ ๋น„ํ™œ์„ฑํ™”ํ•ฉ๋‹ˆ๋‹ค.
#### load_textual_inversion[[diffusers.StableDiffusionImg2ImgPipeline.load_textual_inversion]]
```python
load_textual_inversion(pretrained_model_name_or_path: str | list[str] | dict[str, torch.Tensor] | list[dict[str, torch.Tensor]], token: str | list[str] | None = None, tokenizer: 'PreTrainedTokenizer' | None = None, text_encoder: 'PreTrainedModel' | None = None, **kwargs)
```
[์†Œ์Šค](https://github.com/huggingface/diffusers/blob/main/src/diffusers/loaders/textual_inversion.py#L270)
**๋งค๊ฐœ๋ณ€์ˆ˜:**
pretrained_model_name_or_path (`str` ๋˜๋Š” `os.PathLike` ๋˜๋Š” `list[str or os.PathLike]` ๋˜๋Š” `Dict` ๋˜๋Š” `list[Dict]`) : ๋‹ค์Œ ์ค‘ ํ•˜๋‚˜์ด๊ฑฐ๋‚˜, ์ด๋“ค์˜ ๋ฆฌ์ŠคํŠธ์ผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค: - Hub์— ํ˜ธ์ŠคํŒ…๋œ ์‚ฌ์ „ ํ•™์Šต ๋ชจ๋ธ์˜ *model id* ๋ฌธ์ž์—ด (์˜ˆ: `sd-concepts-library/low-poly-hd-logos-icons`). - ํ…์ŠคํŠธ ์ธ๋ฒ„์ „ ๊ฐ€์ค‘์น˜๋ฅผ ํฌํ•จํ•˜๋Š” *๋””๋ ‰ํ„ฐ๋ฆฌ* ๊ฒฝ๋กœ (์˜ˆ: `./my_text_inversion_directory/`). - ํ…์ŠคํŠธ ์ธ๋ฒ„์ „ ๊ฐ€์ค‘์น˜๋ฅผ ํฌํ•จํ•˜๋Š” *ํŒŒ์ผ* ๊ฒฝ๋กœ (์˜ˆ: `./my_text_inversions.pt`). - [torch state dict](https://pytorch.org/tutorials/beginner/saving_loading_models.html#what-is-a-state-dict).
token (`str` ๋˜๋Š” `list[str]`, *์„ ํƒ ์‚ฌํ•ญ*) : ํ…์ŠคํŠธ ์ธ๋ฒ„์ „ ๊ฐ€์ค‘์น˜์— ์‚ฌ์šฉํ•  ํ† ํฐ์„ ์žฌ์ •์˜ํ•ฉ๋‹ˆ๋‹ค. `pretrained_model_name_or_path`๊ฐ€ ๋ฆฌ์ŠคํŠธ์ธ ๊ฒฝ์šฐ, `token`๋„ ๋™์ผํ•œ ๊ธธ์ด์˜ ๋ฆฌ์ŠคํŠธ์—ฌ์•ผ ํ•ฉ๋‹ˆ๋‹ค.
text_encoder ([CLIPTextModel](https://huggingface.co/docs/transformers/main/en/model_doc/clip#transformers.CLIPTextModel), *์„ ํƒ ์‚ฌํ•ญ*) : ๋™๊ฒฐ๋œ ํ…์ŠคํŠธ ์ธ์ฝ”๋”([clip-vit-large-patch14](https://huggingface.co/openai/clip-vit-large-patch14)). ์ง€์ •๋˜์ง€ ์•Š์œผ๋ฉด ํ•จ์ˆ˜๊ฐ€ self.tokenizer๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
tokenizer ([CLIPTokenizer](https://huggingface.co/docs/transformers/main/en/model_doc/clip#transformers.CLIPTokenizer), *์„ ํƒ ์‚ฌํ•ญ*) : ํ…์ŠคํŠธ๋ฅผ ํ† ํฐํ™”ํ•  `CLIPTokenizer`์ž…๋‹ˆ๋‹ค. ์ง€์ •ํ•˜์ง€ ์•Š์œผ๋ฉด ํ•จ์ˆ˜๊ฐ€ self.tokenizer๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
weight_name (`str`, *์„ ํƒ ์‚ฌํ•ญ*) : ์ปค์Šคํ…€ ๊ฐ€์ค‘์น˜ ํŒŒ์ผ์˜ ์ด๋ฆ„. ๋‹ค์Œ ๊ฒฝ์šฐ์— ์‚ฌ์šฉํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค: - ์ €์žฅ๋œ ํ…์ŠคํŠธ ์ธ๋ฒ„์ „ ํŒŒ์ผ์ด ๐Ÿค— Diffusers ํ˜•์‹์ด์ง€๋งŒ `text_inv.bin`๊ณผ ๊ฐ™์€ ํŠน์ • ๊ฐ€์ค‘์น˜ ์ด๋ฆ„์œผ๋กœ ์ €์žฅ๋œ ๊ฒฝ์šฐ. - ์ €์žฅ๋œ ํ…์ŠคํŠธ ์ธ๋ฒ„์ „ ํŒŒ์ผ์ด Automatic1111 ํ˜•์‹์ธ ๊ฒฝ์šฐ.
cache_dir (`str | os.PathLike`, *์„ ํƒ ์‚ฌํ•ญ*) : ํ‘œ์ค€ ์บ์‹œ๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š์„ ๊ฒฝ์šฐ, ๋‹ค์šด๋กœ๋“œ๋œ ์‚ฌ์ „ ํ•™์Šต ๋ชจ๋ธ ๊ตฌ์„ฑ์ด ์บ์‹œ๋˜๋Š” ๋””๋ ‰ํ„ฐ๋ฆฌ์˜ ๊ฒฝ๋กœ์ž…๋‹ˆ๋‹ค.
force_download (`bool`, *์„ ํƒ ์‚ฌํ•ญ*, ๊ธฐ๋ณธ๊ฐ’ `False`) : ์บ์‹œ๋œ ๋ฒ„์ „์ด ์กด์žฌํ•˜๋”๋ผ๋„ ๋ชจ๋ธ ๊ฐ€์ค‘์น˜ ๋ฐ ๊ตฌ์„ฑ ํŒŒ์ผ์˜ (์žฌ)๋‹ค์šด๋กœ๋“œ๋ฅผ ๊ฐ•์ œํ• ์ง€ ์—ฌ๋ถ€.
proxies (`dict[str, str]`, *์„ ํƒ ์‚ฌํ•ญ*) : ํ”„๋กœํ† ์ฝœ ๋˜๋Š” ์—”๋“œํฌ์ธํŠธ๋ณ„๋กœ ์‚ฌ์šฉํ•  ํ”„๋ก์‹œ ์„œ๋ฒ„์˜ ์‚ฌ์ „์ž…๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, `{'http': 'foo.bar:3128', 'http://hostname': 'foo.bar:4012'}`์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค. ๊ฐ ์š”์ฒญ์— ํ”„๋ก์‹œ๊ฐ€ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.
local_files_only (`bool`, *์„ ํƒ ์‚ฌํ•ญ*, ๊ธฐ๋ณธ๊ฐ’ `False`) : ๋กœ์ปฌ ๋ชจ๋ธ ๊ฐ€์ค‘์น˜์™€ ๊ตฌ์„ฑ ํŒŒ์ผ๋งŒ ๋กœ๋“œํ• ์ง€ ์—ฌ๋ถ€๋ฅผ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค. `True`๋กœ ์„ค์ •ํ•˜๋ฉด Hub์—์„œ ๋ชจ๋ธ์„ ๋‹ค์šด๋กœ๋“œํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
hf_token (`str` ๋˜๋Š” *bool*, *์„ ํƒ ์‚ฌํ•ญ*) : ์›๊ฒฉ ํŒŒ์ผ์— ๋Œ€ํ•œ HTTP bearer ์ธ์ฆ์œผ๋กœ ์‚ฌ์šฉํ•  ํ† ํฐ์ž…๋‹ˆ๋‹ค. `True`์ธ ๊ฒฝ์šฐ, `diffusers-cli login`์—์„œ ์ƒ์„ฑ๋œ ํ† ํฐ(`~/.huggingface`์— ์ €์žฅ๋จ)์ด ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.
revision (`str`, *์„ ํƒ ์‚ฌํ•ญ*, ๊ธฐ๋ณธ๊ฐ’ `"main"`) : ์‚ฌ์šฉํ•  ํŠน์ • ๋ชจ๋ธ ๋ฒ„์ „์ž…๋‹ˆ๋‹ค. Git์—์„œ ํ—ˆ์šฉํ•˜๋Š” ๋ธŒ๋žœ์น˜ ์ด๋ฆ„, ํƒœ๊ทธ ์ด๋ฆ„, ์ปค๋ฐ‹ ID ๋˜๋Š” ๊ธฐํƒ€ ์‹๋ณ„์ž์ผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
subfolder (`str`, *์„ ํƒ ์‚ฌํ•ญ*, ๊ธฐ๋ณธ๊ฐ’ `""`) : Hub ๋˜๋Š” ๋กœ์ปฌ์˜ ๋” ํฐ ๋ชจ๋ธ ์ €์žฅ์†Œ ๋‚ด์—์„œ ๋ชจ๋ธ ํŒŒ์ผ์˜ ์„œ๋ธŒํด๋” ์œ„์น˜์ž…๋‹ˆ๋‹ค.
mirror (`str`, *์„ ํƒ ์‚ฌํ•ญ*) : ์ค‘๊ตญ์—์„œ ๋ชจ๋ธ์„ ๋‹ค์šด๋กœ๋“œํ•  ๋•Œ ์ ‘๊ทผ์„ฑ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•œ ๋ฏธ๋Ÿฌ ์†Œ์Šค์ž…๋‹ˆ๋‹ค. ํ•ด๋‹น ์†Œ์Šค์˜ ์ ์‹œ์„ฑ์ด๋‚˜ ์•ˆ์ „์„ฑ์„ ๋ณด์žฅํ•˜์ง€ ์•Š์œผ๋ฉฐ, ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๋ฏธ๋Ÿฌ ์‚ฌ์ดํŠธ๋ฅผ ์ฐธ๊ณ ํ•˜์„ธ์š”.
[StableDiffusionPipeline](/docs/diffusers/main/ko/api/pipelines/stable_diffusion/text2img#diffusers.StableDiffusionPipeline)์˜ ํ…์ŠคํŠธ ์ธ์ฝ”๋”์— Textual Inversion ์ž„๋ฒ ๋”ฉ์„ ๋กœ๋“œํ•ฉ๋‹ˆ๋‹ค(๐Ÿค— Diffusers์™€ Automatic1111 ํ˜•์‹ ๋ชจ๋‘ ์ง€์›).
์˜ˆ:
๐Ÿค— Diffusers ํ˜•์‹์œผ๋กœ Textual Inversion ์ž„๋ฒ ๋”ฉ ๋ฒกํ„ฐ๋ฅผ ๋กœ๋“œํ•˜๋ ค๋ฉด:
```py
from diffusers import StableDiffusionPipeline
import torch
model_id = "stable-diffusion-v1-5/stable-diffusion-v1-5"
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16).to("cuda")
pipe.load_textual_inversion("sd-concepts-library/cat-toy")
prompt = "A <cat-toy> backpack"
image = pipe(prompt, num_inference_steps=50).images[0]
image.save("cat-backpack.png")
```
Automatic1111 ํ˜•์‹์˜ Textual Inversion ์ž„๋ฒ ๋”ฉ ๋ฒกํ„ฐ๋ฅผ ๋กœ๋“œํ•˜๋ ค๋ฉด ๋จผ์ € ๋ฒกํ„ฐ๋ฅผ ๋‹ค์šด๋กœ๋“œ(์˜ˆ: [civitAI](https://civitai.com/models/3036?modelVersionId=9857)์—์„œ)ํ•œ ๋‹ค์Œ ๋ฒกํ„ฐ๋ฅผ ๋กœ๋“œํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
๋กœ์ปฌ์—์„œ:
```py
from diffusers import StableDiffusionPipeline
import torch
model_id = "stable-diffusion-v1-5/stable-diffusion-v1-5"
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16).to("cuda")
pipe.load_textual_inversion("./charturnerv2.pt", token="charturnerv2")
prompt = "charturnerv2, multiple views of the same character in the same outfit, a character turnaround of a woman wearing a black jacket and red shirt, best quality, intricate details."
image = pipe(prompt, num_inference_steps=50).images[0]
image.save("character.png")
```
#### from_single_file[[diffusers.StableDiffusionImg2ImgPipeline.from_single_file]]
```python
from_single_file(pretrained_model_link_or_path, **kwargs)
```
[์†Œ์Šค](https://github.com/huggingface/diffusers/blob/main/src/diffusers/loaders/single_file.py#L248)
**๋งค๊ฐœ๋ณ€์ˆ˜:**
pretrained_model_link_or_path (`str` ๋˜๋Š” `os.PathLike`, *์„ ํƒ ์‚ฌํ•ญ*) : ๋‹ค์Œ ์ค‘ ํ•˜๋‚˜์ผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. - Hub์˜ `.ckpt` ํŒŒ์ผ ๋งํฌ(์˜ˆ: `"https://huggingface.co/<repo_id>/blob/main/<path_to_file>.ckpt"`). - ๋ชจ๋“  ํŒŒ์ดํ”„๋ผ์ธ ๊ฐ€์ค‘์น˜๋ฅผ ํฌํ•จํ•˜๋Š” *ํŒŒ์ผ*์˜ ๊ฒฝ๋กœ.
dtype (`str` ๋˜๋Š” `torch.dtype`, *์„ ํƒ ์‚ฌํ•ญ*) : ๊ธฐ๋ณธ `torch.dtype`๋ฅผ ์žฌ์ •์˜ํ•˜์—ฌ ๋‹ค๋ฅธ dtype๋กœ ๋ชจ๋ธ์„ ๋กœ๋“œํ•ฉ๋‹ˆ๋‹ค.
force_download (`bool`, *์„ ํƒ ์‚ฌํ•ญ*, ๊ธฐ๋ณธ๊ฐ’ `False`) : ์บ์‹œ๋œ ๋ฒ„์ „์ด ์กด์žฌํ•˜๋”๋ผ๋„ ๋ชจ๋ธ ๊ฐ€์ค‘์น˜ ๋ฐ ๊ตฌ์„ฑ ํŒŒ์ผ์˜ (์žฌ)๋‹ค์šด๋กœ๋“œ๋ฅผ ๊ฐ•์ œํ• ์ง€ ์—ฌ๋ถ€.
cache_dir (`str | os.PathLike`, *์„ ํƒ ์‚ฌํ•ญ*) : ํ‘œ์ค€ ์บ์‹œ๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š์„ ๊ฒฝ์šฐ, ๋‹ค์šด๋กœ๋“œ๋œ ์‚ฌ์ „ ํ•™์Šต ๋ชจ๋ธ ๊ตฌ์„ฑ์ด ์บ์‹œ๋˜๋Š” ๋””๋ ‰ํ„ฐ๋ฆฌ์˜ ๊ฒฝ๋กœ์ž…๋‹ˆ๋‹ค.
proxies (`dict[str, str]`, *์„ ํƒ ์‚ฌํ•ญ*) : ํ”„๋กœํ† ์ฝœ ๋˜๋Š” ์—”๋“œํฌ์ธํŠธ๋ณ„๋กœ ์‚ฌ์šฉํ•  ํ”„๋ก์‹œ ์„œ๋ฒ„์˜ ์‚ฌ์ „์ž…๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, `{'http': 'foo.bar:3128', 'http://hostname': 'foo.bar:4012'}`์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค. ๊ฐ ์š”์ฒญ์— ํ”„๋ก์‹œ๊ฐ€ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.
local_files_only (`bool`, *์„ ํƒ ์‚ฌํ•ญ*, ๊ธฐ๋ณธ๊ฐ’ `False`) : ๋กœ์ปฌ ๋ชจ๋ธ ๊ฐ€์ค‘์น˜์™€ ๊ตฌ์„ฑ ํŒŒ์ผ๋งŒ ๋กœ๋“œํ• ์ง€ ์—ฌ๋ถ€๋ฅผ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค. `True`๋กœ ์„ค์ •ํ•˜๋ฉด Hub์—์„œ ๋ชจ๋ธ์„ ๋‹ค์šด๋กœ๋“œํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
token (`str` ๋˜๋Š” *bool*, *์„ ํƒ ์‚ฌํ•ญ*) : ์›๊ฒฉ ํŒŒ์ผ์— ๋Œ€ํ•œ HTTP bearer ์ธ์ฆ์œผ๋กœ ์‚ฌ์šฉํ•  ํ† ํฐ์ž…๋‹ˆ๋‹ค. `True`์ธ ๊ฒฝ์šฐ, `diffusers-cli login`์—์„œ ์ƒ์„ฑ๋œ ํ† ํฐ(`~/.huggingface`์— ์ €์žฅ๋จ)์ด ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.
revision (`str`, *์„ ํƒ ์‚ฌํ•ญ*, ๊ธฐ๋ณธ๊ฐ’ `"main"`) : ์‚ฌ์šฉํ•  ํŠน์ • ๋ชจ๋ธ ๋ฒ„์ „์ž…๋‹ˆ๋‹ค. Git์—์„œ ํ—ˆ์šฉํ•˜๋Š” ๋ธŒ๋žœ์น˜ ์ด๋ฆ„, ํƒœ๊ทธ ์ด๋ฆ„, ์ปค๋ฐ‹ ID ๋˜๋Š” ๊ธฐํƒ€ ์‹๋ณ„์ž์ผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
original_config_file (`str`, *์„ ํƒ ์‚ฌํ•ญ*) : ๋ชจ๋ธ์„ ํ•™์Šตํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ๋œ ์›๋ž˜ config ํŒŒ์ผ์˜ ๊ฒฝ๋กœ์ž…๋‹ˆ๋‹ค. ์ œ๊ณต๋˜์ง€ ์•Š์œผ๋ฉด checkpoint ํŒŒ์ผ์—์„œ config ํŒŒ์ผ์„ ์ถ”๋ก ํ•ฉ๋‹ˆ๋‹ค.
config (`str`, *์„ ํƒ ์‚ฌํ•ญ*) : ๋‹ค์Œ ์ค‘ ํ•˜๋‚˜์ผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. - Hub์— ํ˜ธ์ŠคํŒ…๋œ ์‚ฌ์ „ ํ•™์Šต๋œ ํŒŒ์ดํ”„๋ผ์ธ์˜ *repo id* ๋ฌธ์ž์—ด(์˜ˆ: `CompVis/ldm-text2im-large-256`). - Diffusers ํ˜•์‹์˜ ํŒŒ์ดํ”„๋ผ์ธ ๊ตฌ์„ฑ ์š”์†Œ ์„ค์ •์„ ํฌํ•จํ•˜๋Š” *๋””๋ ‰ํ„ฐ๋ฆฌ* ๊ฒฝ๋กœ(์˜ˆ: `./my_pipeline_directory/`).
disable_mmap ('bool', *์„ ํƒ ์‚ฌํ•ญ*, ๊ธฐ๋ณธ๊ฐ’ 'False') : Safetensors ๋ชจ๋ธ์„ ๋กœ๋“œํ•  ๋•Œ mmap์„ ๋น„ํ™œ์„ฑํ™”ํ• ์ง€ ์—ฌ๋ถ€์ž…๋‹ˆ๋‹ค. ๋ชจ๋ธ์ด ๋„คํŠธ์›Œํฌ ๋งˆ์šดํŠธ๋‚˜ ํ•˜๋“œ ๋“œ๋ผ์ด๋ธŒ์— ์žˆ๋Š” ๊ฒฝ์šฐ ์ด ์˜ต์…˜์„ ์‚ฌ์šฉํ•˜๋ฉด ์„ฑ๋Šฅ์ด ๋” ์ข‹์•„์งˆ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
kwargs (๋‚จ์€ ํ‚ค์›Œ๋“œ ์ธ์ˆ˜์˜ ์‚ฌ์ „, *์„ ํƒ ์‚ฌํ•ญ*) : ๋กœ๋“œ ๋ฐ ์ €์žฅ ๊ฐ€๋Šฅํ•œ ๋ณ€์ˆ˜(ํŠน์ • ํŒŒ์ดํ”„๋ผ์ธ ํด๋ž˜์Šค์˜ ํŒŒ์ดํ”„๋ผ์ธ ๊ตฌ์„ฑ ์š”์†Œ)๋ฅผ ๋ฎ์–ด์“ธ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋ฎ์–ด์“ฐ๊ธฐ๋œ ๊ตฌ์„ฑ ์š”์†Œ๋Š” ํŒŒ์ดํ”„๋ผ์ธ์˜ `__init__` ๋ฉ”์„œ๋“œ์— ์ง์ ‘ ์ „๋‹ฌ๋ฉ๋‹ˆ๋‹ค. ์ž์„ธํ•œ ๋‚ด์šฉ์€ ์•„๋ž˜ ์˜ˆ์‹œ๋ฅผ ์ฐธ์กฐํ•˜์„ธ์š”.
`.ckpt` ๋˜๋Š” `.safetensors` ํ˜•์‹์œผ๋กœ ์ €์žฅ๋œ ์‚ฌ์ „ ํ•™์Šต๋œ ํŒŒ์ดํ”„๋ผ์ธ ๊ฐ€์ค‘์น˜์—์„œ [DiffusionPipeline](/docs/diffusers/main/ko/api/pipelines/overview#diffusers.DiffusionPipeline)์„ ์ดˆ๊ธฐํ™”ํ•ฉ๋‹ˆ๋‹ค. ํŒŒ์ดํ”„๋ผ์ธ์€ ๊ธฐ๋ณธ์ ์œผ๋กœ ํ‰๊ฐ€ ๋ชจ๋“œ(`model.eval()`)๋กœ ์„ค์ •๋ฉ๋‹ˆ๋‹ค.
์˜ˆ:
```py
>>> from diffusers import StableDiffusionPipeline
>>> # Download pipeline from huggingface.co and cache.
>>> pipeline = StableDiffusionPipeline.from_single_file(
... "https://huggingface.co/WarriorMama777/OrangeMixs/blob/main/Models/AbyssOrangeMix/AbyssOrangeMix.safetensors"
... )
>>> # Download pipeline from local file
>>> # file is downloaded under ./v1-5-pruned-emaonly.ckpt
>>> pipeline = StableDiffusionPipeline.from_single_file("./v1-5-pruned-emaonly.ckpt")
>>> # Enable float16 and move to GPU
>>> pipeline = StableDiffusionPipeline.from_single_file(
... "https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5/blob/main/v1-5-pruned-emaonly.ckpt",
... torch_dtype=torch.float16,
... )
>>> pipeline.to("cuda")
```
#### load_lora_weights[[diffusers.StableDiffusionImg2ImgPipeline.load_lora_weights]]
```python
load_lora_weights(pretrained_model_name_or_path_or_dict: str | dict[str, torch.Tensor], adapter_name: str | None = None, hotswap: bool = False, **kwargs)
```
[์†Œ์Šค](https://github.com/huggingface/diffusers/blob/main/src/diffusers/loaders/lora_pipeline.py#L150)
**๋งค๊ฐœ๋ณ€์ˆ˜:**
pretrained_model_name_or_path_or_dict (`str` ๋˜๋Š” `os.PathLike` ๋˜๋Š” `dict`) : [lora_state_dict()](/docs/diffusers/main/ko/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict)์„(๋ฅผ) ์ฐธ์กฐํ•˜์„ธ์š”.
adapter_name (`str`, *์„ ํƒ ์‚ฌํ•ญ*) : ๋กœ๋“œ๋œ ์–ด๋Œ‘ํ„ฐ ๋ชจ๋ธ์„ ์ฐธ์กฐํ•  ๋•Œ ์‚ฌ์šฉํ•  ์–ด๋Œ‘ํ„ฐ ์ด๋ฆ„. ์ง€์ •ํ•˜์ง€ ์•Š์œผ๋ฉด ๋กœ๋“œ ์ค‘์ธ ์–ด๋Œ‘ํ„ฐ์˜ ์ด ๊ฐœ์ˆ˜๋ฅผ i๋ผ๊ณ  ํ•  ๋•Œ `default_{i}`๊ฐ€ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.
low_cpu_mem_usage (`bool`, *์„ ํƒ ์‚ฌํ•ญ*) : ๋ฌด์ž‘์œ„ ๊ฐ€์ค‘์น˜๋ฅผ ์ดˆ๊ธฐํ™”ํ•˜์ง€ ์•Š๊ณ  ์‚ฌ์ „ ํ•™์Šต๋œ LoRA ๊ฐ€์ค‘์น˜๋งŒ ๋กœ๋“œํ•˜์—ฌ ๋ชจ๋ธ ๋กœ๋”ฉ ์†๋„๋ฅผ ๋†’์ž…๋‹ˆ๋‹ค.
hotswap (`bool`, *์„ ํƒ ์‚ฌํ•ญ*) : ๊ธฐ๋ณธ๊ฐ’์€ `False`์ž…๋‹ˆ๋‹ค. ๊ธฐ์กด (LoRA) ์–ด๋Œ‘ํ„ฐ๋ฅผ ์ƒˆ๋กœ ๋กœ๋“œํ•œ ์–ด๋Œ‘ํ„ฐ๋กœ ์ œ์ž๋ฆฌ์—์„œ ๊ต์ฒดํ• ์ง€ ์—ฌ๋ถ€์ž…๋‹ˆ๋‹ค. ์ฆ‰, ์ถ”๊ฐ€ ์–ด๋Œ‘ํ„ฐ๋ฅผ ๋กœ๋“œํ•˜๋Š” ๋Œ€์‹  ๊ธฐ์กด ์–ด๋Œ‘ํ„ฐ์˜ ๊ฐ€์ค‘์น˜๋ฅผ ์ƒˆ ์–ด๋Œ‘ํ„ฐ์˜ ๊ฐ€์ค‘์น˜๋กœ ๋Œ€์ฒดํ•ฉ๋‹ˆ๋‹ค. ์ด๋Š” ๋” ๋น ๋ฅด๊ณ  ๋ฉ”๋ชจ๋ฆฌ ํšจ์œจ์ ์ผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ ํ•ซ์Šค์™‘์˜ ์ฃผ์š” ์ด์ ์€ ๋ชจ๋ธ์ด torch.compile๋กœ ์ปดํŒŒ์ผ๋œ ๊ฒฝ์šฐ, ์ƒˆ ์–ด๋Œ‘ํ„ฐ๋ฅผ ๋กœ๋“œํ•  ๋•Œ ๋ชจ๋ธ์˜ ์žฌ์ปดํŒŒ์ผ์ด ํ•„์š”ํ•˜์ง€ ์•Š๋‹ค๋Š” ์ ์ž…๋‹ˆ๋‹ค. ํ•ซ์Šค์™‘์„ ์‚ฌ์šฉํ•  ๋•Œ ์ „๋‹ฌํ•˜๋Š” `adapter_name`์€ ์ด๋ฏธ ๋กœ๋“œ๋œ ์–ด๋Œ‘ํ„ฐ์˜ ์ด๋ฆ„์ด์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์ƒˆ ์–ด๋Œ‘ํ„ฐ์™€ ๊ธฐ์กด ์–ด๋Œ‘ํ„ฐ์˜ ๋žญํฌ์™€/๋˜๋Š” LoRA ์•ŒํŒŒ(์ฆ‰, ์Šค์ผ€์ผ๋ง)๊ฐ€ ๋‹ค๋ฅธ ๊ฒฝ์šฐ, ์–ด๋Œ‘ํ„ฐ๋ฅผ ๋กœ๋“œํ•˜๊ธฐ ์ „์— ์ถ”๊ฐ€ ๋ฉ”์„œ๋“œ๋ฅผ ํ˜ธ์ถœํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค: ```py pipeline = ... # load diffusers pipeline max_rank = ... # the highest rank among all LoRAs that you want to load # call *before* compiling and loading the LoRA adapter pipeline.enable_lora_hotswap(target_rank=max_rank) pipeline.load_lora_weights(file_name) # optionally compile the model now ``` ํ…์ŠคํŠธ ์ธ์ฝ”๋”์˜ ์–ด๋Œ‘ํ„ฐ ํ•ซ์Šค์™‘์€ ์•„์ง ์ง€์›๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ์ด ๊ธฐ๋ฒ•์—๋Š” ๋ช‡ ๊ฐ€์ง€ ์ถ”๊ฐ€ ์ œํ•œ ์‚ฌํ•ญ์ด ์žˆ์œผ๋ฉฐ, ์—ฌ๊ธฐ์—์„œ ๋ฌธ์„œํ™”๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค: https://huggingface.co/docs/peft/main/en/package_reference/hotswap
kwargs (`dict`, *์„ ํƒ ์‚ฌํ•ญ*) : [lora_state_dict()](/docs/diffusers/main/ko/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict)๋ฅผ ์ฐธ์กฐํ•˜์„ธ์š”.
`pretrained_model_name_or_path_or_dict`์— ์ง€์ •๋œ LoRA ๊ฐ€์ค‘์น˜๋ฅผ `self.unet`์™€ `self.text_encoder`์— ๋กœ๋“œํ•ฉ๋‹ˆ๋‹ค.
๋ชจ๋“  kwargs๋Š” `self.lora_state_dict`๋กœ ์ „๋‹ฌ๋ฉ๋‹ˆ๋‹ค.
state dict๊ฐ€ ๋กœ๋“œ๋˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•œ ์ž์„ธํ•œ ๋‚ด์šฉ์€ [lora_state_dict()](/docs/diffusers/main/ko/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict)์„ ์ฐธ์กฐํ•˜์„ธ์š”.
`self.unet`์— ์ƒํƒœ ์‚ฌ์ „์ด ๋กœ๋“œ๋˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•œ ์ž์„ธํ•œ ๋‚ด์šฉ์€ [load_lora_into_unet()](/docs/diffusers/main/ko/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_into_unet)์„ ์ฐธ์กฐํ•˜์‹ญ์‹œ์˜ค.
`self.text_encoder`์— state dict๊ฐ€ ๋กœ๋“œ๋˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•œ ์ž์„ธํ•œ ๋‚ด์šฉ์€ [load_lora_into_text_encoder()](/docs/diffusers/main/ko/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_into_text_encoder)๋ฅผ ์ฐธ์กฐํ•˜์„ธ์š”.
#### save_lora_weights[[diffusers.StableDiffusionImg2ImgPipeline.save_lora_weights]]
```python
save_lora_weights(save_directory: str | os.PathLike, unet_lora_layers: dict[str, typing.Union[torch.nn.Module, torch.Tensor]] = None, text_encoder_lora_layers: dict[str, torch.nn.Module] = None, is_main_process: bool = True, weight_name: str = None, save_function: typing.Callable = None, safe_serialization: bool = True, unet_lora_adapter_metadata = None, text_encoder_lora_adapter_metadata = None)
```
[์†Œ์Šค](https://github.com/huggingface/diffusers/blob/main/src/diffusers/loaders/lora_pipeline.py#L469)
**๋งค๊ฐœ๋ณ€์ˆ˜:**
save_directory (`str` ๋˜๋Š” `os.PathLike`) : LoRA ํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ ์ €์žฅํ•  ๋””๋ ‰ํ„ฐ๋ฆฌ์ž…๋‹ˆ๋‹ค. ์กด์žฌํ•˜์ง€ ์•Š์œผ๋ฉด ์ƒ์„ฑ๋ฉ๋‹ˆ๋‹ค.
unet_lora_layers (`dict[str, torch.nn.Module]` ๋˜๋Š” `dict[str, torch.Tensor]`) : `unet`์— ํ•ด๋‹นํ•˜๋Š” LoRA ๋ ˆ์ด์–ด์˜ state dict์ž…๋‹ˆ๋‹ค.
text_encoder_lora_layers (`dict[str, torch.nn.Module]` ๋˜๋Š” `dict[str, torch.Tensor]`) : `text_encoder`์— ํ•ด๋‹นํ•˜๋Š” LoRA ๋ ˆ์ด์–ด์˜ state dict์ž…๋‹ˆ๋‹ค. ๐Ÿค— Transformers์—์„œ ๊ฐ€์ ธ์˜ค๋ฏ€๋กœ text encoder LoRA state dict๋ฅผ ๋ช…์‹œ์ ์œผ๋กœ ์ „๋‹ฌํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
is_main_process (`bool`, *์„ ํƒ ์‚ฌํ•ญ*, ๊ธฐ๋ณธ๊ฐ’ `True`) : ์ด ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ•˜๋Š” ํ”„๋กœ์„ธ์Šค๊ฐ€ ๋ฉ”์ธ ํ”„๋กœ์„ธ์Šค์ธ์ง€ ์—ฌ๋ถ€์ž…๋‹ˆ๋‹ค. ๋ถ„์‚ฐ ํ•™์Šต ์ค‘์— ๋ชจ๋“  ํ”„๋กœ์„ธ์Šค์—์„œ ์ด ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ•ด์•ผ ํ•˜๋Š” ๊ฒฝ์šฐ ์œ ์šฉํ•ฉ๋‹ˆ๋‹ค. ์ด ๊ฒฝ์šฐ ๋ ˆ์ด์Šค ์กฐ๊ฑด์„ ๋ฐฉ์ง€ํ•˜๊ธฐ ์œ„ํ•ด ๋ฉ”์ธ ํ”„๋กœ์„ธ์Šค์—์„œ๋งŒ `is_main_process=True`๋กœ ์„ค์ •ํ•˜์„ธ์š”.
save_function (`Callable`) : ์ƒํƒœ ์‚ฌ์ „(state dictionary)์„ ์ €์žฅํ•˜๋Š” ๋ฐ ์‚ฌ์šฉํ•  ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค. ๋ถ„์‚ฐ ํ•™์Šต ์ค‘์— `torch.save`๋ฅผ ๋‹ค๋ฅธ ๋ฐฉ๋ฒ•์œผ๋กœ ๋Œ€์ฒดํ•ด์•ผ ํ•˜๋Š” ๊ฒฝ์šฐ ์œ ์šฉํ•ฉ๋‹ˆ๋‹ค. ํ™˜๊ฒฝ ๋ณ€์ˆ˜ `DIFFUSERS_SAVE_MODE`๋กœ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
safe_serialization (`bool`, *์„ ํƒ ์‚ฌํ•ญ*, ๊ธฐ๋ณธ๊ฐ’ `True`) : `safetensors` ๋˜๋Š” `pickle`๋ฅผ ์‚ฌ์šฉํ•œ ์ „ํ†ต์ ์ธ PyTorch ๋ฐฉ์‹์œผ๋กœ ๋ชจ๋ธ์„ ์ €์žฅํ• ์ง€ ์—ฌ๋ถ€.
unet_lora_adapter_metadata : state dict์™€ ํ•จ๊ป˜ ์ง๋ ฌํ™”๋  unet์— ์—ฐ๊ฒฐ๋œ LoRA ์–ด๋Œ‘ํ„ฐ ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ.
text_encoder_lora_adapter_metadata : state dict์™€ ํ•จ๊ป˜ ์ง๋ ฌํ™”๋  ํ…์ŠคํŠธ ์ธ์ฝ”๋”์™€ ๊ด€๋ จ๋œ LoRA ์–ด๋Œ‘ํ„ฐ ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ.
UNet๊ณผ ํ…์ŠคํŠธ ์ธ์ฝ”๋”์— ํ•ด๋‹นํ•˜๋Š” LoRA ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ์ €์žฅํ•ฉ๋‹ˆ๋‹ค.
#### encode_prompt[[diffusers.StableDiffusionImg2ImgPipeline.encode_prompt]]
```python
encode_prompt(prompt, device, num_images_per_prompt, do_classifier_free_guidance, negative_prompt = None, prompt_embeds: typing.Optional[torch.Tensor] = None, negative_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/stable_diffusion/pipeline_stable_diffusion_img2img.py#L358)
**๋งค๊ฐœ๋ณ€์ˆ˜:**
prompt (`str` ๋˜๋Š” `list[str]`, *์„ ํƒ ์‚ฌํ•ญ*) : ์ธ์ฝ”๋”ฉํ•  ํ”„๋กฌํ”„ํŠธ
device : (`torch.device`): torch ๋””๋ฐ”์ด์Šค
num_images_per_prompt (`int`) : ํ”„๋กฌํ”„ํŠธ๋‹น ์ƒ์„ฑํ•  ์ด๋ฏธ์ง€ ์ˆ˜
do_classifier_free_guidance (`bool`) : classifier free guidance๋ฅผ ์‚ฌ์šฉํ• ์ง€ ์—ฌ๋ถ€
negative_prompt (`str` ๋˜๋Š” `list[str]`, *์„ ํƒ ์‚ฌํ•ญ*) : ์ด๋ฏธ์ง€ ์ƒ์„ฑ์„ ์•ˆ๋‚ดํ•˜์ง€ ์•Š์„ ํ”„๋กฌํ”„ํŠธ์ž…๋‹ˆ๋‹ค. ์ •์˜๋˜์ง€ ์•Š์€ ๊ฒฝ์šฐ ๋Œ€์‹  `negative_prompt_embeds`๋ฅผ ์ „๋‹ฌํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๊ฐ€์ด๋˜์Šค๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ ๋ฌด์‹œ๋ฉ๋‹ˆ๋‹ค(์ฆ‰, `guidance_scale`์ด `1`๋ณด๋‹ค ์ž‘์€ ๊ฒฝ์šฐ ๋ฌด์‹œ๋ฉ๋‹ˆ๋‹ค).
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์ด๋ฉด ์ตœ์ข… ๋ ˆ์ด์–ด ๋ฐ”๋กœ ์ด์ „ ๋ ˆ์ด์–ด์˜ ์ถœ๋ ฅ์„ ํ”„๋กฌํ”„ํŠธ ์ž„๋ฒ ๋”ฉ ๊ณ„์‚ฐ์— ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
ํ”„๋กฌํ”„ํŠธ๋ฅผ ํ…์ŠคํŠธ ์ธ์ฝ”๋”์˜ ํžˆ๋“  ์ƒํƒœ๋กœ ์ธ์ฝ”๋”ฉํ•ฉ๋‹ˆ๋‹ค.
#### get_guidance_scale_embedding[[diffusers.StableDiffusionImg2ImgPipeline.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/stable_diffusion/pipeline_stable_diffusion_img2img.py#L801)
**๋งค๊ฐœ๋ณ€์ˆ˜:**
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 ๋ฅผ ์ฐธ์กฐํ•˜์„ธ์š”.
## StableDiffusionPipelineOutput[[diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput]]
#### diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput[[diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput]]
```python
diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput(images: list[PIL.Image.Image] | numpy.ndarray, nsfw_content_detected: list[bool] | None)
```
[์†Œ์Šค](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/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`.
Stable Diffusion ํŒŒ์ดํ”„๋ผ์ธ์˜ ์ถœ๋ ฅ ํด๋ž˜์Šค์ž…๋‹ˆ๋‹ค.

Xet Storage Details

Size:
40.8 kB
ยท
Xet hash:
1190604da8f2c3c285de644950424648ba623564fd5c05e2e0693072b3293921

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.