1
0
mirror of https://github.com/huggingface/diffusers.git synced 2026-01-27 17:22:53 +03:00
Files
diffusers/docs/source/ko/training/adapt_a_model.md
Ali Imran 1b456bd5d5 docs: cleanup of runway model (#12503)
* cleanup of runway model

* quality fixes
2025-10-17 14:10:50 -07:00

55 lines
3.2 KiB
Markdown

<!--Copyright 2025 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๊ฐœ์˜ ์ฑ„๋„์„ ๊ธฐ๋ณธ์ ์œผ๋กœ ํ—ˆ์šฉํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, [`stable-diffusion-v1-5/stable-diffusion-v1-5`](https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5)์™€ ๊ฐ™์€ ์‚ฌ์ „ํ•™์Šต๋œ text-to-image ๋ชจ๋ธ์„ ๋ถˆ๋Ÿฌ์˜ค๊ณ  `in_channels`์˜ ์ˆ˜๋ฅผ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค:
```py
from diffusers import StableDiffusionPipeline
pipeline = StableDiffusionPipeline.from_pretrained("stable-diffusion-v1-5/stable-diffusion-v1-5")
pipeline.unet.config["in_channels"]
4
```
์ธํŽ˜์ธํŒ…์€ ์ž…๋ ฅ ์ƒ˜ํ”Œ์— 9๊ฐœ์˜ ์ฑ„๋„์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค. [`stable-diffusion-v1-5/stable-diffusion-inpainting`](https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-inpainting)์™€ ๊ฐ™์€ ์‚ฌ์ „ํ•™์Šต๋œ ์ธํŽ˜์ธํŒ… ๋ชจ๋ธ์—์„œ ์ด ๊ฐ’์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:
```py
from diffusers import StableDiffusionPipeline
pipeline = StableDiffusionPipeline.from_pretrained("stable-diffusion-v1-5/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 = "stable-diffusion-v1-5/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`)๋Š” ๋žœ๋คํ•˜๊ฒŒ ์ดˆ๊ธฐํ™”๋ฉ๋‹ˆ๋‹ค. ๊ทธ๋ ‡์ง€ ์•Š์œผ๋ฉด ๋ชจ๋ธ์ด ๋…ธ์ด์ฆˆ๋ฅผ ๋ฆฌํ„ดํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์ธํŽ˜์ธํŒ…์˜ ๋ชจ๋ธ์„ ํŒŒ์ธํŠœ๋‹ ํ•  ๋•Œ ์ค‘์š”ํ•ฉ๋‹ˆ๋‹ค.