| <!--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. | |
| --> | |
| # ์กฐ๊ฑด๋ถ ์ด๋ฏธ์ง ์์ฑ | |
| [[open-in-colab]] | |
| ์กฐ๊ฑด๋ถ ์ด๋ฏธ์ง ์์ฑ์ ์ฌ์ฉํ๋ฉด ํ ์คํธ ํ๋กฌํํธ์์ ์ด๋ฏธ์ง๋ฅผ ์์ฑํ ์ ์์ต๋๋ค. ํ ์คํธ๋ ์๋ฒ ๋ฉ์ผ๋ก ๋ณํ๋๋ฉฐ, ์๋ฒ ๋ฉ์ ๋ ธ์ด์ฆ์์ ์ด๋ฏธ์ง๋ฅผ ์์ฑํ๋๋ก ๋ชจ๋ธ์ ์กฐ๊ฑดํํ๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค. | |
| [`DiffusionPipeline`]์ ์ถ๋ก ์ ์ํด ์ฌ์ ํ๋ จ๋ diffusion ์์คํ ์ ์ฌ์ฉํ๋ ๊ฐ์ฅ ์ฌ์ด ๋ฐฉ๋ฒ์ ๋๋ค. | |
| ๋จผ์ [`DiffusionPipeline`]์ ์ธ์คํด์ค๋ฅผ ์์ฑํ๊ณ ๋ค์ด๋ก๋ํ ํ์ดํ๋ผ์ธ [์ฒดํฌํฌ์ธํธ](https://huggingface.co/models?library=diffusers&sort=downloads)๋ฅผ ์ง์ ํฉ๋๋ค. | |
| ์ด ๊ฐ์ด๋์์๋ [์ ์ฌ Diffusion](https://huggingface.co/CompVis/ldm-text2im-large-256)๊ณผ ํจ๊ป ํ ์คํธ-์ด๋ฏธ์ง ์์ฑ์ [`DiffusionPipeline`]์ ์ฌ์ฉํฉ๋๋ค: | |
| ```python | |
| >>> from diffusers import DiffusionPipeline | |
| >>> generator = DiffusionPipeline.from_pretrained("CompVis/ldm-text2im-large-256") | |
| ``` | |
| [`DiffusionPipeline`]์ ๋ชจ๋ ๋ชจ๋ธ๋ง, ํ ํฐํ, ์ค์ผ์ค๋ง ๊ตฌ์ฑ ์์๋ฅผ ๋ค์ด๋ก๋ํ๊ณ ์บ์ํฉ๋๋ค. | |
| ์ด ๋ชจ๋ธ์ ์ฝ 14์ต ๊ฐ์ ํ๋ผ๋ฏธํฐ๋ก ๊ตฌ์ฑ๋์ด ์๊ธฐ ๋๋ฌธ์ GPU์์ ์คํํ ๊ฒ์ ๊ฐ๋ ฅํ ๊ถ์ฅํฉ๋๋ค. | |
| PyTorch์์์ ๋ง์ฐฌ๊ฐ์ง๋ก ์์ฑ๊ธฐ ๊ฐ์ฒด๋ฅผ GPU๋ก ์ด๋ํ ์ ์์ต๋๋ค: | |
| ```python | |
| >>> generator.to("cuda") | |
| ``` | |
| ์ด์ ํ ์คํธ ํ๋กฌํํธ์์ `์์ฑ๊ธฐ`๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค: | |
| ```python | |
| >>> image = generator("An image of a squirrel in Picasso style").images[0] | |
| ``` | |
| ์ถ๋ ฅ๊ฐ์ ๊ธฐ๋ณธ์ ์ผ๋ก [`PIL.Image`](https://pillow.readthedocs.io/en/stable/reference/Image.html?highlight=image#the-image-class) ๊ฐ์ฒด๋ก ๋ํ๋ฉ๋๋ค. | |
| ํธ์ถํ์ฌ ์ด๋ฏธ์ง๋ฅผ ์ ์ฅํ ์ ์์ต๋๋ค: | |
| ```python | |
| >>> image.save("image_of_squirrel_painting.png") | |
| ``` | |
| ์๋ ์คํ์ด์ค๋ฅผ ์ฌ์ฉํด๋ณด๊ณ ์๋ด ๋ฐฐ์จ ๋งค๊ฐ๋ณ์๋ฅผ ์์ ๋กญ๊ฒ ์กฐ์ ํ์ฌ ์ด๋ฏธ์ง ํ์ง์ ์ด๋ค ์ํฅ์ ๋ฏธ์น๋์ง ํ์ธํด ๋ณด์ธ์! | |
| <iframe | |
| src="https://stabilityai-stable-diffusion.hf.space" | |
| frameborder="0" | |
| width="850" | |
| height="500" | |
| ></iframe> |