|
<!--Copyright 2023 The HuggingFace Team. All rights reserved. |
|
|
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with |
|
the License. You may obtain a copy of the License at |
|
|
|
http://www.apache.org/licenses/LICENSE-2.0 |
|
|
|
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on |
|
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the |
|
specific language governing permissions and limitations under the License. |
|
--> |
|
|
|
# μλ‘μ΄ μμ
μ λν λͺ¨λΈμ μ μ©νκΈ° |
|
|
|
λ§μ diffusion μμ€ν
μ κ°μ κ΅¬μ± μμλ€μ 곡μ νλ―λ‘ ν μμ
μ λν΄ μ¬μ νμ΅λ λͺ¨λΈμ μμ ν λ€λ₯Έ μμ
μ μ μ©ν μ μμ΅λλ€. |
|
|
|
μ΄ μΈνμΈν
μ μν κ°μ΄λλ μ¬μ νμ΅λ [`UNet2DConditionModel`]μ μν€ν
μ²λ₯Ό μ΄κΈ°ννκ³ μμ νμ¬ μ¬μ νμ΅λ text-to-image λͺ¨λΈμ μ΄λ»κ² μΈνμΈν
μ μ μ©νλμ§λ₯Ό μλ €μ€ κ²μ
λλ€. |
|
|
|
## UNet2DConditionModel νλΌλ―Έν° κ΅¬μ± |
|
|
|
[`UNet2DConditionModel`]μ [input sample](https://huggingface.co/docs/diffusers/v0.16.0/en/api/models#diffusers.UNet2DConditionModel.in_channels)μμ 4κ°μ μ±λμ κΈ°λ³Έμ μΌλ‘ νμ©ν©λλ€. μλ₯Ό λ€μ΄, [`runwayml/stable-diffusion-v1-5`](https://huggingface.co/runwayml/stable-diffusion-v1-5)μ κ°μ μ¬μ νμ΅λ text-to-image λͺ¨λΈμ λΆλ¬μ€κ³ `in_channels`μ μλ₯Ό νμΈν©λλ€: |
|
|
|
```py |
|
from diffusers import StableDiffusionPipeline |
|
|
|
pipeline = StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5") |
|
pipeline.unet.config["in_channels"] |
|
4 |
|
``` |
|
|
|
μΈνμΈν
μ μ
λ ₯ μνμ 9κ°μ μ±λμ΄ νμν©λλ€. [`runwayml/stable-diffusion-inpainting`](https://huggingface.co/runwayml/stable-diffusion-inpainting)μ κ°μ μ¬μ νμ΅λ μΈνμΈν
λͺ¨λΈμμ μ΄ κ°μ νμΈν μ μμ΅λλ€: |
|
|
|
```py |
|
from diffusers import StableDiffusionPipeline |
|
|
|
pipeline = StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-inpainting") |
|
pipeline.unet.config["in_channels"] |
|
9 |
|
``` |
|
|
|
μΈνμΈν
μ λν text-to-image λͺ¨λΈμ μ μ©νκΈ° μν΄, `in_channels` μλ₯Ό 4μμ 9λ‘ μμ ν΄μΌ ν κ²μ
λλ€. |
|
|
|
μ¬μ νμ΅λ text-to-image λͺ¨λΈμ κ°μ€μΉμ [`UNet2DConditionModel`]μ μ΄κΈ°ννκ³ `in_channels`λ₯Ό 9λ‘ μμ ν΄ μ£ΌμΈμ. `in_channels`μ μλ₯Ό μμ νλ©΄ ν¬κΈ°κ° λ¬λΌμ§κΈ° λλ¬Έμ ν¬κΈ°κ° μ λ§λ μ€λ₯λ₯Ό νΌνκΈ° μν΄ `ignore_mismatched_sizes=True` λ° `low_cpu_mem_usage=False`λ₯Ό μ€μ ν΄μΌ ν©λλ€. |
|
|
|
```py |
|
from diffusers import UNet2DConditionModel |
|
|
|
model_id = "runwayml/stable-diffusion-v1-5" |
|
unet = UNet2DConditionModel.from_pretrained( |
|
model_id, subfolder="unet", in_channels=9, low_cpu_mem_usage=False, ignore_mismatched_sizes=True |
|
) |
|
``` |
|
|
|
Text-to-image λͺ¨λΈλ‘λΆν° λ€λ₯Έ κ΅¬μ± μμμ μ¬μ νμ΅λ κ°μ€μΉλ 체ν¬ν¬μΈνΈλ‘λΆν° μ΄κΈ°νλμ§λ§ `unet`μ μ
λ ₯ μ±λ κ°μ€μΉ (`conv_in.weight`)λ λλ€νκ² μ΄κΈ°νλ©λλ€. κ·Έλ μ§ μμΌλ©΄ λͺ¨λΈμ΄ λ
Έμ΄μ¦λ₯Ό 리ν΄νκΈ° λλ¬Έμ μΈνμΈν
μ λͺ¨λΈμ νμΈνλ ν λ μ€μν©λλ€. |
|
|