| <!--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. |
| --> |
|
|
| # ์ค์น |
|
|
| ์ฌ์ฉํ์๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ๋ง๋ ๐ค Diffusers๋ฅผ ์ค์นํ์ธ์. |
|
|
| ๐ค Diffusers๋ Python 3.7+, PyTorch 1.7.0+ ๋ฐ flax์์ ํ
์คํธ๋์์ต๋๋ค. ์ฌ์ฉ์ค์ธ ๋ฅ๋ฌ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ๋ํ ์๋์ ์ค์น ์๋ด๋ฅผ ๋ฐ๋ฅด์ธ์. |
|
|
| - [PyTorch ์ค์น ์๋ด](https://pytorch.org/get-started/locally/) |
| - [Flax ์ค์น ์๋ด](https://flax.readthedocs.io/en/latest/) |
|
|
| ## pip๋ฅผ ์ด์ฉํ ์ค์น |
|
|
| [๊ฐ์ ํ๊ฒฝ](https://docs.python.org/3/library/venv.html)์ ๐ค Diffusers๋ฅผ ์ค์นํด์ผ ํฉ๋๋ค. |
| Python ๊ฐ์ ํ๊ฒฝ์ ์ต์ํ์ง ์์ ๊ฒฝ์ฐ [๊ฐ์ํ๊ฒฝ pip ์ค์น ๊ฐ์ด๋](https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/)๋ฅผ ์ดํด๋ณด์ธ์. |
| ๊ฐ์ ํ๊ฒฝ์ ์ฌ์ฉํ๋ฉด ์๋ก ๋ค๋ฅธ ํ๋ก์ ํธ๋ฅผ ๋ ์ฝ๊ฒ ๊ด๋ฆฌํ๊ณ , ์ข
์์ฑ๊ฐ์ ํธํ์ฑ ๋ฌธ์ ๋ฅผ ํผํ ์ ์์ต๋๋ค. |
|
|
| ํ๋ก์ ํธ ๋๋ ํ ๋ฆฌ์ ๊ฐ์ ํ๊ฒฝ์ ์์ฑํ๋ ๊ฒ์ผ๋ก ์์ํ์ธ์: |
|
|
| ```bash |
| python -m venv .env |
| ``` |
|
|
| ๊ทธ๋ฆฌ๊ณ ๊ฐ์ ํ๊ฒฝ์ ํ์ฑํํฉ๋๋ค: |
|
|
| ```bash |
| source .env/bin/activate |
| ``` |
|
|
| ์ด์ ๋ค์์ ๋ช
๋ น์ด๋ก ๐ค Diffusers๋ฅผ ์ค์นํ ์ค๋น๊ฐ ๋์์ต๋๋ค: |
|
|
| **PyTorch์ ๊ฒฝ์ฐ** |
|
|
| ```bash |
| pip install diffusers["torch"] |
| ``` |
|
|
| **Flax์ ๊ฒฝ์ฐ** |
|
|
| ```bash |
| pip install diffusers["flax"] |
| ``` |
|
|
| ## ์์ค๋ก๋ถํฐ ์ค์น |
|
|
| ์์ค์์ `diffusers`๋ฅผ ์ค์นํ๊ธฐ ์ ์, `torch` ๋ฐ `accelerate`์ด ์ค์น๋์ด ์๋์ง ํ์ธํ์ธ์. |
|
|
| `torch` ์ค์น์ ๋ํด์๋ [torch docs](https://pytorch.org/get-started/locally/#start-locally)๋ฅผ ์ฐธ๊ณ ํ์ธ์. |
|
|
| ๋ค์๊ณผ ๊ฐ์ด `accelerate`์ ์ค์นํ์ธ์. |
|
|
| ```bash |
| pip install accelerate |
| ``` |
|
|
| ๋ค์ ๋ช
๋ น์ด๋ฅผ ์ฌ์ฉํ์ฌ ์์ค์์ ๐ค Diffusers๋ฅผ ์ค์นํ์ธ์: |
|
|
| ```bash |
| pip install git+https://github.com/huggingface/diffusers |
| ``` |
|
|
| ์ด ๋ช
๋ น์ด๋ ์ต์ `stable` ๋ฒ์ ์ด ์๋ ์ต์ฒจ๋จ `main` ๋ฒ์ ์ ์ค์นํฉ๋๋ค. |
| `main` ๋ฒ์ ์ ์ต์ ๊ฐ๋ฐ ์ ๋ณด๋ฅผ ์ต์ ์ํ๋ก ์ ์งํ๋ ๋ฐ ์ ์ฉํฉ๋๋ค. |
| ์๋ฅผ ๋ค์ด ๋ง์ง๋ง ๊ณต์ ๋ฆด๋ฆฌ์ฆ ์ดํ ๋ฒ๊ทธ๊ฐ ์์ ๋์์ง๋ง, ์ ๋ฆด๋ฆฌ์ฆ๊ฐ ์์ง ์ถ์๋์ง ์์ ๊ฒฝ์ฐ์
๋๋ค. |
| ๊ทธ๋ฌ๋ ์ด๋ `main` ๋ฒ์ ์ด ํญ์ ์์ ์ ์ด์ง ์์ ์ ์์์ ์๋ฏธํฉ๋๋ค. |
| ์ฐ๋ฆฌ๋ `main` ๋ฒ์ ์ด ์ง์์ ์ผ๋ก ์๋ํ๋๋ก ๋
ธ๋ ฅํ๊ณ ์์ผ๋ฉฐ, ๋๋ถ๋ถ์ ๋ฌธ์ ๋ ๋ณดํต ๋ช ์๊ฐ ๋๋ ํ๋ฃจ ์์ ํด๊ฒฐ๋ฉ๋๋ค. |
| ๋ฌธ์ ๊ฐ ๋ฐ์ํ๋ฉด ๋ ๋นจ๋ฆฌ ํด๊ฒฐํ ์ ์๋๋ก [Issue](https://github.com/huggingface/transformers/issues)๋ฅผ ์ด์ด์ฃผ์ธ์! |
|
|
|
|
| ## ํธ์ง๊ฐ๋ฅํ ์ค์น |
|
|
| ๋ค์์ ์ํํ๋ ค๋ฉด ํธ์ง๊ฐ๋ฅํ ์ค์น๊ฐ ํ์ํฉ๋๋ค: |
|
|
| * ์์ค ์ฝ๋์ `main` ๋ฒ์ ์ ์ฌ์ฉ |
| * ๐ค Diffusers์ ๊ธฐ์ฌ (์ฝ๋์ ๋ณ๊ฒฝ ์ฌํญ์ ํ
์คํธํ๊ธฐ ์ํด ํ์) |
|
|
| ์ ์ฅ์๋ฅผ ๋ณต์ ํ๊ณ ๋ค์ ๋ช
๋ น์ด๋ฅผ ์ฌ์ฉํ์ฌ ๐ค Diffusers๋ฅผ ์ค์นํฉ๋๋ค: |
|
|
| ```bash |
| git clone https://github.com/huggingface/diffusers.git |
| cd diffusers |
| ``` |
|
|
| **PyTorch์ ๊ฒฝ์ฐ** |
|
|
| ``` |
| pip install -e ".[torch]" |
| ``` |
|
|
| **Flax์ ๊ฒฝ์ฐ** |
|
|
| ``` |
| pip install -e ".[flax]" |
| ``` |
|
|
| ์ด๋ฌํ ๋ช
๋ น์ด๋ค์ ์ ์ฅ์๋ฅผ ๋ณต์ ํ ํด๋์ Python ๋ผ์ด๋ธ๋ฌ๋ฆฌ ๊ฒฝ๋ก๋ฅผ ์ฐ๊ฒฐํฉ๋๋ค. |
| Python์ ์ด์ ์ผ๋ฐ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ๊ฒฝ๋ก์ ๋ํ์ฌ ๋ณต์ ํ ํด๋ ๋ด๋ถ๋ฅผ ์ดํด๋ด
๋๋ค. |
| ์๋ฅผ๋ค์ด Python ํจํค์ง๊ฐ `~/anaconda3/envs/main/lib/python3.7/site-packages/`์ ์ค์น๋์ด ์๋ ๊ฒฝ์ฐ Python์ ๋ณต์ ํ ํด๋์ธ `~/diffusers/`๋ ๊ฒ์ํฉ๋๋ค. |
|
|
| <Tip warning={true}> |
|
|
| ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ๊ณ์ ์ฌ์ฉํ๋ ค๋ฉด `diffusers` ํด๋๋ฅผ ์ ์งํด์ผ ํฉ๋๋ค. |
|
|
| </Tip> |
|
|
| ์ด์ ๋ค์ ๋ช
๋ น์ด๋ฅผ ์ฌ์ฉํ์ฌ ์ต์ ๋ฒ์ ์ ๐ค Diffusers๋ก ์ฝ๊ฒ ์
๋ฐ์ดํธํ ์ ์์ต๋๋ค: |
|
|
| ```bash |
| cd ~/diffusers/ |
| git pull |
| ``` |
|
|
| ์ด๋ ๊ฒ ํ๋ฉด, ๋ค์์ ์คํํ ๋ Python ํ๊ฒฝ์ด ๐ค Diffusers์ `main` ๋ฒ์ ์ ์ฐพ๊ฒ ๋ฉ๋๋ค. |
|
|
| ## ํ
๋ ๋ฉํธ๋ฆฌ ๋ก๊น
์ ๋ํ ์๋ฆผ |
|
|
| ์ฐ๋ฆฌ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ `from_pretrained()` ์์ฒญ ์ค์ ํ
๋ ๋ฉํธ๋ฆฌ ์ ๋ณด๋ฅผ ์๊ฒฉ์ผ๋ก ์์งํฉ๋๋ค. |
| ์ด ๋ฐ์ดํฐ์๋ Diffusers ๋ฐ PyTorch/Flax์ ๋ฒ์ , ์์ฒญ๋ ๋ชจ๋ธ ๋๋ ํ์ดํ๋ผ์ธ ํด๋์ค, ๊ทธ๋ฆฌ๊ณ ํ๋ธ์์ ํธ์คํ
๋๋ ๊ฒฝ์ฐ ์ฌ์ ํ์ต๋ ์ฒดํฌํฌ์ธํธ์ ๋ํ ๊ฒฝ๋ก๋ฅผ ํฌํจํฉ๋๋ค. |
| ์ด ์ฌ์ฉ ๋ฐ์ดํฐ๋ ๋ฌธ์ ๋ฅผ ๋๋ฒ๊น
ํ๊ณ ์๋ก์ด ๊ธฐ๋ฅ์ ์ฐ์ ์์๋ฅผ ์ง์ ํ๋๋ฐ ๋์์ด ๋ฉ๋๋ค. |
| ํ
๋ ๋ฉํธ๋ฆฌ๋ HuggingFace ํ๋ธ์์ ๋ชจ๋ธ๊ณผ ํ์ดํ๋ผ์ธ์ ๋ถ๋ฌ์ฌ ๋๋ง ์ ์ก๋๋ฉฐ, ๋ก์ปฌ ์ฌ์ฉ ์ค์๋ ์์ง๋์ง ์์ต๋๋ค. |
|
|
| ์ฐ๋ฆฌ๋ ์ถ๊ฐ ์ ๋ณด๋ฅผ ๊ณต์ ํ์ง ์๊ธฐ๋ฅผ ์ํ๋ ์ฌ๋์ด ์๋ค๋ ๊ฒ์ ์ดํดํ๊ณ ๊ฐ์ธ ์ ๋ณด๋ฅผ ์กด์คํ๋ฏ๋ก, ํฐ๋ฏธ๋์์ `DISABLE_TELEMETRY` ํ๊ฒฝ ๋ณ์๋ฅผ ์ค์ ํ์ฌ ํ
๋ ๋ฉํธ๋ฆฌ ์์ง์ ๋นํ์ฑํํ ์ ์์ต๋๋ค. |
|
|
| Linux/MacOS์์: |
| ```bash |
| export DISABLE_TELEMETRY=YES |
| ``` |
|
|
| Windows์์: |
| ```bash |
| set DISABLE_TELEMETRY=YES |
| ``` |